|
[Sponsors] |
November 28, 2007, 04:50 |
can any one correct this(udf)
|
#1 |
Guest
Posts: n/a
|
hello
i writting an position based udf like source=5(x*x)*(y*y) here x and y are the position of grids .i tried like this and iam new to c programming.so kinly help me to do this thank you #include "udf.h" DEFINE_SOURCE(cure_source,c,t,ds,eqn) { real source; cell_t c; Thread *t; real xc[ND_ND]; /* loop over all cells */ begin_c_loop_all(c,t) { C_CENTROID(xc,c,t); source=8*C_CENTROID(xc,c,t)*C_CENTROID(xc,c,t); } end_c_loop_all(c,t) return source; } |
|
December 1, 2007, 11:06 |
Re: can any one correct this(udf)
|
#2 |
Guest
Posts: n/a
|
#include "udf.h" DEFINE_SOURCE(cure_source,c,t,ds,eqn) { real source; real xc[ND_ND]; C_CENTROID(xc,c,t); /* Returns centroid in xc[ND_ND] for cell in thread t */ /* xc[0] = x distance, xc[1] = y distance */ source=5.0*xc[0]*xc[0]*xc[1]*xc[1]; ds[eqn]=0.0; return source; }
|
|
December 3, 2007, 23:34 |
Re: can any one correct this(udf)
|
#3 |
Guest
Posts: n/a
|
thank you
|
|
December 3, 2007, 23:38 |
Re: can any one correct this(udf)
|
#4 |
Guest
Posts: n/a
|
thank you mohan again i trapped in to another udf,it is hooked well but when i give iterare it shows fattel error,the udf goes like this
#include"udf.h" #include <mem.h> #include"math.h" #include"complex.h" DEFINE_SOURCE(heat_gen,cell,thread,ds,eqn) { real x[ND_ND]; real source; real ko,E,R,Qalpha; C_CENTROID(x, cell, thread); ko=1.0; E=53830.0; R=8.341; Qalpha=2000000.0; source=C_R(cell,thread)*Qalpha*ko*exp(-E/(R*C_T(cell,thread))); ds[eqn]=0; return source; } pleaese give some sujjestions |
|
December 4, 2007, 13:02 |
Re: can any one correct this(udf)
|
#5 |
Guest
Posts: n/a
|
Hi,
Do you need to have "math.h" and "complex.h"? Instead of complex.h you can use a data structure. For example, typedef struct cmpx { double x; double y; } complex; complex z; z.x="real" z.y="imaginary" This should work. But, I don't see any error in the code. Can u pls. check the following step? 1. Go to the fluent case file directory and invoke fluent 2. load the .cas and .dat file, initialize 3. unload the library namely, "libudf" (define->user-define->function->manage) 4. complie your source term udf again 5. load and hook the UDF in your scalar equation. then you try running. Other way is you can activate the species transport and reaction. Include your custom reaction in DEFINE_VR_RATE(...). This should definitely work. |
|
December 5, 2007, 02:24 |
Re: can any one correct this(udf)
|
#6 |
Guest
Posts: n/a
|
hello
i am new to this udf writing,but other udf like boiling etc hooked well and running.i think the complex.h and math.h is nessesary because there is a funtion called exp(...) used. any way i will try it thank you |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 07:20 |
Is this understanding of turbulence models correct? | 3kha | Main CFD Forum | 3 | January 31, 2011 22:31 |
LES correct function | luiz eduardo | OpenFOAM Running, Solving & CFD | 6 | September 14, 2007 05:10 |
Correct lift but wrong pressure drag - possible? | zx | Main CFD Forum | 4 | July 28, 2007 00:38 |
For a correct the mole fraction ... | kevin | FLUENT | 0 | April 9, 2002 05:39 |