|
|
Description
The DEFINE_DYNAMIC_ZONE_PROPERTY UDF can be used in the following applications:
Swirl Center Definition for In-Cylinder Applications
You can use DEFINE_DYNAMIC_ZONE_PROPERTY to calculate swirl center while computing in-cylinder specific output.
|
|
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 this section in the separate User's Guide .
Usage
| DEFINE_DYNAMIC_ZONE_PROPERTY( name, dt, swirl_center) |
| Argument Type | Description |
| symbol name | UDF name. |
| Dynamic_Thread *dt | 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. | |
| real *swirl_center | Pointer to a real array of 3 dimension. |
| You will assign this value in the UDF. | |
| The
| |
| swirl_center can be assigned in the UDF through | |
| swirl_center[0], swirl_center[1] and | |
| swirl_center[2] respectively. | |
| 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.
Example
/* 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);
}
|
Hooking a Swirl Center UDF to ANSYS FLUENT
After the UDF that you have defined using DEFINE_DYNAMIC_ZONE_PROPERTY is compiled (as described in Chapter 5), 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 Section 6.5.2 for details on how to hook your DEFINE_DYNAMIC_ZONE_PROPERTY UDF to ANSYS FLUENT.
Variable Cell Layering Height
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.
|
|
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 this section in the separate User's Guide .
Usage
| DEFINE_DYNAMIC_ZONE_PROPERTY( name, dt, height) |
| Argument Type | Description |
| symbol name | UDF name. |
| Dynamic_Thread *dt | Pointer to a structure that stores the dynamic mesh attributes. |
| real *height | 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 utilize 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 |
| in_cyl_ca_period | Crank angle period. |
| DYNAMESH_CURRENT_TIME | Current dynamic mesh time. |
| TIME_TO_ABSOLUTE_CRANK_ANGLE( 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 Settings 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.
Example
/* 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);
}
|
Hooking a Variable Cell Layering Height UDF to ANSYS FLUENT
After the UDF that you have defined using DEFINE_DYNAMIC_ZONE_PROPERTY is compiled (as described in Chapter 5), 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 Section 6.5.2 for details on how to hook your DEFINE_DYNAMIC_ZONE_PROPERTY UDF to ANSYS FLUENT.