Converter.elsAProfile: specific elsA CGNS functions

Preamble

This module provides functions to adapt a standard CGNS/python tree for use with ONERA aerodynamic solver elsA.

To use the module:

import Converter.elsAProfile as elsAProfile

List of functions

– Conversion

Converter.elsAProfile.convert2elsAxdt(t[, ...]) Convert a standard CGNS/python tree for use with elsA aerodynamic solver.
Converter.elsAProfile.adaptNearmatch(t) Convert the nearmatch condition for use with elsA aerodynamic solver.
Converter.elsAProfile.adaptPeriodicMatch(t) Convert the periodic match condition for use with elsA aerodynamic solver.
Converter.elsAProfile.buildBCOverlap(t) Convert the Overlap condition from GC (Grid Connectivity condition) to BC (Boundary Condition) for elsA solver.
Converter.elsAProfile.rmGCOverlap(t) Remove the Overlap condition described as Grid Connectivity.
Converter.elsAProfile.addNeighbours(t[, ...]) Fill the NeighbourList nodes with bounding-box domains intersection.
Converter.elsAProfile.buildMaskFiles(t[, ...]) Build the mask files for elsA solver.

– Specific node addition

Converter.elsAProfile.addTurbulentDistanceIndex(t) Add the TurbulentDistance index node for elsA solver.
Converter.elsAProfile.addReferenceState(t[, ...]) Add a reference state for each base.
Converter.elsAProfile.addGlobalConvergenceHistory(t) Create a node for global convergence history storage for each base.
Converter.elsAProfile.addFlowSolution(t[, ...]) Add a node to extract flow solution for each zone of the pyTree.
Converter.elsAProfile.addFlowSolutionEoR(t) Add a node to extract flow solution at End of Run for each zone of the pyTree.
Converter.elsAProfile.addOutput(node, Dict, name) Add an output node to extract required value from a node.
Converter.elsAProfile.addOutputForces(node) Add an output node for forces.
Converter.elsAProfile.addOutputFriction(node) Add an output node for frictions.
Converter.elsAProfile.createElsaHybrid(t[, ...])

Contents

Conversion

Converter.elsAProfile.convert2elsAxdt(t)

Perform all necessary adaptation to your tree to enter elsA aerodynamic solver. It contains the methods addTurbulentDistanceIndex, buildMaskFiles, adaptNearmatch, adaptPeriodicMatch, buildBCOverlap, addNeighbours, addFamilyBCNode, cleanTree and addBaseToDonorZone. Exists also as in place version (_convert2elsAxdt) that modifies t and returns None.

Parameters:t (pyTree) – input tree
Returns:modified reference copy of t
Return type:pyTree: pyTree

Example of use:

# - convert2elsAxdt (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.elsAProfile as elsAProfile

a = G.cart((0,0,0), (1,1,1), (10,10,10))
t = C.newPyTree(['Base',a])
tp = elsAProfile.convert2elsAxdt(t)
C.convertPyTree2File(tp, 'out.cgns')

Converter.elsAProfile.adaptNearmatch(t)

Perform the conversion of nearmatch Cassiopee condition in your tree to enter elsA aerodynamic solver. It adds a .Solver#Property in the GridConnectivity node with elsA keys: type, jtype, matchside, i or j or k_ratio. The GridConnectivity_t type has been modified into a GridConnectivity1to1_t type.

Parameters:t (pyTree) – input tree
Returns:modified reference copy of t
Return type:pyTree: pyTree

Example of use:

# - connectNearMatch (pyTree) -
import Generator.PyTree as G
import Connector.PyTree as X
import Converter.PyTree as C
import Transform.PyTree as T
import Converter.elsAProfile as elsAProfile

a1 = G.cart((0.,0.,0.), (0.1, 0.1, 0.1), (11, 21, 3)); a1[0] = 'cart1'
a2 = G.cart((1., 0.2, 0.), (0.1, 0.1, 0.1), (11, 21, 3)); a2[0] = 'cart2'
a2 = T.oneovern(a2,(1,2,1))
t = C.newPyTree(['Base',a1,a2])
t = X.connectNearMatch(t)
tp = elsAProfile.adaptNearmatch(t)
C.convertPyTree2File(tp, 'out.cgns')

Converter.elsAProfile.adaptPeriodicMatch(t)

Perform the conversion of periodic match Cassiopee condition in your tree to enter elsA aerodynamic solver. It adds a .Solver#Property in the GridConnectivity node with elsA keys: type, jtype, jtopo, ptype... It adds also a .Solver#Param in the ZoneGridConnectivity node with elsA keys: axis_ang, axis_pnt and axis_vct.

