Template User Function (Fortran)

This section provides a template to help you create a user function.

The generic purpose of a user function is to populate a result array with values obtained by operating on args, as shown in the examples, using this template:

subroutine name(result, size, args ...)
use StarRealMod
integer, intent(in) :: size

name: the function name. This name is arbitrary: Simcenter STAR-CCM+ does not impose particular function names for particular functionality. There are some protected names however which must be avoided: ucarg, ucfunc, ucfunction, uclib, ufarg, uffunc, uflib.

result: the array of values that the user function returns. It is declared as:

real(StarReal), intent(out) :: result(size)

for a scalar function, or:

real(StarReal), intent(out) :: result(3,size)

for a vector function. Each element of the result array represents a cell or face, depending on the type of the user function.

size: the number of elements in the result array.

args: the arguments which Simcenter STAR-CCM+ passes to the function are chosen from the list of available variables and requested through ufarg. The form of declaration for an array arg with elements of various types is given in the table below.

Elemental Type Declaration (all intent(in))

int

integer arg(*)

Real

real(StarReal) arg(*)

unsigned int

integer arg(*)

Vector<2, unsigned int>

integer arg(2,*)

Vector<3, CoordReal>

real(CoordReal) arg(3,*)

Vector<3, Real>

real(StarReal) arg(3,*)

For example,

real(CoordReal), intent(in) :: centroid(3,*)
real(StarReal), intent(in) :: temperature(*)

would declare centroid position and temperature as arguments.

The StarReal and CoordReal types define the precision of floating-point variables, and are defined in the StarReal.f file.