discretize.CylMesh¶

class
discretize.
CylMesh
(*args, **kwargs)[source]¶ Bases:
discretize.base.base_tensor_mesh.BaseTensorMesh
,discretize.base.base_mesh.BaseRectangularMesh
,discretize.InnerProducts.InnerProducts
,discretize.View.CylView
,discretize.DiffOperators.DiffOperators
CylMesh is a mesh class for cylindrical problems. It supports both cylindrically symmetric and 3D cylindrical meshes that include an azimuthal discretization.
For a cylindrically symmetric mesh use
h = [hx, 1, hz]
. For example:import discretize from discretize import utils cs, nc, npad = 20., 30, 8 hx = utils.meshTensor([(cs, npad+10, 0.7), (cs, nc), (cs, npad, 1.3)]) hz = utils.meshTensor([(cs, npad ,1.3), (cs, nc), (cs, npad, 1.3)]) mesh = discretize.CylMesh([hx, 1, hz], x0=[0, 0, hz.sum()/2]) mesh.plotGrid()
(Source code, png, pdf)
To create a 3D cylindrical mesh, we also include an azimuthal discretization
import discretize from discretize import utils cs, nc, npad = 20., 30, 8 nc_theta = 8 hx = utils.meshTensor([(cs, npad+10, 0.7), (cs, nc), (cs, npad, 1.3)]) hy = 2 * np.pi/nc_theta * np.ones(nc_theta) hz = utils.meshTensor([(cs,npad, 1.3), (cs,nc), (cs, npad, 1.3)]) mesh = discretize.CylMesh([hx, hy, hz], x0=[0, 0, hz.sum()/2]) mesh.plotGrid()
(Source code, png, pdf)
Required Properties:
axis_u (
Vector3
): Vector orientation of udirection. For more details see the docs for therotation_matrix
property., a 3D Vector of <class ‘float’> with shape (3), Default: Xaxis_v (
Vector3
): Vector orientation of vdirection. For more details see the docs for therotation_matrix
property., a 3D Vector of <class ‘float’> with shape (3), Default: Yaxis_w (
Vector3
): Vector orientation of wdirection. For more details see the docs for therotation_matrix
property., a 3D Vector of <class ‘float’> with shape (3), Default: ZcartesianOrigin (
Array
): Cartesian origin of the mesh, a list or numpy array of <class ‘float’> with shape (*)h (a list of
Array
): h is a list containing the cell widths of the tensor mesh in each dimension., a list (each item is a list or numpy array of <class ‘float’> with shape (*)) with length between 0 and 3reference_system (
String
): The type of coordinate reference frame. Can take on the values cartesian, cylindrical, or spherical. Abbreviations of these are allowed., a unicode string, Default: cartesianx0 (
Array
): origin of the mesh (dim, ), a list or numpy array of <class ‘float’>, <class ‘int’> with shape (*)
 Attributes
area
Face areas
areaFx
Area of the xfaces (radial faces).
areaFy
Area of yfaces (Azimuthal faces).
areaFz
Area of zfaces.
aveCC2F
Construct the averaging operator on cell centers to faces.
aveCCV2F
Construct the averaging operator on cell centers to faces as a vector.
aveE2CC
averaging operator of edges to cell centers
aveE2CCV
averaging operator of edges to a cell centered vector
aveEx2CC
averaging operator of xedges (radial) to cell centers
aveEy2CC
averaging operator of yedges (azimuthal) to cell centers
aveEz2CC
averaging operator of zedges to cell centers
aveF2CC
averaging operator of faces to cell centers
aveF2CCV
averaging operator of xfaces (radial) to cell centered vectors
aveFx2CC
averaging operator of xfaces (radial) to cell centers
aveFy2CC
averaging operator of yfaces (azimuthal) to cell centers
aveFz2CC
averaging operator of zfaces (vertical) to cell centers
aveN2CC
Construct the averaging operator on cell nodes to cell centers.
aveN2E
Construct the averaging operator on cell nodes to cell edges, keeping each dimension separate.
aveN2F
Construct the averaging operator on cell nodes to cell faces, keeping each dimension separate.
axis_u
axis_u (
Vector3
): Vector orientation of udirection. For more details see the docs for therotation_matrix
property., a 3D Vector of <class ‘float’> with shape (3), Default: Xaxis_v
axis_v (
Vector3
): Vector orientation of vdirection. For more details see the docs for therotation_matrix
property., a 3D Vector of <class ‘float’> with shape (3), Default: Yaxis_w
axis_w (
Vector3
): Vector orientation of wdirection. For more details see the docs for therotation_matrix
property., a 3D Vector of <class ‘float’> with shape (3), Default: ZcartesianOrigin
cartesianOrigin (
Array
): Cartesian origin of the mesh, a list or numpy array of <class ‘float’> with shape (*)cellGrad
The cell centered Gradient, takes you to cell faces.
cellGradBC
The cell centered Gradient boundary condition matrix
cellGradx
Cell centered Gradient in the x dimension.
 cellGrady
