.. _om6_wing_quickstart_pyAPI: .. |deg| unicode:: U+000B0 .. DEGREE SIGN :trim: .. |br| raw:: html
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 :ref:`Engineering Sketch Pad ` and :ref:`Python API Reference ` sections of documentation for installation instructions. The ONERA M6 Wing Model in ESP can be found in the `om6wing.csm `_ file. .. figure:: Figures/om6Model.png :width: 800px :align: center :alt: ONERA M6 Wing in ESP *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 :code:`firstLayerThickness` and :code:`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 |deg| Mesh and Case Submission ======================== Just like in the :ref:`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: .. code-block:: python 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: .. literalinclude:: Files/simConfiguration.json :linenos: 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: .. code-block:: python python3 submitCase.py -json simConfiguration.json 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: .. literalinclude:: Files/getCase.json :linenos: Copy the content above into a JSON file called "getCase.json". Then run "downloadCase.py" to download the results. .. code-block:: python 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. .. figure:: Figures/cpCompOM6.png :width: 800px :align: center |br|