CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Please check out my parallelized udf

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Search this Thread Display Modes
Old   June 9, 2011, 17:57
Default Please check out my parallelized udf
Join Date: Mar 2011
Posts: 38
Rep Power: 13
aleisia is on a distinguished road
Hi! I want to model a filter (but not modeling it as a porous media), in a room I have SO2 and air mixture. First I want to get the SO2 mass flow rate at the inlet surface of the filter, then multiply it by 0.999989, and set the sink rate of the filter volume as -0.999989*(SO2 mass flow rate at the inlet surface)/(Volume of filter). For the outlet of the filter, I set it as "interior", and my simulation is always transient.

Below is my code, please advise.

Parallelized udf

#include "udf.h"
DEFINE_SOURCE(cell_SO2mass_source,cell,thread,dS,e qn)

#if !RP_HOST
real x[ND_ND];
real source,
t, massflowrate, volume, vol_tot;
real ti = RP_Get_Real("flow-time");
real NV_VEC(flux), NV_VEC(A); /* declaring vectors flux and A */
face_t face, f
d = Get_Domain(1);
t= Lookup_Thread(d, 12); /* defining the inlet surface thread by specifying the Zone_ID*/
#endif /* !RP_HOST */

/* Send the ID value to all the nodes */
host_to_node_int_1(12); /* Does nothing in serial */
host_to_node_real_3(t, cell, thread); /* Does nothing in serial, t is the thread of inlet surface, thread is the thread of the filter volume */

#if !RP_HOST

if PRINCIPAL_FACE_P(f,t) /* tests if the face is the principle face FOR COMPILED UDFs ONLY */

NV_D(flux, =, F_U(f,t), F_V(f,t), F_W(f,t)); /* defining flux in terms of velocity field */
NV_S(flux, *=, F_R(f,t)) /* multiplying density to get flux vector */
F_AREA(A,f,t) /* face normal vector returned from F_AREA */
massflowrate+= F_YI(f,t,i)*NV_DOT(flux,A); /* dot product of the inlet surface flux and area vector*/
/* multiplied by the mass fraction of species i */

# if RP_NODE /* Perform node synchronized actions here, Does nothing in Serial */
massflowrate = PRF_GRSUM1(massflowrate);
# endif /* RP_NODE */

volume = C_VOLUME(cell,thread); /* get cell volume */
vol_tot += volume;
# if RP_NODE /* Perform node synchronized actions here,Does nothing in Serial */
vol_tot = PRF_GRSUM1(vol_tot);
# endif /* RP_NODE */
#endif /* !RP_HOST */

/* Pass the node's SO2 mass flow rate and volume to the Host for calculating source */
node_to_host_real_2(massflowrate, vol_tot); /* Does nothing in SERIAL */

#if !RP_NODE /* SERIAL or HOST */
source=-0.999989* massflowrate/vol_tot;

return source;
Message("Sink Rate in Filter %d is %f (kg/m^3/s)\n", filter_zone _id,( =-0.999989* massflowrate/vol_tot));
#endif /* !RP_NODE */


My questions:
1. Is there any command like "
if PRINCIPAL_FACE_P(f,t) " for the cells, because I need to calculate the total volume, too. If so, I will add it right after "begin_c_loop(cell,thread)" but outside of the loop "{}".
2. the "filter_zone_id" is the filter volume that I'm interested in, should I use "d" here? or should I go to the "zone" panel, and find out the zone_ID of this filter volume? then put this integer substituting "filter_zone-id"? Let's assume the zone_ID=5, and the zone_ID=12 for the inlet surface, as I already wrote above, to get "
t= Lookup_Thread(d, 12);"
3. Do I have to write another "host_to_node_int_1(5); " to pass the "5" from the host to the node? or "host_to_node_real_3(t, cell, thread);" is actually sufficient enough? After all, cell and thread is already called in DEFINE_SOURCE and they are for the "domain d" of the filter volume.
4. Did I put the "source" right? I mean, I should define the "source" in the host instead of in the nodes, right? i.e., define the source on the basis of the total volume in the host instead of in the partitioned domain in the nodes, am I getting this right?

aleisia is offline   Reply With Quote


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 using c_face_loop(c,t,i) frederic FLUENT 3 January 17, 2017 00:17
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 22:38
critical error during installation of openfoam Fabio88 OpenFOAM Installation 21 June 2, 2010 04:01
Help Parallelizing UDF AndresC FLUENT 0 February 25, 2010 16:50

All times are GMT -4. The time now is 07:30.