|
[Sponsors] |
November 21, 2009, 12:03 |
global variable in udf
|
#1 |
Member
MOHSEN Zendehbad
Join Date: Aug 2009
Posts: 35
Rep Power: 17 |
i am writing a DEFINE_SOURCE, how can i define a global variable in udf whose value doesn't reset by the repetition of the udf for each cell in the zone.
|
|
November 21, 2009, 15:16 |
|
#2 |
Senior Member
Herman
Join Date: Nov 2009
Posts: 122
Rep Power: 17 |
Hi,
when you need a global variable you have to define that variable OUTSIDE of any single function, so the variable is visible to all functions within a UDF source file .I past to you a text that you can find in UDF guide. Global variables are variables that are defined outside of any single function and are visible to all function(s) within a UDF source file. Global variables can also be used by other functions outside of the source file unless they are declared as static (see Section A.5.3: Static Variables). Global variables are typically declared at the beginning of a file, after preprocessor directives as in #include "udf.h" real volume; /* real variable named volume is declared globally */ DEFINE_ADJUST(compute_volume, domain) { /* code that computes volume of some zone */ volume = .... } Otherwise, If you have a global variable that is declared in one source code file, but a function in another source file needs to use it, then it must be defined in the other source file as an EXTERNAL variable. See also: http://hpce.iitm.ac.in/website/Manua...help/index.htm |
|
November 22, 2009, 06:30 |
|
#3 |
Member
MOHSEN Zendehbad
Join Date: Aug 2009
Posts: 35
Rep Power: 17 |
DEAR ENRY:
thank you for your swift response. MOHSEN |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to write k and epsilon before the abnormal end | xiuying | OpenFOAM Running, Solving & CFD | 8 | August 27, 2013 16:33 |
Convergence moving mesh | lr103476 | OpenFOAM Running, Solving & CFD | 30 | November 19, 2007 15:09 |
IcoFoam parallel woes | msrinath80 | OpenFOAM Running, Solving & CFD | 9 | July 22, 2007 03:58 |
Could anybody help me see this error and give help | liugx212 | OpenFOAM Running, Solving & CFD | 3 | January 4, 2006 19:07 |
Replace periodic by inlet-outlet pair | lego | CFX | 3 | November 5, 2002 21:09 |