Base API¶
Base Rectangular Mesh¶

class
discretize.BaseMesh.
BaseRectangularMesh
(n, x0=None, **kwargs)[source]¶ Bases:
discretize.BaseMesh.BaseMesh
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  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 (*)

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

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

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

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

vnEz
¶ Number of zedges in each direction
Return type: numpy.ndarray Returns: vnEz or None if dim < 3

vnFx
¶ Number of xfaces in each direction
Return type: numpy.ndarray Returns: vnFx

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

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

r
(x, xType='CC', outType='CC', format='V')[source]¶ 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:
..code:
# 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')
 axis_u (
Base Tensor Mesh¶

class
discretize.TensorMesh.
BaseTensorMesh
(h=None, x0=None, **kwargs)[source]¶ Bases:
discretize.BaseMesh.BaseMesh
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  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 (*)

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

hx
¶ Width of cells in the x direction

hy
¶ Width of cells in the y direction

hz
¶ Width of cells 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.

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.

gridCC
¶ Cellcentered grid.

gridN
¶ Nodal grid.

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

gridFx
¶ Face staggered grid in the x direction.

gridFy
¶ Face staggered grid in the y direction.

gridFz
¶ Face staggered grid in the z direction.

gridEx
¶ Edge staggered grid in the x direction.

gridEy
¶ Edge staggered grid in the y direction.

gridEz
¶ Edge staggered grid in the z direction.

getTensor
(key)[source]¶ Returns a tensor list.
Parameters: key (str) – What tensor (see below) Return type: list Returns: list of the tensors that make up the mesh. 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

isInside
(pts, locType='N')[source]¶ 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

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
 axis_u (