discretize.CurvilinearMesh¶

class
discretize.
CurvilinearMesh
(node_list, **kwargs)¶ Bases:
discretize.base.BaseRectangularMesh
,discretize.operators.DiffOperators
,discretize.operators.InnerProducts
,discretize.mixins.InterfaceMixins
CurvilinearMesh is a mesh class that deals with curvilinear meshes.
Example of a curvilinear mesh:
import discretize X, Y = discretize.utils.exampleLrmGrid([3,3],'rotate') mesh = discretize.CurvilinearMesh([X, Y]) mesh.plot_grid(show_it=True)
(Source code, png, pdf)
 Attributes
area
area has been deprecated. See face_areas for documentation
 average_cell_to_edge
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
Construct the averaging operator on cell edges to cell centers.
average_edge_to_cell_vector
Construct the averaging operator on cell edges to cell centers.
 average_edge_to_face_vector
average_edge_x_to_cell
Construct the averaging operator on cell edges in the x direction to cell centers.
average_edge_y_to_cell
Construct the averaging operator on cell edges in the y direction to cell centers.
average_edge_z_to_cell
Construct the averaging operator on cell edges in the z direction to cell centers.
average_face_to_cell
Construct the averaging operator on cell faces to cell centers.
average_face_to_cell_vector
Construct the averaging operator on cell faces to cell centers.
average_face_x_to_cell
Construct the averaging operator on cell faces in the x direction to cell centers.
average_face_y_to_cell
Construct the averaging operator on cell faces in the y direction to cell centers.
average_face_z_to_cell
Construct the averaging operator on cell faces in the z direction 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
Deprecated since version 0.7.0.
axis_v
Deprecated since version 0.7.0.
axis_w
Deprecated since version 0.7.0.
boundary_edge_vector_integral
Represents the operation of integrating a vector function on the boundary
boundary_edges
Boundary edge locations
boundary_face_outward_normals
Outward directed normal vectors for the boundary faces
boundary_face_scalar_integral
Represents the operation of integrating a scalar function on the boundary
boundary_faces
Boundary face locations
boundary_node_vector_integral
Represents the operation of integrating a vector function dotted with the boundary normal
boundary_nodes
Boundary node locations
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_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
Construct cell volumes of the 3D model as 1d array
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
edge_curl
Construct the 3D curl operator.
edge_lengths
Edge lengths
edge_tangents
Edge tangents
edges
Edge grid
edges_x
Edge staggered grid in the x direction.
edges_y
Edge staggered grid in the y direction.
edges_z
Edge staggered grid in the z direction.
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
Area of the faces
face_divergence
Construct divergence operator (facestg to cellcentres).
face_normals
Face normals: calling this will average the computed normals so that there is one per face.
face_x_divergence
Construct divergence operator in the x component (facestg to cellcentres).
 face_y_divergence
face_z_divergence
Construct divergence operator in the z component (facestg to cellcenters).
faces
Face grid
faces_x
Face staggered grid in the x direction.
faces_y
Face staggered grid in the y direction.
faces_z
Face staggered grid in the y direction.
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
Number of zedges
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
Total number of nodes
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).
 node_list
nodes
Nodal grid.
normals
normals has been deprecated. See face_normals for documentation
 orientation
origin
Origin of the mesh
project_edge_to_boundary_edge
Projects values defined on all edges to the boundary edges
project_face_to_boundary_face
Projects values defined on all faces to the boundary faces
project_node_to_boundary_node
Projects values defined on all edges to the boundary edges
reference_is_rotated
True if the axes are rotated from the traditional <X,Y,Z> system
reference_system
The type of coordinate reference frame.
rotation_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
Number of zedges in each direction
shape_faces_x
Number of xfaces in each direction
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
vol
vol has been deprecated. See cell_volumes for documentation
 x0
Methods
cell_gradient_weak_form_robin
([alpha, beta, …])Robin boundary condition for the weak formulation of the cell gradient
copy
()Make a copy of the current mesh
edge_divergence_weak_form_robin
([alpha, …])Robin boundary condition for the weak formulation of the edge divergence
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.
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
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, …])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
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
()Every object will be valid upon initialization
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
deserialize
equals
serialize
to_dict
Attributes¶

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

CurvilinearMesh.
average_cell_to_edge
¶

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

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

CurvilinearMesh.
average_edge_to_cell
¶ Construct the averaging operator on cell edges to cell centers.

CurvilinearMesh.
average_edge_to_cell_vector
¶ Construct the averaging operator on cell edges to cell centers.

CurvilinearMesh.
average_edge_to_face_vector
¶

