Transform: mesh Transformations
Version: 2.4 (29/03/2017)
Author: Onera

Preamble
Transform module performs simple transformations of meshes. It
works on arrays (as defined in Converter documentation)
or on CGNS/Python trees (pyTrees) containing grid coordinates
information.
This module is part of Cassiopee, a free open-source
pre- and post-processor for CFD simulations.
To use it with the array interface,
you have to import Transform module:
import Transform as T
Then, a defines an array, and A defines a list of arrays.
To use it with the pyTree interface:
import Transform.PyTree as T
Then, a defines a zone node, A defines a list of zone nodes or a pyTree.
Simple operations
Warning: the pyTree functions subzone, oneovern, join, reorder
destroy the 'BCMatch' and 'BCNearMatch' boundary conditions.
They can be rebuilt by connectMatch and connectNearMatch functions of Connector module.
T.subzone: extract a subzone.
For a structured array, you must specify the min and max indices in i,j,k directions of the subzone:
b = T.subzone(a, (imin,jmin,kmin), (imax,jmax,kmax))
For an unstructured array, you must specify the vertices belonging to subzone (index starts from 1):
b = T.subzone(a, [1,2,...])
Extract a subzone of an unstructured array providing the indices of elements (index starts from 0):
b = T.subzone(a, [0,1,...], type='elements')
Extract a subzone of an unstructured array providing the indices of faces
(for unstructured zones with basic elements: indFace=indElt*numberOfFaces+noFace, for NGON zones: use the natural face indexing, starting from 1):
b = T.subzone(a, [1,2,...], type='faces')
Example of use: subzone extraction (array),
subzone extraction (pyTree).
T.join: join two arrays in one (if possible) or join a list of arrays in one
(if possible).
Warning: for the pyTree version, join does not take into account
modifications of boundary conditions:
c = T.join(a, b, tol=1.e-10) .or. c = T.join(A, tol=1.e-10)
Example of use: 2 arrays join (array),
2 zones join (pyTree).
T.merge: merge a set of curvilinear grids (surface grids must be k=1) if possible.
Parameter sizeMax defines the maximum size of merged grids.
dir is the constraint direction along which the merging is prefered.
Default value is 0 (no prefered direction), 1 for i, 2 for j, 3 for k.
alphaRef can be used for surface grids and avoids merging adjacent zones
sharing an angle deviating of alphaRef to 180:
B = T.merge(A, sizeMax=1000000000, dir=0, tol=1.e-10, alphaRef=180.)
Example of use: grid merging (array),
grid merging (pyTree).
T.mergeCart: merge a set of Cartesian grids (patch grids) if possible.
Parameter sizeMax defines the maximum size of merged grids:
B = T.mergeCart(A, sizeMax=1000000000, tol=1.e-10)
Example of use: Cartesian grid merging (array),
Cartesian grid merging (pyTree).
T.patch: patch (replace) an array b into an array a, from position (i,j,k) when
dealing with structured arrays, and at given nodes (specified as a list or a numpy array of indices starting from 1)
when dealing with structured or unstructured arrays:
c = T.patch(a, b, position=(i,j,k)) .or. c = T.patch(a, b, nodes=[1,2,3])
Example of use: array patching (array),
zone patching (pyTree).
T.oneovern: extract one point over N points from a:
b = T.oneovern(a, (Ni,Nj,Nk)) .or. B = T.oneovern(A, (Ni,Nj,Nk))
Example of use: point extraction (array),
point extraction (pyTree).
T.collapse: for a TRI zone a, collapse smallest edges of each triangle.
Return a BAR array:
b = T.collapse(a) .or. B = T.collapse(A)
Example of use: collapse a tri mesh (array),
collapse a tri mesh (pyTree).
T.reorder: change the (i,j,k) ordering of structured array a.
In the following example, i1 becomes k2, j1 becomes -j2, k1 becomes -i2:
b = T.reorder(a, (3,-2,-1)) .or. B = T.reorder(A, (3,-2,-1))
Change the ordering of a TRI- or QUAD-array or a 2D NGON array. All elements are
numbered in the same way:
b = T.reorder(a, (-1,)) .or. B = T.reorder(A, (-1,))
For pyTree version, the global top tree a belongs to can be specified
to update its matching boundaries impacted by the reordering of
a (toptree is modified):
a = T.reorder(a, (3,-2,-1), toptree=[])
Example of use: i, j, k reordering (array),
i, j, k reordering (pyTree).
T.reorderAll: reorient surfaces zones consistently between them. All zones must have the same type, either structured or unstructured (TRI currently).
The zones must be abutting or overlapping and the reorientation of the first zone is used to reorient the other ones.
For the unstructured case, if the zones represent a piecewise closed volume, reorientation is guaranteed to be outward (by default).
Parameter 'dir' allows the user to change ordering (default value is 1). If dir=-1, the reordering is performed
in the opposite direction:
B = T.reorderAll(A, dir)
NB: if reorder fails, A is returned.
Example of use: surface block reordering (array),
surface block reordering (pyTree).
T.makeDirect: make a structured zone direct (change eventually k ordering):
b = T.makeDirect(a) .or. B = T.makeDirect(A)
Example of use: make array direct (array),
make zone direct (pyTree).
T.makeCartesianXYZ: align a Cartesian mesh such that i,j, k are aligned with x,y,z respectively:
b = T.makeDirect(a) .or. B = T.makeCartesianXYZ(A)
Example of use: align i,j,k, with X,Y,Z (array),
align i,j,k with X,Y,Z (pyTree).
T.addkplane: add one or more (z+1) plane:
b = T.addkplane(a, N=1) .or. B = T.addkplane(A, N=1)
Example of use: k plane addition (array),
k plane addition (pyTree).
Mesh positioning
The following functions are applicable to both structured and unstructured grids.
T.translate: translate of a vector (0.,1.,0.):
b = T.translate(a, (0.,1.,0.)) .or. B = T.translate(A, (0.,1.,0.))
Example of use: translation (array),
translation (pyTree).
T.rotate: make a rotation of center (0.2,0.2,0.) around z-axis of angle of 18 degrees:
b = T.rotate(a, (0.2,0.2,0.), (0.,0.,1.), 18.,vectors=None) .or. B = T.rotate(A, (0.2,0.2,0.), (0.,0.,1.), 18.,vectors=[])
Make a rotation of center (0.2,0.2,0.) around z-axis of angle of 18 degrees.
The velocity vector is also rotated:
b = T.rotate(a, (0.2,0.2,0.), (0.,0.,1.), 18.,vectors=[['VelocityX','VelocityY','VelocityZ']]) .or. B = T.rotate(A, (0.2,0.2,0.), (0.,0.,1.), 18.,vectors=[['VelocityX','VelocityY','VelocityZ']])
Make a rotation of center (0.2,0.2,0.) transforming frame vector (e1,e2,e3) in frame vector (f1,f2,f3):
b = T.rotate(a, (0.2,0.2,0.), (e1,e2,e3), (f1,f2,f3)) .or. B = T.rotate(A, (0.2,0.2,0.), (e1,e2,e3), (f1,f2,f3))
Make a rotation of center (0.2,0.2,0.) wrt three angles (alpha, beta, gamma).
alpha is a rotation along X (Ox->Ox, Oy->Oy1, Oz->Oz1),
beta along y (Ox1->Ox2, Oy1->Oy1, Oz1->Oz2),
gamma along z (Ox2->Ox3, Oy2->Oy3, Oz2->Oz2):
b = T.rotate(a, (0.2,0.2,0.), (alpha,beta,gamma)) .or. B = T.rotate(A, (0.2,0.2,0.), (alpha,beta,gamma))
Example of use: rotation (array),
rotation (pyTree).
Mesh transformation
The following functions, except "perturbate", are applicable to both structured and unstructured grids.
T.cart2Cyl: transform a mesh in Cartesian coordinates into cylindrical coordinates,
such that the origin of the frame is (x0,y0,z0) and (0,0,1) means the cylindrical axis is (0z).
b = T.cart2Cyl(a, (x0,y0,z0), (0,0,1)) .or. B = T.cart2Cyl(A, (x0,y0,z0), (0,0,1))
Example of use: cart2Cyl (array),
cart2Cyl(pyTree).
T.homothety: make an homothety of center C (0.,0.,0.) and of multiplication factor alpha=0.1
(CM' = alpha * CM):
b = T.homothety(a, (0.,0.,0.), 0.1) .or. B = T.homothety(A, (0.,0.,0.), 0.1)
Example of use: homothety (array),
homothety (pyTree).
T.contract: make a contraction of a, regarding a plane defined by point
(0.,0.,0.) and by dir1 (1,0,0) and dir2 (0,1,0) and of multiplication factor alpha=0.1:
b = T.contract(a, (0.,0.,0.), (1,0,0), (0,1,0), 0.1) .or. B = T.contract(A, (0.,0.,0.), (1,0,0), (0,1,0), 0.1)
Example of use: array contraction (array),
array contraction (pyTree).
T.scale: scale a mesh with a given constant factor or per direction:
b = T.scale(a, factor=0.1) .or. B = T.scale(A, factor=(0.1,0.2,0.3))
Example of use: array scaling (array),
array scaling (pyTree).
T.symetrize: make a symmetry of a, considering the plane passing by a point
(1.,2.,3.) and defined by two vectors (1,0,0) and (0,1,0). Beware the
(i,j,k) trihedra may be modified. Use
reorder to avoid this:
b = T.symetrize(a, (1.,2.,3.), (1,0,0), (0,1,0)) .or. B = T.symetrize(A, (1.,2.,3.), (1,0,0), (0,1,0))
Example of use: symmetry (array),
symmetry (pyTree).
T.perturbate: perturbate randomly a mesh with a given radius. If dim=2, z coordinates are fixed, if dim=1, y and z coordinates are fixed:
b = T.perturbate(a, 0.1, dim=3)
Example of use: random perturbation (array),
random perturbation (pyTree).
T.smooth: perform a Laplacian smoothing on a 'QUAD', 'TRI' array or a list of structured arrays with a weight eps, and niter smoothing iterations. Type=0 means isotropic Laplacian, type=1 means scaled Laplacian, type=2
means taubin smoothing.
Constraints can be defined in order to avoid smoothing some points (for instance the exterior faces of a):
b = T.smooth(a, eps=0.5, niter=4, type=0, fixedConstraints=[], projConstraints=[])
Example of use: Laplacian smoothing (array),
Laplacian smoothing (pyTree).
T.splitCurvatureAngle: split a i-array following curvature angle. If angle is lower than 180-45 degrees or greater than 180+45 degrees, curve is split:
A = T.splitCurvatureAngle(a, 45.)
Example of use: line splitting (array),
line splitting (pyTree).
T.splitCurvatureRadius: split a i-array following curvature radius, using B-splines approximation.
The curve can be closed or not. Parameter Rs is a
threshold curvature radius, so that the initial curve is split
at points of curvature radius lower than than Rs:
B = T.splitCurvatureRadius(a, cs)
Example of use: curve splitting (array),
curve splitting (pyTree).
T.splitConnexity: split an unstructured array into connex parts:
B = T.splitConnexity(a)
Example of use: identify connex parts (array),
Identify connex parts (pyTree).
T.splitSharpEdges: split an array into smooth parts. AlphaRef specifies the split angle
between neighbouring elements:
B = T.splitSharpEdges(a, alphaRef=30.)
Example of use: identify smooth parts (array),
Identify smooth parts (pyTree).
T.splitBAR: split a 'BAR' array into 2 BAR arrays delimited by the node N (start 0):
B = T.splitBAR(a, N)
Example of use: BAR splitting (array),
BAR splitting (pyTree).
T.splitTBranches: split a 'BAR' array into several BAR arrays, at vertices where T-branches exist:
B = T.splitTBranches(a, tol=1.e-13) .or. B = T.splitTBranches(A, tol=1.e-13)
Example of use: T-Branch BAR splitting (array),
T-Branch BAR splitting (pyTree).
T.splitTRI: split an unstructured TRI array into several TRI arrays delimited by the
input poly lines which are a lists of index list.
2 consecutives indices in a list must define an existing edge in
the mesh:
B = T.splitTRI(a, polyLines)
Example of use: TRI splitting (array).
T.splitManifold:
split an unstructured mesh (only TRI or BAR currently) into several manifold pieces:
B = T.splitManifold(a)
Example of use: Manifold splitting (array).
T.splitSize: split structured blocks when their number of points is greater than N. Argument 'multigrid' ensures the given multigrid level when splitting, if input grids respect this multigrid level:
B = T.splitSize(a, N, multigrid=0, dirs=[1,2,3]) .or. B = T.splitSize(A, N, multigrid=0, dirs=[1,2,3])
SplitSize can also be used to split blocks in order to best fit on a number
of R=12 processors. MinPtsPerDir specifies the minimum number of points
per direction the splitter must respect:
B = T.splitSize(a, R=12, multigrid=0, dirs=[1,2,3], type=2, minPtsPerDir=5) .or. B = T.splitSize(A, R=12, multigrid=0, dirs=[1,2,3], minPtsPerDir=5)
Example of use: size splitting (array),
size splitting (pyTree).
T.splitNParts: split structured blocks in N parts. Argument 'multigrid' ensures the given multigrid level when
splitting, if input grids respect this multigrid level. Parameter dirs enable to enforce splitting in one direction, i.e. dirs=[1]
force splitting only in the first mesh direction.
Boundary conditions are split, but grid connectivity is removed:
B = T.splitNParts(a, N, multigrid=0, dirs=[1,2,3]) .or. B = T.splitNParts(A, N, multigrid=0, dirs=[1,2,3])
Example of use: N-part splitting (array),
N-part splitting (pyTree).
T.splitMultiplePts: split structured blocks at border points where they are connected to an even number of blocks. Parameter dim is the dimension of the problem:
B = T.splitMultiplePts(A, dim=3)
Example of use: multiple point splitting (array),
multiple point splitting (pyTree).
T.breakElements: break a NGON zone into a list of unstructured zones, as BAR, TRI, QUAD, TETRA, PENTA, PYRA, HEXA or NGON zones:
B = T.breakElements(a) .or. B = T.breakElements(A)
Example of use: break a NGON zone into a set of unstructured zones (array),
break a NGON zone into a set of unstructured zones (pyTree).
T.dual: returns the dual of a mesh. If extraPoints=1,
points in the center of external faces are added:
b = T.dual(a, extraPoints=1)
Example of use: create the dual of a NGON mesh (array),
create the dual of a NGON mesh (pyTree).
T.deformPoint: deform a, by moving point (x,y,z) of vector (dx,dy,dz). Fourth argument
controls the depth of deformation. Last argument controls the width
of deformation:
b = T.deformPoint(a, (x,y,z), (dx,dy,dz), 0.5, 0.4)
Example of use: point deformation (array),
point deformation (pyTree).
T.deform: deform a, by moving each point of a given vector array (array):
b = T.deform(a, vector)
Deform a, by moving each point of a given vector defined by
variables 'dx','dy','dz', defined in a (pyTree):
b = T.deform(a, ['dx','dy','dz'])
Example of use: surface deformation (array),
mesh deformation (pyTree).
T.deformNormals: deform a surface a, by moving each point of the surface by a scalar field alpha times the surface normals in niter steps (array):
b = T.deformNormals(a, alpha., niter=1)
Deform a surface a, by moving each point of the surface by a variable named alpha times the surface normals in niter steps (pyTree):
b = T.deformNormals(a, alpha, niter=1)
Example of use: deformation a mesh of alpha times the normals (array),
deformation a mesh of alpha times the normals (pyTree).
T.deformMesh: deform a mesh defined by a, given surface or
a set of surfaces for which a deformation is defined at nodes as 'dx,dy,dz'.
Beta defined the deformation zone as multiplication factor of local
deformation:
b = T.deformMesh(a, surfaces, beta=4.)
Example of use: mesh deformation (array),
mesh deformation (pyTree).
T.projectAllDirs: project a (A) onto a list of surfaces S following a vector defined for each point of a (A).
The three components of the vector are defined by the list of strings vect.
If oriented=0, use both direction for projection else use vector direction
only:
b = T.projectAllDir(a, S, vect=['nx','ny','nz'], oriented=0) .or. B = T.projectAllDirs(A, S, vect=['nx','ny','nz'], oriented=0)
Example of use: surface mesh projection (array),
surface mesh projection (pyTree).
T.projectDir: project a (A) onto a list of surfaces S following a
given direction.
If smooth=1, unprojected points are smoothed (available only for structured arrays).
If oriented=0, use both direction for projection else use vector direction
only:
b = T.projectDir(a, S, (1.,0,0), smooth=0, oriented=0) .or. B = T.projectDir(A, S, (1.,0,0), smooth=0, oriented=0)
Example of use: surface mesh projection (array),
surface mesh projection (pyTree).
T.projectOrtho: project a (A) onto a list of surfaces S following normals:
b = T.projectOrtho(a, S) .or. B = T.projectOrtho(A, S)
Example of use: surface mesh projection (array),
surface mesh projection (pyTree).
T.projectOrthoSmooth: project a (A) onto a list of surfaces S following smoothed normals. niter is the number of smoothing iterations:
b = T.projectOrthoSmooth(a, S, niter=1) .or. B = T.projectOrthoSmooth(A, S, niter=1)
Example of use: surface mesh projection (array),
surface mesh projection (pyTree).
T.projectRay: project a (A) onto a list of surfaces S following rays issued from P:
b = T.projectRay(a, S, P) .or. B = T.projectRay(A, S, P)
Example of use: surface mesh projection (array),
surface mesh projection (pyTree).
Return to main userguide