Defining a Library Registration Function

This section provides an example of a library registration function.

The example functions zeroGradT, initVelocity, and sutherlandViscosity must be registered with Simcenter STAR-CCM+ through the library registration function.

In C, this function could be achieved by coding the following in uclib.c, using the uclib.h file:


  #include "uclib.h"
  
  void zeroGradT(Real*, int, int*, Real*);
  void initVelocity(Real*, int, CoordReal*);
  void sutherlandViscosity(Real*, int, Real*);
  
  void 
  USERFUNCTION_EXPORT uclib()
  {
    /* Register user functions here */
    ucfunc(zeroGradT, "BoundaryProfile", "Zero Gradient Temperature");
    ucarg (zeroGradT, "Face", "FaceCellIndex", sizeof(int[2]));
    ucarg (zeroGradT, "Cell", "Temperature", sizeof(Real));
    
    ucfunc(initVelocity, "RegionProfile", "Initial Velocity");
    ucarg(initVelocity, "Cell", "Centroid", sizeof(CoordReal[3]));
    
    ucfunc(sutherlandViscosity, "ScalarFieldFunction", "Sutherland Viscosity");
    ucarg(sutherlandViscosity, "Cell", "Temperature", sizeof(Real));
  }

The equivalent library registration function in Fortran 90 could be coded in uflib.f, using the StarReal.f file:


      subroutine uflib()
      use StarRealMod
      implicit none
C Register user functions here
      external zeroGradT,initVelocity,sutherlandViscosity
      call uffunc(zeroGradT, "BoundaryProfile", 
     &            "Zero Gradient Temperature")
      call ufarg (zeroGradT, "Face",
     &            "FaceCellIndex", 2*StarIntSize)
      call ufarg (zeroGradT, "Cell",
     &            "Temperature", StarRealSize)
  
      call uffunc(initVelocity, "RegionProfile",
     &            "Initial Velocity")
      call ufarg(initVelocity, "Cell",
     &           "Centroid", 3*CoordRealSize)
  
      call uffunc(sutherlandViscosity, "ScalarFieldFunction",
     &            "Sutherland Viscosity")
      call ufarg(sutherlandViscosity, "Cell",
     &           "Temperature", StarRealSize)
      return
      end