CurvilinearMesh.
average_edge_x_to_cell
¶ Construct the averaging operator on cell edges in the x direction to cell centers.

CurvilinearMesh.
average_edge_y_to_cell
¶ Construct the averaging operator on cell edges in the y direction to cell centers.

CurvilinearMesh.
average_edge_z_to_cell
¶ Construct the averaging operator on cell edges in the z direction to cell centers.

CurvilinearMesh.
average_face_to_cell
¶ Construct the averaging operator on cell faces to cell centers.

CurvilinearMesh.
average_face_to_cell_vector
¶ Construct the averaging operator on cell faces to cell centers.

CurvilinearMesh.
average_face_x_to_cell
¶ Construct the averaging operator on cell faces in the x direction to cell centers.

CurvilinearMesh.
average_face_y_to_cell
¶ Construct the averaging operator on cell faces in the y direction to cell centers.

CurvilinearMesh.
average_face_z_to_cell
¶ Construct the averaging operator on cell faces in the z direction to cell centers.

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

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

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

CurvilinearMesh.
axis_u
¶ Deprecated since version 0.7.0: axis_u will be removed in discretize 1.0.0, it is replaced by mesh.orientation for better mesh orientation validation.
See also

CurvilinearMesh.
axis_v
¶ Deprecated since version 0.7.0: axis_v will be removed in discretize 1.0.0, it is replaced by mesh.orientation for better mesh orientation validation.
See also

CurvilinearMesh.
axis_w
¶ Deprecated since version 0.7.0: axis_w will be removed in discretize 1.0.0, it is replaced by mesh.orientation for better mesh orientation validation.
See also

CurvilinearMesh.
boundary_edge_vector_integral
¶ Represents the operation of integrating a vector function on the boundary
This matrix represents the boundary surface integral of a vector function multiplied with a finite volume test function on the mesh.
In 1D and 2D, the operation assumes that the right array contains only a single component of the vector
u
. In 3D, however, we must assume thatu
will contain each of the three vector components, and it must be ordered as,[edges_1_x, ... ,edge_N_x, edge_1_y, ..., edge_N_y, edge_1_z, ..., edge_N_z]
, whereN
is the number of boundary edges. Returns
 scipy.sparse.csr_matrix
Sparse matrix of shape (n_edges, n_boundary_edges) for 1D or 2D mesh, (n_edges, 3*n_boundary_edges) for a 3D mesh.
Notes
The integral we are representing on the boundary of the mesh is
\[\int_{\Omega} \vec{w} \cdot (\vec{u} \times \hat{n}) \partial \Omega\]In discrete form this is:
\[w^T * P * u_b\]where w is defined on all edges, and u_b is all three components defined on boundary edges.

CurvilinearMesh.
boundary_edges
¶ Boundary edge locations
 Returns
 np.ndarray of float
location array of shape (mesh.n_boundary_edges, dim)

CurvilinearMesh.
boundary_face_outward_normals
¶ Outward directed normal vectors for the boundary faces
 Returns
 np.ndarray of float
Array of vectors of shape (mesh.n_boundary_faces, dim)

CurvilinearMesh.
boundary_face_scalar_integral
¶ Represents the operation of integrating a scalar function on the boundary
This matrix represents the boundary surface integral of a scalar function multiplied with a finite volume test function on the mesh.
 Returns
 scipy.sparse.csr_matrix
Sparse matrix of shape (n_faces, n_boundary_faces)
Notes
The integral we are representing on the boundary of the mesh is
\[\int_{\Omega} u\vec{w} \cdot \hat{n} \partial \Omega\]In discrete form this is:
\[w^T * P * u_b\]where w is defined on all faces, and u_b is defined on boundary faces.

CurvilinearMesh.
boundary_faces
¶ Boundary face locations
 Returns
 np.ndarray of float
location array of shape (mesh.n_boundary_faces, dim)

CurvilinearMesh.
boundary_node_vector_integral
¶ Represents the operation of integrating a vector function dotted with the boundary normal
This matrix represents the boundary surface integral of a vector function dotted with the boundary normal and multiplied with a scalar finite volume test function on the mesh.
 Returns
 scipy.sparse.csr_matrix
Sparse matrix of shape (n_nodes, ndim * n_boundary_nodes).
Notes
The integral we are representing on the boundary of the mesh is
\[\int_{\Omega} (w \vec{u}) \cdot \hat{n} \partial \Omega\]In discrete form this is:
\[w^T * P * u_b\]where w is defined on all nodes, and u_b is all three components defined on boundary nodes.

CurvilinearMesh.
boundary_nodes
¶ Boundary node locations
 Returns
 np.ndarray of float
