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:

  • 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
  • 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 (*)

check_cartesian_origin_shape(change)[source]
isSymmetric

Is the mesh cylindrically symmetric?

Return type:bool
Returns:True if the mesh is cylindrically symmetric, False otherwise
nNx

Number of nodes in the x-direction

Return type:int
Returns:nNx
nNy

Number of nodes in the y-direction

Return type:int
Returns:nNy
nN

Total number of nodes

Return type:int
Returns:nN
vnFx

Number of x-faces in each direction

Return type:numpy.array
Returns:vnFx, (dim, )
vnEy

Number of y-edges in each direction

Return type:numpy.array
Returns:vnEy or None if dim < 2, (dim, )
vnEz

Number of z-edges in each direction

Return type:numpy.array
Returns:vnEz or None if nCy > 1, (dim, )
nEz

Number of z-edges

Return type:int
Returns:nEz
vectorCCx

Cell-centered grid vector (1D) in the x direction.

vectorCCy

Cell-centered 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

x-edge 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

y-edge lengths - these are the azimuthal edges. Azimuthal edges exist for all cylindrical meshes. These are arc-lengths (:math:` heta r`)

Return type:numpy.ndarray
Returns:vector of the azimuthal edges
edgeEz

z-edge 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 x-faces (radial faces). Radial faces exist on all cylindrical meshes

\[A_x = r heta h_z\]
Return type:numpy.ndarray
Returns:area of x-faces
areaFy

Area of y-faces (Azimuthal faces). Azimuthal faces exist only on 3D cylindrical meshes.

\[A_y = h_x h_z\]
Return type:numpy.ndarray
Returns:area of y-faces
areaFz

Area of z-faces.

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

Face areas

For a 3D cyl mesh: [radial, azimuthal, vertical], while a cylindrically symmetric mesh doesn’t have y-Faces, 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 x-faces (radial-faces) in cylindrical coordinates \((r, heta, z)\).

Return type:numpy.ndarray
Returns:grid locations of radial faces
gridEy

Grid of y-edges (azimuthal-faces) in cylindrical coordinates \((r, heta, z)\).

Return type:numpy.ndarray
Returns:grid locations of azimuthal faces
gridEz

Grid of z-faces (vertical-faces) in cylindrical coordinates \((r, heta, z)\).

Return type:numpy.ndarray
Returns:grid locations of radial faces
faceDiv

Construct divergence operator (faces to cell-centres).

faceDivx

Construct divergence operator in the x component (faces to cell-centres).

faceDivy

Construct divergence operator in the y component (faces to cell-centres).

faceDivz

Construct divergence operator in the z component (faces to cell-centres).

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 x-edges (radial) to cell centers

Return type:scipy.sparse.csr_matrix
Returns:matrix that averages from x-edges to cell centers
aveEy2CC

averaging operator of y-edges (azimuthal) to cell centers

Return type:scipy.sparse.csr_matrix
Returns:matrix that averages from y-edges to cell centers
aveEz2CC

averaging operator of z-edges to cell centers

Return type:scipy.sparse.csr_matrix
Returns:matrix that averages from z-edges 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 x-faces (radial) to cell centers

Return type:scipy.sparse.csr_matrix
Returns:matrix that averages from x-faces to cell centers
aveFy2CC

averaging operator of y-faces (azimuthal) to cell centers

Return type:scipy.sparse.csr_matrix
Returns:matrix that averages from y-faces to cell centers
aveFz2CC

averaging operator of z-faces (vertical) to cell centers

Return type:scipy.sparse.csr_matrix
Returns:matrix that averages from z-faces 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 x-faces (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:

scipy.sparse.csr_matrix

Returns:

M, the interpolation matrix

locType can be:

'Ex'    -> x-component of field defined on edges
'Ey'    -> y-component of field defined on edges
'Ez'    -> z-component of field defined on edges
'Fx'    -> x-component of field defined on faces
'Fy'    -> y-component of field defined on faces
'Fz'    -> z-component of field defined on faces
'N'     -> scalar field defined on nodes
'CC'    -> scalar field defined on cell centers
'CCVx'  -> x-component of vector field defined on cell centers
'CCVy'  -> y-component of vector field defined on cell centers
'CCVz'  -> z-component 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

Mesh Viewing

class discretize.View.CylView[source]

Bases: object

plotGrid(*args, **kwargs)[source]
plotImage(*args, **kwargs)[source]