.. _om6_wing_pyAPI: .. |deg| unicode:: U+000B0 .. DEGREE SIGN :trim: ONERA M6 Wing with Python API ***************************** The ONERA M6 wing is a swept, semi-span wing with no twist that uses a symmetric airfoil. Widely known to aerodynamicists, the model serves as a classic reference to validate CFD methods for external flow due to its ideal combination of a simple geometry and a complex transonic flow. More information about the ONERA M6 Wing can be found at `NASA's website `_. The model used here has a normalized root chord of 1 m, resulting in the following geometric parameters: - Mean Aerodynamic Chord (MAC) = 0.80167 m - Semi-span = 1.47602 m - Reference area = 1.15315 m\ :sup:`2` .. image:: Figures/Geometry_Iso.png :scale: 70% :align: center The mesh used for this case contains 113K nodes and 663K tetrahedrons, and the flow conditions are: - Mach Number = 0.84 - Reynolds Number (based on MAC) = 11.72 Million - Alpha = 3.06 |deg| - Reference Temperature = 297.78 K Upload the Mesh File ==================== Before uploading a mesh, install the Flow360 Python API client. Visit the :ref:`API Reference ` section of this documentation for installation instructions. To upload a mesh and run a case, open the Python interpreter and import the Flow360 client. .. code-block:: python python3 import flow360client Specify no-slip boundaries - you can do this in three ways: a. By directly feeding it into the :code:`noSlipWalls` argument: .. code-block:: python noSlipWalls = [1] b. By using a "\*.mapbc" file: .. code-block:: python noSlipWalls = flow360client.noSlipWallsFromMapbc('/path/to/fname.mapbc') (**Note**: Make sure the boundary names in the "\*.mapbc" file do NOT contain any spaces) c. Or by using a :code:`meshJson` object: .. code-block:: python import json meshJson = json.load(open('/path/to/Flow360Mesh.json')) The `Flow360Mesh.json `_ file for this tutorial has the following contents: .. code-block:: json { "boundaries" : { "noSlipWalls" : [1] } } Download the mesh file from `here `__. If using options (a) or (b), use the following command to upload the mesh: .. code-block:: python meshId = flow360client.NewMesh(fname='/path/to/mesh.lb8.ugrid', noSlipWalls=noSlipWalls, meshName='my_mesh', tags=[], endianness='little' ) If using option (c), use the following command to upload the mesh: .. code-block:: python meshId = flow360client.NewMesh(fname='/path/to/mesh.lb8.ugrid', meshJson=meshJson, meshName='my_mesh', tags=[], endianness='little' ) (**Note**: Arguments for :code:`meshName` and :code:`tags` are optional. If using a mesh filename of the format "\*.lb8.ugrid" (little-endian format) or "\*.b8.ugrid" (big-endian format), the endianness argument is optional. However, if you choose to use a mesh filename without ".lb8." or ".b8.", the endianness ('little' or 'big') must be specified appropriately in :code:`NewMesh`. More information on endianness can be found `here `__.) Supported mesh file formats are "\*.ugrid", "\*.cgns" and their "\*.gz" and "\*.bz2" compressions. The mesh status can be checked by using: .. code-block:: python ## to list all your mesh files flow360client.mesh.ListMeshes() ## to view a particular mesh flow360client.mesh.GetMeshInfo('mesh_Id') Replace :code:`mesh_Id` with your mesh's ID. Run a Case ========== The `Flow360.json `_ file for this case has the following contents. A full dictionary of configuration parameters for the JSON input file can be found :ref:`here `. .. literalinclude:: Files/Flow360.json :linenos: Use this JSON configuration file and run the case with the following command: .. code-block:: python caseId = flow360client.NewCase(meshId='mesh_Id', config='/output/path/for/Flow360.json', caseName='my_case', tags=[] ) (**Note**: Arguments for :code:`caseName` and :code:`tags` are optional.) The case status can be checked by using: .. code-block:: python ## to list all your cases flow360client.case.ListCases() ## to view a particular case flow360client.case.GetCaseInfo('case_Id') Replace :code:`case_Id` with your case's ID. Deleting a Mesh or Case ======================= An uploaded mesh or case can be deleted using the following commands. *Caution: Cases and mesh files (including the results) cannot be recovered once deleted.* .. code-block:: python ## Delete a mesh flow360client.mesh.DeleteMesh('mesh_Id') ## Delete a case flow360client.case.DeleteCase('case_Id') .. _python-download: Download the Results ==================== To download the surface data and the entire flow field, use the following command lines, respectively: .. code-block:: python flow360client.case.DownloadSurfaceResults('case_Id', 'surfaces.tar.gz') flow360client.case.DownloadVolumetricResults('case_Id', 'volume.tar.gz') Once downloaded, you can postprocess these output files in either Tecplot or ParaView. You can specify the export format in the "Flow360.json" file under the :code:`volumeOutput` and :code:`surfaceOutput` sections. To download the solver logs, use the following command: .. code-block:: python flow360client.case.DownloadSolverOut('case_Id', fileName='flow360_case.user.log') You can also download the nonlinear residuals, surface forces and total forces by using the following command line: .. code-block:: python flow360client.case.DownloadResultsFile('case_Id', 'fileName.csv') Replace :code:`caseId` with your case's ID and :code:`fileName` with "nonlinear_residual", "surface_forces" and "total_forces" to retrieve their respective data. .. _visResults: Visualizing the Results ======================= While your case is running, or after that, you can visualize the residuals and forces plots on the Web UI by clicking on your case name and viewing them under the **Convergence** and **Forces** tabs, respectively. .. image:: Figures/ConvergenceTab.png :align: center For example, the Forces plots for this case are: .. image:: Figures/CD_CL.png :scale: 40% :align: center .. image:: Figures/CF.png :scale: 40% :align: center .. image:: Figures/CM.png :scale: 40% :align: center Once your case has completed running, you can also visualize the contour plots of the results under the **Visualization** tab. Currently, contour plots for coefficient of pressure (C\ :sub:`p`\), coefficient of skin friction (C\ :sub:`f`\), y\ :sup:`+`\, and C\ :sub:`f`\ with streamlines are provided. .. image:: Figures/VisResults.png :align: center