FLUENT6 - freezing the values of selected flow variables in selected cell zones

There are times when it is desirable to freeze the solution for one of the variables in one or more cell zones. FLUENT provides a method for fixing the values in a cell zone if constant values are desired, but does not permit holding the values at their current values.
The UDF below enables the cell temperature to be held at it's current value in a specific cell zone. It can be easily extended to multiple variables or cell zones.

To use the UDF, the DEFINE_ON_DEMAND macro should be executed to store the current cell value in user-defined memory. The DEFINE_SOURCE macro should then be hooked to the appropriate fluid zone in the boundary condition panel.

/* freeze one of the variables in one fluid zone only */

/* requires one UDMI */

#include "udf.h"

#define ZONE_ID 3 /* zone id of the cell zone to be held constant */

/* store current cell temperature in user-defined memory */
DEFINE_ON_DEMAND(update_UDMI)
{
Domain *domain = Get_Domain(1);
Thread *t;
cell_t c;

thread_loop_c(t,domain)
{
if ( ZONE_ID == THREAD_ID(t) )
{
begin_c_loop(c,t)
{
C_UDMI(c,t,0) = C_T(c,t);
}
end_c_loop(c,t)
}
}
}


/* add source to transport equation to freeze value */
#define BIG 9.9e20

DEFINE_SOURCE(freeze_energy, c, t, dS, eqn)
{
real source = 0.0;

if ( ZONE_ID == THREAD_ID(t) )
{
source = BIG*( C_UDMI(c,t,0) - C_T(c,t) );
dS[eqn] = -BIG;
}
else
dS[eqn] = 0.0;

return source;
}





Show Form
No comments yet. Be the first to add a comment!