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

Parallelisation UDF

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 5, 2005, 02:38
Default Parallelisation UDF
  #1
mAx
Guest
 
Posts: n/a
Hi, I have a problem with my UDF. It runs well under serial, but not under parallel. And I need to run it under parallel. I paste, the UDF below. Could someone tell me what's wrong? Thank you very much. ******* #include <stdio.h> #include "udf.h"

#if !RP_NODE # define UDF_FILENAME "udf_loc_velo" # define UDF_DATA "data.dat"

# define K_SPRING 1605 /*spring constant/2 (N/m)*/ # define m 0.0365 /*mass of piston/2 (kg)*/ # define init_disp 0.008 /*initial displacement of spring (m)*/

/* read current location and velocity from file */ static void read_loc_velo_file (real *loc, real *velo) { FILE *fp = fopen(UDF_FILENAME, "r");

if (fp != NULL)

{

float read_loc, read_velo;

fscanf (fp, "%e %e", &read_loc, &read_velo);

fclose (fp);

*loc = (real) read_loc;

*velo = (real) read_velo;

} else

{

*loc = 0.0;

*velo = 0.0;

} }

/* write current location and velocity in file */ static void write_loc_velo_file (real loc, real velo) { FILE *fp = fopen(UDF_FILENAME, "w");

if (fp != NULL)

{

fprintf (fp, "%e %e", loc, velo);

fclose (fp);

} else

Message ("\nWarning: cannot write %s file", UDF_FILENAME); }

/* write current location and velocity in datafile */ static void write_data_file (real time, real loc, real velo, real force) { FILE *fp = fopen(UDF_DATA, "a+");

fprintf (fp, "%e %e %e %e \n", time, loc, velo, force); fclose (fp);

}

#endif /* !RP_NODE */

DEFINE_ON_DEMAND(reset_velocity) { #if !RP_NODE real loc, velo;

read_loc_velo_file (&loc, &velo); write_loc_velo_file (loc, 0.0);

Message ("\nUDF reset_velocity called:"); #endif }

DEFINE_CG_MOTION(valve, dt, cg_vel, cg_omega, time, dtime) { #if RP_NODE Thread *t = DT_THREAD (dt); face_t f; #endif real loc,velo,force;

/* reset velocities */ NV_S (cg_vel, =, 0.0); NV_S (cg_omega, =, 0.0);

if (!Data_Valid_P ())

return;

#if RP_NODE /* compute force on piston wall */ force = 0.0;

begin_f_loop (f, t)

{

real *AA;

AA = F_AREA_CACHE (f, t);

force += F_P (f, t) * AA[2];

} end_f_loop (f, t) #endif

#if PARALLEL force = PRF_GRSUM1(force); node_to_host_real_1 (force); #endif

# if RP_2D if (rp_axi)

force *= 2.0 * M_PI; # endif

#if !RP_NODE read_loc_velo_file (&loc, &velo);

/* add in spring force */ {

real s_force = K_SPRING * (loc + init_disp);

force = force - s_force; }

/* compute change in velocity */ {

real dv = dtime * force / m ;

velo += dv;

loc += velo * dtime; }

Message ("\nUDF valve: time(s)= %f, z_vel(m/s)= %f, force(N)= %f, loc(m)= %f\n",

time, velo, force, loc); write_loc_velo_file (loc, velo); write_data_file (time,loc,velo,force); #endif /* !RP_NODE */

#if PARALLEL host_to_node_real_1 (velo); #endif

cg_vel[2] = velo; }

DEFINE_CG_MOTION(moving_fluid, dt, cg_vel, cg_omega, time, dtime) { #if !RP_NODE Thread *t = DT_THREAD (dt); face_t f; real force, loc; #endif real velo;

/* reset velocities */ NV_S (cg_vel, =, 0.0); NV_S (cg_omega, =, 0.0);

if (!Data_Valid_P ())

return;

#if !RP_NODE read_loc_velo_file (&loc, &velo); #endif /* !RP_NODE */

#if PARALLEL host_to_node_real_1 (velo); #endif

cg_vel[2] = velo; }

  Reply With Quote

Reply


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
Dynamic Mesh UDF Qureshi FLUENT 7 March 23, 2017 08:37
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 22:38
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 05:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


All times are GMT -4. The time now is 16:53.