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/)
-   -   serial udf to parallel udf (https://www.cfd-online.com/Forums/fluent-udf/200770-serial-udf-parallel-udf.html)

radioss April 12, 2018 08:44

serial udf to parallel udf
 
1 Attachment(s)
i tryed everything on that udf but i couldnt convert to parallel

radioss April 13, 2018 09:18

Please help me

AlexanderZ April 14, 2018 03:55

was
Code:

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) */
#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)

change to
Code:

Visit each face on the inlet and add up Vx, Vr, Area, and Pressure */
    begin_f_loop_int (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) */
#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_int (f, t)
# if RP_NODE /* Perform node synchronized actions here; Does nothing in serial
                        A_sum = PRF_GRSUM1(A_sum);
                        VA_sum = PRF_GRSUM1(VA_sum);
Pthrus = PRF_GRSUM1(Pthrus);
# endif /* RP_NODE */

line 46 you have #if !RP_HOST
was: close it on line 70 by #endif
new: put it to the very end into line 292

best regards

radioss April 14, 2018 15:43

Thanks for answer but i have error still , Error at host: Error code: 193
Code:

#include "udf.h"
#include "dynamesh_tools.h"

#define nozzle_tid      12    /* Zone ID of nozzle exit */
#define missile_tid      14    /* Zone ID of missile wall */
#define moving_fluid_id  2    /* Zone ID of fluid surrounding the missile */

#define t_liftoff        0.1    /* Time at which to allow lift-off (sec) */
#define g_c              9.81  /* Gravity acceleration */
#define initial_mass    200.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(launch, prop, dt, time, dtime)
{

#if !RP_HOST
/* 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 */

/* Compute area-weighted average exit velocity */

Message("\n ****************************************");
Message("\n *******  Nozzle Exit Conditions  *******");
Message("\n ****************************************");


/* 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) */
#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_int (f, t)

#if RP_NODE
 if(rp_axi)
  {A_sum *= 2*pi;
  VA_sum *= 2*pi;
  Pthrust *= 2*pi;}
#endif

    V_avg = VA_sum / A_sum;

Message("\n  -> Current Time            = %f sec", time);
Message("\n  -> Liftoff time            = %f sec", t_liftoff);
Message("\n  -> Total inlet area        = %f m2", A_sum);
Message("\n  ->                        = %f ft2", A_sum / (0.3048 * 0.3048));
Message("\n");
Message("\n  -> Average Velocity        = %f m/sec", V_avg);
Message("\n                              = %f ft/sec", V_avg / 0.3048);
Message("\n");
Message("\n  -> Average Inlet Pressure  = %f Pa", Pthrust / A_sum);
Message("\n                              = %f psi", Pthrust / A_sum * (14.7/101325.));

/*  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;

                Message("\n  -> Mass Flow Rate          = %f kg/sec", MDOT);
                Message("\n  ->                        = %f lbm/sec", MDOT / 2.205);
        }

    else
        {

        Message("\n  NOW INSIDE UNTESTED PORTION OF THE UDF");


/*
THE FOLLOWING HAS NOT BEEN TESTED YET!!
*/

/*            if (IS_PROFILE (THREAD_VAR (t).mfi.mass_flux))
            {
Message("\n====================================");
Message("\n MDOT HAS BEEN SPECIFIED AS PROFILE");
Message("\n Beginning face loop.");

                begin_f_loop (f, t)
                {
                    mass_flux = NV_MAG (F_AREA_CACHE (f, t))
                                * F_VAR (f, t, THREAD_VAR (t).mfi.mass_flux);

Message("\n MASS FLOW RATE FOUND.\n");

                }
                end_f_loop (f, t)

Message("\n VALUE OF MDOT = %f", MDOT);
Message("\n====================================");
            }
            else
            {

Message("\n LOOKING UP MASS FLOW RATE (NOT PROFILE)\n");

                mass_flux = THREAD_VAR(t).mfi.mass_flux.constant * A_sum;
                MDOT = A_sum * mass_flux;

Message("\n Finished calculating for non profile case.  Results:");
Message("\n      mass_flux  = %f", THREAD_VAR(t).mfi.mass_flux.constant);
Message("\n      A_sum = %f", A_sum);
Message("\n      MDOT  = %f", MDOT);


            }
*/


/*  END OF UNTESTED SECTION */


/*
#if RP_2D
  if (rp_axi) MDOT *= 2.0 * pi;
#endif
*/
        }


