|
[Sponsors] |
July 22, 2020, 18:39 |
Running UDF in Parallel Mode
|
#1 |
New Member
sina hassanpoor
Join Date: Jun 2019
Posts: 4
Rep Power: 7 |
Hi everyone, hope you be healthy!
i wrote this udf for calculating the average pressure on a wall, but i think it only can be interpret in serial and i should rewrite this code for parallel or linux node, anyone can help me or rerwite it? #include "udf.h" real pavg; DEFINE_EXECUTE_AT_END(average_pressure) { Domain *d; face_t f; real pressure = 0.0; real A[ND_ND]; real area = 0.0; real area_tot = 0.0; int ID = 7; /*this is the ID of the boundary wall that I want to get the temperature from*/ Thread *t; int zone_ID; d = Get_Domain(1); t = Lookup_Thread(d,ID); pavg = 0.0; begin_f_loop(f,t) { F_AREA(A,f,t); area = NV_MAG(A)*2.0*M_PI; /*AREA*/ area_tot += area; pressure = F_P(f,t); pavg += pressure*area; Message ("Text %g \n", pavg); } end_f_loop(f,t) pavg /= area_tot; printf("Pavg = %g area_tot = %g\n",pavg,area_tot); Message ("Text %g \n", pavg); } DEFINE_CG_MOTION(move_body, dt, vel,omega, time, dtime) { real ome,Ra,A,B; /* reset velocities */ NV_S(vel,=,0.0); NV_S(omega,=,0.0); /* motion */ ome=pavg / 1000; vel[0] = 0.0; vel[1] = ome; vel[2] = 0.0; omega[0] = 0.0; omega[1] = 0.0; omega[2] = 0.0; } |
|
July 26, 2020, 22:47 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
compile the code
Code:
#include "udf.h" real pavg; DEFINE_EXECUTE_AT_END(average_pressure) { Domain *d; face_t f; real pressure = 0.0; real A[ND_ND]; real area = 0.0; real area_tot = 0.0; int ID = 7; /*this is the ID of the boundary wall that I want to get the temperature from*/ Thread *t; int zone_ID; d = Get_Domain(1); t = Lookup_Thread(d,ID); pavg = 0.0; begin_f_loop(f,t) { F_AREA(A,f,t); area = NV_MAG(A)*2.0*M_PI; /*AREA*/ area_tot += area; pressure = F_P(f,t); pavg += pressure*area; Message0("Text %g \n", pavg); } end_f_loop(f,t) #if RP_NODE area_tot = PRF_GRSUM1(area_tot); #endif pavg /= area_tot; Message0("Pavg = %g area_tot = %g\n",pavg,area_tot); Message0("Text %g \n", pavg); } DEFINE_CG_MOTION(move_body, dt, vel,omega, time, dtime) { real ome,Ra,A,B; /* reset velocities */ NV_S(vel,=,0.0); NV_S(omega,=,0.0); /* motion */ ome=pavg / 1000; vel[0] = 0.0; vel[1] = ome; vel[2] = 0.0; omega[0] = 0.0; omega[1] = 0.0; omega[2] = 0.0; }
__________________
best regards ****************************** press LIKE if this message was helpful |
|
July 27, 2020, 06:15 |
|
#3 |
New Member
sina hassanpoor
Join Date: Jun 2019
Posts: 4
Rep Power: 7 |
Thanks a lot alexander, it worked for area and based on that, i corrected it for pressure
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
parallel implementation of DEFINE_INIT UDF not working | eml51 | Fluent UDF and Scheme Programming | 1 | January 28, 2019 22:26 |
Running parallel case after parallel meshing with snappyHexMesh? | Adam Persson | OpenFOAM Running, Solving & CFD | 0 | August 31, 2015 23:04 |
simpleFoam parallel | AndrewMortimer | OpenFOAM Running, Solving & CFD | 12 | August 7, 2015 19:45 |
problem with compiling boundary condition udf in parallel mode | chem engineer | Fluent UDF and Scheme Programming | 11 | June 29, 2015 07:23 |
[PyFoam] Problems with the new PyFoam release | zfaraday | OpenFOAM Community Contributions | 13 | December 9, 2014 19:58 |