Parameters:t (pyTree) – input tree
Returns:modified reference copy of t
Return type:pyTree: pyTree

Example of use:

# - connectMatch (pyTree) -
import Generator.PyTree as G
import Connector.PyTree as X
import Converter.PyTree as C
import Converter.elsAProfile as elsAProfile

a = G.cylinder((0.,0.,0.), 0.1, 1., 0., 90., 5., (11,11,11)) 
t = C.newPyTree(['Base',a])
t = X.connectMatchPeriodic(t, rotationCenter=[0.,0.,0.],
                           translation=[0.,0.,5.])
t = X.connectMatchPeriodic(t, rotationCenter=[0.,0.,0.],
                           rotationAngle=[0.,0.,90.])
tp = elsAProfile.adaptPeriodicMatch(t)
C.convertPyTree2File(tp, 'out.cgns')

Converter.elsAProfile.buildBCOverlap(t)

Perform the conversion of the overlap Cassiopee condition in your tree to enter elsA aerodynamic solver. It transforms the GridConnectivity overlap node into a BC node, attached to family (UserDefined BC taggued). It adds also a .Solver#Overlap in the BC Family node with elsA key: NeighbourList.

Parameters:t (pyTree) – input tree
Returns:modified reference copy of t
Return type:pyTree: pyTree

Example of use:

# - applyBCOverlaps (pyTree) -
import Converter.PyTree as C
import Connector.PyTree as X
import Generator.PyTree as G
import Converter.elsAProfile as elsAProfile

a = G.cylinder((0,0,0), 1., 1.5, 360., 0., 1., (30,30,10))
a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'jmin')
t = C.newPyTree(['Base',a])
t = X.applyBCOverlaps(t)
tp = elsAProfile.buildBCOverlap(t)
C.convertPyTree2File(tp, 'out.cgns')

Converter.elsAProfile.rmGCOverlap(t)

Remove the overlap condition described as Grid Connectivity in the tree.

Parameters:t (pyTree) – input tree
Returns:modified reference copy of t
Return type:pyTree: pyTree

Example of use:

# - applyBCOverlaps (pyTree) -
import Converter.PyTree as C
import Connector.PyTree as X
import Generator.PyTree as G
import Converter.elsAProfile as elsAProfile

a = G.cylinder((0,0,0), 1., 1.5, 360., 0., 1., (30,30,10))
a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'jmin')
t = C.newPyTree(['Base',a])
t = X.applyBCOverlaps(t)
tp = elsAProfile.buildBCOverlap(t)
tp = elsAProfile.rmGCOverlap(tp)
C.convertPyTree2File(tp, 'out.cgns')

Converter.elsAProfile.addNeighbours(t, sameBase=0)

Fill the NeighbourList nodes if needed with bounding-box domains intersection between bases. If sameBase=1, the intersecting domains are also searched in the current base.

Parameters:
  • t (pyTree) – input tree
  • sameBase (integer) – choice for keeping the same current base in the bounding-box intersection (1 for yes, 0 else)
Returns:

modified reference copy of t

Return type:

pyTree: pyTree

Example of use:

# - applyBCOverlaps (pyTree) -
import Converter.PyTree as C
import Connector.PyTree as X
import Generator.PyTree as G
import Converter.elsAProfile as elsAProfile
import Converter.Internal as Internal


a = G.cylinder((0,0,0), 1., 1.5, 360., 0., 1., (30,30,10))
a = C.addBC2Zone(a, 'overlap1', 'BCOverlap', 'jmax')
a = C.addBC2Zone(a, 'wall1', 'BCWall', 'jmin')
b = G.cart((-10.,-10.,-10.),(0.4,0.4,0.4), (50,50,50))

t = C.newPyTree(['Cyl',a,'Cart',b])
t = X.applyBCOverlaps(t)
tp = elsAProfile.buildBCOverlap(t)
tp = elsAProfile.rmGCOverlap__(tp)
tp = elsAProfile.addNeighbours(tp)
C.convertPyTree2File(tp, 'out.cgns')

Converter.elsAProfile.buildMaskFiles(t, keepOversetHoles=True, fileDir='.')

Build the mask files in bin_v3d format. It can also keep or delete the OversetHoles nodes in the tree. The fileDir variable allows to choose the directory where the v3d hole files will be written.

Parameters:
  • t (pyTree) – input tree
  • keepOversetHoles (boolean) – choice for keeping or not the OversetHoles in the tree
  • fileDir (string) – path of directory for files writing
Returns:

modified reference copy of t

Return type:

pyTree: pyTree

Example of use:

