1.2. Run CFD using Python API: An example of ONERA M6 Wing
The Onera M6 wing is a classic CFD validation case for external flows because of its simple geometry combined with complexities of transonic flow (i.e. local supersonic flow, shocks, and turbulent boundary layer separation). It is a swept, semi-span wing with no twist and uses a symmetric airfoil using the ONERA D section. More information about the geometry can be found at NASA’s website. The geometry parameters are:
Mean Aerodynamic Chord (MAC) = 0.80167
Semi-span = 1.47602
Reference area = 1.15315
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°.
Reference Temperature = 297.78 K
1.2.1. Upload the Mesh File
Before uploading a mesh, if you have not done so already, install the Flow360 Python API client. For installation instructions, visit the API Reference section of this documentation. To upload a mesh and run a case, open your Python interpreter and import the flow360 client.
python3
import flow360client
Specify no-slip boundaries - you can do this in three ways:
By directly feeding it into the noSlipWalls argument:
noSlipWalls = [1]
By using the .mapbc file:
noSlipWalls = flow360client.noSlipWallsFromMapbc('/path/to/fname.mapbc')
(Note: Make sure the boundary names in your .mapbc file do NOT contain any spaces )
And by using the meshJson object:
import json
meshJson = json.load(open('/path/to/Flow360Mesh.json'))
The Flow360Mesh.json file for this tutorial has the following contents:
{
"boundaries" :
{
"noSlipWalls" : [1]
}
}
Download the mesh file from here. If using options (a) and (b), use the following command to upload your mesh:
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 your mesh:
meshId = flow360client.NewMesh(fname='/path/to/mesh.lb8.ugrid',
meshJson=meshJson,
meshName='my_mesh',
tags=[],
endianness='little'
)
(Note: Arguments of meshName and tags are optional. If using a mesh filename of the format mesh.lb8.ugrid (little-endian format) or mesh.b8.ugrid (big-endian format), the endianness argument is optional. However, if you choose to use a mesh filename of the format mesh.ugrid, you must specify the appropriate endianness (‘little’ or ‘big’) in NewMesh. More information on endianness can be found here.)
Currently supported mesh file formats are .ugrid, .cgns and their .gz and .bz2 compressions. The mesh status can be checked by using:
## to list all your mesh files
flow360client.mesh.ListMeshes()
## to view a particular mesh
flow360client.mesh.GetMeshInfo('mesh_Id')
Replace the mesh_Id with your mesh’s ID.
1.2.2. 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 here.
1{
2 "geometry" : {
3 "meshName" : "wing_tetra.1.lb8.ugrid",
4 "refArea" : 1.15315084119231,
5 "momentCenter" : [0.0, 0.0, 0.0],
6 "momentLength" : [1.47602, 0.801672958512342, 1.47602]
7 },
8 "runControl" : {
9 "restart" : false
10 },
11 "volumeOutput" : {
12 "outputFormat" : "tecplot",
13 "animationFrequency" : -1,
14 "primitiveVars" : true,
15 "vorticity" : false,
16 "residualNavierStokes" : false,
17 "residualTurbulence" : false,
18 "T" : false,
19 "s" : false,
20 "Cp" : false,
21 "mut" : false,
22 "mutRatio" : false,
23 "Mach" : true
24 },
25 "surfaceOutput" : {
26 "outputFormat" : "tecplot",
27 "animationFrequency" : -1,
28 "primitiveVars" : true,
29 "Cp" : true,
30 "Cf" : true,
31 "CfVec" : false,
32 "yPlus" : false,
33 "wallDistance" : false
34 },
35 "sliceOutput" : {
36 "outputFormat" : "tecplot",
37 "animationFrequency" : -1,
38 "primitiveVars" : true,
39 "vorticity" : true,
40 "T" : true,
41 "s" : true,
42 "Cp" : true,
43 "mut" : true,
44 "mutRatio" : true,
45 "Mach" : true
46 },
47 "navierStokesSolver" : {
48 "absoluteTolerance" : 1e-10,
49 "kappaMUSCL" : -1.0
50 },
51 "turbulenceModelSolver" : {
52 "modelType" : "SpalartAllmaras",
53 "absoluteTolerance" : 1e-8,
54 "kappaMUSCL" : -1.0
55 },
56 "freestream" :
57 {
58 "Reynolds" : 14.6e6,
59 "Mach" : 0.84,
60 "Temperature" : 288.15,
61 "alphaAngle" : 3.06,
62 "betaAngle" : 0.0
63 },
64 "boundaries" : {
65 "1" : {
66 "type" : "NoSlipWall",
67 "name" : "wing"
68 },
69 "2" : {
70 "type" : "SlipWall",
71 "name" : "symmetry"
72 },
73 "3" : {
74 "type" : "Freestream",
75 "name" : "freestream"
76 }
77 },
78 "timeStepping" : {
79 "maxPseudoSteps" : 500,
80 "CFL" : {
81 "initial" : 5,
82 "final": 200,
83 "rampSteps" : 40
84 }
85 }
86}
Use this JSON configuration file and run the case with the following command:
caseId = flow360client.NewCase(meshId='mesh_Id',
config='/output/path/for/Flow360.json',
caseName='my_case',
tags=[]
)
(Note: Arguments of meshName and tags are optional.)
The case status can be checked by using:
## to list all your cases
flow360client.case.ListCases()
## to view a particular case
flow360client.case.GetCaseInfo('case_Id')
Replace the mesh_Id and case_Id with your mesh and case IDs, respectively.
1.2.3. Deleting a Mesh/Case
An uploaded mesh/case can be deleted using the following commands (Caution: You will not be able to recover your deleted case or mesh files including its results after your deletion):
## Delete a mesh
flow360client.mesh.DeleteMesh('')
## Delete a case
flow360client.case.DeleteCase('')
1.2.4. Download the Results
To download the surface data (surface distributions and slices) and the entire flow field, use the following command lines, respectively:
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 this in the Flow360.json file under the volumeOutput, surfaceOutput, and sliceOutput sections.
To download the solver.out file, use the following command:
flow360client.case.DownloadSolverOut('case_Id', fileName='solver.out')
You can also download the nonlinear residuals, surface forces and total forces by using the following command line:
flow360client.case.DownloadResultsFile('case_Id', 'fileName.csv')
Replace caseId with your caseId and fileName with nonlinear_residual, surface_forces and total_forces for their respective data.
1.2.5. Visualizing the Results
While your case is running, or after that, you can visualize the Residuals and Forces plot on our website (https://client.flexcompute.com/app/case/all) by clicking on your case name and viewing them under the Convergence and Forces tabs, respectively.
For example, the Forces plots for this case are:
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 (Cp), Coefficient of Skin Friction (Cf), Y+, and Cf with streamlines are provided.