|
[Sponsors] |
UDF: exporting a variable between two DEFINE function |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 17, 2009, 12:31 |
UDF: exporting a variable between two DEFINE function
|
#1 |
New Member
Carlo Locci
Join Date: Apr 2009
Posts: 8
Rep Power: 17 |
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!! |
|
Tags |
udf exporting variable |
|
|
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 |