CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

UDF Help

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 14, 2003, 01:44
Default UDF Help
  #1
chiph
Guest
 
Posts: n/a
I have a problem about UDF. Which is including macros of DEFINE_ADJUST and DEFINE_PROFILE, and the profile of velocity is ok, but when I hooks the DEFINE_ADJUST macro (which I want to print out some data)there has an error message;

Iterating... iter continuity x-velocity y-velocity time/iter

Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: ()

#include "udf.h" Thread *thread;

DEFINE_ADJUST(my_adjust, d) { real x[ND_ND], y;

face_t f;

float u;

float h = 0.02;

begin_f_loop(f, thread)

{

F_CENTROID(x,f,thread);

y = x[1];

u = 100.0*y*(h-y);

}

end_f_loop(f,thread)

printf("y= %5f ; u= %5f\n", y,u); printf("End of Adjust "); }

DEFINE_PROFILE(x_vel, thread, position) {

real x[ND_ND], y;

face_t f;

float u;

float h = 0.02;

begin_f_loop(f, thread)

{

F_CENTROID(x,f,thread);

y = x[1];

u = 100.0*y*(h-y);

F_PROFILE(f,thread,position) = u;

}

end_f_loop(f,thread) }
  Reply With Quote

Old   September 14, 2003, 08:57
Default Re: UDF Help
  #2
ap
Guest
 
Posts: n/a
I think you should solve your problem putting this line

if (!Data_Valid_P()) return;

just before the

begin_f_loop(f, thread)

in your DEFINE_ADJUST function. This allows FLUENT to check if all variables you are accessing are defined, avoiding access violations.

Hi

ap
  Reply With Quote

Old   September 14, 2003, 09:25
Default Re: UDF Help
  #3
chiph
Guest
 
Posts: n/a
Hi, ap;

Thanks for your help. I try with your suggestion, but it still have the same error message. Do you have another comment?

chiph
  Reply With Quote

Old   September 14, 2003, 10:07
Default Re: UDF Help
  #4
ap
Guest
 
Posts: n/a
I checked your code and tried it on a case file of mine. Now it runs, but I don't know if it works properly because I'm not sure which data you need to print out.

I made these changes:

- Added the thread_loop_f(thread, d) loop, which is what solves the problem of access violation. DEFINE_ADJUST works on the domain d, but you have to retrieve threads using a command like this. I don't know if you need it, but there is the equivalent macro for cells: thread_loop_c(thread, d).

- Moved the declaration of *thread in the DEFINE_ADJUST function. DEFINE_PROFILE doesn't need it, so it's better to define it locally.

- Substituted all float variables with real one. Real is an internal data type of FLUENT which stands for float or double, in dependence of which solver you run. Use real and your code will work with both single and double precision solvers.

I commented my changes in the code: try it and keep me up to date


#include "udf.h"


DEFINE_ADJUST(my_adjust, d)
{
Thread *thread; /* I moved this here */
real x[ND_ND], y;
face_t f;
real u;
real h = 0.02;


if (!Data_Valid_P()) return; /* I added this */
thread_loop_f(thread, d) /* I added this: loops over all face threads in a domain*/
{
begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
y = x[1];
u = 100.0*y*(h-y);
}
end_f_loop(f,thread)
}
printf("y= %5f ; u= %5f\n", y,u);
printf("End of Adjust ");
}

DEFINE_PROFILE(x_vel, thread, position)
{
real x[ND_ND], y;
face_t f;

real u;
real h = 0.02;

begin_f_loop(f, thread)
{
F_CENTROID(x,f,thread);
y = x[1];
u = 100.0*y*(h-y);

F_PROFILE(f,thread,position) = u;
}
end_f_loop(f,thread)
}




Hope this works

Hi

ap
  Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Mesh UDF Qureshi FLUENT 7 March 23, 2017 08:37
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 22:38
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 05:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


All times are GMT -4. The time now is 02:14.