# - blankCells (pyTree) -
import Converter.PyTree as C
import Connector.PyTree as X
import Generator.PyTree as G
import Geom.PyTree as D
import Transform.PyTree as T
import Converter.elsAProfile as elsAProfile

surf = D.sphere((0,0,0), 0.5, 20)

a = G.cart((-1.,-1.,-1.),(0.1,0.1,0.1), (20,20,20))
t = C.newPyTree(['Cart']); t[2][1][2].append(a)
t = C.initVars(t, 'centers:cellN', 1.)

bodies = [[surf]]
# Matrice de masquage (arbre d'assemblage)
import numpy
BM = numpy.array([ [ 1] ] )

t = X.blankCells(t, bodies, BM, blankingType='cell_intersect', delta=0.)
t = X.cellN2OversetHoles(t)
tp = elsAProfile.buildMaskFiles(t,keepOversetHoles=False)
C.convertPyTree2File(tp, 'out.cgns')

Converter.elsAProfile.addTurbulentDistanceIndex(t)

Add a TurbulentDistanceIndex node in the FlowSolution#Init node if TurbulentDistance node exists. All values are equal to -1.

Parameters:t (pyTree) – input tree
Returns:modified reference copy of t
Return type:pyTree: pyTree

Example of use:

# - distance2Walls (pyTree) -
import Dist2Walls.PyTree as Dist2Walls
import Generator.PyTree as G
import Converter.PyTree as C
import Converter.Internal as Internal
import Geom.PyTree as D
import Converter.elsAProfile as elsAProfile

a = G.cart((0.,0.,0.),(0.1,0.1,0.1),(10,10,10))
sphere = D.sphere((1.2,0.,0.),0.2,100)
t = C.newPyTree(['Base',a])
t = Dist2Walls.distance2Walls(t, sphere)
Internal._renameNode(t,'FlowSolution#Centers','FlowSolution#Init')
tp = elsAProfile.addTurbulentDistanceIndex(t)
C.convertPyTree2File(tp, 'out.cgns')

Converter.elsAProfile.addReferenceState(t, conservative=None, temp=None, turbmod='spalart', name='ReferenceState', comments=None, k=None, eps=None)

Add a reference state node in each base. You must specify conservative as a list of reference conservative values. You can optionaly specify temp, a reference temperature, turbmod, the turbulence model in ‘komega’, ‘kkl’, ‘smith’, ‘spalart’, ‘keps’, ‘rsm’, and reference values for k and eps. Name of node and comments can also be specified. Exists also as in place version (_addReferenceState) that modifies t and returns None.

Parameters:
  • t (pyTree) – input tree
  • conservative (list of floats) – list of all conservative variables [ro,rovx,rovy,rovz,roe,rok,roeps] in this order. Only the first five are required.
  • temp (float) – optional temperature data.
  • turbmod (string) – turbulence model name.
  • name (string) – name of the ReferenceState node.
  • comments (string) – optional comments to describe the reference state.
  • k (float) – value of first turbulence model variable.
  • eps (float) – value of second turbulence model variable.
Returns:

modified reference copy of t

Return type:

pyTree: pyTree

Example of use:

# - addReferenceState (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.elsAProfile as elsAProfile

a = G.cart((0,0,0), (1,1,1), (10,10,10))
t = C.newPyTree(['Base',a])
tp = elsAProfile.addReferenceState(t, conservative=[1.,0,0,0,1.7])
C.convertPyTree2File(tp, 'out.cgns')

Converter.elsAProfile.addGlobalConvergenceHistory(t, normValue=0)

Add a convergence node in each base. The type of norm used in residual computation can be specified (0: L0, 1: L2). Exists also as in place version (_addGlobalConvergenceHistory) that modifies t and returns None.

Parameters:
  • t (pyTree) – input tree
  • normValue (integer) – an optional integer, specifying the type of norm as value of the GlobalConvergenceHistory node.
Returns:

modified reference copy of t

Return type:

pyTree: pyTree

Example of use:

# - addGlobalConvergenceHistory (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.elsAProfile as elsAProfile

a = G.cart((0,0,0), (1,1,1), (10,10,10))
t = C.newPyTree(['Base',a])
tp = elsAProfile.addGlobalConvergenceHistory(t)
C.convertPyTree2File(tp, 'out.cgns')

Converter.elsAProfile.addFlowSolution(t, name='', loc='CellCenter', variables=None, governingEquations=None, writingMode=None, writingFrame='relative', period=None, output=None, addBCExtract=False, protocol="end")

