CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   user-defined memory (

Mark May 24, 2005 11:18

user-defined memory

I am wondering if there is a way to pass a value of a variable from one routine to another. For example, I have a DEFINE_ON_DEMAND function that calculates a value for velocity. I want to pass this velocity to my DEFINE_PROFILE function. C_UDMI is a user-defined memory location for cells. Is there one for just a single value?



Alec Eiffel May 24, 2005 11:33

Re: user-defined memory
I dont know of any way other than UDM's to pass variables between macros. I suggest you put a thread loop in your DEFINE_ON_DEMAND macro and fills all cells in the domain with with the same velocity value in a UDM. Then when you access the UDM in DEFINE_PROFILE it doesnt matter which cell is accessed because they all have same value.

Luca May 24, 2005 11:44

Re: user-defined memory
Use a global variable. Luca

Mark May 24, 2005 11:54

Re: user-defined memory
For clarity, I am using compiled udfs.


I have tried this but cannot seem to get it to work. I am relatively new with C and am trying to figure out where I declare the variables as "extern". Is it in the routine I am working with it? just in the .c file? or in a .h file which I then include?

Also, when using external variables do all of the routines have to be in the same .c file?

Thanks, Mark

Mark May 24, 2005 11:54

Re: user-defined memory

Thanks for the suggestion, but I would like to reduce the looping if at all possible.


Luca May 24, 2005 11:58

Re: user-defined memory
I use a unique file, if you have more than 1 file you should pay attention. I declare a variable outside an EXECUTE_ON_DEMAND or DEFINE_PROFILE funtion. This way I can modifiy its value outside the function. I hope to be clear. Luca

Mark May 24, 2005 12:40

Re: user-defined memory
Hi Luca,

Do you also declare that variable as "extern" inside the function?


pUl| May 24, 2005 12:43

Re: user-defined memory
Luca, is it possible to initialize UDM-0 with specified x and y values?

For instance, lets say we have a pipe and I know the experimental values of velocities at certain points in the radial direction. However, I do not wish to use these values in my CFD simulation. Instead, I wish to use these values later in one of my custom field functions that calculates say the sum of squared errors between the simulated and experimental velocities.

So how can I store user-specified values in a UDM for later postprocessing?

Mahesh June 8, 2005 01:17

Re: user-defined memory
I think u can use the UDM defined in 'on-demand' UDF to 'profile' udf. For post-processing, u can define another UDM with expt. values or define custom field function.

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