discretize.CylMesh¶

class
discretize.
CylMesh
(h=None, x0=None, **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, hires.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, hires.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: X  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  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  cartesianOrigin (
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 3  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  x0 (
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
check_cartesian_origin_shape plotGrid plotImage  axis_u (
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: face areas Return type: numpy.ndarray

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

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

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

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: matrix that averages from edges to cell centers Return type: scipy.sparse.csr_matrix

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

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

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

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

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

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

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

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

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

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
¶ X
Type: axis_u ( Vector3
)Type: Vector orientation of udirection. For more details see the docs for the rotation_matrix
property., a 3D Vector of <class ‘float’> with shape (3), Default

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

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

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

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

CylMesh.
cellGradBC
¶ The cell centered Gradient boundary condition matrix

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

CylMesh.
cellGrady
¶

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

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

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

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

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

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

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: grid locations of azimuthal faces Return type: numpy.ndarray

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

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

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: grid locations of nodes Return type: numpy.ndarray

CylMesh.
h
¶ 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
Type: h (a list of Array
)

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: True if the mesh is cylindrically symmetric, False otherwise Return type: bool

CylMesh.
nE
¶ Total number of edges.
Returns: nE Return type: int = sum([nEx, nEy, nEz])

CylMesh.
nEz
¶ returns: Number of zedges :rtype: int

CylMesh.
nN
¶ returns: Total number of nodes :rtype: int

CylMesh.
nNx
¶ returns: Number of nodes in the xdirection :rtype: int

CylMesh.
nNy
¶ returns: Number of nodes in the ydirection :rtype: int

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

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

CylMesh.
normals
¶ Face Normals
Return type: numpy.ndarray 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
¶ cartesian
Type: reference_system ( String
)Type: The type of coordinate reference frame. Can take on the values cartesian, cylindrical, or spherical. Abbreviations of these are allowed., a unicode string, Default

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: numpy.ndarray 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: numpy.ndarray Returns: [nCx, nCy, nCz]

CylMesh.
vnE
¶ Total number of edges in each direction
Returns:  vnE (numpy.ndarray = [nEx, nEy, nEz], (dim, ))
 .. plot:: – :includesource:
import discretize import numpy as np M = discretize.TensorMesh([np.ones(n) for n in [2,3]]) M.plotGrid(edges=True, showIt=True)

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

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

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

CylMesh.
vnF
¶ Total number of faces in each direction
Return type: numpy.ndarray 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, showIt=True)
(Source code, png, hires.png, pdf)

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

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

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

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

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

CylMesh.
cartesianGrid
(self, 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: locType (str) – grid location Returns: cartesian coordinates for the cylindrical grid Return type: numpy.ndarray

CylMesh.
copy
(self)¶ 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
(self, 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
(self, BC, discretization='CC')¶ The weak form boundary condition projection matrices.
Example
# 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
(self, discretization='CC')¶ The weak form boundary condition projection matrices when mixed boundary condition is used

CylMesh.
getEdgeInnerProduct
(self, prop=None, invProp=False, invMat=False, doFast=True)¶ Generate the edge inner product matrix
Parameters:  prop (numpy.ndarray) – material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6))
 invProp (bool) – inverts the material property
 invMat (bool) – inverts the matrix
 doFast (bool) – do a faster implementation if available.
Returns: M, the inner product matrix (nE, nE)
Return type:

CylMesh.
getEdgeInnerProductDeriv
(self, prop, doFast=True, invProp=False, invMat=False)¶ Parameters:  prop (numpy.ndarray) – material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6))
 doFast (bool) – do a faster implementation if available.
 invProp (bool) – inverts the material property
 invMat (bool) – inverts the matrix
Returns: dMdm, the derivative of the inner product matrix (nE, nC*nA)
Return type:

CylMesh.
getFaceInnerProduct
(self, prop=None, invProp=False, invMat=False, doFast=True)¶ Generate the face inner product matrix
Parameters:  prop (numpy.ndarray) – material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6))
 invProp (bool) – inverts the material property
 invMat (bool) – inverts the matrix
 doFast (bool) – do a faster implementation if available.
Returns: M, the inner product matrix (nF, nF)
Return type:

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

CylMesh.
getInterpolationMat
(self, loc, locType='CC', zerosOutside=False)[source]¶ Produces interpolation matrix
Parameters:  loc (numpy.ndarray) – Location of points to interpolate to
 locType (str) –
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: M, the interpolation matrix
Return type:

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

CylMesh.
getTensor
(self, key)¶ Returns a tensor list.
Parameters: key (str) – 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 of the tensors that make up the mesh. Return type: list

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

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

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

CylMesh.
projectEdgeVector
(self, 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: numpy.ndarray Returns: projected edge vector, (nE, )

CylMesh.
projectFaceVector
(self, 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: numpy.ndarray Returns: projected face vector, (nF, )

CylMesh.
r
(self, 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
(self, 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
(self, 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.
 include_class  If True (the default), the name of the class
will also be saved to the serialized dictionary under key

CylMesh.
setCellGradBC
(self, BC)¶ Function that sets the boundary conditions for cellcentred derivative operators.
Example
..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
(mesh, 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: models (dict(numpy.ndarray)) – Name(‘s) and array(‘s). Match number of cells

CylMesh.
to_omf
(mesh, 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: models (dict(numpy.ndarray)) – Name(‘s) and array(‘s). Match number of cells

CylMesh.
to_vtk
(mesh, 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: models (dict(numpy.ndarray)) – Name(‘s) and array(‘s). Match number of cells

CylMesh.
validate
(self)¶ 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
(mesh, filename, models=None, directory='')¶ Makes and saves a VTK object from this mesh and given models
Parameters:

CylMesh.
write_vtk
(mesh, filename, models=None, directory='')¶ Makes and saves a VTK object from this mesh and given models
Parameters: