|
[Sponsors] |
July 13, 2012, 00:07 |
Wrote my first udf but nothing happens
|
#1 | |
Super Moderator
Ghazlani M. Ali
Join Date: May 2011
Location: Tokyo, Japan
Posts: 1,385
Blog Entries: 23
Rep Power: 29 |
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:
|
||
July 13, 2012, 05:44 |
|
#2 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49 |
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 Last edited by flotus1; July 13, 2012 at 06:37. |
|
July 13, 2012, 10:12 |
|
#3 | |
Super Moderator
Ghazlani M. Ali
Join Date: May 2011
Location: Tokyo, Japan
Posts: 1,385
Blog Entries: 23
Rep Power: 29 |
thanks alexander for you reply. went back and change the code into this one:
Quote:
Thanks again for your help |
||
July 13, 2012, 10:44 |
|
#4 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49 |
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. |
|
July 13, 2012, 11:48 |
|
#5 | |
Super Moderator
Ghazlani M. Ali
Join Date: May 2011
Location: Tokyo, Japan
Posts: 1,385
Blog Entries: 23
Rep Power: 29 |
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:
|
||
July 13, 2012, 11:53 |
|
#6 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49 |
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. |
|
July 13, 2012, 12:04 |
|
#7 | |
Super Moderator
Ghazlani M. Ali
Join Date: May 2011
Location: Tokyo, Japan
Posts: 1,385
Blog Entries: 23
Rep Power: 29 |
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... |
||
July 13, 2012, 14:05 |
|
#8 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,427
Rep Power: 49 |
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. |
|
July 13, 2012, 16:15 |
|
#9 |
Super Moderator
Ghazlani M. Ali
Join Date: May 2011
Location: Tokyo, Japan
Posts: 1,385
Blog Entries: 23
Rep Power: 29 |
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...
|
|
July 15, 2012, 10:32 |
hi
|
#10 |
New Member
G I Joe
Join Date: Mar 2012
Posts: 1
Rep Power: 0 |
how can we differentiate between a 32 & 64 bit udf in fluent???
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dynamic Mesh UDF | Qureshi | FLUENT | 7 | March 23, 2017 08:37 |
Source Term UDF VS Porous Media Model | pchoopanya | Fluent UDF and Scheme Programming | 1 | August 28, 2013 07:12 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
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 |