cellGradz
Cell centered Gradient in the x dimension.
dim
The dimension of the mesh (1, 2, or 3).
edge
Edge lengths
edgeCurl
The edgeCurl (edges to faces)
edgeEx
xedge lengths  these are the radial edges. Radial edges only exist
edgeEy
yedge lengths  these are the azimuthal edges. Azimuthal edges exist
edgeEz
zedge lengths  these are the vertical edges. Vertical edges only
faceDiv
Construct divergence operator (faces to cellcentres).
faceDivx
Construct divergence operator in the x component (faces to cellcentres).
faceDivy
Construct divergence operator in the y component (faces to cellcentres).
faceDivz
Construct divergence operator in the z component (faces to cellcentres).
gridCC
Cellcentered grid.
gridEx
Edge staggered grid in the x direction.
gridEy
Grid of yedges (azimuthalfaces) in cylindrical coordinates \((r, \theta, z)\).
gridEz
Grid of zfaces (verticalfaces) in cylindrical coordinates \((r, \theta, z)\).
gridFx
Grid of xfaces (radialfaces) in cylindrical coordinates \((r, \theta, z)\).
gridFy
Face staggered grid in the y direction.
gridFz
Face staggered grid in the z direction.
gridN
Nodal grid in cylindrical coordinates \((r, \theta, z)\).
h
h (a list of
Array
): h is a list containing the cell widths of the tensor mesh in each dimension., a list (each item is a list or numpy array of <class ‘float’> with shape (*)) with length between 0 and 3h_gridded
Returns an (nC, dim) numpy array with the widths of all cells in order
hx
Width of cells in the x direction
hy
Width of cells in the y direction
hz
Width of cells in the z direction
isSymmetric
Is the mesh cylindrically symmetric?
nC
Total number of cells
nCx
Number of cells in the x direction
nCy
Number of cells in the y direction
nCz
Number of cells in the z direction
nE
Total number of edges.
nEx
Number of xedges
nEy
Number of yedges
nEz
Returns
nF
Total number of faces.
nFx
Number of xfaces
nFy
Number of yfaces
nFz
Number of zfaces
nN
Returns
nNx
Returns
nNy
Returns
nNz
Number of nodes in the zdirection
nodalGrad
Construct gradient operator (nodes to edges).
nodalLaplacian
Construct laplacian operator (nodes to edges).
normals
Face Normals
reference_is_rotated
True if the axes are rotated from the traditional <X,Y,Z> system
reference_system
reference_system (
String
): The type of coordinate reference frame. Can take on the values cartesian, cylindrical, or spherical. Abbreviations of these are allowed., a unicode string, Default: cartesianrotation_matrix
Builds a rotation matrix to transform coordinates from their coordinate system into a conventional cartesian system.
tangents
Edge Tangents
vectorCCx
Cellcentered grid vector (1D) in the x direction.
vectorCCy
Cellcentered grid vector (1D) in the y direction.
vectorCCz
Cellcentered grid vector (1D) in the z direction.
vectorNx
Nodal grid vector (1D) in the x direction.
vectorNy
Nodal grid vector (1D) in the y direction.
vectorNz
Nodal grid vector (1D) in the z direction.
vnC
Total number of cells in each direction
vnE
Total number of edges in each direction
vnEx
Number of xedges in each direction
vnEy
Number of yedges in each direction
vnEz
Returns
vnF
Total number of faces in each direction
vnFx
Returns
vnFy
Number of yfaces in each direction
vnFz
Number of zfaces in each direction
vnN
Total number of nodes in each direction
vol
Volume of each cell
x0
x0 (
Array
): origin of the mesh (dim, ), a list or numpy array of <class ‘float’>, <class ‘int’> with shape (*)
Methods
Generic (shallow and deep) copying operations.
check_cartesian_origin_shape
plotGrid
plotImage
Attributes¶

