|
[Sponsors] |
October 26, 2019, 04:11 |
UDF Code doesn't work
|
#1 |
New Member
jens meier
Join Date: Sep 2019
Posts: 28
Rep Power: 7 |
Hey, I really need your help.
I'm struggling with an UDF Code that should calculate the force that particles and a fluid (water) exert on a moving body. The velocity of the body should slow down dependent on these two forces. I wrote an UDF code, but Fluent says ERROR, the UDF isn't compiled for parallel use on the current platform. I really don't understand that. Here's my code. I really appreciate if somebody could check and help me #include "udf.h" static real v_prev = 0.3; DEFINE_DPM_BC(Particle_Infos,p,t,f,f_normal,dim) { #if !RP_HOST cell_t p_cell; /* Cells where particles reside */ real p_n; /* Number of particles in a parcel */ real p_mass; /* Mass of each particle */ real pur_vel[ND_ND]; /* Velocity of each particle */ int i; /* vector number*/ flow_time = CURRENT_TIME; /* Get current flow time */ Thread *p_cell_thread; /**** Now calculating force of particles*******/ p_cell = F_C0(f,t); /* return cell thread index in which face thread "t" is */ p_cell_thread = THREAD_T0(t); /* Get the face centroid from ANSYS FLUENT */ F_CENTROID(pur_f_centroid,f,t); /* Get the number of the particles in a parcel from FLUENT */ p_n = P_N(p); /* Get the mass of the particle from ANSYS FLUENT */ p_mass = P_MASS(p); /* Get the velocity of the particle from ANSYS FLUENT */ for(i=0;i<dim;i++) pur_vel[i] = P_VEL(p)[i]; /* When the particles hit the wall face, mark the cell, which consists this face.*/ C_UDMI(p_cell,p_cell_thread,0) = PUR_cell; /* Store the number of particles hitting this face all the time. */ C_UDMI(p_cell,p_cell_thread,1) += p_n; C_UDMI(p_cell,p_cell_thread,2) += p_n * p_mass; /* mass of particles hitting the face */ C_UDMI(p_cell,p_cell_thread,6) += p_n * p_mass * pur_vel[0]; /* Total impulse of all parcels in x direction in a cell */ C_UDMI(p_cell,p_cell_thread,17) += 1; /* Store the number of parcels hitting on this face all the time*/ return PATH_ABORT; #endif } DEFINE_CG_MOTION(bubble, dt, vel, omega, time, dtime) { Thread *t; face_t f; real NV_VEC(A); real Wall_Shear_Force; real viscous,force; real dv; real force_p; /* reset velocities */ NV_S (vel, =, 0.0); NV_S (omega, =, 0.0); if (!Data_Valid_P ()) return; /* get the thread pointer for which this motion is defined */ t = DT_THREAD (dt); /* compute pressure force on body by looping through all faces */ viscous = 0.0; begin_f_loop (f, t) { cell_t c0 = F_C0(f,t); Thread *t0 = THREAD_T0(t); F_AREA (A, f, t); Wall_Shear_Force = -F_STORAGE_R_N3V(f,t ,SV_WALL_SHEAR)[0]; viscous += Wall_Shear_Force ; force_p += C_UDMI(c0,t0,6); } end_f_loop (f, t) # if RP_NODE { /* Reduce in parallel */ PRF_GRSUM1 (viscous); PRF_GRSUM1 (force_p); } # endif /* compute change in velocity, i.e., dv = F * dt / mass velocity update using explicit Euler formula */ dv = dtime * (viscous + 0.000512 + force_p/dtime) / 0.000055; v_prev += dv; Message0("time = %f, x_vel = %f, force = %f\n", time, v_prev, force); /* set x-component of velocity */ vel[0] = v_prev; } |
|
October 28, 2019, 02:13 |
|
#2 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
try
Code:
#include "udf.h" static real v_prev = 0.3; DEFINE_DPM_BC(Particle_Infos,p,t,f,f_normal,dim) { #if !RP_HOST cell_t p_cell; /* Cells where particles reside */ real p_n; /* Number of particles in a parcel */ real p_mass; /* Mass of each particle */ real pur_vel[ND_ND]; /* Velocity of each particle */ int i; /* vector number*/ Thread *p_cell_thread; real flow_time; flow_time = CURRENT_TIME; /* Get current flow time */ /**** Now calculating force of particles*******/ p_cell = F_C0(f,t); /* return cell thread index in which face thread "t" is */ p_cell_thread = THREAD_T0(t); /* Get the face centroid from ANSYS FLUENT */ p_n = P_N(p); /* Get the mass of the particle from ANSYS FLUENT */ p_mass = P_MASS(p); /* Get the velocity of the particle from ANSYS FLUENT */ for(i=0;i<dim;i++) pur_vel[i] = P_VEL(p)[i]; /* When the particles hit the wall face, mark the cell, which consists this face.*/ C_UDMI(p_cell,p_cell_thread,0) = PUR_cell; /* Store the number of particles hitting this face all the time. */ C_UDMI(p_cell,p_cell_thread,1) += p_n; C_UDMI(p_cell,p_cell_thread,2) += p_n * p_mass; /* mass of particles hitting the face */ C_UDMI(p_cell,p_cell_thread,6) += p_n * p_mass * pur_vel[0]; /* Total impulse of all parcels in x direction in a cell */ C_UDMI(p_cell,p_cell_thread,17) += 1; /* Store the number of parcels hitting on this face all the time*/ return PATH_ABORT; #endif } DEFINE_CG_MOTION(bubble, dt, vel, omega, time, dtime) { Thread *t; face_t f; real NV_VEC(A); real Wall_Shear_Force; real viscous,force; real dv; real force_p; /* reset velocities */ NV_S (vel, =, 0.0); NV_S (omega, =, 0.0); if (!Data_Valid_P ()) return; /* get the thread pointer for which this motion is defined */ t = DT_THREAD (dt); /* compute pressure force on body by looping through all faces */ viscous = 0.0; begin_f_loop (f, t) { cell_t c0 = F_C0(f,t); Thread *t0 = THREAD_T0(t); F_AREA (A, f, t); Wall_Shear_Force = -F_STORAGE_R_N3V(f,t ,SV_WALL_SHEAR)[0]; viscous += Wall_Shear_Force ; force_p += C_UDMI(c0,t0,6); } end_f_loop (f, t) # if RP_NODE { /* Reduce in parallel */ PRF_GRSUM1 (viscous); PRF_GRSUM1 (force_p); } # endif /* compute change in velocity, i.e., dv = F * dt / mass velocity update using explicit Euler formula */ dv = dtime * (viscous + 0.000512 + force_p/dtime) / 0.000055; v_prev += dv; Message0("time = %f, x_vel = %f, force = %f\n", time, v_prev, force); /* set x-component of velocity */ vel[0] = v_prev; } C_UDMI(p_cell,p_cell_thread,0) = PUR_cell; PUR_cell; is not defined !!!!!!
__________________
best regards ****************************** press LIKE if this message was helpful |
|
October 28, 2019, 04:13 |
|
#3 |
New Member
jens meier
Join Date: Sep 2019
Posts: 28
Rep Power: 7 |
thank you !
I added a real PUR_cell; Now I can compile the code, but when I start calculating, Fluent breaks down and only the Workbench is open. What could now be the problem? best regards |
|
October 28, 2019, 04:19 |
|
#4 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
i don't know.
I recommend you to run Fluent separably
__________________
best regards ****************************** press LIKE if this message was helpful |
|
October 28, 2019, 06:23 |
|
#5 |
New Member
jens meier
Join Date: Sep 2019
Posts: 28
Rep Power: 7 |
thank you anyway.
Fluent does what it wants to, its kind of hopeless |
|
October 29, 2019, 00:54 |
|
#6 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
if you expect to get help you should describe everything in details
__________________
best regards ****************************** press LIKE if this message was helpful |
|
October 29, 2019, 05:07 |
|
#7 |
New Member
jens meier
Join Date: Sep 2019
Posts: 28
Rep Power: 7 |
I try to explain the problem in detail.
There is a moving body whose velocity slows down dependent on the viscous force that a fluid exerts on this body. So this UDF works fine. Now I inserted particles and realized that there is no difference. So my UDF Code doesn't see those particles. Thats the reason why I tried to extend my UDF code. The idea is that the impulse of all particles hitting the moving body is summed up and divided by time step in order to get the force. The UDF you see in this thread is the one who tries to calculate viscous force as well as force of particles. I can compile the UDF, but when I start calculating, FLUENT breaks down with No Error Messages. |
|
October 30, 2019, 01:19 |
|
#8 |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
something wrong with your settings, play with them
__________________
best regards ****************************** press LIKE if this message was helpful |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Urgent help for UDF Code needed | force_95 | FLUENT | 2 | October 25, 2019 08:35 |
Need help with udf code for particles | force_95 | FLUENT | 0 | October 24, 2019 09:58 |
UDF code for heat generating source | valerhain | Fluent UDF and Scheme Programming | 13 | November 18, 2015 15:24 |
udf fluent 6.3.26 don't work in fluent 12 | enry | Fluent UDF and Scheme Programming | 16 | September 9, 2010 03:44 |
Optimizing UDF Code | Cebeci | FLUENT | 18 | September 6, 2003 04:40 |