Add a FlowSolution node for each zone. name is a suffix that can be appened to the ‘FlowSolution’ name. loc must be ‘Vertex’ or ‘CellCenter’ or ‘cellfict’. governingEquation is the value of the ‘GoverningEquation’ node. output can be optionaly a dictionary specifying the ‘.Solver#Output’ node data. If addBCExtract is true, the boundary windows are also extracted. protocol is an optional string in ‘iteration’, ‘end’, ‘after’, specifying when extraction is performed. Exists also as in place version (_addFlowSolution) that modifies t and returns None.

Parameters:
  • t (pyTree) – input tree
  • name (string) – suffix node name to add to ‘FlowSolution’
  • loc (string) – location of extraction (‘CellCenter’, ‘Vertex’ or ‘cellfict’)
  • variables (list of string) – list of variables (elsA names)
  • governingEquations (string) – kind of governing equations (‘Euler’, ‘NSTurbulent’...)
  • writingMode (integer) – writingmode value for elsA
  • writingFrame (string) – frame of FlowSolution (‘absolute’,’relative’)
  • period (integer) – period of extraction
  • output (dictionary) – an optional dictionary of node to add to ‘.Solver#Output’ if necessary
  • addBCExtract (boolean) – boolean to add extract from BC windows (pseudo CellFict)
  • protocol (string) – Protocol node value (‘iteration’,’end’,’after’) for extraction
Returns:

modified reference copy of t

Return type:

pyTree: pyTree

Example of use:

# - addFlowSolution (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.elsAProfile as elsAProfile

a = G.cart((0,0,0), (1,1,1), (10,10,10))
t = C.newPyTree(['Base', a])
t = elsAProfile.addFlowSolution(t)
C.convertPyTree2File(t, 'out.cgns')

Converter.elsAProfile.addFlowSolutionEoR(t, name='', variables=None, governingEquations=None, writingFrame='relative', addBCExtract=False, protocol="end")

Add a FlowSolution#EndOfRun node for each zone. name is a suffix that can be appened to the ‘FlowSolution#EndOfRun’ name. governingEquation is the value of the ‘GoverningEquation’ node. If addBCExtract is true, the boundary windows are also extracted. protocol is an optional string in ‘iteration’, ‘end’, ‘after’, specifying when extraction is performed. Exists also as in place version (_addFlowSolutionEoR) that modifies t and returns None.

Parameters:
  • t (pyTree) – input tree
  • name (string) – suffix node name to add to ‘FlowSolution’
  • variables (list of string) – list of variables (elsA names)
  • governingEquations (string) – kind of governing equations (‘Euler’, ‘NSTurbulent’...)
  • writingFrame (string) – frame of FlowSolution (‘absolute’,’relative’)
  • addBCExtract (boolean) – boolean to add extract from BC windows (pseudo CellFict)
  • protocol (string) – Protocol node value (‘iteration’,’end’,’after’) for extraction
Returns:

modified reference copy of t

Return type:

pyTree: pyTree

Example of use:

# - addFlowSolution (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.elsAProfile as elsAProfile

a = G.cart((0,0,0), (1,1,1), (10,10,10))
t = C.newPyTree(['Base', a])
t = elsAProfile.addFlowSolutionEoR(t)
C.convertPyTree2File(t, 'out.cgns')

Converter.elsAProfile.addOutput(a, Dict, name)
Add a .Solver#Output node in order to extract required value. Dict is a python dictionary containing all output informations. For example:
>>> Dict={}
>>> Dict["var"]="convflux_rou convflux_rov convflux_row"
>>> Dict["loc"]=1
>>> Dict["fluxcoef"]=1.
>>> Dict["period"]=10

Name is a suffix that can be appened to the ‘.Solver#Output’ name. Exists also as in place version (_addOutput) that modifies t and returns None.

Parameters:
  • a (pyTree) – input node
  • Dict (python dictionary) – dictionary containing all output informations.
  • name (string) – suffix node name to add to ‘.Solver#Output’
Returns:

modified reference copy of a

Return type:

pyTree: pyTree

Example of use:

# - addOutputForces (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.Internal as Internal
import Converter.elsAProfile as elsAProfile

a = G.cart((0,0,0), (1,1,1), (10,10,10))
a = C.addBC2Zone(a, 'wall', 'BCWall', 'imin')
bcs = Internal.getNodesFromName(a, 'wall')

dict = {}
dict['var'] = 'convflux_rou convflux_rov convflux_row'
dict['loc'] = 1
dict['fluxcoef'] = 1.
dict['period'] = 10

for b in bcs: elsAProfile._addOutput(b,dict,name='')

C.convertPyTree2File(a, 'out.cgns')

