|
[Sponsors] |
September 14, 2003, 00:44 |
UDF Help
|
#1 |
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) } |
|
September 14, 2003, 07:57 |
Re: UDF Help
|
#2 |
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 |
|
September 14, 2003, 08:25 |
Re: UDF Help
|
#3 |
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 |
|
September 14, 2003, 09:07 |
Re: UDF Help
|
#4 |
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 |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dynamic Mesh UDF | Qureshi | FLUENT | 7 | March 23, 2017 07:37 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 22:14 |
How to add a UDF to a compiled UDF library | kim | FLUENT | 3 | October 26, 2011 21:38 |
UDF...UDF...UDF...UDF | Luc SEMINEL | FLUENT | 0 | November 25, 2002 04:03 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 04:01 |