location array of shape (mesh.n_boundary_nodes, dim)

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

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

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

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

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

CurvilinearMesh.
cell_centers
¶ Cellcentered grid

CurvilinearMesh.
cell_gradient
¶ The cell centered Gradient, takes you to cell faces.

CurvilinearMesh.
cell_gradient_BC
¶ The cell centered Gradient boundary condition matrix

CurvilinearMesh.
cell_gradient_x
¶ Cell centered Gradient in the x dimension. Has neumann boundary conditions.

CurvilinearMesh.
cell_gradient_y
¶

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

CurvilinearMesh.
cell_volumes
¶ Construct cell volumes of the 3D model as 1d array

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

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

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

CurvilinearMesh.
edge_curl
¶ Construct the 3D curl operator.

CurvilinearMesh.
edge_lengths
¶ Edge lengths

CurvilinearMesh.
edge_tangents
¶ Edge tangents

CurvilinearMesh.
edges
¶ Edge grid

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

CurvilinearMesh.
edges_y
¶ Edge staggered grid in the y direction.

CurvilinearMesh.
edges_z
¶ Edge staggered grid in the z direction.

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

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

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

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

CurvilinearMesh.
face_areas
¶ Area of the faces

CurvilinearMesh.
face_divergence
¶ Construct divergence operator (facestg to cellcentres).

CurvilinearMesh.
face_normals
¶ Face normals: calling this will average the computed normals so that there is one per face. This is especially relevant in 3D, as there are up to 4 different normals for each face that will be different.
To reshape the normals into a matrix and get the y component:
NyX, NyY, NyZ = M.reshape(M.face_normals, 'F', 'Fy', 'M')

CurvilinearMesh.
face_x_divergence
¶ Construct divergence operator in the x component (facestg to cellcentres).

CurvilinearMesh.
face_y_divergence
¶

CurvilinearMesh.
face_z_divergence
¶ Construct divergence operator in the z component (facestg to cellcenters).

CurvilinearMesh.
faces
¶ Face grid

CurvilinearMesh.
faces_x
¶ Face staggered grid in the x direction.

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

CurvilinearMesh.
faces_z
¶ Face staggered grid in the y direction.

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

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

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

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

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

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

CurvilinearMesh.
n_cells
¶

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

CurvilinearMesh.
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)

CurvilinearMesh.
n_edges_x
¶

CurvilinearMesh.
n_edges_y
¶

CurvilinearMesh.
n_edges_z
¶

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

CurvilinearMesh.
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)

CurvilinearMesh.
n_faces_x
¶

CurvilinearMesh.
n_faces_y
¶

CurvilinearMesh.
n_faces_z
¶

CurvilinearMesh.
n_nodes
¶

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

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

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

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

CurvilinearMesh.
node_list
¶

CurvilinearMesh.
nodes
¶ Nodal grid.

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

CurvilinearMesh.
orientation
¶

CurvilinearMesh.
origin
¶ Origin of the mesh

CurvilinearMesh.
project_edge_to_boundary_edge
¶ Projects values defined on all edges to the boundary edges
 Returns
 scipy.sparse.csr_matrix
Projection matrix with shape (n_boundary_edges, n_edges)

CurvilinearMesh.
project_face_to_boundary_face
¶ Projects values defined on all faces to the boundary faces
 Returns
 scipy.sparse.csr_matrix
Projection matrix with shape (n_boundary_faces, n_faces)

CurvilinearMesh.
project_node_to_boundary_node
¶ Projects values defined on all edges to the boundary edges
 Returns
 scipy.sparse.csr_matrix
Projection matrix with shape (n_boundary_nodes, n_nodes)

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

CurvilinearMesh.
reference_system
¶ The type of coordinate reference frame. Can take on the values

CurvilinearMesh.
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 relationship 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
.

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

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

CurvilinearMesh.
shape_edges_y
¶ Number of yedges in each direction
 Returns
 tuple of int or None
(nx_nodes, ny_cells, nz_nodes), None if dim < 2
Notes
Also accessible as vnEy.

CurvilinearMesh.
shape_edges_z
¶ Number of zedges in each direction
 Returns
 tuple of int or None
(nx_nodes, ny_nodes, nz_cells), None if dim < 3
Notes
Also accessible as vnEz.

CurvilinearMesh.
shape_faces_x
¶ Number of xfaces in each direction
 Returns
 tuple of int
(nx_nodes, ny_cells, nz_cells)
Notes
Also accessible as vnFx.

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

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

CurvilinearMesh.
shape_nodes
¶ Number of nodes in each direction
 Returns
 tuple of int
