CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   udf and threads (

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) {



t0 = THREAD_T0(tf);

c0 = F_C0(f,tf);


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


t1 = THREAD_T1(tf);

c1 = F_C1(f,tf);


} } 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.


Marc November 11, 2005 05:08

Re: udf and threads

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 22:54.