Cylindrical Mesh¶

class
discretize.
CylMesh
(h=None, x0=None, **kwargs)[source]¶ Bases:
discretize.TensorMesh.BaseTensorMesh
,discretize.BaseMesh.BaseRectangularMesh
,discretize.InnerProducts.InnerProducts
,discretize.View.CylView
,discretize.DiffOperators.DiffOperators
CylMesh is a mesh class for cylindrical problems
Note
for a cylindrically symmetric mesh use [hx, 1, hz]
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 = Mesh.CylMesh([hx,1,hz], [0.,0,hz.sum()/2.])
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’> with shape (*)

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

isSymmetric
¶ Is the mesh cylindrically symmetric?
Return type: bool Returns: True if the mesh is cylindrically symmetric, False otherwise

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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]
Return type: numpy.ndarray Returns: face areas

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

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

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

gridEy
¶ Grid of yedges (azimuthalfaces) in cylindrical coordinates \((r, heta, z)\).
Return type: numpy.ndarray Returns: grid locations of azimuthal faces

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

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).

cellGradx
¶

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

nodalGrad
¶ Construct gradient operator (nodes to edges).

nodalLaplacian
¶ Construct laplacian operator (nodes to edges).

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

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

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

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

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

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

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

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

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

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

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

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

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

getInterpolationMatCartMesh
(Mrect, locType='CC', locTypeTo=None)[source]¶ Takes a cartesian mesh and returns a projection to translate onto the cartesian grid.
Parameters:  Mrect (discretize.BaseMesh.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
 axis_u (