discretize.CylindricalMesh¶

class
discretize.
CylindricalMesh
(*args, **kwargs)[source]¶ Bases:
discretize.base.base_tensor_mesh.BaseTensorMesh
,discretize.base.base_mesh.BaseRectangularMesh
,discretize.operators.inner_products.InnerProducts
,discretize.operators.differential_operators.DiffOperators
CylindricalMesh 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.unpack_widths([(cs, npad+10, 0.7), (cs, nc), (cs, npad, 1.3)]) hz = utils.unpack_widths([(cs, npad ,1.3), (cs, nc), (cs, npad, 1.3)]) mesh = discretize.CylindricalMesh([hx, 1, hz], origin=[0, 0, hz.sum()/2]) mesh.plot_grid()
(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.unpack_widths([(cs, npad+10, 0.7), (cs, nc), (cs, npad, 1.3)]) hy = 2 * np.pi/nc_theta * np.ones(nc_theta) hz = utils.unpack_widths([(cs,npad, 1.3), (cs,nc), (cs, npad, 1.3)]) mesh = discretize.CylindricalMesh([hx, hy, hz], origin=[0, 0, hz.sum()/2]) mesh.plot_grid()
(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: Zcartesian_origin (
Array
): Cartesian origin of the mesh, a list or numpy array of <class ‘float’> with shape (*)h (a tuple of
Array
): h is a list containing the cell widths of the tensor mesh in each dimension., a tuple (each item is a list or numpy array of <class ‘float’> with shape (*)) with length between 1 and 3origin (
Array
): origin of the mesh (dim, ), a list or numpy array of <class ‘float’>, <class ‘int’> with shape (*)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
 Attributes
area
area has been deprecated. See face_areas for documentation
areaFx
areaFx has been deprecated. See face_x_areas for documentation
areaFy
areaFy has been deprecated. See face_y_areas for documentation
areaFz
areaFz has been deprecated. See face_z_areas for documentation
average_cell_to_face
Construct the averaging operator on cell centers to faces.
average_cell_vector_to_face
Construct the averaging operator on cell centers to faces as a vector.
average_edge_to_cell
averaging operator of edges to cell centers
average_edge_to_cell_vector
averaging operator of edges to a cell centered vector
average_edge_x_to_cell
averaging operator of xedges (radial) to cell centers
average_edge_y_to_cell
averaging operator of yedges (azimuthal) to cell centers
average_edge_z_to_cell
averaging operator of zedges to cell centers
average_face_to_cell
averaging operator of faces to cell centers
average_face_to_cell_vector
averaging operator of xfaces (radial) to cell centered vectors
average_face_x_to_cell
averaging operator of xfaces (radial) to cell centers
average_face_y_to_cell
averaging operator of yfaces (azimuthal) to cell centers
average_face_z_to_cell
averaging operator of zfaces (vertical) to cell centers
average_node_to_cell
Construct the averaging operator on cell nodes to cell centers.
average_node_to_edge
Construct the averaging operator on cell nodes to cell edges, keeping each dimension separate.
average_node_to_face
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 has been deprecated. See cartesian_origin for documentation
cartesian_origin
cartesian_origin (
Array
): Cartesian origin of the mesh, a list or numpy array of <class ‘float’> with shape (*)cellGrad
cellGrad has been deprecated. See cell_gradient for documentation
cellGradBC
cellGradBC has been deprecated. See cell_gradient_BC for documentation
cellGradx
cellGradx has been deprecated. See cell_gradient_x for documentation
cellGrady
cellGrady has been deprecated. See cell_gradient_y for documentation
cellGradz
cellGradz has been deprecated. See cell_gradient_z for documentation
cell_centers
Cellcentered grid.
cell_centers_x
Cellcentered grid vector (1D) in the x direction.
cell_centers_y
Cellcentered grid vector (1D) in the y direction.
cell_centers_z
Cellcentered grid vector (1D) in the z direction.
cell_gradient
The cell centered Gradient, takes you to cell faces.
cell_gradient_BC
The cell centered Gradient boundary condition matrix
cell_gradient_x
Cell centered Gradient in the x dimension.
 cell_gradient_y
cell_gradient_z
Cell centered Gradient in the x dimension.
cell_volumes
Volume of each cell
dim
The dimension of the mesh (1, 2, or 3).
edge
edge has been deprecated. See edge_lengths for documentation
edgeCurl
edgeCurl has been deprecated. See edge_curl for documentation
edgeEx
edgeEx has been deprecated. See edge_x_lengths for documentation
edgeEy
edgeEy has been deprecated. See edge_y_lengths for documentation
edgeEz
edgeEz has been deprecated. See edge_z_lengths for documentation
edge_curl
The edgeCurl (edges to faces)
edge_lengths
Edge lengths
edge_tangents
Edge Tangents
edge_x_lengths
xedge lengths  these are the radial edges. Radial edges only exist
edge_y_lengths
yedge lengths  these are the azimuthal edges. Azimuthal edges exist
edge_z_lengths
zedge lengths  these are the vertical edges. Vertical edges only
edges_x
Edge staggered grid in the x direction.
edges_y
Grid of yedges (azimuthalfaces) in cylindrical coordinates \((r, \theta, z)\).
edges_z
Grid of zfaces (verticalfaces) in cylindrical coordinates \((r, \theta, z)\).
faceDiv
faceDiv has been deprecated. See face_divergence for documentation
faceDivx
faceDivx has been deprecated. See face_x_divergence for documentation
faceDivy
faceDivy has been deprecated. See face_y_divergence for documentation
faceDivz
faceDivz has been deprecated. See face_z_divergence for documentation
face_areas
Face areas
face_divergence
Construct divergence operator (faces to cellcentres).
face_normals
Face Normals
face_x_areas
Area of the xfaces (radial faces).
face_x_divergence
Construct divergence operator in the x component (faces to cellcentres).
face_y_areas
Area of yfaces (Azimuthal faces).
face_y_divergence
Construct divergence operator in the y component (faces to cellcentres).
face_z_areas
Area of zfaces.
face_z_divergence
Construct divergence operator in the z component (faces to cellcentres).
faces_x
Grid of xfaces (radialfaces) in cylindrical coordinates \((r, \theta, z)\).
faces_y
Face staggered grid in the y direction.
faces_z
Face staggered grid in the z direction.
h
h (a tuple of
Array
): h is a list containing the cell widths of the tensor mesh in each dimension., a tuple (each item is a list or numpy array of <class ‘float’> with shape (*)) with length between 1 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
isSymmetric has been deprecated. See is_symmetric for documentation
is_symmetric
Is the mesh cylindrically symmetric?
nCx
Number of cells in the x direction
nCy
Number of cells in the y direction
nCz
Number of cells in the z direction
nNx
Number of nodes in the xdirection
nNy
Number of nodes in the ydirection
nNz
Number of nodes in the zdirection
n_cells
Total number of cells in the mesh.
n_edges
Total number of edges.
n_edges_per_direction
The number of edges in each direction
n_edges_x
Number of xedges
n_edges_y
Number of yedges
n_edges_z
Returns
n_faces
Total number of faces.
n_faces_per_direction
The number of faces in each direction
n_faces_x
Number of xfaces
n_faces_y
Number of yfaces
n_faces_z
Number of zfaces
n_nodes
Returns
nodalGrad
nodalGrad has been deprecated. See nodal_gradient for documentation
nodalLaplacian
nodalLaplacian has been deprecated. See nodal_laplacian for documentation
nodal_gradient
Construct gradient operator (nodes to edges).
nodal_laplacian
Construct laplacian operator (nodes to edges).
nodes
Nodal grid in cylindrical coordinates \((r, \theta, z)\).
nodes_x
Nodal grid vector (1D) in the x direction.
nodes_y
Nodal grid vector (1D) in the y direction.
nodes_z
Nodal grid vector (1D) in the z direction.
normals
normals has been deprecated. See face_normals for documentation
origin
origin (
Array
): origin of the mesh (dim, ), a list or numpy array of <class ‘float’>, <class ‘int’> with shape (*)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.
shape_cells
The number of cells in each direction
shape_edges_x
Number of xedges in each direction
shape_edges_y
Number of yedges in each direction
shape_edges_z
Returns
shape_faces_x
Returns
shape_faces_y
Number of yfaces in each direction
shape_faces_z
Number of zfaces in each direction
shape_nodes
Number of nodes in each direction
 stencil_cell_gradient
 stencil_cell_gradient_x
 stencil_cell_gradient_y
 stencil_cell_gradient_z
tangents
tangents has been deprecated. See edge_tangents for documentation
vectorCCx
vectorCCx has been deprecated. See cell_centers_x for documentation
vectorCCy
vectorCCy has been deprecated. See cell_centers_y for documentation
vectorCCz
vectorCCz has been deprecated. See cell_centers_z for documentation
vectorNx
vectorNx has been deprecated. See nodes_x for documentation
vectorNy
vectorNy has been deprecated. See nodes_y for documentation
vectorNz
vectorNz has been deprecated. See nodes_z for documentation
vol
vol has been deprecated. See cell_volumes for documentation
 x0
Methods
cartesianGrid
(*args, **kwargs)cartesianGrid has been deprecated.
cartesian_grid
([location_type, theta_shift])Takes a grid location (‘CC’, ‘N’, ‘Ex’, ‘Ey’, ‘Ez’, ‘Fx’, ‘Fy’, ‘Fz’) and returns that grid in cartesian coordinates
copy
()Make a copy of the current mesh
deserialize
(value, **kwargs)Creates HasProperties instance from serialized dictionary
equal
(other)Determine if two HasProperties instances are equivalent
from_omf
(element)Convert an OMF element to it’s proper
discretize
type.getBCProjWF
(*args, **kwargs)getBCProjWF has been deprecated.
getBCProjWF_simple
(*args, **kwargs)getBCProjWF_simple has been deprecated.
getEdgeInnerProduct
(*args, **kwargs)getEdgeInnerProduct has been deprecated.
getEdgeInnerProductDeriv
(*args, **kwargs)getEdgeInnerProductDeriv has been deprecated.
getFaceInnerProduct
(*args, **kwargs)getFaceInnerProduct has been deprecated.
getFaceInnerProductDeriv
(*args, **kwargs)getFaceInnerProductDeriv has been deprecated.
getInterpolationMat
(*args, **kwargs)getInterpolationMat has been deprecated.
getInterpolationMatCartMesh
(*args, **kwargs)getInterpolationMatCartMesh has been deprecated.
getTensor
(*args, **kwargs)getTensor has been deprecated.
get_BC_projections
(BC[, discretization])The weak form boundary condition projection matrices.
get_BC_projections_simple
([discretization])The weak form boundary condition projection matrices when mixed boundary condition is used
get_edge_inner_product
([model, …])Generate the edge inner product matrix
get_edge_inner_product_deriv
(model[, …]) Parameters
get_face_inner_product
([model, …])Generate the face inner product matrix
get_face_inner_product_deriv
(model[, …]) Parameters
get_interpolation_matrix
(loc[, …])Produces interpolation matrix
Takes a cartesian mesh and returns a projection to translate onto the cartesian grid.
get_tensor
(key)Returns a tensor list.
isInside
(*args, **kwargs)isInside has been deprecated.
is_inside
(pts[, location_type])Determines if a set of points are inside a mesh.
plotGrid
(*args, **kwargs)plotGrid has been deprecated.
plotImage
(*args, **kwargs)plotImage has been deprecated.
plotSlice
(*args, **kwargs)plotSlice has been deprecated.
plot_3d_slicer
(v[, xslice, yslice, zslice, …])Plot slices of a 3D volume, interactively (scroll wheel).
plot_grid
([ax, nodes, faces, centers, …])Plot the nodal, cellcentered and staggered grids.
plot_image
(v[, v_type, grid, view, ax, …])Plots fields on the given mesh.
plot_slice
(v[, v_type, normal, ind, grid, …])Plots slice of fields on the given 3D mesh.
projectEdgeVector
(*args, **kwargs)projectEdgeVector has been deprecated.
projectFaceVector
(*args, **kwargs)projectFaceVector has been deprecated.
project_edge_vector
(edge_vector)Project vectors onto the edges of the mesh
project_face_vector
(face_vector)Project vectors onto the faces of the mesh.
r
(*args, **kwargs)r has been deprecated.
reshape
(x[, x_type, out_type, format])A quick reshape command that will do the best it can at giving you what you want.
save
([file_name, verbose])Save the mesh to json :param str file: file_name for saving the casing properties :param str directory: working directory for saving the file
serialize
([include_class, save_dynamic])Serializes a HasProperties instance to dictionary
setCellGradBC
(*args, **kwargs)setCellGradBC has been deprecated.
Function that sets the boundary conditions for cellcentred derivative operators.
toVTK
([models])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.to_omf
([models])Convert this mesh object to it’s proper
omf
data object with the given model dictionary as the cell data of that dataset.to_vtk
([models])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.validate
()Call all registered class validator methods
writeVTK
(file_name[, models, directory])Makes and saves a VTK object from this mesh and given models
write_vtk
(file_name[, models, directory])Makes and saves a VTK object from this mesh and given models
check_cartesian_origin_shape
Attributes¶

CylindricalMesh.
area
¶ area has been deprecated. See face_areas for documentation

CylindricalMesh.
areaFx
¶ areaFx has been deprecated. See face_x_areas for documentation

CylindricalMesh.
areaFy
¶ areaFy has been deprecated. See face_y_areas for documentation

CylindricalMesh.
areaFz
¶ areaFz has been deprecated. See face_z_areas for documentation

CylindricalMesh.
average_cell_to_face
¶ Construct the averaging operator on cell centers to faces.

CylindricalMesh.
average_cell_vector_to_face
¶ Construct the averaging operator on cell centers to faces as a vector.

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

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

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

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

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

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

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

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

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

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

CylindricalMesh.
average_node_to_cell
¶ Construct the averaging operator on cell nodes to cell centers.

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

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

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

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

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

CylindricalMesh.
cartesianOrigin
¶ cartesianOrigin has been deprecated. See cartesian_origin for documentation

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

CylindricalMesh.
cellGrad
¶ cellGrad has been deprecated. See cell_gradient for documentation

CylindricalMesh.
cellGradBC
¶ cellGradBC has been deprecated. See cell_gradient_BC for documentation

CylindricalMesh.
cellGradx
¶ cellGradx has been deprecated. See cell_gradient_x for documentation

CylindricalMesh.
cellGrady
¶ cellGrady has been deprecated. See cell_gradient_y for documentation

CylindricalMesh.
cellGradz
¶ cellGradz has been deprecated. See cell_gradient_z for documentation

CylindricalMesh.
cell_centers
¶ Cellcentered grid.

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

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

CylindricalMesh.
cell_centers_z
¶ Cellcentered grid vector (1D) in the z direction.

CylindricalMesh.
cell_gradient
¶

CylindricalMesh.
cell_gradient_BC
¶ The cell centered Gradient boundary condition matrix

CylindricalMesh.
cell_gradient_x
¶

CylindricalMesh.
cell_gradient_y
¶

CylindricalMesh.
cell_gradient_z
¶ Cell centered Gradient in the x dimension. Has neumann boundary conditions.

CylindricalMesh.
cell_volumes
¶ Volume of each cell
 Returns
 numpy.ndarray
cell volumes

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

CylindricalMesh.
edge
¶ edge has been deprecated. See edge_lengths for documentation

CylindricalMesh.
edgeCurl
¶ edgeCurl has been deprecated. See edge_curl for documentation

CylindricalMesh.
edgeEx
¶ edgeEx has been deprecated. See edge_x_lengths for documentation

CylindricalMesh.
edgeEy
¶ edgeEy has been deprecated. See edge_y_lengths for documentation

CylindricalMesh.
edgeEz
¶ edgeEz has been deprecated. See edge_z_lengths for documentation

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

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

CylindricalMesh.
edge_tangents
¶ Edge Tangents
 Returns
 numpy.ndarray
normals, (n_edges, dim)

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

CylindricalMesh.
edge_y_lengths
¶ 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

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

CylindricalMesh.
edges_x
¶ Edge staggered grid in the x direction.

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

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

CylindricalMesh.
faceDiv
¶ faceDiv has been deprecated. See face_divergence for documentation

CylindricalMesh.
faceDivx
¶ faceDivx has been deprecated. See face_x_divergence for documentation

CylindricalMesh.
faceDivy
¶ faceDivy has been deprecated. See face_y_divergence for documentation

CylindricalMesh.
faceDivz
¶ faceDivz has been deprecated. See face_z_divergence for documentation

CylindricalMesh.
face_areas
¶ 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

CylindricalMesh.
face_divergence
¶ Construct divergence operator (faces to cellcentres).

CylindricalMesh.
face_normals
¶ Face Normals
 Returns
 numpy.ndarray
normals, (n_faces, dim)

CylindricalMesh.
face_x_areas
¶ 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

CylindricalMesh.
face_x_divergence
¶ Construct divergence operator in the x component (faces to cellcentres).

CylindricalMesh.
face_y_areas
¶ 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

CylindricalMesh.
face_y_divergence
¶ Construct divergence operator in the y component (faces to cellcentres).

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

CylindricalMesh.
face_z_divergence
¶ Construct divergence operator in the z component (faces to cellcentres).

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

CylindricalMesh.
faces_y
¶ Face staggered grid in the y direction.

CylindricalMesh.
faces_z
¶ Face staggered grid in the z direction.

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

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

CylindricalMesh.
hx
¶ Width of cells in the x direction
 Returns
 numpy.ndarray
Deprecated since version 0.5.0: hx will be removed in discretize 1.0.0 to reduce namespace clutter, please use mesh.h[0].

CylindricalMesh.
hy
¶ Width of cells in the y direction
 Returns
 numpy.ndarray or None
Deprecated since version 0.5.0: hy will be removed in discretize 1.0.0 to reduce namespace clutter, please use mesh.h[1].

CylindricalMesh.
hz
¶ Width of cells in the z direction
 Returns
 numpy.ndarray or None
Deprecated since version 0.5.0: hz will be removed in discretize 1.0.0 to reduce namespace clutter, please use mesh.h[2].

CylindricalMesh.
isSymmetric
¶ isSymmetric has been deprecated. See is_symmetric for documentation

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

CylindricalMesh.
nCx
¶ Number of cells in the x direction
 Returns
 int
Deprecated since version 0.5.0: nCx will be removed in discretize 1.0.0, it is replaced by mesh.shape_cells[0] to reduce namespace clutter.

CylindricalMesh.
nCy
¶ Number of cells in the y direction
 Returns
 int or None
None if dim < 2
Deprecated since version 0.5.0: nCy will be removed in discretize 1.0.0, it is replaced by mesh.shape_cells[1] to reduce namespace clutter.

CylindricalMesh.
nCz
¶ Number of cells in the z direction
 Returns
 int or None
None if dim < 3
Deprecated since version 0.5.0: nCz will be removed in discretize 1.0.0, it is replaced by mesh.shape_cells[2] to reduce namespace clutter.

CylindricalMesh.
nNx
¶ Number of nodes in the xdirection
 Returns
 int
Deprecated since version 0.5.0: nNx will be removed in discretize 1.0.0, it is replaced by mesh.shape_nodes[0] to reduce namespace clutter.

CylindricalMesh.
nNy
¶ Number of nodes in the ydirection
 Returns
 int or None
None if dim < 2
Deprecated since version 0.5.0: nNy will be removed in discretize 1.0.0, it is replaced by mesh.shape_nodes[1] to reduce namespace clutter.

CylindricalMesh.
nNz
¶ Number of nodes in the zdirection
 Returns
 int or None
None if dim < 3
Deprecated since version 0.5.0: nNz will be removed in discretize 1.0.0, it is replaced by mesh.shape_nodes[2] to reduce namespace clutter.

CylindricalMesh.
n_cells
¶

CylindricalMesh.
n_edges
¶ Total number of edges.
 Returns
 int
sum([n_edges_x, n_edges_y, n_edges_z])
Notes
Also accessible as nE.

CylindricalMesh.
n_edges_per_direction
¶ The number of edges in each direction
 Returns
 n_edges_per_directiontuple
[n_edges_x, n_edges_y, n_edges_z], (dim, )
Notes
Also accessible as vnE.
Examples
>>> import discretize >>> import matplotlib.pyplot as plt >>> import numpy as np >>> M = discretize.TensorMesh([np.ones(n) for n in [2,3]]) >>> M.plot_grid(edges=True, show_it=True)
(Source code, png, pdf)

CylindricalMesh.
n_edges_x
¶

CylindricalMesh.
n_edges_y
¶

CylindricalMesh.
n_edges_z
¶  Returns
 int
Number of zedges

CylindricalMesh.
n_faces
¶ Total number of faces.
 Returns
 int
sum([n_faces_x, n_faces_y, n_faces_z])
Notes
Also accessible as nF.

CylindricalMesh.
n_faces_per_direction
¶ The number of faces in each direction
 Returns
 n_faces_per_directiontuple
[n_faces_x, n_faces_y, n_faces_z], (dim, )
Notes
Also accessible as vnF.
Examples
>>> import discretize >>> import numpy as np >>> import matplotlib.pyplot as plt >>> M = discretize.TensorMesh([np.ones(n) for n in [2,3]]) >>> M.plot_grid(faces=True, show_it=True)
(Source code, png, pdf)

CylindricalMesh.
n_faces_x
¶

CylindricalMesh.
n_faces_y
¶

CylindricalMesh.
n_faces_z
¶

CylindricalMesh.
n_nodes
¶  Returns
 int
Total number of nodes

CylindricalMesh.
nodalGrad
¶ nodalGrad has been deprecated. See nodal_gradient for documentation

CylindricalMesh.
nodalLaplacian
¶ nodalLaplacian has been deprecated. See nodal_laplacian for documentation

CylindricalMesh.
nodal_gradient
¶ Construct gradient operator (nodes to edges).

CylindricalMesh.
nodal_laplacian
¶ Construct laplacian operator (nodes to edges).

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

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

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

CylindricalMesh.
nodes_z
¶ Nodal grid vector (1D) in the z direction.

CylindricalMesh.
normals
¶ normals has been deprecated. See face_normals for documentation

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

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

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

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

CylindricalMesh.
shape_cells
¶ The number of cells in each direction
 Returns
 tuple of ints
Notes
Also accessible as vnC.

CylindricalMesh.
shape_edges_x
¶ Number of xedges in each direction
 Returns
 tuple of int
(nx_cells, ny_nodes, nz_nodes)
Notes
Also accessible as vnEx.

CylindricalMesh.
shape_edges_y
¶ Number of yedges in each direction
 Returns
 tuple of ints
vnEy or None if dim < 2, (dim, )

CylindricalMesh.
shape_edges_z
¶  Returns
 tuple of ints
Number of zedges in each direction or None if nCy > 1, (dim, )

CylindricalMesh.
shape_faces_x
¶  Returns
 numpy.ndarray
Number of xfaces in each direction, (dim, )

CylindricalMesh.
shape_faces_y
¶ Number of yfaces in each direction
 Returns
 tuple of int or None
(nx_cells, ny_nodes, nz_cells), None if dim < 2
Notes
Also accessible as vnFy.

CylindricalMesh.
shape_faces_z
¶ Number of zfaces in each direction
 Returns
 tuple of int or None
(nx_cells, ny_cells, nz_nodes), None if dim < 3
Notes
Also accessible as vnFz.

CylindricalMesh.
shape_nodes
¶

CylindricalMesh.
stencil_cell_gradient
¶

CylindricalMesh.
stencil_cell_gradient_x
¶

CylindricalMesh.
stencil_cell_gradient_y
¶

CylindricalMesh.
stencil_cell_gradient_z
¶

CylindricalMesh.
tangents
¶ tangents has been deprecated. See edge_tangents for documentation

CylindricalMesh.
vectorCCx
¶ vectorCCx has been deprecated. See cell_centers_x for documentation

CylindricalMesh.
vectorCCy
¶ vectorCCy has been deprecated. See cell_centers_y for documentation

CylindricalMesh.
vectorCCz
¶ vectorCCz has been deprecated. See cell_centers_z for documentation

CylindricalMesh.
vectorNx
¶ vectorNx has been deprecated. See nodes_x for documentation

CylindricalMesh.
vectorNy
¶ vectorNy has been deprecated. See nodes_y for documentation

CylindricalMesh.
vectorNz
¶ vectorNz has been deprecated. See nodes_z for documentation

CylindricalMesh.
vol
¶ vol has been deprecated. See cell_volumes for documentation

CylindricalMesh.
x0
¶
Methods¶

CylindricalMesh.
cartesianGrid
(*args, **kwargs)¶ cartesianGrid has been deprecated. See cartesian_grid for documentation

CylindricalMesh.
cartesian_grid
(location_type='cell_centers', theta_shift=None, **kwargs)[source]¶ Takes a grid location (‘CC’, ‘N’, ‘Ex’, ‘Ey’, ‘Ez’, ‘Fx’, ‘Fy’, ‘Fz’) and returns that grid in cartesian coordinates
 Parameters
 location_type{‘CC’, ‘N’, ‘Ex’, ‘Ey’, ‘Ez’, ‘Fx’, ‘Fy’, ‘Fz’}
grid location
 theta_shiftfloat, optional
shift for theta
 Returns
 numpy.ndarray
cartesian coordinates for the cylindrical grid

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

classmethod
CylindricalMesh.
deserialize
(value, **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.

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

CylindricalMesh.
getBCProjWF
(*args, **kwargs)¶ getBCProjWF has been deprecated. See get_BC_projections for documentation

CylindricalMesh.
getBCProjWF_simple
(*args, **kwargs)¶ getBCProjWF_simple has been deprecated. See get_BC_projections_simple for documentation

CylindricalMesh.
getEdgeInnerProduct
(*args, **kwargs)¶ getEdgeInnerProduct has been deprecated. See get_edge_inner_product for documentation

CylindricalMesh.
getEdgeInnerProductDeriv
(*args, **kwargs)¶ getEdgeInnerProductDeriv has been deprecated. See get_edge_inner_product_deriv for documentation

CylindricalMesh.
getFaceInnerProduct
(*args, **kwargs)¶ getFaceInnerProduct has been deprecated. See get_face_inner_product for documentation

CylindricalMesh.
getFaceInnerProductDeriv
(*args, **kwargs)¶ getFaceInnerProductDeriv has been deprecated. See get_face_inner_product_deriv for documentation

CylindricalMesh.
getInterpolationMat
(*args, **kwargs)¶ getInterpolationMat has been deprecated. See get_interpolation_matrix for documentation

CylindricalMesh.
getInterpolationMatCartMesh
(*args, **kwargs)¶ getInterpolationMatCartMesh has been deprecated. See get_interpolation_matrix_cartesian_mesh for documentation

CylindricalMesh.
getTensor
(*args, **kwargs)¶ getTensor has been deprecated. See get_tensor for documentation

CylindricalMesh.
get_BC_projections
(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']

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

CylindricalMesh.
get_edge_inner_product
(model=None, invert_model=False, invert_matrix=False, do_fast=True, **kwargs)¶ Generate the edge inner product matrix
 Parameters
 modelnumpy.ndarray
material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6))
 invert_modelbool
inverts the material property
 invert_matrixbool
inverts the matrix
 do_fastbool
do a faster implementation if available.
 Returns
 scipy.sparse.csr_matrix
M, the inner product matrix (nE, nE)

CylindricalMesh.
get_edge_inner_product_deriv
(model, do_fast=True, invert_model=False, invert_matrix=False, **kwargs)¶  Parameters
 modelnumpy.ndarray
material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6))
 do_fastbool
