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/)
-   -   Having trouble adapting serial UDF to work in parallel (https://www.cfd-online.com/Forums/fluent-udf/111322-having-trouble-adapting-serial-udf-work-parallel.html)

muyuntao January 3, 2013 12:24

Having trouble adapting serial UDF to work in parallel
 
1 Attachment(s)
Hi,everyone!

I'm in Asia,a student .now facing a big issue trying to make a serial UDF parallel.
The UDF works perfectly in serial but I need now to adapt it for parallel computation.
The main problem is that : I don't know how to add "#if !RP_NODE
,host_to_node_int_2(type_diff,therm_diff" and where to add it.
I have stoped for ten days for such problem. could anyone help me? Thank you!!!
my E-mail Address 594ntl@sina.com

#include "udf.h"
#include "dynamesh_tools.h"
#define nozzle_tid 6 /* Zone ID of nozzle exit */
#define missile_tid 5 /* Zone ID of missile wall */
#define moving_fluid_id 3 /* Zone ID of fluid surrounding the missile */
#define t_liftoff 0.000001 /* Time at which to allow lift-off (sec) */
#define g_c 9.81 /* Gravity acceleration */
#define initial_mass 2.0 /* Initial mass of the rocket (kg) */
#define burn_rate 0.0 /* Fuel burn rate (kg/sec) */
#define pi 4.0*atan(1.0)
float U_sum; /* Sum of inlet U velocity */
float V_sum; /* Sum of inlet V velocity */
float W_sum; /* Sum of inlet W velocity */
float A_sum; /* Sum of facet areas */
float P_sum; /* Sum of face pressure */
float P_i; /* Pressure on face i */
float A_i; /* Area of face i */
float U_i; /* U velocity on face i */
float V_i; /* V velocity on face i */
float W_i; /* W velocity on face i */
float A[3]; /* Area vector of face i */
float VA_sum; /* Sum of velocity times area */
float VEL_i; /* Velocity magnitude on face i */
float V_avg; /* Average velocity */
float V_e; /* Nozzle exit velocity relative to missile */
float Pthrust; /* Thrust due to pressure */
float Mthrust; /* Thrust due to momentum */
float MDOT; /* Mass flow rate from the missile */
float Vmiss[3]; /* Missile velocity vector */
/*float Umiss;*/ /* Missile x velocity */
/*float Vmiss;*/ /* Missile y or r velocity */
/*float Wmiss;*/ /* Missile z velocity (zero for 2-D) */

Domain *domain;
face_t f; /* Nozzle faces */
Thread *t; /* Nozzle thread */
Dynamic_Thread *tmiss; /* Missile wall thread */

DEFINE_SDOF_PROPERTIES(lmmm, prop, dt, time, dtime)
{

/* Define the mass and moments of inertia */
prop[SDOF_MASS] = initial_mass - (burn_rate * time);
prop[SDOF_IXX] = 0.0;
prop[SDOF_IYY] = 0.0;
prop[SDOF_IZZ] = 0.0;
/* Define ejector moments */
prop[SDOF_LOAD_M_X] = 0.;
prop[SDOF_LOAD_M_Y] = 0.;
prop[SDOF_LOAD_M_Z] = 0.;
/* Calculate rocket thrust and assign to X ejector force.*/
U_sum = 0.0;
V_sum = 0.0;
W_sum = 0.0;
A_sum = 0.0;
P_sum = 0.0;
Pthrust = 0.0;
A_sum = 0.0;
VA_sum = 0.0;
Pthrust = 0.0;
Mthrust = 0.0;
/* Lookup thread values */
domain = Get_Domain(1);
t = Lookup_Thread(domain, nozzle_tid);
tmiss = THREAD_DT(Lookup_Thread(domain, missile_tid)); /* Missile wall */

/* Visit each face on the inlet and add up Vx, Vr, Area, and Pressure */
begin_f_loop (f, t)
{
/* Retrieve the area vector of the current face */
F_AREA(A, f, t);
/* Message("\n check 1");*/
/* Calculate the area of current face */
A_i = NV_MAG(A);
/*Message("\n check 2");*/
/* Retrieve the pressure on the current face */
P_i = F_P(f,t);
/*Message("\n check 3");*/
U_i = F_U(f,t); /* U Velocity on the current face */
V_i = F_V(f,t); /* V velocity on the current face */
#if RP_2D
W_i = 0.0; /* W Velocity (2D) */
#else
W_i = F_W(f, t); /* W Velocity (3D) */
Attachment 17968
#endif
VEL_i = sqrt(U_i*U_i+V_i*V_i+W_i*W_i); /* Velocity magnitude */

A_sum += A_i; /* Increment the face area */
VA_sum += VEL_i * A_i; /* Increment the VxA */
Pthrust += P_i * A_i; /* Increment the pressure force */
}
end_f_loop (f, t)
#if RP_2D
if(rp_axi)
{A_sum *= 2*pi;
VA_sum *= 2*pi;
Pthrust *= 2*pi;}
#endif
V_avg = VA_sum / A_sum;

/* OBTAIN THE MASS FLOW RATE ACROSS THE INLET */
MDOT = 0.0;
/* Obtain the mass flow rate if inlet is mass flow type */
if (THREAD_VAR(t).mfi.flow_spec == MASS_FLOW_TYPE)
{
MDOT = THREAD_VAR(t).mfi.mass_flow;
}
else
{
Message("\n NOW INSIDE UNTESTED PORTION OF THE UDF");
}

/* OBTAIN THE CURRENT MISSILE VELOCITY */
if(time < t_liftoff)
{DT_VEL_CG(tmiss)[0] = 0.0;}

#if RP_2D
if (rp_axi)
{
}
else
{
}
#endif
#if RP_3D
#endif


V_e = V_avg - Vmiss[0];
Mthrust = V_e * MDOT;
/* Set calculated thrust as a body force (ejector force) */
prop[SDOF_LOAD_F_X] = Pthrust + Mthrust;
prop[SDOF_LOAD_F_Y] = 0.0;
prop[SDOF_LOAD_F_Z] = 0.0;
/* Dummy Override */
#if RP_2D
prop[SDOF_LOAD_F_Z] = 0.;
if (rp_axi)
prop[SDOF_LOAD_F_Y] = 0.;
#endif

}
Attachment 17968

drnaferio November 10, 2015 13:42

Have you solved problem related to parallel processing ?


All times are GMT -4. The time now is 03:33.