CylMesh.
area
¶ Face areas
For a 3D cyl mesh: [radial, azimuthal, vertical], while a cylindrically symmetric mesh doesn’t have yFaces, so it returns [radial, vertical]
 Returns
 numpy.ndarray
face areas

CylMesh.
areaFx
¶ Area of the xfaces (radial faces). Radial faces exist on all cylindrical meshes
\[A_x = r \theta h_z\] Returns
 numpy.ndarray
area of xfaces

CylMesh.
areaFy
¶ Area of yfaces (Azimuthal faces). Azimuthal faces exist only on 3D cylindrical meshes.
\[A_y = h_x h_z\] Returns
 numpy.ndarray
area of yfaces

CylMesh.
areaFz
¶ Area of zfaces.
\[A_z = \frac{\theta}{2} (r_2^2  r_1^2)z\] Returns
 numpy.ndarray
area of the zfaces

CylMesh.
aveCC2F
¶ Construct the averaging operator on cell centers to faces.

CylMesh.
aveCCV2F
¶ Construct the averaging operator on cell centers to faces as a vector.

CylMesh.
aveE2CC
¶ averaging operator of edges to cell centers
 Returns
 scipy.sparse.csr_matrix
matrix that averages from edges to cell centers

CylMesh.
aveE2CCV
¶ averaging operator of edges to a cell centered vector
 Returns
 scipy.sparse.csr_matrix
matrix that averages from edges to cell centered vectors

CylMesh.
aveEx2CC
¶ averaging operator of xedges (radial) to cell centers
 Returns
 scipy.sparse.csr_matrix
matrix that averages from xedges to cell centers

CylMesh.
aveEy2CC
¶ averaging operator of yedges (azimuthal) to cell centers
 Returns
 scipy.sparse.csr_matrix
matrix that averages from yedges to cell centers

CylMesh.
aveEz2CC
¶ averaging operator of zedges to cell centers
 Returns
 scipy.sparse.csr_matrix
matrix that averages from zedges to cell centers

CylMesh.
aveF2CC
¶ averaging operator of faces to cell centers
 Returns
 scipy.sparse.csr_matrix
matrix that averages from faces to cell centers

CylMesh.
aveF2CCV
¶ averaging operator of xfaces (radial) to cell centered vectors
 Returns
 scipy.sparse.csr_matrix
matrix that averages from faces to cell centered vectors

CylMesh.
aveFx2CC
¶ averaging operator of xfaces (radial) to cell centers
 Returns
 scipy.sparse.csr_matrix
matrix that averages from xfaces to cell centers

CylMesh.
aveFy2CC
¶ averaging operator of yfaces (azimuthal) to cell centers
 Returns
 scipy.sparse.csr_matrix
matrix that averages from yfaces to cell centers

CylMesh.
aveFz2CC
¶ averaging operator of zfaces (vertical) to cell centers
 Returns
 scipy.sparse.csr_matrix
matrix that averages from zfaces to cell centers

CylMesh.
aveN2CC
¶ Construct the averaging operator on cell nodes to cell centers.

CylMesh.
aveN2E
¶ Construct the averaging operator on cell nodes to cell edges, keeping each dimension separate.

