Running a Co-Simulation between Partner Code and Simcenter STAR-CCM+

Compile your code then launch your program from Simcenter STAR-CCM+ for co-simulation.

The following steps provide instructions for compiling and launching your program using the helper scripts provided in Simcenter STAR-CCM+. These instructions are not relevant if you are using Microsoft Visual Studio (on Windows). In this case, you specify compiling and launching details using a Property Sheet in Microsoft Visual Studio. For instructions, see Compiling and Launching the Partner Code Using Windows.

  1. Before coupling to a Simcenter STAR-CCM+ simulation, compile your code. You can use your own build system or the buildapi helper script that is provided in the Simcenter STAR-CCM+ installation. To use the buildapi script:
    1. In a terminal/command prompt, go to the folder that contains the code files.
    2. From this location, run the buildapi helper script:
      • On Windows, set the Intel C++ Compiler environment before running the buildapi.bat script:
        > call "[INTEL_C++_INSTALLDIR]\bin\compilervars.bat" intel64
        > [INSTALLDIR]\star\bin\buildapi.bat <executable name>
      • On Linux, make sure that you use g++ 4.3.4 or greater before running the buildapi script:
        % [INSTALLDIR]/star/bin/buildapi <executable name>
      where <executable name> specifies a name for the output executable file.

      As the argument for the source files is not specified, this command compiles all the .cpp files that are located in the project folder and creates an executable output file that is used to launch the partner program. See the section, Helper Scripts, for more information as well as additional arguments that you can use with this script.

  2. Launch the Simcenter STAR-CCM+ simulation that you want to couple with your program.
  3. Set up the simulation for Simcenter STAR-CCM+ to Simcenter STAR-CCM+ Co-Simulation. For more information, see STAR-CCM+ Co-Simulation Workflow.
  4. In the Simcenter STAR-CCM+ simulation, select the External Links > [Link 1] > Conditions > Launch Partner Option node and set Method to Launch Application via Command Line.
  5. Select the [Link 1] > Values > Launch Command Line node. For the Command Line property, enter:
    • On Windows:
      > <executable>
    • On Linux:
      % [INSTALLDIR]/star/bin/starapi <executable>
    where <executable> specifies the path to the executable file created when compiling your code. See the section, Helper Scripts, for more information about the starapi script as well as additional options that you can use with this script.
  6. Run the co-simulation from the Simcenter STAR-CCM+ simulation.
    NoteSolution stepping is not allowed for co-simulation with external code through the Co-Simulation API.
When you run the co-simulation, the starapi helper script launches your program and the associated Simcenter STAR-CCM+ API server. The Simcenter STAR-CCM+ simulation connects to the running program through the Simcenter STAR-CCM+ API server and the co-simulation analysis starts.
NoteWhen using the Launch Application via Command Line method, the Simcenter STAR-CCM+ simulation and the Simcenter STAR-CCM+ API server share the same Simcenter STAR-CCM+ license, meaning that you require a single license to run the co-simulation. On the other hand, if you launch the partner program separately (for example running the starapi script in a command console) and then connect the Simcenter STAR-CCM+ simulation to the running program by specifying the partner program host and port, you require two Simcenter STAR-CCM+ licenses.