Use VSCode to develop STAR-CCM+ user library: build dynamic link library through Fortran
Although the official STAR-CCM+ documentation specifically states that FORTRAN is not supported under Windows1. But in fact, as long as the compiler supports it, user library compiled using Fortran under Windows can be loaded and run normally in STAR-CCM+.
1. Build CMake Project
First, we refer to the tutorial case in the official documentation 2 and build a CMake project. The project structure is as follows:
STARCCM_FORTRAN_SAMPLE
│ CMakeLists.txt # CMake Configuration File
│ README.md # Description document, not required
├───.vscode
│ launch.json # Automatically generated file when starting debug mode, not required
│ settings.json # Define CMake related variables
└───src
initVelocity.f
StarReal.f.in
sutherlandViscosity.f
uflib.f
zeroGradT.f
The main content of CMake configuration file CMakeLists.txt
is as follows:
Use VSCode to develop STAR-CCM+ user library: Calculate physical properties through CoolProp
STAR-CCM+ user program (user library)1 is a dynamic link library compiled and constructed according to certain rules by an external compiler (usually C/C++, but also supports Fortran in Linux). By registering the constructed dynamic link library in the sim file, certain custom functions can be implemented. A user library usually contains one or more user-defined functions, which are generally used to implement special configuration or field functions.
Uer library need to register dynamic link libraries before they can be called, and the format of dynamic link libraries is often closely related to the operating system, hardware platform, etc. Therefore, user library are usually compiled for specific platforms and cannot run across platforms.