CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   udf and threads (http://www.cfd-online.com/Forums/fluent/38574-udf-threads.html)

sergei November 10, 2005 21:27

udf and threads
 
I'm writing a udf source file that adds up density gradient (x-component) along cell faces. It either takes cell gradent itself (along a boundary face) or average two neiboring cells (along a non-boundary face). There is no problem with the first case but something is wrong with C_R_G(c0,t0) and C_R_G(c1,t1) for the second case. It gives me a segmentation fault. It looks like C_R_G(c0,t0) and/or C_R_G(c1,t1) do not exist or references incorrectly.

Can somebody help?

Thanks. Sergei

DEFINE_SOURCE(FSD_source, c, t, dS, eqn) { int j; real value; Thread *t0, *t1 = NULL; Thread *tf; cell_t c0, c1 = -1; value=0;

c_face_loop(c, t, j) {

f=C_FACE(c,t,j);

tf=C_FACE_THREAD(c,t,j);

t0 = THREAD_T0(tf);

c0 = F_C0(f,tf);

if (BOUNDARY_FACE_THREAD_P(tf))

value+=C_R_G(c,t)[0]; else

{

t1 = THREAD_T1(tf);

c1 = F_C1(f,tf);

value+=(C_R_G(c0,t0)[0]+C_R_G(c1,t1)[0])/2;

} } return value; }

RoM November 11, 2005 02:26

Re: udf and threads
 
Try the text command solve/set/expert and answer "yes" to the question "Keep temporary solver memory from being freed?". This should preserve all gradients and not remove them continually from memory.

RoM

Marc November 11, 2005 05:08

Re: udf and threads
 
Hi,

you also might encounter problems in the first step: since you have no values no gradients can be built. So you can try adding a big loop around your UDF, e.g. "if (N_ITER>1) {...}"

Hope that helps ...


All times are GMT -4. The time now is 10:29.