Python API

Use python based automation to quickly setup HyperMesh CFD for ultraFluidX simulations in batch mode.

Setting up multiple simulations that are variations of a base simulation can be very time consuming. Running HyperMesh CFD in batch mode can speed up this process by setting up the base simulation once manually and coding the variations in a script. This batch-processing feature is now enabled with a combination of template files and a fully featured Python API. The python script can be programmed to read, modify, and write template files from within HyperMesh CFD without interacting with the graphical user interface.

The Python API can be used to import a model, an .xml template, or setup directly using the API and then export an .stl model and .xml file. The ultraFluidX solver can then read the .stl and .xml files to run the simulation.

To invoke HyperMesh CFD case setup in batch mode, run the following executable with the python script as an argument. In this example, the python script is named userScript.py.
>> $INSTALL_PATH/hwVWTuFX/hwx/bin/win64/ExecWinEnvVWTUFX.exe -b -c Inspire -p VWT -pr UFX -v VWT2022 -ef Insp.env -ex ExecMainVWTUFX.exe -l en_US -f $USER_PATH/userScript.py
Below is a sample python script that reads in a model, an .xml template file, and writes out an .stl and complete .xml template file inside a folder named uFX_Simulation.
from hwx import inspire
from hwx.inspire import vwt

# Open Model
inspire.openFile(r"usrPATH/roadster_model.stl")

# Import Template and Export uFX setup
vwt.ReadAndExportTemplateFile("usrPATH/templateIN.xml", "usrPATH/uFX_output")

# Exit