CylMesh.
aveN2F
¶ Construct the averaging operator on cell nodes to cell faces, keeping each dimension separate.

CylMesh.
axis_u
¶ axis_u (
Vector3
): Vector orientation of udirection. For more details see the docs for therotation_matrix
property., a 3D Vector of <class ‘float’> with shape (3), Default: X

CylMesh.
axis_v
¶ axis_v (
Vector3
): Vector orientation of vdirection. For more details see the docs for therotation_matrix
property., a 3D Vector of <class ‘float’> with shape (3), Default: Y

CylMesh.
axis_w
¶ axis_w (
Vector3
): Vector orientation of wdirection. For more details see the docs for therotation_matrix
property., a 3D Vector of <class ‘float’> with shape (3), Default: Z

CylMesh.
cartesianOrigin
¶ cartesianOrigin (
Array
): Cartesian origin of the mesh, a list or numpy array of <class ‘float’> with shape (*)

CylMesh.
cellGrad
¶ The cell centered Gradient, takes you to cell faces.

CylMesh.
cellGradBC
¶ The cell centered Gradient boundary condition matrix

CylMesh.
cellGradx
¶

CylMesh.
cellGrady
¶

CylMesh.
cellGradz
¶ Cell centered Gradient in the x dimension. Has neumann boundary conditions.

CylMesh.
dim
¶ The dimension of the mesh (1, 2, or 3).
 Returns
 int
dimension of the mesh

CylMesh.
edge
¶ Edge lengths
 Returns
 numpy.ndarray
vector of edge lengths \((r, \theta, z)\)

CylMesh.
edgeCurl
¶ The edgeCurl (edges to faces)
 Returns
 scipy.sparse.csr_matrix
edge curl operator

CylMesh.
edgeEx
¶ xedge lengths  these are the radial edges. Radial edges only exist for a 3D cyl mesh.
 Returns
 numpy.ndarray
vector of radial edge lengths

CylMesh.
edgeEy
¶ yedge lengths  these are the azimuthal edges. Azimuthal edges exist for all cylindrical meshes. These are arclengths (\(\theta r\))
 Returns
 numpy.ndarray
vector of the azimuthal edges

CylMesh.
edgeEz
¶ zedge lengths  these are the vertical edges. Vertical edges only exist for a 3D cyl mesh.
 Returns
 numpy.ndarray
vector of the vertical edges

CylMesh.
faceDiv
¶ Construct divergence operator (faces to cellcentres).

CylMesh.
faceDivx
¶ Construct divergence operator in the x component (faces to cellcentres).

CylMesh.
faceDivy
¶ Construct divergence operator in the y component (faces to cellcentres).

CylMesh.
faceDivz
¶ Construct divergence operator in the z component (faces to cellcentres).

CylMesh.
gridCC
¶ Cellcentered grid.

CylMesh.
gridEx
¶ Edge staggered grid in the x direction.

CylMesh.
gridEy
¶ Grid of yedges (azimuthalfaces) in cylindrical coordinates \((r, \theta, z)\).
 Returns
 numpy.ndarray
grid locations of azimuthal faces

CylMesh.
gridEz
¶ Grid of zfaces (verticalfaces) in cylindrical coordinates \((r, \theta, z)\).
 Returns
 numpy.ndarray
grid locations of radial faces

CylMesh.
gridFx
¶ Grid of xfaces (radialfaces) in cylindrical coordinates \((r, \theta, z)\).
 Returns
 numpy.ndarray
grid locations of radial faces

CylMesh.
gridFy
¶ Face staggered grid in the y direction.

CylMesh.
gridFz
¶ Face staggered grid in the z direction.

CylMesh.
gridN
¶ Nodal grid in cylindrical coordinates \((r, \theta, z)\). Nodes do not exist in a cylindrically symmetric mesh.
 Returns
 numpy.ndarray
grid locations of nodes