do a faster implementation if available.
 invert_modelbool
inverts the material property
 invert_matrixbool
inverts the matrix
 Returns
 scipy.sparse.csr_matrix
dMdm, the derivative of the inner product matrix (nE, nC*nA)

CylindricalMesh.
get_face_inner_product
(model=None, invert_model=False, invert_matrix=False, do_fast=True, **kwargs)¶ Generate the face inner product matrix
 Parameters
 modelnumpy.ndarray
material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6))
 invert_modelbool
inverts the material property
 invert_matrixbool
inverts the matrix
 do_fastbool
do a faster implementation if available.
 Returns
 scipy.sparse.csr_matrix
M, the inner product matrix (nF, nF)

CylindricalMesh.
get_face_inner_product_deriv
(model, do_fast=True, invert_model=False, invert_matrix=False, **kwargs)¶  Parameters
 modelnumpy.ndarray
material property (tensor properties are possible) at each cell center (nC, (1, 3, or 6))
 do_fast :
bool do a faster implementation if available.
 invert_modelbool
inverts the material property
 invert_matrixbool
inverts the matrix
 Returns
 scipy.sparse.csr_matrix
dMdmu(u), the derivative of the inner product matrix for a certain u

CylindricalMesh.
get_interpolation_matrix
(loc, location_type='cell_centers', zeros_outside=False, **kwargs)[source]¶ Produces interpolation matrix
 Parameters
 locnumpy.ndarray
