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

Save variable in DEFINE_EXECUTE_AT_END

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 18, 2012, 12:10
Default Save variable in DEFINE_EXECUTE_AT_END
  #1
New Member
 
Tim Sønderby
Join Date: Jun 2012
Posts: 5
Rep Power: 14
tim.sonderby is on a distinguished road
Send a message via Skype™ to tim.sonderby
HI,

I have a problem to store the CURRENT_TIME so that I can be used in the workbench as a parameter.

I have tried to use C_UDMI(c,t,0) but that does not work (yes I have allocated memory), but that juse returns a FATAL_Vialation.

everything works except for the storage of the time into a variable that can be acceded from the workbench:



/************************************************** ***************
UDF to calculate the variance on concentration. This can be used
for dertermination of the mixing time.

Define the limit for the variance that defines the mixing time.
Make sure that the tracer is the first material in mixture.

Auther: Tim Soenderby
Created: 16 June 2012
Modified: 16 June 2012
************************************************** **************/

#include "udf.h"
#define TAU_LIMIT 1e-8

real num_cells;
real avg_concentration;
real volume;
real TAU;
real mix_time;

DEFINE_EXECUTE_AT_END(store_mixing_time)
{
/* declare domain pointer since it is not passed as an argument to the DEFINE macro */
Domain *d;
Thread *t;
cell_t c;
/* Get the domain 1 (Mixture) */
d = Get_Domain(1);

num_cells = 0.;
volume = 0.;
avg_concentration =0.;
TAU = 0.;

/* Loop over all cell threads in the domain */
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
avg_concentration += C_YI(c,t,0)*C_VOLUME(c,t);
volume += C_VOLUME(c,t);
num_cells += 1;
}
end_c_loop(c,t)
}

avg_concentration = avg_concentration/volume;


/* Loop over all cell threads in the domain */
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
TAU += (C_YI(c,t,0)-avg_concentration)*(C_YI(c,t,0)-avg_concentration);
}
end_c_loop(c,t)
}

/*calculating the variance*/
TAU = 1/(num_cells-1)*TAU;

if (mix_time == 0.)
{
Message("**************** CHECKING IF MIXING TIME IS REACHED ***************\n");
if (( TAU < TAU_LIMIT) && (TAU > 0))
{
mix_time = CURRENT_TIME; /*source of error*/
C_UDMI(c,t,0) = mix_time;
Message("Mixing time is reached, and is: %g\n", mix_time);
}
}

Message("Number of cellss are: %g\n", num_cells);
Message("volume is: %g\n", volume);
Message("avg_cons is: %g\n", avg_concentration);
Message("TAU is: %g\n", TAU);

}
tim.sonderby is offline   Reply With Quote

Old   June 19, 2012, 05:04
Default
  #2
New Member
 
Tim Sønderby
Join Date: Jun 2012
Posts: 5
Rep Power: 14
tim.sonderby is on a distinguished road
Send a message via Skype™ to tim.sonderby
Okay I found a solution.


C_UDMI has to be in a loop, otherwise it crashes.
tim.sonderby is offline   Reply With Quote

Old   November 23, 2012, 09:22
Default
  #3
Senior Member
 
Join Date: May 2011
Posts: 231
Rep Power: 16
Kanarya is on a distinguished road
Quote:
Originally Posted by tim.sonderby View Post
Okay I found a solution.


C_UDMI has to be in a loop, otherwise it crashes.
Hi,

I would like to save the mass flow rate only at outlet. is it possible with DEFINE_EXECUTE_AT_END?
thanks in advance!!!
Kanarya is offline   Reply With Quote

Reply

Tags
memory, _at_end

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
OpenFoam-1.6-ext Allwmake compilation error - one last barrier Pat84 OpenFOAM Installation 15 July 25, 2012 21:49
emag beta feature: charge density charlotte CFX 4 March 22, 2011 09:14
error in COMSOL:'ERROR:6164 Duplicate Variable' bhushas COMSOL 1 May 30, 2008 04:35
Env variable not set gruber2 OpenFOAM Installation 5 December 30, 2005 04:27
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 20:09


All times are GMT -4. The time now is 15:38.