[ANSYS, Inc. Logo] return to home search
next up previous contents index

2.7.4 DEFINE_UDS_UNSTEADY



Description


You can use DEFINE_UDS_UNSTEADY to customize unsteady terms in your user-defined scalar (UDS) transport equations. See this section in the separate User's Guide for details on setting up and solving UDS transport equations.



Usage



DEFINE_UDS_UNSTEADY( name,c,t,i,apu,su)


Argument Type Description
symbol name UDF name.
cell_t c Cell index.
Thread *t Pointer to cell thread on which the unsteady term for
  the user-defined scalar transport equation is to be applied.
int i Index that identifies the user-defined scalar for which the
  unsteady term is to be set.
real *apu Pointer to central coefficient.
real *su 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:


$\displaystyle \mbox{unsteady term}$ $\textstyle =$ $\displaystyle - \int \frac{\partial}{\partial t} \left(\rho \phi \right) dV$  
  $\textstyle \approx$ $\displaystyle - \left[ \frac{\left(\rho \phi \right)^n - \left(\rho \phi \right)^{n-1}} {\Delta t} \right] \cdot \Delta V$  
  $\textstyle =$ $\displaystyle \underbrace{-\frac{\rho \Delta V}{\Delta t}}_{\mathtt{apu}} \phi^n + \underbrace{\frac{\rho \Delta V}{\Delta t} \phi^{n-1}}_{\mathtt{su}}$ (2.7-3)

Equation  2.7-3 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 = $0$ is associated with scalar-0 (the first scalar equation being solved).



Example


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*/
}



Hooking a UDS Unsteady Function to ANSYS FLUENT


After the UDF that you have defined using DEFINE_UDS_UNSTEADY is interpreted (Chapter  4) or compiled (Chapter  5), the name of the argument that you supplied as the first DEFINE macro argument (e.g., my_uds_unsteady) will become visible and selectable in the User-Defined Scalars dialog box in ANSYS FLUENT. See Section  6.6.3 for details.


next up previous contents index Previous: 2.7.3 DEFINE_UDS_FLUX
Up: 2.7 User-Defined Scalar (UDS)
Next: 3. Additional Macros for
Release 12.0 © ANSYS, Inc. 2009-01-14