定义库注册函数

本节提供库注册函数的示例。

示例函数 zeroGradT、initVelocity 和 sutherlandViscosity 必须通过库注册函数向 Simcenter STAR-CCM+ 注册。

在 C 中,通过使用 uclib.h 文件在 uclib.c 中对以下内容进行编码,可以实现此函数:


  #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));
  }

使用 StarReal.f 文件,可以在 uflib.f 中对 Fortran 90 中的等效库注册函数进行编码:


      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