Notes
Also accessible as vnN.

CurvilinearMesh.
stencil_cell_gradient
¶

CurvilinearMesh.
stencil_cell_gradient_x
¶

CurvilinearMesh.
stencil_cell_gradient_y
¶

CurvilinearMesh.
stencil_cell_gradient_z
¶

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

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

CurvilinearMesh.
x0
¶
Methods¶

CurvilinearMesh.
cell_gradient_weak_form_robin
(alpha=1.0, beta=0.0, gamma=0.0)¶ Robin boundary condition for the weak formulation of the cell gradient
This function returns the necessary parts for the weak form of the cell gradient operator to represent the Robin boundary conditions.
The implementation assumes a ghost cell that mirrors the boundary cells across the boundary faces, with a piecewise linear approximation to the values at the ghost cell centers.
The parameters can either be defined as a constant applied to the entire boundary, or as arrays that represent those values on the
discretize.base.BaseTensorMesh.boundary_faces()
.The returned arrays represent the proper boundary conditions on a solution
u
such that the inner product of the gradient ofu
with a test function y would be <y, gradient*u
>= y.dot((face_divergence.T*cell_volumes + A)*u + y.dot(b)
.The default values will produce a zerodirichlet boundary condition.
 Parameters
 alpha, betascalar or array_like
Parameters for the Robin boundary condition. array_like must be defined on each boundary face.
 gamma: scalar or array_like
right hand side boundary conditions. If this parameter is array like, it can be fed either a (n_boundary_faces,) shape array or an (n_boundary_faces, n_rhs) shape array if multiple systems have the same alpha and beta parameters.
 Returns
 Ascipy.sparse.csr_matrix
Matrix to add to (face_divergence.T * cell_volumes)
 bnumpy.ndarray
Array to add to the result of the (face_divergence.T * cell_volumes + A) @ u.
Notes
The weak form is obtained by multiplying the gradient by a (piecewiseconstant) test function, and integrating over the cell, i.e.
(1)¶\[\int_V \vec{y} \cdot \nabla u \partial V\]This equation can be transformed to reduce the differentiability requirement on u to be,
(2)¶\[\int_V u (\nabla \cdot \vec{y}) \partial V + \int_{dV} u \vec{y} \partial V.\]The first term in equation :eq:transformed is constructed using the matrix operators defined on this mesh as
D
=discretize.operators.DiffOperators.face_divergence()
andV
, a diagonal matrix ofdiscretize.base.BaseMesh.cell_volumes()
, as\[(D*y)^T*V*u.\]This function returns the necessary matrices to complete the transformation of equation :eq:transformed. The second part of equation :eq:transformed becomes,
(3)¶\[\int_V \nabla \cdot (\phi u) \partial V = \int_{\partial\Omega} \phi\vec{u}\cdot\hat{n} \partial a\]which is then approximated with the matrices returned here such that the full form of the weak formulation in a discrete form would be.
\[y^T(D^T V + B)u + y^Tb\]Examples
We first create a very simple 2D tensor mesh on the [0, 1] boundary:
>>> import matplotlib.pyplot as plt >>> import scipy.sparse as sp >>> import discretize >>> mesh = discretize.TensorMesh([32, 32])
Define the alpha, beta, and gamma parameters for a zero  Dirichlet condition on the boundary, this corresponds to setting:
>>> alpha = 1.0 >>> beta = 0.0 >>> gamma = 0.0 >>> A, b = mesh.cell_gradient_weak_form_robin(alpha, beta, gamma)
We can then represent the operation of taking the weak form of the gradient of a function defined on cell centers with appropriate robin boundary conditions as:
>>> V = sp.diags(mesh.cell_volumes) >>> D = mesh.face_divergence >>> phi = np.sin(np.pi * mesh.cell_centers[:, 0]) * np.sin(np.pi * mesh.cell_centers[:, 1]) >>> phi_grad = (D.T @ V + A) @ phi + b

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

CurvilinearMesh.
edge_divergence_weak_form_robin
(alpha=0.0, beta=1.0, gamma=0.0)¶ Robin boundary condition for the weak formulation of the edge divergence
This function returns the necessary parts to form the full weak form of the edge divergence using the nodal gradient with appropriate boundary conditions.
The alpha, beta, and gamma parameters can be scalars, or arrays. If they are arrays, they can either be the same length as the number of boundary faces, or boundary nodes. If multiple parameters are arrays, they must all be the same length.
beta can not be 0.
It is assumed here that quantity that is approximated on the boundary is the gradient of another quantity. See the Notes section for explicit details.
 Parameters
 alpha, betascalar or array_like
Parameters for the Robin boundary condition. array_like must be defined on either boundary faces or boundary nodes.
 gamma: scalar or array_like
right hand side boundary conditions. If this parameter is array like, it can be fed either a (n_boundary_XXX,) shape array or an (n_boundary_XXX, n_rhs) shape array if multiple systems have the same alpha and beta parameters.
Notes
For these returned operators, it is assumed that the quantity on the boundary is related to the gradient of some other quantity.
The weak form is obtained by multiplying the divergence by a (piecewiseconstant) test function, and integrating over the cell, i.e.
(4)¶\[\int_V y \nabla \cdot \vec{u} \partial V\]This equation can be transformed to reduce the differentiability requirement on \(\vec{u}\) to be,
(5)¶\[\int_V \vec{u} \cdot (\nabla y) \partial V + \int_{dV} y \vec{u} \cdot \hat{n} \partial S.\]Furthermore, when applying these types of transformations, the unknown vector \(\vec{u}\) is usually related to some scalar potential as:
(6)¶\[\vec{u} = \nabla \phi\]Thus the robin conditions returned by these matrices apply to the quantity of \(\phi\).
\[ \begin{align}\begin{aligned}\alpha \phi + \beta \nabla \phi \cdot \hat{n} = \gamma\\\alpha \phi + \beta \vec{u} \cdot \hat{n} = \gamma\end{aligned}\end{align} \]The returned operators cannot be used to impose a Dirichlet condition on \(\phi\).

CurvilinearMesh.
equals
(other)¶

static
CurvilinearMesh.
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.

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

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

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

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

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

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

CurvilinearMesh.
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']

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

CurvilinearMesh.
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)

