![]() |
Wrote my first udf but nothing happens
Hello everyone,
I started learning UDF today, i created my first code. It's an easy source term that i apply on a SPECIFIC domain of fluid. the source is a x-momentum, here is my code: Quote:
|
Because of numerical inaccuracies, you always have to provide a small threshold for statements like "if (position != ..."
The position of the cells in your domain will never be -0.135608, but rather -0.135608000001 Make it "if(position < x_0+threshold && position > x_0-threshold)" instead |
thanks alexander for you reply. went back and change the code into this one:
Quote:
Thanks again for your help |
Are you 100% sure that there are cell centroids within the ranges you specified?
Remember that sources are applied on a "per-cell" basis. For debugging purposes, try applying the source to a bigger area with less restrictions, say if (xc[0] < 0) source= 1000; return source; If this still has no effect... well we will have to think again. |
thanks a lot for your support, recently compilation works but i soon as i hit on run calculation it shows me this error i dont know why:
Quote:
|
Are you running in parallel?
Normal UDFs do not work in parallel, but as far as I understood, they can be changed accordingly. Refer to the UDF manual. For now, try running on 1 core only. |
changed into serial, still error problem.
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: #f Yeah this is definitely the coordinates. Quote:
the procedure: i load the case, define then interpret the udf. i go to cell condition turn on source term , aplly x-momentum click on ok. then initialize and finally run calculation... i appreciate your help... |
1 Attachment(s)
Here is a source UDF I currently use (stripped it from everything but the coordinate thing):
Copy it and try to run it. DEFINE_SOURCE(sourceterm,c,t,dS,eqn) { double x[ND_ND]; double x0,y0; double y_m=0.0; double I_0=1000; C_CENTROID(x,c,t); if(x[1] <= y_m) { source = I_0; } } return source; When you say "apply x momentum" you mean you add 1 momentum source like in my attached picture? The rest of your procedure seems ok. |
finally it worked. My udf was good. it worked after i changed the scenario. i was applying the source in a convergent divergent nozzle. velocity was near transonic, may be that's why nothing was happening. after i changed the geometry into a duct where air was flowing with 1 m/s. i could see the source in the velocity contour plot. thanks a lot for you support alex, you deserve a reputation up...
|
hi
how can we differentiate between a 32 & 64 bit udf in fluent???
|
| All times are GMT -4. The time now is 19:08. |