Python API Reference
Contents
6. Python API Reference#
6.1. Installing Flow360 Client#
The Flow360 client can be installed (and updated) from PyPI. Make sure you have the Python setuptools. If not, sudo apt-get install python3-setuptools.
pip3 install flow360client
pip3 install --upgrade flow360client
6.2. Sign in with your Account and Password#
An account can be created at https://client.flexcompute.com/app/signup.
python3
>>> import flow360client
enter your email registered at flexcompute:********@gmail.com
Password: ***********
Do you want to keep logged in on this machine ([Y]es / [N]o)Y
Once you have installed the Flow360 client and signed into it, you can run your first case using the ONERA M6 Wing tutorial in the Quick Start section of this document.
6.3. flow360client module#
- flow360client.NewCase(meshId, config, caseName=None, tags=[], priority='high', parentId=None)#
Submit a new case from mesh Id.
- Parameters
meshId (str) – Mesh Id of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
config (path (str) or dict) – Flow360.json parameters for the case. It can be path to the json file or python dict.
caseName (str, optional) – Case name, if not provided it will be the same as config file name, required if dict provided as a config, by default None
tags (list, optional) – List of tags, by default []
priority (str, optional) – Queueing priority, ‘high’ or ‘low’, by default ‘high’
parentId (str, optional) – Parent case Id for forked cases. Format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, by default None
- Returns
Case id of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
- Return type
- flow360client.NewCaseListWithPhase(meshId, config, caseName=None, tags=[], priority='high', parentId=None, phaseCount=1)#
Submits a sequence of cases sharing the same meshId, where each case forks from the previous one. The maxPhysicalStep is split equally among the list of cases. This capability should only be used for conducting a long unsteady simulation to avoid running a single case for long time. For example, if the maxPhysicalStep is 1000 and phaseCount=2, the above API submits 2 cases with maxPhysicalStep=500 for each.
- Parameters
meshId (str) – Mesh Id of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
config (path (str) or dict) – Flow360.json parameters for the case. It can be path to the json file or python dict.
caseName (str, optional) – Case name, if not provided it will be the same as config file name, required if dict provided as a config, by default None
tags (list, optional) – List of tags, by default []
priority (str, optional) – Queueing priority, ‘high’ or ‘low’, by default ‘high’
parentId (str, optional) – Parent case Id for forked cases. Format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, by default None
phaseCount (int, optional) – [description], by default 1
- Returns
List of case ids, where case id is of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
- Return type
- flow360client.NewMesh(fname, noSlipWalls=None, meshName=None, tags=[], fmat=None, endianness=None, solverVersion=None, meshJson=None)#
Uploads new mesh. Supports CGNS and UGRID mesh formats. For CGNS mesh format, noSlipWalls are validated with the mesh before upload (requires h5py to by installed).
- Parameters
fname (path (str)) – Path to mesh file.
noSlipWalls (list, optional) – List of no-slip walls in the mesh, must be provided if meshJson not provided, by default None
meshName (str, optional) – Mesh name, if not provided mesh file name will be used, by default None
tags (list, optional) – List of mesh tags, by default []
fmat (str, optional) – Mesh file format, supported [aflr3, cgns]. Automatically deducted if not provided, by default None
endianness (str, optional) – Endianness for UGIRD mesh, ‘big’ for .b8.ugrid, and ‘little’ for .lb8.ugrid, if not provided, read from file extention, by default None
solverVersion (str, optional) – Solver version to be used for mesh and cases created from this mesh. If not provided, the latest will be used, by default None
meshJson (path (str) or dict, optional) – Flow360Mesh.json parameters for the mesh. It can be path to the json file or python dict. Must be provided if noSlipWalls not provided, by default None
- Returns
Mesh id of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
- Return type
- flow360client.NewMeshFromSurface(surfaceMeshId, config, meshName=None, tags=[], solverVersion=None)#
Generates new volume mesh from surface mesh.
- Parameters
surfaceMeshId (str) – Surface mesh Id of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
config (path (str) or dict) – Flow360SurfaceToVolumeMesh.json parameters for the volume mesher. It can be path to the json file or python dict.
meshName (str, optional) – Mesh name, if not provided it will be the same as config file name, required if dict provided as a config, by default None
tags (list, optional) – List of mesh tags, by default []
solverVersion (str, optional) – Solver version to be used for mesh and cases created from this mesh. If not provided, the latest will be used, by default None
- Returns
Mesh id of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
- Return type
- flow360client.NewSurfaceMeshFromGeometry(fileName, geometryToSurfaceMeshJson, surfaceMeshName=None, tags=[], solverVersion=None)#
Creates new surface mesh from geometry.
- Parameters
fileName (path (str)) – Geometry file name. Supported format: CSM (Engineering Sketch Pad)
geometryToSurfaceMeshJson (path (str) or dict) – Flow360GeometryToSurfaceMesh.json parameters for the surface mesher. It can be path to the json file or python dict.
surfaceMeshName (str, optional) – Surface mesh name, by default None
tags (list, optional) – List of surface mesh tags, by default []
solverVersion (str, optional) – Solver version to be used for surface mesh, volume mesh and cases created from this mesh. If not provided, the latest will be used, by default None
- Returns
Surface mesh id of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
- Return type
- flow360client.noSlipWallsFromMapbc(mapbcFile)#
Reads noSlipWalls from mapbc file (UGRID).
- flow360client.generator.case.generateCaseJson()#
Interactive command-line generator for Flow360Case.json with explanation. Walks through following configuration sections:
geometry
freestream
boundaries
slidingInterfaces
timeStepping
navierStokesSolver
turbulenceModelSolver
volumeOutput
surfaceOutput
- Returns
Returns Flow360Case.json - a simulation configuration file
- Return type
json (dict)
- flow360client.case.DeleteCase(caseId)#
Deletes case of given caseId
- Parameters
caseId (str) – Case Id to be deleted. Format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- Returns
Returns http response of the delete operation.
- Return type
http response
- flow360client.case.DownloadResultsFile(caseId, src, target=None)#
For a given caseId downloads a result file. The following files can be downloaded through this function:
surfaces.tar.gz - surface data of the case, for visualisation or postprocessing
volumes.tar.gz - volumetric data of the case, for visualisation or postprocessing
nonlinear_residual_v2.csv- nonlinear residuals. The header of the file is
physical_step, pseudo_step, <equation>...
linear_residual_v2.csv - linear residuals. The header of the file is
physical_step, pseudo_step, 0_NavierStokes_linearIterations, <equation>..., 0_<turbulence model>_linearIterations, <equation>...
cfl_v2.csv - cfl number. The header of the file is
physical_step, pseudo_step, <equation>...
minmax_state_v2.csv - min and max state of the case. Contains minimum value of pressure, minimum value of density, and maximum value of velocity magnitude, with respective locations. The header of the file is
physical_step, pseudo_step, min_rho, min_rho_x, min_rho_y, min_rho_z, min_p, min_p_x, min_p_y, min_p_z, max_umag, max_umag_x, max_umag_y, max_umag_z
surface_forces_v2.csv - all surface forces splited by boundary (no-slip wall surfaces). The header of the file is
physical_step, pseudo_step, <name>_CL, <name>_CD, <name>_CFx, <name>_CFy, <name>_CFz, <name>_CMx, <name>_CMy, <name>_CMz, <name>_CLPressure, <name>_CDPressure, <name>_CFxPressure, <name>_CFyPressure, <name>_CFzPressure, <name>_CMxPressure, <name>_CMyPressure, <name>_CMzPressure, <name>_CLViscous, <name>_CDViscous, <name>_CFxViscous, <name>_CFyViscous, <name>_CFzViscous, <name>_CMxViscous, <name>_CMyViscous, <name>_CMzViscous, <name>_HeatTransfer
, wherename
is the name of the no-slip wall surface.total_forces_v2.csv - total forces of the case integrated over all no-slip walls. The header of the file is
physical_step, pseudo_step, CL, CD, CFx, CFy, CFz, CMx, CMy, CMz, CLPressure, CDPressure, CFxPressure, CFyPressure, CFzPressure, CMxPressure, CMyPressure, CMzPressure, CLViscous, CDViscous, CFxViscous, CFyViscous, CFzViscous, CMxViscous, CMyViscous, CMzViscous, HeatTransfer
bet_forces_v2.csv - forces from BET model. The header of the file is
physical_step, pseudo_step, Disk<i>_Force_x, Disk<i>_Force_y, Disk<i>_Force_z, Disk<i>_Moment_x, Disk<i>_Moment_y, Disk<i>_Moment_z, Disk<i>_Blade<b>_R<j>_Radius, Disk<i>_Blade<b>_R<j>_ThrustCoeff, Disk<i>_Blade<b>_R<j>_TorqueCoeff
, wherei
is an index of BET disk,b
is an index of the blade, andj
is an index of the loading node.actuatorDisk_output_v2.csv - output of actuatorDisk model. The header of the file is
physical_step, pseudo_step, Disk<i>_Power
, wherei
is an index of the actuator disk.
- flow360client.case.DownloadSurfaceResults(caseId, fileName=None)#
Downloads surface results for a give caseId.
- flow360client.case.DownloadVolumetricResults(caseId, fileName=None)#
Downloads volumetric results for a give caseId.
- flow360client.case.GetCaseInfo(caseId)#
Parses information about case of given caseId
- Parameters
caseId (str) – Case Id of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- Returns
Returns http response.
- Return type
http response
- flow360client.case.GetCaseLinearResidual(caseId)#
Gets solver linear residuals for a given caseId
- Parameters
caseId (str) – Case Id of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- Returns
Returns dict consisting linear residuals for all the equations. The format is the following (for a case with SpalartAllmaras turbulence model):
{ 'physical_step': [...], 'pseudo_step': [...], '0_NavierStokes_linearIterations': [...], '0_cont': [...], '1_momx': [...], '2_momy': [...], '3_momz': [...], '4_energ': [...], '5_SpalartAllmaras_linearIterations': [...], '5_nuHat': [...] }
- Return type
- flow360client.case.GetCaseResidual(caseId)#
Gets solver nonlinear residuals for a given caseId
- Parameters
caseId (str) – Case Id of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- Returns
Returns dict consisting nonlinear residuals for all the equations. The format is the following:
{ 'physical_step': [...], 'pseudo_step': [...], '0_cont': [...], '1_momx': [...], '2_momy': [...], '3_momz': [...], '4_energ': [...], '5_nuHat': [...] }
- Return type
- flow360client.case.GetCaseTotalForces(caseId)#
For a given caseId gets the case’s total forces
- Parameters
caseId (str) – Case Id of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- Returns
Returns a dict consisting total forces in the following format:
{ 'physical_step': [...], 'pseudo_step': [...], 'CL': [...], 'CD': [...], 'CFx': [...], 'CFy': [...], 'CFz': [...], 'CMx': [...], 'CMy': [...], 'CMz': [...], 'CLPressure': [...], 'CDPressure': [...], 'CFxPressure': [...], 'CFyPressure': [...], 'CFzPressure': [...], 'CMxPressure': [...], 'CMyPressure': [...], 'CMzPressure': [...], 'CLViscous': [...], 'CDViscous': [...], 'CFxViscous': [...], 'CFyViscous': [...], 'CFzViscous': [...], 'CMxViscous': [...], 'CMyViscous': [...], 'CMzViscous': [...], 'HeatTransfer': [...] }
- Return type
- flow360client.mesh.DeleteMesh(meshId)#
Deleted mesh of given meshId
- Parameters
meshId (str) – Mesh Id to be deleted. Format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- Returns
Returns http response of the delete operation.
- Return type
http response
- flow360client.mesh.GetMeshInfo(meshId)#
Parses information about mesh of given meshId
- Parameters
meshId (str) – Mesh Id of format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- Returns
Returns http response.
- Return type
http response
- flow360client.mesh.ListMeshes(include_deleted=False)#
Gets list of meshes.
- flow360client.surfaceMesh.DeleteSurfaceMesh(surfaceMeshId)#
Deletes surface mesh of given surfaceMeshId
- Parameters
surfaceMeshId (str) – Surface mesh id to be deleted. Format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- Returns
Returns http response of the delete operation.
- Return type
http response