An Example of User Coding

User coded functions can be used to define the displacements or grid velocity that Simcenter STAR-CCM+ requires.

Such a function requires access to all the vertices in the mesh, obtained as follows:-

ucarg((void *)userMotionFunc, "Vertex", "Coord", sizeof(CoordReal[3]));

The argument type here is “Vertex”, rather than “Cell” or “Face”, and the array being requested is “Coord”. The argument belongs to the function, userMotionFunc, which could have a declaration as follows:

void userMotionFunc(Real (*result)[3], int size, CoordReal (*vpos)[3])
{
   // user coding here to calculate the displacement
   // or grid velocity, which will be returned
   // in the result array
 }

In this function, the result array would return one of the following quantities:

  • incremental displacement;
  • total displacement;
  • grid velocity.

The particular quantity depends on the choice you have made on the User Defined Vertex Option node and its associated value node.

When a suitable function has been compiled and linked, it appears in the Field Functions list as a vector function. Select the Field Function option for the Method property of the UDV: LinearDisplacement node or Grid Velocity node, and choose the user coded field function from the list.