|
[Sponsors] |
May 23, 2011, 05:44 |
Parallel DPM Udf problem
|
#1 |
New Member
Johney Grey
Join Date: May 2011
Posts: 6
Rep Power: 15 |
Hi, all! I wrote a DPM UDF for fluent 6.3.26. But I don't know how to edit it to parallel UDF(1CPU 8cores ). Can anyone help me, plz?
By the way, could this udf run on Liunx system? #include "udf.h" #include "dpm.h" #include "math.h" #include "time.h" #include "stdio.h" static int n=0; double integral(double s) // to generate a parabolic particle distribution { double a=0.0,b=5.0,mid=2.5,y=-0.004*mid*mid*mid+0.3*mid; for(;fabs(s-y)>1e-6; ) { if(s>y) { a=mid; mid=(mid+b)/2.0; } else { b=mid; mid=(a+mid)/2.0; } y=-0.004*mid*mid*mid+0.3*mid; } return mid; } DEFINE_DPM_INJECTION_INIT(init_particles,I) { Particle *p; FILE *fp; real xm[ND_ND]; double R=0.0, x=0.0, y=0.0, an=0.0,k=0.0; if(n==0)srand((unsigned)time( NULL )); k=rand()/(double)(RAND_MAX); R=integral(k); an=rand()/(double)(RAND_MAX)*2*3.1415926; x=R*sin(an)/200.0; y=R*cos(an)/200.0; Message ("\n n=%d, k=%f\n",n, k); n++; p=I->p_init; P_POS(p)[0]=x; P_POS(p)[1]=y; P_POS(p)[2]=0.0; Message ("particle position x=%f, y=%f\n", P_POS(p)[0],P_POS(p)[1]); xm[0]=P_POS(p)[0]; xm[1]=P_POS(p)[1]; xm[2]=P_POS(p)[2]; P_DIAM(p)=5e-6; P_RHO(p)=1000; P_MASS(p)=P_RHO(p)*M_PI*pow(P_DIAM(p),3.0)/6.0; P_FLOW_RATE(p)=P_MASS(p)/0.06; fp=fopen("e:\\test\\pa.txt","at"); fprintf(fp,"%f %f %f\n",R,xm[0],xm[1]); fclose(fp); } |
|
June 10, 2011, 05:12 |
|
#2 |
Member
john
Join Date: Nov 2010
Posts: 50
Rep Power: 16 |
for parallel code you should keep
#if !RP_HOST #endif and #if ! RP_NODE #endif has to be kept at appropriate places in the code. See UDF manual for more details |
|
June 10, 2011, 09:26 |
|
#3 |
New Member
Johney Grey
Join Date: May 2011
Posts: 6
Rep Power: 15 |
Thanks for your reply. But I just don't know where to put them. The manual only has one page mentioned about the paralleliztion of DPM model. And it mainly talks about message output.
|
|
June 11, 2011, 01:43 |
|
#4 |
Member
john
Join Date: Nov 2010
Posts: 50
Rep Power: 16 |
HI i am not an expert, based on my knowledge i have corrected your code below
#include "udf.h" #include "dpm.h" #include "math.h" #include "time.h" #include "stdio.h" static int n=0; double integral(double s) // to generate a parabolic particle distribution { #if !RP_HOST double a=0.0,b=5.0,mid=2.5,y=-0.004*mid*mid*mid+0.3*mid; for(;fabs(s-y)>1e-6; ) { if(s>y) { a=mid; mid=(mid+b)/2.0; } else { b=mid; mid=(a+mid)/2.0; } y=-0.004*mid*mid*mid+0.3*mid; } return mid; #end if } DEFINE_DPM_INJECTION_INIT(init_particles,I) { #if !RP_HOST Particle *p; FILE *fp; real xm[ND_ND]; double R=0.0, x=0.0, y=0.0, an=0.0,k=0.0; if(n==0)srand((unsigned)time( NULL )); k=rand()/(double)(RAND_MAX); R=integral(k); an=rand()/(double)(RAND_MAX)*2*3.1415926; x=R*sin(an)/200.0; y=R*cos(an)/200.0; // Message ("\n n=%d, k=%f\n",n, k); n++; p=I->p_init; P_POS(p)[0]=x; P_POS(p)[1]=y; P_POS(p)[2]=0.0; //Message ("particle position x=%f, y=%f\n", P_POS(p)[0],P_POS(p)[1]); xm[0]=P_POS(p)[0]; xm[1]=P_POS(p)[1]; xm[2]=P_POS(p)[2]; P_DIAM(p)=5e-6; P_RHO(p)=1000; P_MASS(p)=P_RHO(p)*M_PI*pow(P_DIAM(p),3.0)/6.0; P_FLOW_RATE(p)=P_MASS(p)/0.06; #endif node_to_host_real_3(R, xm[0],xm[1]); #if !RP_NODE fp=fopen("e:\\test\\pa.txt","at"); fprintf(fp,"%f %f %f\n",R,xm[0],xm[1]); fclose(fp); #endif } you may need to change some more look at carefully and change. all the best |
|
June 11, 2011, 11:03 |
|
#5 | |
New Member
Johney Grey
Join Date: May 2011
Posts: 6
Rep Power: 15 |
Quote:
|
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
problem loading UDF library in parallel cluster | Veera Gutti | FLUENT | 8 | July 26, 2016 08:24 |
UDF compiling problem | Wouter | Fluent UDF and Scheme Programming | 6 | June 6, 2012 05:43 |
A UDF Problem in Parallel Mode | Jun | FLUENT | 1 | October 26, 2011 13:49 |
problem loading UDF in parallel fluent | Tim | FLUENT | 12 | July 12, 2008 13:59 |
DPM - UDF for fluctuating bubble size | Jaroslav Kotara | FLUENT | 1 | April 19, 2006 10:02 |