|
[Sponsors] |
November 13, 2008, 09:12 |
parapllelizing a serial udf
|
#1 |
Guest
Posts: n/a
|
I need help in parallelizing an interpretable serial udf.
Attached is the udf #include "udf.h" #include "unsteady.h" #include "mem.h" #define npt_press 721 #define cycle_time 0.02400 int liner = 6; double pbound,vbound,tbound; double time[1000], pressure[1000], Temp[1000], velocity[1000]; //typedef struct //{ // double p, T, v; // double t; //}ptvar; //ptvar *pt_dat; //ptvar pt_dat[npt_press+1]; DEFINE_INIT(my_init_func,d) { #if !RP_HOST int i; int phase_domain_index; cell_t c; Thread *t; //Domain *mixture_domain; Domain *subdomain; Thread *tw = Lookup_Thread(d,liner); face_t f; real xc[ND_ND]; FILE *fp1; //mixture_domain = Get_Domain(1); d = Get_Domain(1); //Message("I am in initilization"); //if(pt_dat!=NULL) //pt_dat=(ptvar *) malloc ( npt_press *sizeof(ptvar)); fp1=fopen("bdata.txt","r"); for(i=1;i<=npt_press;i++) { fscanf(fp1,"%lf %lf %lf %lf\n",&(time[i]),&(pressure[i]),&(Temp[i]),&(velocity[i])); pressure[i]=pressure[i]*1e5; //Message("pt_dat[%d].t=%lf,pt_dat[%d].p=%lf\n",i,pt_dat[i].t,i,pt_dat[i].p); } /* Added to initilize the boundary conditions */ pbound=pressure[i]; vbound=velocity[i]; tbound=Temp[i]; //Message("Pbound=%g\n",vbound); /* updating the cylinder motion */ begin_f_loop(f,tw) { F_V(f,tw) =vbound; } end_f_loop(f,tw) /* loop over all subdomains (phases) in the superdomain (mixture) */ // sub_domain_loop(subdomain, mixture_domain, phase_domain_index) sub_domain_loop(subdomain, d, phase_domain_index) { /* loop if secondary phase */ if (DOMAIN_ID(subdomain) == 3) /* loop over all cell threads in the secondary phase domain */ thread_loop_c (t,subdomain) { /* loop over all cells in secondary phase cell threads */ begin_c_loop_all (c,t) { C_CENTROID(xc,c,t); if (((xc[1] > -0.057) && (xc[1] < -0.047)) && (sqrt(ND_SUM(pow(xc[0] - 0.0,2.), pow(xc[2] - 0.0,2.), 0.0)) < 0.0125) // //&& (sqrt(ND_SUM(pow(xc[0] - 0.0,2.), pow(xc[2] - 0.0,2.), 0.0)) > 0.04035) ) /* set volume fraction to 1 for centroid */ C_VOF(c,t) = 0.9; else /* otherwise initialize to zero */ C_VOF(c,t) = 0.; } end_c_loop_all (c,t) } } #endif } DEFINE_PROFILE(pressure_profile,t,k) { #if !RP_HOST int i,j; double time_use,tvar; double fx,fxm; int ncycle; face_t f; //Message("Pbound=%g\n",pbound); begin_f_loop(f,t) { F_PROFILE(f,t,k) = pbound ; } end_f_loop(f, t) #endif } DEFINE_PROFILE(temp_profile,t,k) { #if !RP_HOST int i,j; double time_use,tvar; double fx,fxm; int ncycle; face_t f; //Message("Pbound=%g\n",tbound); begin_f_loop(f,t) { F_PROFILE(f,t,k) = tbound ; } end_f_loop(f, t) #endif } /* Pls. check if this can be added to DEFINE_EXECUTE_AT_END(bound_update) */ //DEFINE_ADJUST(liner_velocity,d) // { //int i,j; //double time_use,tvar; //double fx,fxm; //int ncycle; //Thread *tw = Lookup_Thread(d,liner); //face_t f; //Message("Pbound=%g\n",vbound); // begin_f_loop(f,tw) // { // F_V(f,tw) =vbound; // } // end_f_loop(f,tw) //} DEFINE_EXECUTE_AT_END(bound_update) { #if !RP_HOST int i,j; double time_use,tvar; double fx,fxm; int ncycle; face_t f; Domain *d=Get_Domain(1); Thread *tw = Lookup_Thread(d,liner); /*Getting the boundary conditions for the next time step */ time_use=CURRENT_TIME+CURRENT_TIMESTEP; ncycle=time_use/cycle_time; //Message("I am in bound%g,%d\n",CURRENT_TIME,ncycle); time_use=time_use-ncycle*cycle_time; //Message("ncycle=%g\n",ncycle); /* program to sort */ for(i=1;i<=npt_press;i++) { tvar=-time_use+time[i]; //Message("pt.dat[i].p=%f, tvar=%f\n",pt_dat[i].t,tvar); if(tvar>=0.0) break; } j=i; //Message("j=%d i=%d\n",j,i); if(tvar==0.0) { pbound=pressure[i]; vbound=velocity[i]; tbound=Temp[i]; } else { fxm=(time[j+1]-time_use)/(time[j+1]-time[j]); fx=(-time[j]+time_use)/(time[j+1]-time[j]); vbound=fxm * velocity[j]+fx * velocity[j+1]; pbound=fxm * pressure[j]+fx * pressure[j+1]; tbound=fxm * Temp[j]+fx * Temp[j+1]; } /* Pls uncomment if the below is required */ /* Pls. Check whether the wall velocity is updated */ //Message("Pbound=%g\n",vbound); begin_f_loop(f,tw) { F_V(f,tw) =vbound; } end_f_loop(f,tw) #endif } |
|
November 13, 2008, 09:32 |
Re: parallelizing a serial udf
|
#2 |
Guest
Posts: n/a
|
Hi,
when I am trying to interpret the parallel udf, it gives me the following error Error: CAR: invalid argument [1]: wrong type [not a pair] Error Object: () What does this mean? |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
More DPM incompletes in parallel than in serial | Paul | FLUENT | 0 | December 16, 2008 10:27 |
Serial vs parallel different results | luca | OpenFOAM Bugs | 2 | December 3, 2008 11:12 |
automatic serial job | Toralf | CFX | 4 | October 17, 2007 03:12 |
parallel Vs. serial | co2 | FLUENT | 1 | December 31, 2003 03:19 |
5.5 serial run | Bogesz | CFX | 2 | July 5, 2002 12:53 |