Base API¶
Base Rectangular Mesh¶

class
discretize.BaseMesh.
BaseRectangularMesh
(n, x0=None)[source]¶ Bases:
discretize.BaseMesh.BaseMesh
Required Properties:
 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.array Returns: [nCx, nCy, nCz]

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

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

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

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

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

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

vnFz
¶ Number of zfaces in each direction
Return type: numpy.array 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')
 x0 (
Base Tensor Mesh¶

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

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
 h (a list of