2.3.38.  DEFINE_SPARK_GEOM (R14.5 spark model)

The DEFINE_SPARK_GEOM is available with the R14.5 spark model only. See the R14.5 ANSYS Fluent User's Guide for information about using the R14.5 spark model in ANSYS Fluent.

2.3.38.1. Description

You can use DEFINE_SPARK_GEOM to define custom spark kernel volume shapes.

2.3.38.2. Usage

DEFINE_SPARK_GEOM (name,c,t)

Argument Type

Description

symbol name

UDF name.

cell_t c

Cell index.

Thread *t

Pointer to cell thread on which the source term is to be applied.

Function returns

integer inside

There are three arguments to DEFINE_SPARK_GEOM: name, c, and t. You will supply name, the name of the UDF, and the variables c and t are passed by the ANSYS Fluent solver into the UDF. The UDF will need to return an integer value that indicates whether or not the cell defined by the arguments c and t is within the spark kernel volume. A returned value of zero indicates that the cell is not within the spark kernel. All other values indicate that the cell is within the kernel.

2.3.38.3. Example

This example UDF is used to define three different custom shape types: a sphere, a cylinder, or a frustum.

#include "udf.h"
 
 typedef enum {
    SPHERE,
    CYLINDER,
    FRUSTUM
 } Spark_Geom;
 
 DEFINE_SPARK_GEOM(spark_geom,c,t)
 {
    int inside=0;
    Spark_Geom spark_geom=FRUSTUM; /* set to chosen shape */
    Spark_Par *spark_par = getSparkPar();
    int snum=0; /* spark index */
    switch(spark_geom) {
      case SPHERE:
        {
           real rad,rad2;
           real NV_VEC(xc);
           real NV_VEC(xdiff);
           real time = CURRENT_TIME;
           real start_time = spark_par[snum].start_time;
           real duration = spark_par[snum].duration;

           /* user sphere data */
           real r0 = 0.001;    /* initial radius */
           real rf = 0.003;    /* final radius */
           real xcen[3]={0.0,0.0,0.0}; /* sphere centre */
           real dr = ABS(rf-r0);
           C_CENTROID(xc,c,t);
           NV_VV(xdiff, =, xc,-,xcen);   /* user growth rate */
           rad = r0 + (time-start_time)*dr/duration;
           rad2 = rad*rad;

           /* flag cell if inside sphere */
           if (NV_DOT(xdiff,xdiff) < rad2)
             inside = 1;
             break;
        }
      case CYLINDER:
        {
           real rad, rad2;
           real am, NV_VEC(xa);
           real cm, NV_VEC(xc);
           real time = CURRENT_TIME;
           real start_time = spark_par[snum].start_time;
           real duration = spark_par[snum].duration;

           /* user cylinder data */
           real r0 = 0.001;    /* initial radius */
           real rf = 0.003;    /* final radius */
           real x0[3]={0.0,0.0,0.0}; /* axis start */
           real x1[3]={-0.003,0.0,0.0}; /* axis end */
           real dr = ABS(rf-r0);

           /* user growth rate */
           rad = r0 + (time-start_time)*dr/duration;
           rad2 = rad*rad;
         
           /* compute normalized axis vector */
           NV_VV(xa,=,x1,-,x0);
           am = NV_MAG(xa);
           NV_S(xa,/=,am);
           C_CENTROID(xc,c,t);
           NV_V (xc, -=, x0);
           cm = NV_DOT(xc,xa);

           /* flag cell if inside cylinder */
           if (cm >= 0 && cm <= am)
             {
               NV_VS(xc,-=,xa,*,cm);
               if (NV_MAG2(xc) <= rad2)
                 inside = 1;
             }
         break;
        }
      case FRUSTUM:
        {
           real rad, rad0, rad1, rad2;
           real am, NV_VEC(xa);
           real cm, NV_VEC(xc);
           real time = CURRENT_TIME;
           real start_time = spark_par[snum].start_time;
           real duration = spark_par[snum].duration;

           /* user frustum data */
           real r00 = 0.001, r01 = 0.002;  /* initial radii */
           real rf0 = 0.003, rf1 = 0.004;  /* final radii */
           real x0[3]={0.0,0.0,0.0};    /* axis start */
           real x1[3]={-0.003,-0.003,0.0};  /* axis end */
           real dr0 = ABS(rf0-r00);
           real dr1 = ABS(rf1-r01);

           /* user growth rate */
           rad0 = r00 + (time-start_time)*dr0/duration;
           rad1 = r01 + (time-start_time)*dr1/duration;

          /* compute normalized axis vector */
           NV_VV(xa,=,x1,-,x0);
           am = NV_MAG(xa);
           NV_S(xa,/=,am);
           C_CENTROID(xc,c,t);
           NV_V (xc, -=, x0);
           cm = NV_DOT(xc,xa);
           rad = rad0 + cm/am * (rad1-rad0);
           rad2 = rad*rad;

           /* flag cell if inside frustum */
           if (cm >= 0 && cm <= am)
             {
               NV_VS(xc,-=,xa,*,cm);
               if (NV_MAG2(xc) <= rad2)
                  inside = 1;
             }
           break;
         }
         default:
        break;
        }
    return inside;
 }

2.3.38.4. Hooking a Spark Geometry UDF to ANSYS Fluent

After the UDF that you have defined using DEFINE_SPARK_GEOM is compiled (Compiling UDFs), the name that you specified in the DEFINE macro argument will become visible and selectable in the Set Spark Ignition dialog box in ANSYS Fluent. See Hooking DEFINE_SPARK_GEOM UDFs for details.


Release 18.2 - © ANSYS, Inc. All rights reserved.