CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

serial udf to parallel udf

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 12, 2018, 09:44
Default serial udf to parallel udf
  #1
New Member
 
Şükrü
Join Date: Aug 2017
Posts: 21
Rep Power: 7
radioss is on a distinguished road
i tryed everything on that udf but i couldnt convert to parallel
Attached Files
File Type: c silo.c (8.5 KB, 36 views)
radioss is offline   Reply With Quote

Old   April 13, 2018, 10:18
Default
  #2
New Member
 
Şükrü
Join Date: Aug 2017
Posts: 21
Rep Power: 7
radioss is on a distinguished road
Please help me
radioss is offline   Reply With Quote

Old   April 14, 2018, 04:55
Default
  #3
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,178
Rep Power: 31
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
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
AlexanderZ is offline   Reply With Quote

Old   April 14, 2018, 16:43
Default
  #4
New Member
 
Şükrü
Join Date: Aug 2017
Posts: 21
Rep Power: 7
radioss is on a distinguished road
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 is offline   Reply With Quote

Old   April 14, 2018, 16:43
Default
  #5
New Member
 
Şükrü
Join Date: Aug 2017
Posts: 21
Rep Power: 7
radioss is on a distinguished road
i edited as you say , i am wrong ?
radioss is offline   Reply With Quote

Old   April 15, 2018, 22:00
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,178
Rep Power: 31
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
did you compile code?

try to debug on single core, than move to parallel

best regards
AlexanderZ is offline   Reply With Quote

Old   April 16, 2018, 09:02
Default
  #7
New Member
 
Şükrü
Join Date: Aug 2017
Posts: 21
Rep Power: 7
radioss is on a distinguished road
i compiled but i cant run on serial fluent cause fluent running parallel automaticly
radioss is offline   Reply With Quote

Old   April 23, 2018, 04:02
Default
  #8
New Member
 
Şükrü
Join Date: Aug 2017
Posts: 21
Rep Power: 7
radioss is on a distinguished road
anyone can help ?
radioss is offline   Reply With Quote

Old   April 23, 2018, 21:47
Default
  #9
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,178
Rep Power: 31
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
How to use FLUENT only in single processing mode
AlexanderZ is offline   Reply With Quote

Old   December 31, 2018, 14:11
Default
  #10
New Member
 
sajjad ghahari
Join Date: Sep 2016
Posts: 4
Rep Power: 8
sajjad.gh is on a distinguished road
Quote:
Originally Posted by radioss View Post
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 is offline   Reply With Quote

Old   January 19, 2019, 09:56
Default
  #11
New Member
 
sajjad ghahari
Join Date: Sep 2016
Posts: 4
Rep Power: 8
sajjad.gh is on a distinguished road
any help? any suggestion?
sajjad.gh is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in using UDF in parallel computing Yogini Fluent UDF and Scheme Programming 0 January 22, 2013 09:23
Transient pressure UDF for parallel fluent droberts Fluent UDF and Scheme Programming 5 October 11, 2010 05:13
Dynamic Mesh- Parallel UDF DE HEART Fluent UDF and Scheme Programming 14 August 11, 2010 02:29
Face handling in Parallel UDF O.D.Y. Fluent UDF and Scheme Programming 0 May 1, 2009 07:10
Differences between serial and parallel runs carsten OpenFOAM Bugs 11 September 12, 2008 12:16


All times are GMT -4. The time now is 05:13.