Creating a New User Library

This section provides information about creating a user library on Linux or Windows.

A user library is created from its constituent user functions and a library registration function.

Creating a User Library on Linux

On Linux, Simcenter STAR-CCM+ does not require a particular compiler to be used for this process. For a selection of generic compilers, the table below gives example commands to create a library with base-name user from C or Fortran source files. Optional compilation flags, such as for optimization, can also be used; consult the compiler manual for more information.

Compiler Precision Compilation Command

GCC

mixed

gcc -fPIC -shared *.c -o libuser.so

GCC

double

gcc -DDOUBLE_PRECISION -fPIC -shared *.c -o libuser.so

GNU Fortran 77

mixed

g77 -fPIC -shared *.f -o libuser.so

G95

mixed

g95 -fPIC -shared *.f -o libuser.so

Creating a User Library on Windows

FORTRAN is not supported on Windows.

These instructions are for Microsoft Visual C++ 2013. Older versions may not work and if so, in a different manner. Only 64 bit versions are supported on Windows. Link against UserFunctions.lib found in the compiler subdirectory of your Simcenter STAR-CCM+ installation directory, for example:

C:\Program Files\Siemens\18.02.002\STAR-CCM+18.02.002\star\lib\win64\clang15.0vc14.2\lib

To create a user library on Windows, follow the steps below:

  1. Open a VS2013 x64 Native Tools Command Prompt to compile a 64-bit library.
  2. Compile the source code into object files using the command:
    cl /MD /D_WINDOWS -c *.c

    For *.cpp files, substitute *.c with *.cpp.

    For double precision code, include the compiler option /DDOUBLE_PRECISION.

  3. Link the objects into a Dynamic Link Library (DLL) using the UserFunctions.lib found in the compiler subdirectory of your Simcenter STAR-CCM+ installation directory:
    link -dll /out:libuser.dll *.obj “C:\Program Files\Siemens\18.02.002\STAR-CCM+18.02.002\star\lib\win64\clang15.0vc14.2\lib
    \UserFunctions.lib”
  4. Check that you have a function that is called uclib exported from the DLL. Simcenter STAR-CCM+ looks for this function in the DLL:
    dumpbin/exports libuser.dll

    An example of a dump output is given below:

    Microsoft (R) COFF/PE Dumper Version 12.00.30501.0
    Copyright (C) Microsoft Corporation.  All rights reserved.
    Dump of file libuser.dll
    File Type: DLL
      Section contains the following exports for libuser.dll
    
        00000000 characteristics
        54D1FF8D time date stamp Wed Feb 04 11:16:29 2015
            0.00 version
               1 ordinal base
               1 number of functions
               1 number of names
        ordinal hint RVA      name
              1    0 00001000 uclib
      Summary
            1000 .data
            1000 .pdata
            1000 .rdata
            1000 .reloc
            1000 .text
    

With Visual Studio 2013, you do not need to embed a manifest file. The DLL that is built has a dependency on the visual studio runtime (MSVCR120.DLL). The visual studio runtime must be stored on disk so that Simcenter STAR-CCM+ can find it. Typically, if visual studio is installed, MSVCR120.DLL is already on the machine. If not, you can install the re-distributable or simply copy the DLL to the same location as the user coding .dll.