CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

UDF: exporting a variable between two DEFINE function

Register Blogs Community New Posts Updated Threads Search

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   August 17, 2009, 12:31
Default UDF: exporting a variable between two DEFINE function
  #1
New Member
 
Carlo Locci
Join Date: Apr 2009
Posts: 8
Rep Power: 17
Carlo is on a distinguished road
Hi to all. Here's my problem:
I'm dealing with coal combustion; in my case I have also gas recirculation. In particular, I have an UDF that computes the outlet NOx mass fraction; this value must be imposed in an inlet (due to the recirculation). Any idea to do it? Here's my UDF:

#include "udf.h"

DEFINE_ADJUST(noflux, domain)
{
int zone_ID = 4;
Thread *t = Lookup_Thread(domain,zone_ID);
face_t f;
real summ=0.;
real m;
real sumnox=0.;
real mnox;
real nox;
real sumarea=0.;
real area;
real Cnox;
real NV_VEC (A);
begin_f_loop(f,t)
{
F_AREA(A,f,t);
nox=C_POLLUT(f,t,1); /*Pollutant mass fraction Kg(NO)/Kg(g) in each face*/
mnox=F_U(f,t)*F_R(f,t)*NV_MAG(A)*6.28*nox; /*[Kg(NO)/Kg(g)]*[Kg(g)/s]=[Kg(NO)/s] in each face*/
sumnox += mnox; /*Kg(NO)/s in the whole domain*/
m=F_U(f,t)*F_R(f,t)*NV_MAG(A)*6.28;
summ += m; /*Kg(g)/s in the whole domain*/
area=NV_MAG(A)*6.28;
sumarea += area;
}
end_f_loop(f,t)
Cnox=sumnox/summ; /*[Kg(NO)/s]/[Kg(g)/s]*/
printf("massf: %g,%g,%g,%g\n", summ,sumnox,Cnox,sumarea);
}

real Cnox; /*Why do I have to declare it twice? Does fluent hold it?*/
DEFINE_PROFILE(noflux_b, t, nv)
{
face_t f;
begin_f_loop(f, t)
{
F_PROFILE(f,t,nv) = Cnox;
}
end_f_loop(f, t)
}

The ID=4 corresponds to the outlet. Am I doing it right? After having compiled and loaded the UDF, I hooked the noxflux function (DEFINE_ADJUST) whereas in the boundary condition of the considered inlet, in the NO mass fraction menu I set the noxflux_b function (DEFINE_PROFILE).
I'm not sure about this way to proceed. Indeed I don't know if the second DEFINE holds the Cnox variable value or if It clears it. I think this because if I don't declare "real Cnox" before starting the second DEFINE, I get the error "undeclared...etc", as if it had seen the Cnox variable for the first time! Any Idea?
Thanks!!
Carlo is offline   Reply With Quote

 

Tags
udf exporting variable


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
[blockMesh] BlockMesh FOAM warning gaottino OpenFOAM Meshing & Mesh Conversion 7 July 19, 2010 14:11
UDF parse error at profile function line Wiggy Fluent UDF and Scheme Programming 1 July 27, 2009 15:59
OpenFoam 14 installation problem gfcoppola OpenFOAM Installation 20 November 2, 2007 13:38
Droplet Evaporation Christian Main CFD Forum 2 February 27, 2007 06:27
define profile UDF greg FLUENT 1 June 3, 2006 03:44


All times are GMT -4. The time now is 08:25.