Compiling and Launching the Partner Code using Linux
On Linux, you can compile and launch the ball valve simulation using the buildapi and starapi helper scripts that are provided in the Simcenter STAR-CCM+ installation. To compile the sample code, you require g++ version 4.3.4 or greater.
- Navigate to the couplingWithCaeCodes folder of the downloaded tutorial files.
-
Copy the entire CoSimAPI_Code folder to your working
directory.
The files that are contained in this folder make up the partner code that solves for the ball valve motion.
- Open a terminal.
-
Navigate to the CoSimAPI_Code folder:
% cd [PATH]/CoSimAPI_Code
where [PATH] is the path to your working directory. -
Enter the following command:
% [INSTALLDIR]/star/bin/buildapi spindleValve_solid
where [INSTALLDIR] is the path to your Simcenter STAR-CCM+ installation directory.This command compiles all the .cpp files that are located in the CoSimAPI_Code folder and creates an executable output file, spindleValve_solid, that simulates the ball valve motion.
The starapi helper script launches the partner program, and allows the partner code to load the Co-Simulation API library and spawn the partner simulation.
You can run the script from a terminal or from the Simcenter STAR-CCM+ fluid simulation. In this tutorial on Linux, you run the script from a terminal. This method requires two Simcenter STAR-CCM+ licenses, one for the Simcenter STAR-CCM+ fluid simulation and one for the partner simulation. However, if you do not wish to monitor the output from the ball valve simulation, you can use the second method for sharing a single Simcenter STAR-CCM+ license. For more information, see Running a Co-Simulation between Partner Code and Simcenter STAR-CCM+.
-
Navigate to your working directory:
% cd [PATH]/[WORKDIR_NAME]
where
[PATH]
is the path to your working directory and[WORKDIR_NAME]
is the name of your working directory. -
Enter the following command, specifying the relative path to the
spindleValve_solid executable and to the input mesh
file that you created in the previous sections of this tutorial:
% [INSTALLDIR]/star/bin/starapi [FILEPATH]/spindleValve_solid [FILEPATH]/spindleball.stl
where [INSTALLDIR] is the path to your Simcenter STAR-CCM+ installation directory.
For example, if you saved all the files as instructed in this tutorial, the command complete with the path to the files is:% [INSTALLDIR]/star/bin/starapi CoSimAPI_Code/spindleValve_solid CoSimAPI_Mesh/spindleball.stl
Information on the launching process is displayed in the terminal.The message spindleValve_solid: Simcenter STAR-CCM+ waiting for CONNECT from partner... tells you that the Simcenter STAR-CCM+ API Server has been launched and the partner code, spindleValve_solid, is ready to import fields from the Simcenter STAR-CCM+ spindleValve_fluid simulation.
Note Leave the terminal open. Closing the terminal terminates the partner program process.