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/)
-   -   Using a C_UDMI defined in one UDF in another UDF (https://www.cfd-online.com/Forums/fluent-udf/200354-using-c_udmi-defined-one-udf-another-udf.html)

sthinmind March 30, 2018 18:23

Using a C_UDMI defined in one UDF in another UDF
 
I use a C_UDMI to calculate the number of particles that deposit on a wall as:

DEFINE_DPM_BC(Deposition,p,t,f,f_normal,dim)
{
#if !RP_HOST
Thread *tcell=P_CELL_THREAD(p);
cell_t c=P_CELL(p);
Domain *d;
d=Get_Domain(1);
C_UDMI(c,tcell,0) += 1.;
return PATH_ABORT;
#endif
}

Then, I want to use this C_UDMI in another UDF to move the mesh where particles are deposited:

DEFINE_GRID_MOTION(beam,domain,dt,time,dtime)
{
Thread *tf;
face_t f;
int n;
Node *v;
/* get the thread pointer for which this motion is defined */
tf=DT_THREAD(dt);
begin_f_loop(f,tf)
{
f_node_loop(f,tf,n)
{
v = F_NODE(f,tf,n);
......
......C_UDMI.......
......
}
}
end_f_loop(f,tf);
}



Is this possible? Can anyone help how to do this?

Thanks,

doruk March 31, 2018 02:18

real G;
G=C_UDMI(c,t,0); will allow you to use it on another define macro

but above you are trying to use cell data in face node loop. You cant transfer data like that

sthinmind March 31, 2018 10:36

Thanks for your response. So does G have all information that C_UDMI has?(cell information and stored values)
Do I need to define G in the second UDF as well? Something like:

DEFINE_GRID_MOTION(beam,domain,dt,time,dtime)
{
Thread *tf;
face_t f;
int n;
Real G

....

pakk March 31, 2018 11:45

Quote:

Originally Posted by sthinmind (Post 687196)
I use a C_UDMI to calculate the number of particles that deposit on a wall as:

DEFINE_DPM_BC(OSU_Deposition_Model_R1,p,t,f,f_norm al,dim)
{
#if !RP_HOST
Thread *tcell=P_CELL_THREAD(p);
cell_t c=P_CELL(p);
Domain *d;
d=Get_Domain(1);
C_UDMI(c,tcell,0) += 1.;
return PATH_ABORT;
#endif
}

Then, I want to use this C_UDMI in another UDF to move the mesh where particles are deposited:

DEFINE_GRID_MOTION(beam,domain,dt,time,dtime)
{
Thread *tf;
face_t f;
int n;
Node *v;
/* get the thread pointer for which this motion is defined */
tf=DT_THREAD(dt);
begin_f_loop(f,tf)
{
f_node_loop(f,tf,n)
{
v = F_NODE(f,tf,n);
......
......C_UDMI.......
......
}
}
end_f_loop(f,tf);
}



Is this possible? Can anyone help how to do this?

Thanks,

Yes, it is possible. It is even simpler than your code.

In your UDF "OSU_Deposition_Model_R1", you now store face data in a C_UDMI, by first finding the associated cell. You can skip that step, and directly store it in F_UDMI(f,t).

Code:

DEFINE_DPM_BC(OSU_Deposition_Model_R1,p,t,f,f_normal,dim)
{
#if !RP_HOST
F_UDMI(f,t,0) += 1.;
return PATH_ABORT;
#endif       
}

And in your other code, you can simply extract the data with F_UDMI(tf,t).

sthinmind April 1, 2018 20:20

Thanks for your response.

I guess I need the nodal values in DEFINE_GRID_MOTION to move the mesh? How do I store the same value (F_UDMI) in the neighboring nodes? How do I find the nodes around a the face f? (In 2D there are two nodes at two sides of the face)


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