deepinheart |
February 11, 2010 12:34 |
DEFINE_GRID_MOTION crash without any info??
This is my code to run DEFINE_GRID_MOTION. However, it crashed whenever I run "dynamic mesh preview" more than 1 time step. If I run 1 step each time I restart fluent, it works.
Maybe it is because of the stack pointer I add. But I've already free it after use. Would you please help me out?
Note: The pointer value is used to receive a udf loadinterp and it works well (I checked that inside Fluent).
BTW, how to use Macro to compile UDF step by step?
Thanks a lot!:)
Code:
DEFINE_GRID_MOTION(DefineGridMotionTest, domain, dt, time, dtime)
{
Thread *tf = DT_THREAD (dt);
face_t f;
Node *v;
float *value= (float *)malloc(3*sizeof(float));
float NV_VEC (dx);
int n;
char str [ FILENAME_MAX ];
sprintf_s(str,FILENAME_MAX, "c:\\BoundGrid_%d.txt", N_TIME+1);
// set deforming flag on adjacent cell zone
SET_DEFORMING_THREAD_FLAG (THREAD_T0 (tf));
Message ("time = %f %d\n", time,N_TIME);
begin_f_loop (f, tf)
{
f_node_loop (f, tf, n)
{
v = F_NODE (f, tf, n);
// update node if x position is greater than 0.02
// and that the current node has not been previously
// visited when looping through previous faces
if (NODE_POS_NEED_UPDATE (v))
{
// indicate that node position has been update
// so that it's not updated more than once
NODE_POS_UPDATED (v);
value = loadinterp(str, NODE_COORD (v)[0], NODE_COORD (v)[1],NODE_COORD (v)[2]);
NV_DS (dx, =, *value,*(value+1),*(value+2),*,dtime);
NV_V (NODE_COORD (v), +=, dx);
}
}
}
end_f_loop (f, tf);
free(value);
}
|