Converter.elsAProfile.addOutputForces(a, name="", var=None, loc=4, writingmode=1, period=None, pinf=None, fluxcoef=None, torquecoef=None, xyztorque=None, frame=None, governingEquations="NSTurbulent", xtorque=None, ytorque=None, ztorque=None)

Add a .Solver#Output:Forces node in order to extract required value. name is a suffix that can be appened to the ‘.Solver#Output:Forces’ name. loc is the location (integer value for elsA) for extraction. writingmode value is the integer corresponding to elsA. period is the extraction frequency

Exists also as in place version (_addOutputForces) that modifies t and returns None.

Parameters:
  • a (pyTree) – input node
  • name (string) – suffix node name to add to ‘.Solver#Output:Forces’
  • var (list of strings) – list of variables names
  • loc (string) – suffix node name to add to ‘.Solver#Output:Forces’
  • writingmode (integer) – writingmode value for elsA
  • period (integer) – period of extraction
  • pinf (float) – value of farfield pressure
  • fluxcoef (float) – coefficient to correct the forces
  • torquecoef (float) – coefficient to correct the torques
  • xyztorque (list of float) – coordinates of the torque origin
  • frame (string) – writing frame (‘relative’,’absolute’)
  • governingEquations (string) – governing equations of the model
  • xtorque (float) – X-coordinate of the torque origin
  • ytorque (float) – Y-coordinate of the torque origin
  • ztorque (float) – Z-coordinate of the torque origin
Returns:

modified reference copy of a

Return type:

pyTree: pyTree

Example of use:

# - addOutputForces (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.Internal as Internal
import Converter.elsAProfile as elsAProfile

a = G.cart((0,0,0), (1,1,1), (10,10,10))
a = C.addBC2Zone(a, 'wall', 'BCWall', 'imin')
bcs = Internal.getNodesFromName(a, 'wall')
for b in bcs: elsAProfile._addOutputForces(b)

C.convertPyTree2File(a, 'out.cgns')

Converter.elsAProfile.addOutputFriction(a, name="", var=None, loc=4, writingmode=1, period=None, fluxcoef=None, torquecoef=None, writingframe=None)

Add a .Solver#Output:Friction node in order to extract required value. name is a suffix that can be appened to the ‘.Solver#Output:Friction’ name. loc is the location (integer value for elsA) for extraction. writingmode value is the integer corresponding to elsA. period is the extraction frequency

Exists also as in place version (_addOutputFriction) that modifies t and returns None.

Parameters:
  • a (pyTree) – input node
  • name (string) – suffix node name to add to ‘.Solver#Output:Forces’
  • var (list of strings) – list of variables names
  • loc (string) – suffix node name to add to ‘.Solver#Output:Forces’
  • writingmode (integer) – writingmode value for elsA
  • period (integer) – period of extraction
  • fluxcoef (float) – coefficient to correct the forces
  • torquecoef (float) – coefficient to correct the torques
  • writingframe (string) – writing frame (‘relative’,’absolute’)
Returns:

modified reference copy of a

Return type:

pyTree: pyTree

Example of use:

# - addOutputFriction (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.Internal as Internal
import Converter.elsAProfile as elsAProfile

a = G.cart((0,0,0), (1,1,1), (10,10,10))
a = C.addBC2Zone(a, 'wall', 'BCWall', 'imin')
bcs = Internal.getNodesFromName(a, 'wall')
for b in bcs: elsAProfile._addOutputFriction(b)

C.convertPyTree2File(a, 'out.cgns')

Converter.elsAProfile.createElsaHybrid(t, method=0, axe2D=0)

Add nodes required by elsA Hybrid solver for NGON zones. For elsA < 3.8.01, use method=0, for newer versions use method=1. If the mesh is 2D, use axe2D to precise 2D plane (0: (x,y), 1: (x,z), 2: (y,z)). Exists also as in place version (_createElsaHybrid) that modifies t and returns None.

Parameters:
  • t (pyTree) – input tree
  • method (0 or 1) – 0 (if for elsA < 3.8.01), 1 otherwise
Returns:

modified reference copy of t

Return type:

pyTree

Example of use:

# - createElsaHybrid (pyTree) -
import Converter.PyTree as C
import Generator.PyTree as G
import Converter.elsAProfile as elsAProfile

# Must be NGon
a = G.cartNGon((0,0,0), (1,1,1), (10,10,10))
a = C.fillEmptyBCWith(a, 'farfield', 'BCFarfield')
elsAProfile._createElsaHybrid(a)
C.convertPyTree2File(a, 'out.cgns')

Table Of Contents

Download pdf version