CylMesh.
h
¶ h (a list of
Array
): h is a list containing the cell widths of the tensor mesh in each dimension., a list (each item is a list or numpy array of <class ‘float’> with shape (*)) with length between 0 and 3

CylMesh.
h_gridded
¶ Returns an (nC, dim) numpy array with the widths of all cells in order

CylMesh.
hx
¶ Width of cells in the x direction

CylMesh.
hy
¶ Width of cells in the y direction

CylMesh.
hz
¶ Width of cells in the z direction

CylMesh.
isSymmetric
¶ Is the mesh cylindrically symmetric?
 Returns
 bool
True if the mesh is cylindrically symmetric, False otherwise

CylMesh.
nE
¶ Total number of edges.
 Returns
 nEint = sum([nEx, nEy, nEz])

CylMesh.
nEz
¶  Returns
 int
Number of zedges

CylMesh.
nN
¶  Returns
 int
Total number of nodes

CylMesh.
nNx
¶  Returns
 int
Number of nodes in the xdirection

CylMesh.
nNy
¶  Returns
 int
Number of nodes in the ydirection

CylMesh.
nodalGrad
¶ Construct gradient operator (nodes to edges).

CylMesh.
nodalLaplacian
¶ Construct laplacian operator (nodes to edges).

CylMesh.
normals
¶ Face Normals
 Return type
 Returns
normals, (sum(nF), dim)

CylMesh.
reference_is_rotated
¶ True if the axes are rotated from the traditional <X,Y,Z> system with vectors of \((1,0,0)\), \((0,1,0)\), and \((0,0,1)\)

CylMesh.
reference_system
¶ reference_system (
String
): The type of coordinate reference frame. Can take on the values cartesian, cylindrical, or spherical. Abbreviations of these are allowed., a unicode string, Default: cartesian

CylMesh.
rotation_matrix
¶ Builds a rotation matrix to transform coordinates from their coordinate system into a conventional cartesian system. This is built off of the three axis_u, axis_v, and axis_w properties; these mapping coordinates use the letters U, V, and W (the three letters preceding X, Y, and Z in the alphabet) to define the projection of the X, Y, and Z durections. These UVW vectors describe the placement and transformation of the mesh’s coordinate sytem assuming at most 3 directions.
Why would you want to use these UVW mapping vectors the this rotation_matrix property? They allow us to define the realationship between local and global coordinate systems and provide a tool for switching between the two while still maintaing the connectivity of the mesh’s cells. For a visual example of this, please see the figure in the docs for the
InterfaceVTK
.

CylMesh.
tangents
¶ Edge Tangents
 Return type
 Returns
normals, (sum(nE), dim)

CylMesh.
vectorCCx
¶ Cellcentered grid vector (1D) in the x direction.

CylMesh.
vectorCCy
¶ Cellcentered grid vector (1D) in the y direction.

CylMesh.
vectorCCz
¶ Cellcentered grid vector (1D) in the z direction.

CylMesh.
vectorNx
¶ Nodal grid vector (1D) in the x direction.

CylMesh.
vectorNy
¶ Nodal grid vector (1D) in the y direction.

CylMesh.
vectorNz
¶ Nodal grid vector (1D) in the z direction.

CylMesh.
vnC
¶ Total number of cells in each direction
 Return type
 Returns
[nCx, nCy, nCz]

CylMesh.
vnE
¶ Total number of edges in each direction
 Returns
 vnEnumpy.ndarray = [nEx, nEy, nEz], (dim, )
import discretize import numpy as np M = discretize.TensorMesh([np.ones(n) for n in [2,3]]) M.plotGrid(edges=True, show_it=True)
(Source code, png, pdf)

CylMesh.
vnEx
¶ Number of xedges in each direction
 Return type
 Returns
vnEx

CylMesh.
vnEy
¶ Number of yedges in each direction
 Returns
 numpy.ndarray
vnEy or None if dim < 2, (dim, )

CylMesh.
vnEz
¶  Returns
 numpy.ndarray
Number of zedges in each direction or None if nCy > 1, (dim, )

