You can use DEFINE_UDS_UNSTEADY to
customize unsteady terms in your user-defined scalar (UDS) transport
equations. See User-Defined Scalar (UDS) Transport Equations in the User's
Guide for details on setting up and solving UDS transport
equations.
DEFINE_UDS_UNSTEADY (name,c,t,i,apu,su)
|
Argument Type |
Description |
|---|---|
|
|
UDF name. |
|
|
Cell index. |
|
|
Pointer to cell thread on which the unsteady term for the user-defined scalar transport equation is to be applied. |
|
|
Index that identifies the user-defined scalar for which the unsteady term is to be set. |
|
|
Pointer to central coefficient. |
|
|
Pointer to source term. |
Function returns
void
There are six arguments to DEFINE_UDS_UNSTEADY: name, c, t, i, apu, and su. You supply name, the name of the UDF. c, t, and i are variables that are passed by
the ANSYS Fluent solver to your UDF. Your UDF will need to set the values
of the unsteady terms referenced by the real pointers apu and su to the central coefficient and source term, respectively.
The ANSYS Fluent solver expects that the transient term will be
decomposed into a source term, su, and a
central coefficient term, apu. These terms
are included in the equation set in a similar manner to the way the
explicit and implicit components of a source term might be handled.
Hence, the unsteady term is moved to the right-hand side and discretized
as follows:
(2–29) |
Equation 2–29 shows how su and apu are defined. Note
that if more than one scalar is being solved, a conditional if statement can be used in your UDF to define a different
unsteady term for each i. i= is associated with scalar-0 (the first scalar equation
being solved).
The following UDF, named my_uds_unsteady, modifies user-defined scalar time derivatives using DEFINE_UDS_UNSTEADY. The source code can be interpreted
or compiled in ANSYS Fluent.
/***********************************************************************
UDF for specifying user-defined scalar time derivatives
************************************************************************/
#include "udf.h"
DEFINE_UDS_UNSTEADY(my_uds_unsteady,c,t,i,apu,su)
{
real physical_dt, vol, rho, phi_old;
physical_dt = RP_Get_Real("physical-time-step");
vol = C_VOLUME(c,t);
rho = C_R_M1(c,t);
*apu = -rho*vol / physical_dt;/*implicit part*/
phi_old = C_STORAGE_R(c,t,SV_UDSI_M1(i));
*su = rho*vol*phi_old/physical_dt;/*explicit part*/
}
After the UDF that you have defined using DEFINE_UDS_UNSTEADY is interpreted (Interpreting UDFs)
or compiled (Compiling UDFs), the name
of the argument that you supplied as the first DEFINE macro argument (for example, my_uds_unsteady) will become visible and selectable in the User-Defined
Scalars dialog box in ANSYS Fluent. See Hooking DEFINE_UDS_UNSTEADY UDFs for details.