The DEFINE_DYNAMIC_ZONE_PROPERTY UDF
can be used in the following applications:
swirl center definition for in-cylinder applications
variable cell layering height
You can use DEFINE_DYNAMIC_ZONE_PROPERTY to calculate swirl center while computing in-cylinder specific output.
Important: Note that UDFs that are defined using DEFINE_DYNAMIC_ZONE_PROPERTY can only be executed as compiled UDFs.
For information on setting in-cylinder parameters, see In-Cylinder Settings in the User's Guide.
DEFINE_DYNAMIC_ZONE_PROPERTY (name, dt, swirl_center)
|
Argument Type |
Description |
|---|---|
|
|
UDF name. |
|
|
Pointer to a structure that stores the dynamic mesh attributes. This is set to NULL internally as there are no dynamic zones in the current calculation of swirl center. |
|
|
Pointer to a real array of 3 dimension. You will assign this
value in the UDF. The |
Function returns
void
There are three arguments to DEFINE_DYNAMIC_ZONE_PROPERTY: name, dt, and
swirl_center. You supply name, the name of the UDF, and pointer to a real array, swirl_center. dt is a variable that is passed by the ANSYS Fluent solver
to your UDF.
/* UDF hook for calculating Swirl Center while computing
In-Cylinder specific output. Arguments for the UDF
hook are name of the UDF, dt (dynamic thread) which is
set to NULL and it is not supposed to be manipulated
in the UDF, as there are no dynamic zones in the current
context and swirl center which is to be calculated in the
UDF. Works in parallel as well.
*/
#include "udf.h"
#define RPM RP_Get_Real("dynamesh/in-cyn/crank-rpm")
static real Zmin_at_TDC = -0.0014; /* Piston location at TDC */
static real Zmax = 0.0145; /* Zmax, a fixed point */
static void my_swirl_center(real * swirl_center)
{
real piston_displacement, lambda, CA, l, r;
#if !RP_NODE
l = RP_Get_List_Ref_Float("dynamesh/in-cyn/piston-data", 0);
r= 0.5 * RP_Get_List_Ref_Float("dynamesh/in-cyn/piston-data",1);
#endif
host_to_node_real_2(l,r);
lambda = r/l;
CA = (CURRENT_TIME*RPM*6.0 +
RP_Get_Real("dynamesh/in-cyn/crank-start-angle"))*M_PI/180;
piston_displacement = r*((1+1/lambda) - cos(CA) -
pow(1-lambda*lambda*sin(CA)*sin(CA),0.5)/lambda);
swirl_center[0]=0;
swirl_center[1]=0;
if (Zmin_at_TDC<Zmax)
swirl_center[2]=0.5*(Zmin_at_TDC+Zmax-piston_displacement);
else
swirl_center[2]=0.5*(Zmin_at_TDC+Zmax+piston_displacement);
return;
}
DEFINE_DYNAMIC_ZONE_PROPERTY(swirl_udf, dt, sc)
{
my_swirl_center(sc);
}
After the UDF that you have defined using DEFINE_DYNAMIC_ZONE_PROPERTY is compiled (as described in Compiling UDFs), the name of the argument that you supplied as the first DEFINE macro argument will become visible in the In-Cylinder Output Controls dialog box in ANSYS Fluent.
See Hooking DEFINE_DYNAMIC_ZONE_PROPERTY UDFs for details on
how to hook your DEFINE_DYNAMIC_ZONE_PROPERTY UDF to ANSYS Fluent.
You can use DEFINE_DYNAMIC_ZONE_PROPERTY to specify a varying cell layering height when using the dynamic
layering method to split or merge cells adjacent to a moving boundary.
The cell layering height can be specified as a function of time for
general applications, or as a function of crank angle for in-cylinder
applications.
Important: Note that UDFs that are defined using DEFINE_DYNAMIC_ZONE_PROPERTY can only be executed as compiled UDFs.
For information on the dynamic layering method, see Dynamic Layering in the User's Guide.
DEFINE_DYNAMIC_ZONE_PROPERTY (name, dt, height)
|
Argument Type |
Description |
|---|---|
|
|
UDF name. |
|
|
Pointer to a structure that stores the dynamic mesh attributes. |
|
|
Pointer to a real value layering height whose value will be varied in the UDF as a function of time or crank angle. |
Function returns
void
There are three arguments to DEFINE_DYNAMIC_ZONE_PROPERTY: name, dt, and
height. You supply name, the name of the UDF, and height, the cell
layering height to be assigned in the UDF as a function of time /
crank angle. dt is a variable that is passed
by the ANSYS Fluent solver to your UDF.
In addition to the arguments listed previously, you can use
the variable in_cyl_ca_period and the macros
DYNAMESH_CURRENT_TIME and TIME_TO_ABSOLUTE_CRANK_ANGLE (time), which are described as follows:
|
Variable/Macro |
Description |
|---|---|
|
|
Crank angle period. |
|
|
Current dynamic mesh time. |
|
|
Macro which takes the current time as input and returns the absolute value of the crank angle that is displayed on the mesh preview screen. |
Note that in_cyl_ca_period is the value
entered for Crank Period in the In-Cylinder tab of the Options dialog box (which can be
opened via the Dynamic Mesh task page). The usage
of this variable or the macros specified previously necessitates that
the DEFINE_DYNAMIC_ZONE_PROPERTY UDF be a
compiled UDF. Their usage is illustrated in the example that follows.
Note that the header file dynamesh_tools.h should be included in the UDF, as shown in the example that follows.
/* UDF hook for implementing varying cell layering height.
Arguments are the Name of the UDF,
variable for dynamic thread, and variable
which holds the layering height value.
Works only as a compiled UDF, because the usage of
in_cyn_ca_period and the macros are not
allowed in interpreted UDFs.
Header file dynamesh_tools.h should be
included in order to access the macros
DYNAMESH_CURRENT_TIME and TIME_TO_ABSOLUTE_CRANK_ANGLE
*/
#include "udf.h"
#include "dynamesh_tools.h"
DEFINE_DYNAMIC_ZONE_PROPERTY(nonconst_height, dt, lh)
{
int temp;
/* Local variable for storing the value of
Absolute Crank Angle */ real abs_ca;
/* Local variables for saving time and
Crank Angle, etc. */ real half,quart,time,ca;
half = in_cyn_ca_period / 2.0;
quart = in_cyn_ca_period /4.0;
time = DYNAMESH_CURRENT_TIME;
ca = TIME_TO_ABSOLUTE_CRANK_ANGLE(time);
temp = (int) (ca / half);
abs_ca = ca - temp * half ;
/* *lh controls the layering height */
if(abs_ca <= quart)
*lh = (0.5 + (abs_ca)/ quart * 0.8);
else
*lh = (0.5 + ((half - abs_ca) / quart) * 0.8);
}
After the UDF that you have defined using DEFINE_DYNAMIC_ZONE_PROPERTY is compiled (as described in Compiling UDFs), the name of the argument that you supplied as the first DEFINE macro argument will become visible in the Dynamic Mesh Zones dialog box in ANSYS Fluent.
See Hooking DEFINE_DYNAMIC_ZONE_PROPERTY UDFs for details on
how to hook your DEFINE_DYNAMIC_ZONE_PROPERTY UDF to ANSYS Fluent.