CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent Multiphase (https://www.cfd-online.com/Forums/fluent-multiphase/)
-   -   The way of information transfer between Fluent solver and udf (https://www.cfd-online.com/Forums/fluent-multiphase/218048-way-information-transfer-between-fluent-solver-udf.html)

CrystalEternity June 6, 2019 01:33

The way of information transfer between Fluent solver and udf
 
Now I'm a little confused about how the two are passed on,especially vectors.
For example ,this is an UDF macro from FLUENT help .

/* UDF for computing the magnetic force on a charged particle */

#include "udf.h"

#define Q 1.0 /* particle electric charge */
#define BZ 3.0 /* z component of magnetic field */
#define TSTART 18.0 /* field applied at t = tstart */

/* Calculate magnetic force on charged particle. Magnetic */
/* force is particle charge times cross product of particle */
/* velocity with magnetic field: Fx= q*bz*Vy, Fy= -q*bz*Vx */

DEFINE_DPM_BODY_FORCE(particle_body_force,p,i)
{
real bforce=0;
if(P_TIME(p)>=TSTART)
{
if(i==0) bforce=Q*BZ*P_VEL(p)[1];
else if(i==1) bforce=-Q*BZ*P_VEL(p)[0];
}
else
bforce=0.0;
/* an acceleration should be returned */
return (bforce/P_MASS(p));
}

About this macro,I would like to raise the following questions:
1.How does i identify and allocate variables
2.The explanation about I is that it represents the components in cartesian coordinate system, 0, 1 and 2 can be taken.When the variable is passed and calculated(especially vectors), is it done once or many times?
For example,When the UDF is called, a certain velocity component is obtained from the solver, and the acceleration in the direction is returned. By calling the macro three times, three returns are returned to realize the effect of lorentz force on the particle, or are there other explanations?

CrystalEternity June 8, 2019 21:59

Is there anyone who can help answer these questions


All times are GMT -4. The time now is 19:22.