CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   Segmentation fault at the end of timestep (https://www.cfd-online.com/Forums/fluent-udf/190951-segmentation-fault-end-timestep.html)

mataus July 26, 2017 22:52

Segmentation fault at the end of timestep
 
Hai..
I am trying to add an energy source term to a fluid flow problem.I wrote a UDF and interpret.
But I am getting a segmentation fault at the end of the first-time step.
I allocated 3 memory locations.
I believe the error occurs because of the error in executing at the end macro region.

Please help me


DEFINE_ON_DEMAND(solid)
{
Domain *d=Get_Domain(1);
int zone_id=11;
Thread *t = Lookup_Thread(d,zone_id);
cell_t c;
begin_c_loop(c,t)
{
C_UDMI(c,t,0) = 0.1;
}
end_c_loop(c,t)
}

DEFINE_EXECUTE_AT_END(source_calculation)
{

Domain *d;
Thread *t;
cell_t c;
real dt=CURRENT_TIMESTEP;
int zone_id=11;


thread_loop_c(t,d)
{
begin_c_loop(c,t)

{

C_UDMI(c,t,1)=C_T(c,t)/some constant;

C_UDMI(c,t,2)=0.01;

C_UDMI(c,t,0)=C_UDMI(c,t,0)+(C_UDMI(c,t,2)*dt);
}
end_c_loop(c,t)
}
}

DEFINE_SOURCE(energy, c, t, dS, eqn)
{
real x[ND_ND];
real source;
source = some constant* C_UDMI(c,t,2);

dS[eqn] = 0;
return source;
}

sfn July 27, 2017 09:51

Quote:

some constant
are you sure about that? non declared variable with a space


All times are GMT -4. The time now is 00:32.