1.5. Automated Meshing with Python API#

Flow360 also allows the use of Automated Meshing via the Python API. For this exercise, the ONERA M6 Wing case will once again be used as an example. The geometry is built in Engineering Sketch Pad (ESP) and will be submitted using the Python API to generate mesh and run a simulation. Visit the Engineering Sketch Pad and Python API Reference sections of documentation for installation instructions.

The ONERA M6 Wing Model in ESP can be found in the om6wing.csm file.

ONERA M6 Wing in ESP

Fig. 1.5.1 ONERA M6 Wing generated in ESP#

Through ESP, users have control over the meshing parameters applied including edge and face attributes. The surface mesh parameters are defined in the om6SurfaceMesh.json file.

Within the volume mesh parameters JSON file below, field constraints are used to control the maximum edge length and resolution of the unstructured mesh. Similarly, the initial height of the anisotropic mesh at wall boundaries is indicated by firstLayerThickness and growthRate. The volume mesh parameters are defined in the om6VolumeMesh.json file.

The case configuration parameters for the ONERA M6 Wing simulation are available in the om6Case.json file.

Flow condition

  • Reynolds: 14.6e+6

  • Mach: 0.84

  • AoA: 3.06°

1.5.1. Mesh and Case Submission#

Just like in the previous Web UI exercise, we first generate the surface mesh from the CSM file, then generate a volume mesh from the surface mesh, and finally run the simulation.

Using the Python API, these three steps are executed using the following commands:

surfaceMeshId = flow360client.NewSurfaceMeshFromGeometry("om6wing.csm", "om6SurfaceMesh.json")
volumeMeshId = flow360client.NewMeshFromSurface(surfaceMeshId=surfaceMeshId, config="om6VolumeMesh.json")
caseId = flow360client.NewCase(meshId = volumeMeshId, config="om6Case.json", caseName='QuickStart_OM6_AutomaticMeshing')

For the purposes of this exercise, use the example Python script provided below. This script takes CSM, mesh and case input JSON files as the input configuration parameters for the simulation, submitCase.py. This script requires inputs via a configuration JSON file, which has the following content:

 2    "geometry": {
 3        "csm": "path/to/modelFile.csm"
 4    },
 5    "mesh": {
 6        "surface": "path/to/SurfaceMesh.json",
 7        "volume": "path/to/VolumeMesh.json"
 8    },
 9    "flow360": {
10        "case": "path/to/simulationCase.json"
11    }

Copy the content above into a JSON file called “simConfiguration.json”, then modify the individual paths for the CSM file, surface and volume mesh JSON files, and the case JSON file. Finally, submit with:

python3 submitCase.py -json simConfiguration.json

1.5.2. Download the Results#

To download the surface and volume solution for postprocessing, the Flow360 Python API will also be used. The example script, downloadCase.py, takes a JSON file input and downloads flow results as well as forces and moments convergence history files. The input JSON file has the following content:

2    "flow360": {
3        "caseId": "case_id",
4        "caseName": "CaseName_QuickStartSimulation"
5    }

Copy the content above into a JSON file called “getCase.json”. Then run “downloadCase.py” to download the results.

python3 downloadCase.py -json getCase.json

Force and moment convergence histories are downloaded to the “total_forces_v2.csv” file. The surface and volume results can be postprocessed with either Tecplot or ParaView (output format specified in the submitted case JSON file). For example, pressure coefficient comparisons with experimental data can be found below.