CurvilinearMesh.
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)

CurvilinearMesh.
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)

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

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

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

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

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

CurvilinearMesh.
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()

CurvilinearMesh.
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()

CurvilinearMesh.
plot_slice
(v, v_type='CC', normal='Z', ind=None, slice_loc=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.
 slice_locNone, optional
Value along dimension of slice. Defaults to the center of the mesh.
 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 >>> 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)
We can use the slice_loc kwarg to tell `plot_slice where to slice the mesh. Let’s create a mesh with a random model and plot slice of it. The slice_loc kwarg automatically determines the indices for slicing the mesh along a plane with the given normal.
>>> M = discretize.TensorMesh([32, 32, 32]) >>> v = discretize.utils.random_model(M.vnC, seed=789).reshape(1, order='F') >>> x_slice, y_slice, z_slice = 0.75, 0.25, 0.9 >>> plt.figure(figsize=(7.5, 3)) >>> ax = plt.subplot(131) >>> M.plot_slice(v, normal='X', slice_loc=x_slice, ax=ax) >>> ax = plt.subplot(132) >>> M.plot_slice(v, normal='Y', slice_loc=y_slice, ax=ax) >>> ax = plt.subplot(133) >>> M.plot_slice(v, normal='Z', slice_loc=z_slice, ax=ax) >>> plt.tight_layout() >>> plt.show()
This also works for TreeMesh. We create a mesh here that is refined within three boxes, along with a base level of refinement.
>>> TM = discretize.TreeMesh([32, 32, 32]) >>> TM.refine(3, finalize=False) >>> BSW = [[0.25, 0.25, 0.25], [0.15, 0.15, 0.15], [0.1, 0.1, 0.1]] >>> TNE = [[0.75, 0.75, 0.75], [0.85, 0.85, 0.85], [0.9, 0.9, 0.9]] >>> levels = [6, 5, 4] >>> TM.refine_box(BSW, TNE, levels) >>> v_TM = discretize.utils.volume_average(M, TM, v) >>> plt.figure(figsize=(7.5, 3)) >>> ax = plt.subplot(131) >>> TM.plot_slice(v_TM, normal='X', slice_loc=x_slice, ax=ax) >>> ax = plt.subplot(132) >>> TM.plot_slice(v_TM, normal='Y', slice_loc=y_slice, ax=ax) >>> ax = plt.subplot(133) >>> TM.plot_slice(v_TM, normal='Z', slice_loc=z_slice, ax=ax) >>> plt.tight_layout() >>> plt.show()

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

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

CurvilinearMesh.
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, )

CurvilinearMesh.
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, )

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

CurvilinearMesh.
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')

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

CurvilinearMesh.
serialize
()¶

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

CurvilinearMesh.
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’]

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

CurvilinearMesh.
to_dict
()¶

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

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

CurvilinearMesh.
validate
()¶ Every object will be valid upon initialization

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

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