Location of points to interpolate to
 location_typestr
What to interpolate location_type can be:
'Ex', 'edges_x' > xcomponent of field defined on x edges 'Ey', 'edges_y' > ycomponent of field defined on y edges 'Ez', 'edges_z' > zcomponent of field defined on z edges 'Fx', 'faces_x' > xcomponent of field defined on x faces 'Fy', 'faces_y' > ycomponent of field defined on y faces 'Fz', 'faces_z' > zcomponent of field defined on z faces 'N', 'nodes' > scalar field defined on nodes 'CC', 'cell_centers' > scalar field defined on cell centers 'CCVx', 'cell_centers_x' > xcomponent of vector field defined on cell centers 'CCVy', 'cell_centers_y' > ycomponent of vector field defined on cell centers 'CCVz', 'cell_centers_z' > zcomponent of vector field defined on cell centers
 Returns
 scipy.sparse.csr_matrix
M, the interpolation matrix

CylindricalMesh.
get_interpolation_matrix_cartesian_mesh
(Mrect, location_type='cell_centers', location_type_to=None, **kwargs)[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
 location_type{‘CC’, ‘N’, ‘Ex’, ‘Ey’, ‘Ez’, ‘Fx’, ‘Fy’, ‘Fz’}
grid location
 location_type_to{‘CC’, ‘N’, ‘Ex’, ‘Ey’, ‘Ez’, ‘Fx’, ‘Fy’, ‘Fz’}, or None, optional
grid location to interpolate to. If None, the same grid type as location_type will be assumed
 Returns
 scipy.sparse.csr_matrix
M, the interpolation matrix

CylindricalMesh.
get_tensor
(key)¶ Returns a tensor list.
 Parameters
 keystr
Which tensor (see below)
key can be:
'CC', 'cell_centers' > location of cell centers 'N', 'nodes' > location of nodes 'Fx', 'faces_x' > location of faces with an x normal 'Fy', 'faces_y' > location of faces with an y normal 'Fz', 'faces_z' > location of faces with an z normal 'Ex', 'edges_x' > location of edges with an x tangent 'Ey', 'edges_y' > location of edges with an y tangent 'Ez', 'edges_z' > location of edges with an z tangent
 Returns
 list
list of the tensors that make up the mesh.

CylindricalMesh.
isInside
(*args, **kwargs)¶ isInside has been deprecated. See is_inside for documentation

CylindricalMesh.
is_inside
(pts, location_type='nodes', **kwargs)¶ 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

CylindricalMesh.
plotGrid
(*args, **kwargs)¶ plotGrid has been deprecated. See plot_grid for documentation

CylindricalMesh.
plotImage
(*args, **kwargs)¶ plotImage has been deprecated. See plot_image for documentation

CylindricalMesh.
plotSlice
(*args, **kwargs)¶ plotSlice has been deprecated. See plot_slice for documentation

CylindricalMesh.
plot_3d_slicer
(v, xslice=None, yslice=None, zslice=None, v_type='CC', view='real', axis='xy', transparent=None, clim=None, xlim=None, ylim=None, zlim=None, aspect='auto', grid=[2, 2, 1], pcolor_opts=None, fig=None, **kwargs)¶ Plot slices of a 3D volume, interactively (scroll wheel).
If called from a notebook, make sure to set
%matplotlib notebook
See the class discretize.View.Slicer for more information.
It returns nothing. However, if you need the different figure handles you can get it via
fig = plt.gcf()
and subsequently its children via
fig.get_children()
and recursively deeper, e.g.,
fig.get_children()[0].get_children().
One can also provide an existing figure instance, which can be useful for interactive widgets in Notebooks. The provided figure is cleared first.

CylindricalMesh.
plot_grid
(ax=None, nodes=False, faces=False, centers=False, edges=False, lines=True, show_it=False, **kwargs)¶ Plot the nodal, cellcentered and staggered grids.
 Parameters
 axmatplotlib.axes.Axes or None, optional
The axes to draw on. None produces a new Axes.
 nodes, faces, centers, edges, linesbool, optional
Whether to plot the corresponding item
 show_itbool, optional
whether to call plt.show()
 colorColor or str, optional
If lines=True, the color of the lines, defaults to first color.
 linewidthfloat, optional
If lines=True, the linewidth for the lines.
 Returns
 matplotlib.axes.Axes
Axes handle for the plot
 Other Parameters
 edges_x, edges_y, edges_z, faces_x, faces_y, faces_zbool, optional
When plotting a
TreeMesh
, these are also options to plot the individual component items. cell_linebool, optional
When plotting a
TreeMesh
, you can also plot a line through the cell centers in order. slice{‘both’, ‘theta’, ‘z’}
When plotting a
CylindricalMesh
, which dimension to slice over.
Notes
Excess arguments are passed on to plot
Examples
Plotting a 2D TensorMesh grid
>>> from matplotlib import pyplot as plt >>> import discretize >>> import numpy as np >>> h1 = np.linspace(.1, .5, 3) >>> h2 = np.linspace(.1, .5, 5) >>> mesh = discretize.TensorMesh([h1, h2]) >>> mesh.plot_grid(nodes=True, faces=True, centers=True, lines=True) >>> plt.show()
(Source code, png, pdf)
Plotting a 3D TensorMesh grid
>>> from matplotlib import pyplot as plt >>> import discretize >>> import numpy as np >>> h1 = np.linspace(.1, .5, 3) >>> h2 = np.linspace(.1, .5, 5) >>> h3 = np.linspace(.1, .5, 3) >>> mesh = discretize.TensorMesh([h1, h2, h3]) >>> mesh.plot_grid(nodes=True, faces=True, centers=True, lines=True) >>> plt.show()
Plotting a 2D CurvilinearMesh
>>> from matplotlib import pyplot as plt >>> import discretize >>> X, Y = discretize.utils.exampleLrmGrid([10, 10], 'rotate') >>> M = discretize.CurvilinearMesh([X, Y]) >>> M.plot_grid() >>> plt.show()
Plotting a 3D CurvilinearMesh
>>> from matplotlib import pyplot as plt >>> import discretize >>> X, Y, Z = discretize.utils.exampleLrmGrid([5, 5, 5], 'rotate') >>> M = discretize.CurvilinearMesh([X, Y, Z]) >>> M.plot_grid() >>> plt.show()
Plotting a 2D TreeMesh
>>> from matplotlib import pyplot as plt >>> import discretize >>> M = discretize.TreeMesh([32, 32]) >>> M.insert_cells([[0.25, 0.25]], [4]) >>> M.plot_grid() >>> plt.show()
Plotting a 3D TreeMesh
>>> from matplotlib import pyplot as plt >>> import discretize >>> M = discretize.TreeMesh([32, 32, 32]) >>> M.insert_cells([[0.3, 0.75, 0.22]], [4]) >>> M.plot_grid() >>> plt.show()

CylindricalMesh.
plot_image
(v, v_type='CC', grid=False, view='real', ax=None, clim=None, show_it=False, pcolor_opts=None, stream_opts=None, grid_opts=None, range_x=None, range_y=None, sample_grid=None, stream_thickness=None, stream_threshold=None, **kwargs)¶ Plots fields on the given mesh.
 Parameters
 vnumpy.ndarray
values to plot
 v_type{‘CC’,’CCV’, ‘N’, ‘F’, ‘Fx’, ‘Fy’, ‘Fz’, ‘E’, ‘Ex’, ‘Ey’, ‘Ez’}
Where the values of v are defined.
 view{‘real’, ‘imag’, ‘abs’, ‘vec’}
How to view the array.
 axmatplotlib.axes.Axes, optional
The axes to draw on. None produces a new Axes.
 climtuple of float, optional
length 2 tuple of (vmin, vmax) for the color limits
 range_x, range_ytuple of float, optional
length 2 tuple of (min, max) for the bounds of the plot axes.
 pcolor_optsdict, optional
Arguments passed on to
pcolormesh
 gridbool, optional
Whether to plot the edges of the mesh cells.
 grid_optsdict, optional
If
grid
is true, arguments passed on toplot
for grid sample_gridtuple of numpy.ndarray, optional
If
view
== ‘vec’, mesh cell widths (hx, hy) to interpolate onto for vector plotting stream_optsdict, optional
If
view
== ‘vec’, arguments passed on tostreamplot
 stream_thicknessfloat, optional
If
view
== ‘vec’, linewidth forstreamplot
 stream_thresholdfloat, optional
If
view
== ‘vec’, only plots vectors with magnitude above this threshold show_itbool, optional
Whether to call plt.show()
 numberingbool, optional
For 3D TensorMesh only, show the numbering of the slices
 annotation_colorColor or str, optional
For 3D TensorMesh only, color of the annotation
Examples
2D
TensorMesh
plotting>>> from matplotlib import pyplot as plt >>> import discretize >>> import numpy as np >>> M = discretize.TensorMesh([20, 20]) >>> v = np.sin(M.gridCC[:, 0]*2*np.pi)*np.sin(M.gridCC[:, 1]*2*np.pi) >>> M.plot_image(v) >>> plt.show()
(Source code, png, pdf)
3D
TensorMesh
plotting>>> import discretize >>> import numpy as np >>> M = discretize.TensorMesh([20, 20, 20]) >>> v = np.sin(M.gridCC[:, 0]*2*np.pi)*np.sin(M.gridCC[:, 1]*2*np.pi)*np.sin(M.gridCC[:, 2]*2*np.pi) >>> M.plot_image(v, annotation_color='k') >>> plt.show()

CylindricalMesh.
plot_slice
(v, v_type='CC', normal='Z', ind=None, grid=False, view='real', ax=None, clim=None, show_it=False, pcolor_opts=None, stream_opts=None, grid_opts=None, range_x=None, range_y=None, sample_grid=None, stream_threshold=None, stream_thickness=None, **kwargs)¶ Plots slice of fields on the given 3D mesh.
 Parameters
 vnumpy.ndarray
values to plot
 v_type{‘CC’,’CCV’, ‘N’, ‘F’, ‘Fx’, ‘Fy’, ‘Fz’, ‘E’, ‘Ex’, ‘Ey’, ‘Ez’}, or tuple of these options
Where the values of v are defined.
 normal{‘Z’, ‘X’, ‘Y’}
Normal direction of slicing plane.
 indNone, optional
index along dimension of slice. Defaults to the center index.
 view{‘real’, ‘imag’, ‘abs’, ‘vec’}
How to view the array.
 axmatplotlib.axes.Axes, optional
The axes to draw on. None produces a new Axes. Must be None if
v_type
is a tuple. climtuple of float, optional
length 2 tuple of (vmin, vmax) for the color limits
 range_x, range_ytuple of float, optional
length 2 tuple of (min, max) for the bounds of the plot axes.
 pcolor_optsdict, optional
Arguments passed on to
pcolormesh
 gridbool, optional
Whether to plot the edges of the mesh cells.
 grid_optsdict, optional
If
grid
is true, arguments passed on toplot
for the edges sample_gridtuple of numpy.ndarray, optional
If
view
== ‘vec’, mesh cell widths (hx, hy) to interpolate onto for vector plotting stream_optsdict, optional
If
view
== ‘vec’, arguments passed on tostreamplot
 stream_thicknessfloat, optional
If
view
== ‘vec’, linewidth forstreamplot
 stream_thresholdfloat, optional
If
view
== ‘vec’, only plots vectors with magnitude above this threshold show_itbool, optional
Whether to call plt.show()
Examples
Plot a slice of a 3D
TensorMesh
solution to a Laplace’s equaiton.First build the mesh:
>>> from matplotlib import pyplot as plt >>> import discretize >>> from pymatsolver import Solver >>> import numpy as np >>> hx = [(5, 2, 1.3), (2, 4), (5, 2, 1.3)] >>> hy = [(2, 2, 1.3), (2, 6), (2, 2, 1.3)] >>> hz = [(2, 2, 1.3), (2, 6), (2, 2, 1.3)] >>> M = discretize.TensorMesh([hx, hy, hz])
then build the necessary parts of the PDE:
>>> q = np.zeros(M.vnC) >>> q[[4, 4], [4, 4], [2, 6]]=[1, 1] >>> q = discretize.utils.mkvc(q) >>> A = M.face_divergence * M.cell_gradient >>> b = Solver(A) * (q)
and finaly, plot the vector values of the result, which are defined on faces
>>> M.plot_slice(M.cell_gradient*b, 'F', view='vec', grid=True, pcolor_opts={'alpha':0.8}) >>> plt.show()
(Source code, png, pdf)

CylindricalMesh.
projectEdgeVector
(*args, **kwargs)¶ projectEdgeVector has been deprecated. See project_edge_vector for documentation

CylindricalMesh.
projectFaceVector
(*args, **kwargs)¶ projectFaceVector has been deprecated. See project_face_vector for documentation

CylindricalMesh.
project_edge_vector
(edge_vector)¶ Project vectors onto the edges of the mesh
Given a vector, edge_vector, in cartesian coordinates, this will project it onto the mesh using the tangents
 Parameters
 edge_vectornumpy.ndarray
edge vector with shape (n_edges, dim)
 Returns
 numpy.ndarray
projected edge vector, (n_edges, )

CylindricalMesh.
project_face_vector
(face_vector)¶ Project vectors onto the faces of the mesh.
Given a vector, face_vector, in cartesian coordinates, this will project it onto the mesh using the normals
 Parameters
 face_vectornumpy.ndarray
face vector with shape (n_faces, dim)
 Returns
 numpy.ndarray
projected face vector, (n_faces, )

CylindricalMesh.
r
(*args, **kwargs)¶ r has been deprecated. See reshape for documentation

CylindricalMesh.
reshape
(x, x_type='cell_centers', out_type='cell_centers', format='V', **kwargs)¶ 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.
reshape can fulfil your dreams:
mesh.reshape(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')

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

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

CylindricalMesh.
setCellGradBC
(*args, **kwargs)¶ setCellGradBC has been deprecated. See set_cell_gradient_BC for documentation

CylindricalMesh.
set_cell_gradient_BC
(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’]

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

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

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

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

CylindricalMesh.
writeVTK
(file_name, models=None, directory='')¶ Makes and saves a VTK object from this mesh and given models
 Parameters
 file_namestr
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

CylindricalMesh.
write_vtk
(file_name, models=None, directory='')¶ Makes and saves a VTK object from this mesh and given models
 Parameters
 file_namestr
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