discretize.base.BaseTensorMesh#

- class discretize.base.BaseTensorMesh(h, origin=None, **kwargs)[source]#
Base class for tensor-product style meshes
This class contains properites and methods that are common to Cartesian and cylindrical meshes. That is, meshes whose cell centers, nodes, faces and edges can be constructed with tensor-products of vectors.
Do not use this class directly! Practical tensor meshes supported in discretize will inherit this class; i.e.
discretize.TensorMesh
andCylindricalMesh
. Inherit this class if you plan to develop a new tensor-style mesh class (e.g. a spherical mesh).- Parameters
- h(
dim
) iterableof
int
,numpy.ndarray
,or
tuple
Defines the cell widths along each axis. The length of the iterable object is equal to the dimension of the mesh (1, 2 or 3). For a 3D mesh, the list would have the form [hx, hy, hz] .
Along each axis, the user has 3 choices for defining the cells widths:
int
-> A unit interval is equally discretized into N cells.numpy.ndarray
-> The widths are explicity given for each cellthe widths are defined as a
list
oftuple
of the form (dh, nc, [npad]) where dh is the cell width, nc is the number of cells, and npad (optional) is a padding factor denoting exponential increase/decrease in the cell width for each cell; e.g. [(2., 10, -1.3), (2., 50), (2., 10, 1.3)]
- origin(
dim
) iterable, default: 0 Define the origin or ‘anchor point’ of the mesh; i.e. the bottom-left-frontmost corner. By default, the mesh is anchored such that its origin is at
[0, 0, 0]
.For each dimension (x, y or z), The user may set the origin 2 ways:
a
scalar
which explicitly defines origin along that dimension.{‘0’, ‘C’, ‘N’} a
str
specifying whether the zero coordinate along each axis is the first node location (‘0’), in the center (‘C’) or the last node location (‘N’).
- h(
See also
utils.unpack_widths
The function used to expand a
list
ortuple
to generate widths.
Attributes
area has been deprecated.
Averaging operator from cell centers to edges (scalar quantities).
Averaging operator from cell centers to faces (scalar quantities).
Averaging operator from cell centers to faces (vector quantities).
Averaging operator from edges to cell centers (scalar quantities).
Averaging operator from edges to cell centers (vector quantities).
Averaging operator from edges to faces (vector quantities).
Averaging operator from faces to cell centers (scalar quantities).
Averaging operator from faces to cell centers (vector quantities).
Averaging operator from nodes to cell centers (scalar quantities).
Averaging operator from nodes to edges (scalar quantities).
Averaging operator from nodes to faces (scalar quantities).
Deprecated since version 0.7.0.
Deprecated since version 0.7.0.
Deprecated since version 0.7.0.
Represents the operation of integrating a vector function on the boundary
Boundary edge locations
Outward normal vectors of boundary faces
Represents the operation of integrating a scalar function on the boundary
Boundary face locations
Represents the operation of integrating a vector function dotted with the boundary normal
Boundary node locations
Return gridded cell center locations
Return x-coordinates of the cell centers along the x-direction
Return y-coordinates of the cell centers along the y-direction
Return z-coordinates of the cell centers along the z-direction
Return cell volumes
The dimension of the mesh (1, 2, or 3).
edge has been deprecated.
edgeCurl has been deprecated.
Edge curl operator (edges to faces)
Returns the lengths of all edges in the mesh
Unit tangent vectors for all mesh edges
Gridded edge locations
Gridded x-edge locations
Gridded y-edge locations
Gridded z-edge locations
faceDiv has been deprecated.
Returns the areas of all faces in the mesh
Face divergence operator (faces to cell-centres)
Unit normal vectors for all mesh faces
Gridded face locations
Gridded x-face locations
Gridded y-face locations
Gridded z-face locations
Cell widths along each axis direction
Return dimensions of all mesh cells as staggered grid.
Width of cells in the x direction
Width of cells in the y direction
Width of cells in the z direction
Total number of cells in the mesh.
Total number of edges in the mesh
The number of edges in each direction
Number of x-edges in the mesh
Number of y-edges in the mesh
Number of z-edges in the mesh
Total number of faces in the mesh
The number of faces in each axis direction
Number of x-faces in the mesh
Number of y-faces in the mesh
Number of z-faces in the mesh
Total number of nodes in the mesh
nodalGrad has been deprecated.
nodalLaplacian has been deprecated.
Nodal gradient operator (nodes to edges)
Nodal scalar Laplacian operator (nodes to nodes)
Return gridded node locations
Return x-coordinates of the nodes along the x-direction
Return y-coordinates of the nodes along the y-direction
Return z-coordinates of the nodes along the z-direction
normals has been deprecated.
Rotation matrix defining mesh axes relative to Cartesian
Origin or 'anchor point' of the mesh
Projection matrix from all edges to boundary edges.
Projection matrix from all faces to boundary faces.
Projection matrix from all nodes to boundary nodes.
Indicates whether mesh uses standard coordinate axes
Coordinate reference system
Alias for
orientation
The number of cells in each coordinate direction.
Stencil for cell gradient operator (cell centers to faces)
tangents has been deprecated.
vectorCCx has been deprecated.
vectorCCy has been deprecated.
vectorCCz has been deprecated.
vectorNx has been deprecated.
vectorNy has been deprecated.
vectorNz has been deprecated.
vol has been deprecated.
An alias for the
origin
Methods
closest_points_index
(locations[, grid_loc, ...])Find the indicies for the nearest grid location for a set of points.
copy
()Make a copy of the current mesh
deserialize
(items, **kwargs)Create this mesh from a dictionary of attributes
equals
(other_mesh)Compares current mesh with another mesh to determine if they are identical
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.
getTensor
(*args, **kwargs)getTensor has been deprecated.
get_edge_inner_product
([model, ...])Generate the edge inner product matrix or its inverse.
get_edge_inner_product_deriv
(model[, ...])Function handle to multiply vector with derivative of edge inner product matrix (or its inverse).
get_face_inner_product
([model, ...])Generate the face inner product matrix or its inverse.
get_face_inner_product_deriv
(model[, ...])Function handle to multiply vector with derivative of face inner product matrix (or its inverse).
get_interpolation_matrix
(loc[, ...])Construct linear interpolation matrix from mesh
get_tensor
(key)Returns the base 1D arrays for a specified mesh tensor.
isInside
(*args, **kwargs)isInside has been deprecated.
is_inside
(pts[, location_type])Determine which points lie within the mesh
point2index
(locs)Finds cells that contain the given points.
projectEdgeVector
(*args, **kwargs)projectEdgeVector has been deprecated.
projectFaceVector
(*args, **kwargs)projectFaceVector has been deprecated.
project_edge_vector
(edge_vectors)Project vectors to the edges of the mesh.
project_face_vector
(face_vectors)Project vectors onto the faces of the mesh.
save
([file_name, verbose])Save the mesh to json
An alias for
to_dict()
to_dict
()Representation of the mesh's attributes as a dictionary
validate
()Return the validation state of the mesh