CylMesh.
vnF
¶ Total number of faces in each direction
 Return type
 Returns
[nFx, nFy, nFz], (dim, )
import discretize import numpy as np M = discretize.TensorMesh([np.ones(n) for n in [2,3]]) M.plotGrid(faces=True, show_it=True)
(Source code, png, pdf)

CylMesh.
vnFx
¶  Returns
 numpy.ndarray
Number of xfaces in each direction, (dim, )

CylMesh.
vnFy
¶ Number of yfaces in each direction
 Return type
 Returns
vnFy or None if dim < 2

CylMesh.
vnFz
¶ Number of zfaces in each direction
 Return type
 Returns
vnFz or None if dim < 3

CylMesh.
vnN
¶ Total number of nodes in each direction
 Return type
 Returns
[nNx, nNy, nNz]

CylMesh.
vol
¶ Volume of each cell
 Returns
 numpy.ndarray
cell volumes
Methods¶

CylMesh.
cartesianGrid
(locType='CC', theta_shift=None)[source]¶ Takes a grid location (‘CC’, ‘N’, ‘Ex’, ‘Ey’, ‘Ez’, ‘Fx’, ‘Fy’, ‘Fz’) and returns that grid in cartesian coordinates
 Parameters
 locTypestr
grid location
 Returns
 numpy.ndarray
cartesian coordinates for the cylindrical grid

CylMesh.
copy
()¶ Make a copy of the current mesh

classmethod
CylMesh.
deserialize
(value, trusted=False, strict=False, assert_valid=False, **kwargs)¶ Creates HasProperties instance from serialized dictionary
This uses the Property deserializers to deserialize all JSONcompatible dictionary values into their corresponding Property values on a new instance of a HasProperties class. Extra keys in the dictionary that do not correspond to Properties will be ignored.
Parameters:
value  Dictionary to deserialize new instance from.
trusted  If True (and if the input dictionary has
'__class__'
keyword and this class is in the registry), the new HasProperties class will come from the dictionary. If False (the default), only the HasProperties class this method is called on will be constructed.strict  Requires
'__class__'
, if present on the input dictionary, to match the deserialized instance’s class. Also disallows unused properties in the input dictionary. Default is False.assert_valid  Require deserialized instance to be valid. Default is False.
Any other keyword arguments will be passed through to the Property deserializers.

CylMesh.
equal
(other)¶ Determine if two HasProperties instances are equivalent
Equivalence is determined by checking if all Property values on two instances are equal, using
Property.equal
.

static
CylMesh.
from_omf
(element)¶ Convert an OMF element to it’s proper
discretize
type. Automatically determines the output type. Returns both the mesh and a dictionary of model arrays.

CylMesh.
getBCProjWF
(BC, discretization='CC')¶ The weak form boundary condition projection matrices.
Examples
# Neumann in all directions BC = 'neumann' # 3D, Dirichlet in y Neumann else BC = ['neumann', 'dirichlet', 'neumann'] # 3D, Neumann in x on bottom of domain, Dirichlet else BC = [['neumann', 'dirichlet'], 'dirichlet', 'dirichlet']

CylMesh.
getBCProjWF_simple
(discretization='CC')¶ The weak form boundary condition projection matrices when mixed boundary condition is used

CylMesh.
getEdgeInnerProduct
(prop=None, invProp=False, invMat=False, doFast=True)¶ Generate the edge inner product matrix
 Parameters
 propnumpy.ndarray
material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6))
 invPropbool
inverts the material property
 invMatbool
inverts the matrix
 doFastbool
do a faster implementation if available.
 Returns
 scipy.sparse.csr_matrix
M, the inner product matrix (nE, nE)

CylMesh.
getEdgeInnerProductDeriv
(prop, doFast=True, invProp=False, invMat=False)¶  Parameters
 propnumpy.ndarray
material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6))
 doFastbool
do a faster implementation if available.
 invPropbool
inverts the material property
 invMatbool
inverts the matrix
 Returns
 scipy.sparse.csr_matrix