/*  COMPUTE ROCKET THRUST AS (Avg Velocity) * (mass flow rate)

                force = V_avg * F_VAR (0, t, THREAD_VAR(t).mfi.mass_flux) / total_;
*/



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

                Umiss = DT_VEL_CG(tmiss)[0];                */


Message("\n ***************************************");
Message("\n ********  Thrust / Velocity  *********");
Message("\n ***************************************");


Message("\n  -> Missile Velocity        = %f m/sec", Vmiss[0]);
Message("\n  ->                        = %f ft/sec", Vmiss[0]/0.3048);

#if RP_2D
    if (rp_axi)
    {
            Message("\n  -> Missile Velocity Axial  = %f m/sec", DT_VEL_CG(tmiss)[0]);
                Message("\n  ->                        = %f ft/sec", DT_VEL_CG(tmiss)[0]/0.3048);

        Message("\n  -> Missile Velocity Radial = %f m/sec", DT_VEL_CG(tmiss)[1]);
                Message("\n  ->                        = %f ft/sec", DT_VEL_CG(tmiss)[1]/0.3048);
    }
    else
    {
            Message("\n  -> Missile Velocity (X)    = %f m/sec", DT_VEL_CG(tmiss)[0]);
                Message("\n  ->                        = %f ft/sec", DT_VEL_CG(tmiss)[0]/0.3048);
        Message("\n  -> Missile Velocity (Y)    = %f m/sec", DT_VEL_CG(tmiss)[1]);
                Message("\n  ->                        = %f ft/sec", DT_VEL_CG(tmiss)[1]/0.3048);
    }
#endif

#if RP_3D
  Message("\n  -> Missile Velocity (Z)    = %f m/sec", DT_VEL_CG(tmiss)[2]);
  Message("\n  ->                        = %f ft/sec", DT_VEL_CG(tmiss)[2] / 0.3048);
#endif

        V_e = V_avg - Vmiss[0];
        Mthrust = V_e * MDOT;

Message("\n  -> Relative Velocity      = %f m/sec", V_e);
Message("\n  ->                        = %f ft/sec", V_e / 0.3048);
Message("\n");
Message("\n  -> Momentum Thrust        = %f N", V_e*MDOT);
Message("\n  ->                        = %f lbf", V_e*MDOT / 4.448);
Message("\n");
Message("\n  -> Pressure Thrust        = %f N", Pthrust);
Message("\n  ->                        = %f lbf", Pthrust / 4.448);
Message("\n");
Message("\n  -> TOTAL THRUST            = %f N", Pthrust+Mthrust);
Message("\n  ->                        = %f lbf", (Pthrust+Mthrust)/4.448);
Message("\n ****************************************");
Message("\n");
Message("\n");

/*  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

}
#endif


radioss April 14, 2018 15:43

i edited as you say , i am wrong ?

AlexanderZ April 15, 2018 21:00

did you compile code?

try to debug on single core, than move to parallel

best regards

radioss April 16, 2018 08:02

i compiled but i cant run on serial fluent cause fluent running parallel automaticly

radioss April 23, 2018 03:02

anyone can help ?

AlexanderZ April 23, 2018 20:47

https://www.cfd-online.com/Forums/fl...sing-mode.html

sajjad.gh December 31, 2018 13:11

Quote:

Originally Posted by radioss (Post 689887)
anyone can help ?

Hi radioss, i am facing this issue and i need to run this code in parallel. did u find any solution?

best regards

sajjad.gh January 19, 2019 08:56

any help? any suggestion? :)


All times are GMT -4. The time now is 09:20.