Co-Simulation API Overview
The following sections provide information on how to couple your code with Simcenter STAR-CCM+ through the Simcenter STAR-CCM+ Co-Simulation API. For details on the available API functions and options, refer to the Co-Simulation API Online Help. You can access the Online Help from the Simcenter STAR-CCM+ interface by selecting .
Example Program
- Windows:[INSTALLDIR]\Documents\STAR-CCM+TutorialFiles16.06\tutorials\couplingWithCaeCodes\CoSimAPI_Code
- Linux: [INSTALLDIR]/Documents/STAR-CCM+TutorialFiles16.06/tutorials/couplingWithCaeCodes/CoSimAPI_Code
The Co-Simulation API: Spindle Valve tutorial demonstrates how to couple the SpindleValve example program and Simcenter STAR-CCM+ in a co-simulation analysis.
API Library
- Windows: [INSTALLDIR]\star\lib\[OS]\[COMPILER]\lib\StarccmplusCoSimulationApi.dll
- Linux: [INSTALLDIR]/star/lib/[OS]/[COMPILER]/lib/StarccmplusCoSimulationApi.so
The LibraryLoader.h and LibraryLoader.cpp files included in the SpindleValve example demonstrate how to wrap the API library for dynamic loading.
Header Files
- Windows:
[INSTALLDIR]\star\include
- Linux:
[INSTALLDIR]/star/include
In the online help, you can access an HTML version of the header files under the Files tab.
StarccmplusCosimulationApiV8.h | Contains the function
suites that define the Co-Simulation API v8. Your program only needs to include this header file. The StarccmplusCosimulationApiStruct.h and StarccmplusCosimulationApiConstants.h files are automatically included. |
StarccmplusCosimulationApiStruct.h | Contains the primary access function for the function suite API. |
StarccmplusCosimulationApiConstants.h | Contains constants used by the function suite API. |
Note | The folder contains additional header files corresponding to deprecated versions of the API. Your program can include only one of the provided header files. |
API Structure and Function Suites
The Co-Simulation API consists of a set of functions that provide an interface for communication between your program and the Simcenter STAR-CCM+ API server. These functions are grouped into function suites.
There are two types of function suite. The first type, which includes the main API Suite, the Factory Suite, and the Properties Suite, provides an interface for your program to call into the Simcenter STAR-CCM+ API server. The second type, which includes the Handler Suite, provides an interface for the Simcenter STAR-CCM+ API server to call back into your program. All function suites are contained within the header file, StarccmplusCosimulationApiV#.h, where # is the API version number.
Each function suite is identified by the API version with which the function suite is released and a unique name. This framework allows versioning by providing function suite definitions for each API version. Each new API version may extend an existing function suite, create a new function suite, or retire an old function suite.
Before you can access the function suites, you make a call into the Co-Simulation API library to get a pointer to the API structure.
- API Structure
- The API structure, which is contained in
StarccmplusCosimulationApiStruct.h, contains pointers to the API library functions that allow your program to:
- verify the API version
- retrieve the Simcenter STAR-CCM+ function suites by API version and name
- specify your handler function suite by API version and name
- Main API Suite
- The main function suite,
StarccmplusApiSuiteV#, where # is the API version number, contains pointers to the API library functions that allow your program to:
- initialize or terminate the API library
- synchronize the connection to the partner
- set the time-step
- set the coupling time interval (explicit coupling) or the number of inner iterations per exchange (implicit coupling)
- instruct your program to wait for data from Simcenter STAR-CCM+
- notify Simcenter STAR-CCM+ that the mesh or field data are ready for export
- notify Simcenter STAR-CCM+ that the current processing loop is complete
- notify Simcenter STAR-CCM+ of any errors and warnings
- Factory Suite
- The factory suite,
StarccmplusFactorySuiteV#, where # is the API version number, contains pointers to the API library functions that allow your program to communicate with, and instantiate objects on, the
Simcenter STAR-CCM+ API server. Specifically, this function suite allows you to:
- create physics continua
- create regions and boundaries
- create a co-simulation link
- set up the co-simulation link
- create co-simulation zones
- assign regions and boundaries to co-simulation zones
- provide a mesh
- import/export field data
- get and set certain condition and value information in the API server
- Properties Suite
- To transfer data between your program and the Simcenter STAR-CCM+ API server, you define intermediate data store structures called properties containers. A properties container has its own ID of type int. API calls that create properties containers return the container ID. Your program must retain container IDs for all future operations that involve the same properties container.
- Handler Suite
- The handler suite, StarccmplusHandlerSuiteV#, where # is the API version number, contains pointers to the functions that allow Simcenter STAR-CCM+ to call back into your program.
Helper Scripts
The Simcenter STAR-CCM+ installation contains two helper scripts, buildapi and starapi. These scripts allow you to compile and launch the example program, SpindleValve. See Example Program.
You can also use these scripts to compile and launch your own program. However, you are advised to compile and launch your program using your own build system, based on requirements.
For example, on Windows you typically compile your code using Microsoft Visual Studio. This approach does not require you to launch your program from the command line. You compile and launch your program directly from Microsoft Visual Studio. For instructions, see the Spindle Valve example Compiling and Launching the Partner Code Using Windows.
- Windows:
-
[INSTALLDIR]\star\bin\buildapi.bat
[INSTALLDIR]\star\bin\starapi.bat
-
- Linux:
-
[INSTALLDIR]/star/bin/buildapi
[INSTALLDIR]/star/bin/starapi
-
- buildapi
- The
buildapi helper script provides a build system for compiling your program. The script works with the following compilers:
- gcc for C and Intel Fortran 11 on Linux
- Intel C++ Compiler and Intel Fortran Compiler on Windows
Note The script is tested with the compilers that are used to build Simcenter STAR-CCM+. For information, refer to the Installation Guide, section Certified Platforms for Simcenter STAR-CCM+ 2406. To use the script to compile your code, use the following command:- Windows:
> call "[INTEL_C++_INSTALLDIR]\bin\compilervars.bat" intel64 > [INSTALLDIR]\star\bin\buildapi.bat [<verbosity>] <executable name> [<source files>]
- Linux:
% [INSTALLDIR]/star/bin/buildapi [<verbosity>] <executable name> [<source files>]
- starapi
- The
starapi script launches your program and sets the environment that allows your program to load the co-simulation library and launch the
Simcenter STAR-CCM+ API server. To launch your program from a command console, use the following command:
- Windows:
> [INSTALLADIR]\star\bin\starapi.bat [<verbosity>] <executable> [<executable arguments>]
- Linux:
% [INSTALLDIR]/star/bin/starapi [<verbosity>] <executable> [<executable arguments>]
- Windows: