Template User Function (C)
This section provides a template that you can use when creating 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:
#include "uclib.h"
void name(result, int size, args ...);
name: the function name. This name is arbitrary: Simcenter STAR-CCM+ does not impose particular function names for particular functionality. There are, however, some protected names 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 *result
for a scalar function, or:
Real (*result)[3]
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, which is chosen from the list of available variables and requested through ucarg. The form of declaration for an array arg with elements of various types is given in the table below.
Elemental Type | Declaration |
---|---|
int |
int *arg |
Real |
Real *arg |
unsigned int |
int *arg |
Vector<2, unsigned int> |
int (*arg)[2] |
Vector<3, CoordReal> |
CoordReal (*arg)[3] |
Vector<3, Real> |
Real (*arg)[3] |
For example,
CoordReal (*centroid)[3], Real *temperature
would declare centroid position and temperature as arguments.
The Real and CoordReal types define the precision of floating-point variables, and are defined in the uclib.h file.