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

global variable in udf

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 21, 2009, 11:03
Default global variable in udf
  #1
Member
 
MOHSEN Zendehbad
Join Date: Aug 2009
Posts: 35
Rep Power: 16
mohsen zendehbad is on a distinguished road
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.
mohsen zendehbad is offline   Reply With Quote

Old   November 21, 2009, 14:16
Default
  #2
Senior Member
 
Herman
Join Date: Nov 2009
Posts: 122
Rep Power: 16
enry is on a distinguished road
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
enry is offline   Reply With Quote

Old   November 22, 2009, 05:30
Default
  #3
Member
 
MOHSEN Zendehbad
Join Date: Aug 2009
Posts: 35
Rep Power: 16
mohsen zendehbad is on a distinguished road
DEAR ENRY:
thank you for your swift response.

MOHSEN
mohsen zendehbad is offline   Reply With Quote

Reply


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
How to write k and epsilon before the abnormal end xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 15:33
Convergence moving mesh lr103476 OpenFOAM Running, Solving & CFD 30 November 19, 2007 14:09
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02:58
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 18:07
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 20:09


All times are GMT -4. The time now is 14:41.