dMdm, the derivative of the inner product matrix (nE, nC*nA)

CylMesh.
getFaceInnerProduct
(prop=None, invProp=False, invMat=False, doFast=True)¶ Generate the face inner product matrix
 Parameters
 propnumpy.ndarray
material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6))
 invPropbool
inverts the material property
 invMatbool
inverts the matrix
 doFastbool
do a faster implementation if available.
 Returns
 scipy.sparse.csr_matrix
M, the inner product matrix (nF, nF)

CylMesh.
getFaceInnerProductDeriv
(prop, doFast=True, invProp=False, invMat=False)¶  Parameters
 propnumpy.ndarray
material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6))
 doFast :
bool do a faster implementation if available.
 invPropbool
inverts the material property
 invMatbool
inverts the matrix
 Returns
 scipy.sparse.csr_matrix
dMdmu(u), the derivative of the inner product matrix for a certain u

CylMesh.
getInterpolationMat
(loc, locType='CC', zerosOutside=False)[source]¶ Produces interpolation matrix
 Parameters
 locnumpy.ndarray
Location of points to interpolate to
 locTypestr
What to interpolate locType can be:
'Ex' > xcomponent of field defined on edges 'Ey' > ycomponent of field defined on edges 'Ez' > zcomponent of field defined on edges 'Fx' > xcomponent of field defined on faces 'Fy' > ycomponent of field defined on faces 'Fz' > zcomponent of field defined on faces 'N' > scalar field defined on nodes 'CC' > scalar field defined on cell centers 'CCVx' > xcomponent of vector field defined on cell centers 'CCVy' > ycomponent of vector field defined on cell centers 'CCVz' > zcomponent of vector field defined on cell centers
 Returns
 scipy.sparse.csr_matrix
M, the interpolation matrix

CylMesh.
getInterpolationMatCartMesh
(Mrect, locType='CC', locTypeTo=None)[source]¶ Takes a cartesian mesh and returns a projection to translate onto the cartesian grid.
 Parameters
 Mrectdiscretize.base.BaseMesh
the mesh to interpolate on to
 locTypestr
grid location (‘CC’, ‘N’, ‘Ex’, ‘Ey’, ‘Ez’, ‘Fx’, ‘Fy’, ‘Fz’)
 locTypeTostr
grid location to interpolate to. If None, the same grid type as locType will be assumed
 Returns
 scipy.sparse.csr_matrix
M, the interpolation matrix

CylMesh.
getTensor
(key)¶ Returns a tensor list.
 Parameters
 keystr
Which tensor (see below)
key can be:
'CC' > scalar field defined on cell centers 'N' > scalar field defined on nodes 'Fx' > xcomponent of field defined on faces 'Fy' > ycomponent of field defined on faces 'Fz' > zcomponent of field defined on faces 'Ex' > xcomponent of field defined on edges 'Ey' > ycomponent of field defined on edges 'Ez' > zcomponent of field defined on edges
 Returns
 list
list of the tensors that make up the mesh.

CylMesh.
isInside
(pts, locType='N')¶ Determines if a set of points are inside a mesh.
 Parameters
pts (numpy.ndarray) – Location of points to test
 Return type
 Returns
inside, numpy array of booleans

CylMesh.
plotGrid
(*args, **kwargs)¶

CylMesh.
plotImage
(*args, **kwargs)¶

CylMesh.
projectEdgeVector
(eV)¶ Given a vector, eV, in cartesian coordinates, this will project it onto the mesh using the tangents
 Parameters
eV (numpy.ndarray) – edge vector with shape (nE, dim)
 Return type
 Returns
projected edge vector, (nE, )

CylMesh.
projectFaceVector
(fV)¶ Given a vector, fV, in cartesian coordinates, this will project it onto the mesh using the normals
 Parameters
fV (numpy.ndarray) – face vector with shape (nF, dim)
 Return type
 Returns
projected face vector, (nF, )

CylMesh.
r
(x, xType='CC', outType='CC', format='V')¶ r is a quick reshape command that will do the best it can at giving you what you want.
For example, you have a face variable, and you want the x component of it reshaped to a 3D matrix.
r can fulfil your dreams:
mesh.r(V, 'F', 'Fx', 'M')        {    How: 'M' or ['V'] for a matrix    (ndgrid style) or a vector (n x dim)    }   {   What you want: ['CC'], 'N',   'F', 'Fx', 'Fy', 'Fz',   'E', 'Ex', 'Ey', or 'Ez'   }  {  What is it: ['CC'], 'N',  'F', 'Fx', 'Fy', 'Fz',  'E', 'Ex', 'Ey', or 'Ez'  } { The input: as a list or ndarray }
For example:
# Separates each component of the Ex grid into 3 matrices Xex, Yex, Zex = r(mesh.gridEx, 'Ex', 'Ex', 'M') # Given an edge vector, return just the x edges as a vector XedgeVector = r(edgeVector, 'E', 'Ex', 'V') # Separates each component of the edgeVector into 3 vectors eX, eY, eZ = r(edgeVector, 'E', 'E', 'V')

CylMesh.
save
(filename='mesh.json', verbose=False)¶ Save the mesh to json :param str file: filename for saving the casing properties :param str directory: working directory for saving the file

CylMesh.
serialize
(include_class=True, save_dynamic=False, **kwargs)¶ Serializes a HasProperties instance to dictionary
This uses the Property serializers to serialize all Property values to a JSONcompatible dictionary. Properties that are undefined are not included. If the HasProperties instance contains a reference to itself, a
properties.SelfReferenceError
will be raised.Parameters:
include_class  If True (the default), the name of the class will also be saved to the serialized dictionary under key
'__class__'
save_dynamic  If True, dynamic properties are written to the serialized dict (default: False).
Any other keyword arguments will be passed through to the Property serializers.

CylMesh.
setCellGradBC
(BC)¶ Function that sets the boundary conditions for cellcentred derivative operators.
Examples
..code:: python
# Neumann in all directions BC = ‘neumann’
# 3D, Dirichlet in y Neumann else BC = [‘neumann’, ‘dirichlet’, ‘neumann’]
# 3D, Neumann in x on bottom of domain, Dirichlet else BC = [[‘neumann’, ‘dirichlet’], ‘dirichlet’, ‘dirichlet’]

CylMesh.
toVTK
(models=None)¶ Convert this mesh object to it’s proper VTK or
pyvista
data object with the given model dictionary as the cell data of that dataset. Parameters
 modelsdict(numpy.ndarray)
Name(‘s) and array(‘s). Match number of cells

CylMesh.
to_omf
(models=None)¶ Convert this mesh object to it’s proper
omf
data object with the given model dictionary as the cell data of that dataset. Parameters
 modelsdict(numpy.ndarray)
Name(‘s) and array(‘s). Match number of cells

CylMesh.
to_vtk
(models=None)¶ Convert this mesh object to it’s proper VTK or
pyvista
data object with the given model dictionary as the cell data of that dataset. Parameters
 modelsdict(numpy.ndarray)
Name(‘s) and array(‘s). Match number of cells

CylMesh.
validate
()¶ Call all registered class validator methods
These are all methods decorated with
@properties.validator
. Validator methods are expected to raise a ValidationError if they fail.

CylMesh.
writeVTK
(filename, models=None, directory='')¶ Makes and saves a VTK object from this mesh and given models
 Parameters
 filenamestr
path to the output vtk file or just its name if directory is specified
 modelsdict
dictionary of numpy.array  Name(‘s) and array(‘s). Match number of cells
 directorystr
directory where the UBC GIF file lives

CylMesh.
write_vtk
(filename, models=None, directory='')¶ Makes and saves a VTK object from this mesh and given models
 Parameters
 filenamestr
path to the output vtk file or just its name if directory is specified
 modelsdict
dictionary of numpy.array  Name(‘s) and array(‘s). Match number of cells
 directorystr
directory where the UBC GIF file lives