discretize.base.BaseRectangularMesh

class discretize.base.BaseRectangularMesh(shape_cells, origin=None, orientation=None, reference_system=None, **kwargs)

Bases: discretize.base.BaseMesh

Attributes
axis_u

Deprecated since version 0.7.0.

axis_v

Deprecated since version 0.7.0.

axis_w

Deprecated since version 0.7.0.

dim

The dimension of the mesh (1, 2, or 3).

edge_tangents

Edge Tangents

face_normals

Face Normals

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 x-direction

nNy

Number of nodes in the y-direction

nNz

Number of nodes in the z-direction

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 x-edges

n_edges_y

Number of y-edges

n_edges_z

Number of z-edges

n_faces

Total number of faces.

n_faces_per_direction

The number of faces in each direction

n_faces_x

Number of x-faces

n_faces_y

Number of y-faces

n_faces_z

Number of z-faces

n_nodes

Total number of nodes

normals

normals has been deprecated. See face_normals for documentation

orientation
origin

Origin of the mesh

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 x-edges in each direction

shape_edges_y

Number of y-edges in each direction

shape_edges_z

Number of z-edges in each direction

shape_faces_x

Number of x-faces in each direction

shape_faces_y

Number of y-faces in each direction

shape_faces_z

Number of z-faces in each direction

shape_nodes

Number of nodes in each direction

tangents

tangents has been deprecated. See edge_tangents for documentation

x0

Methods

copy()

Make a copy of the current 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

validate()

Every object will be valid upon initialization

deserialize

equals

serialize

to_dict

Attributes

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

orientation
BaseRectangularMesh.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

orientation
BaseRectangularMesh.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

orientation
BaseRectangularMesh.dim

The dimension of the mesh (1, 2, or 3).

Returns
int

dimension of the mesh

BaseRectangularMesh.edge_tangents

Edge Tangents

Returns
numpy.ndarray

normals, (n_edges, dim)

BaseRectangularMesh.face_normals

Face Normals

Returns
numpy.ndarray

normals, (n_faces, dim)

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

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

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

BaseRectangularMesh.nNx

Number of nodes in the x-direction

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.

BaseRectangularMesh.nNy

Number of nodes in the y-direction

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.

BaseRectangularMesh.nNz

Number of nodes in the z-direction

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.

BaseRectangularMesh.n_cells
BaseRectangularMesh.n_edges

Total number of edges.

Returns
int

sum([n_edges_x, n_edges_y, n_edges_z])

Notes

Also accessible as nE.

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

../../_images/discretize-base-BaseRectangularMesh-1.png
BaseRectangularMesh.n_edges_x
BaseRectangularMesh.n_edges_y
BaseRectangularMesh.n_edges_z
BaseRectangularMesh.n_faces

Total number of faces.

Returns
int

sum([n_faces_x, n_faces_y, n_faces_z])

Notes

Also accessible as nF.

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

../../_images/discretize-base-BaseRectangularMesh-2.png
BaseRectangularMesh.n_faces_x
BaseRectangularMesh.n_faces_y
BaseRectangularMesh.n_faces_z
BaseRectangularMesh.n_nodes
BaseRectangularMesh.normals

normals has been deprecated. See face_normals for documentation

BaseRectangularMesh.orientation
BaseRectangularMesh.origin

Origin of the mesh

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

BaseRectangularMesh.reference_system

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

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

BaseRectangularMesh.shape_cells

The number of cells in each direction

Returns
tuple of ints

Notes

Also accessible as vnC.

BaseRectangularMesh.shape_edges_x

Number of x-edges in each direction

Returns
tuple of int

(nx_cells, ny_nodes, nz_nodes)

Notes

Also accessible as vnEx.

BaseRectangularMesh.shape_edges_y

Number of y-edges in each direction

Returns
tuple of int or None

(nx_nodes, ny_cells, nz_nodes), None if dim < 2

Notes

Also accessible as vnEy.

BaseRectangularMesh.shape_edges_z

Number of z-edges in each direction

Returns
tuple of int or None

(nx_nodes, ny_nodes, nz_cells), None if dim < 3

Notes

Also accessible as vnEz.

BaseRectangularMesh.shape_faces_x

Number of x-faces in each direction

Returns
tuple of int

(nx_nodes, ny_cells, nz_cells)

Notes

Also accessible as vnFx.

BaseRectangularMesh.shape_faces_y

Number of y-faces in each direction

Returns
tuple of int or None

(nx_cells, ny_nodes, nz_cells), None if dim < 2

Notes

Also accessible as vnFy.

BaseRectangularMesh.shape_faces_z

Number of z-faces in each direction

Returns
tuple of int or None

(nx_cells, ny_cells, nz_nodes), None if dim < 3

Notes

Also accessible as vnFz.

BaseRectangularMesh.shape_nodes

Number of nodes in each direction

Returns
tuple of int

Notes

Also accessible as vnN.

BaseRectangularMesh.tangents

tangents has been deprecated. See edge_tangents for documentation

BaseRectangularMesh.x0

Methods

BaseRectangularMesh.copy()

Make a copy of the current mesh

classmethod BaseRectangularMesh.deserialize(items, **kwargs)
BaseRectangularMesh.equals(other)
BaseRectangularMesh.projectEdgeVector(*args, **kwargs)

projectEdgeVector has been deprecated. See project_edge_vector for documentation

BaseRectangularMesh.projectFaceVector(*args, **kwargs)

projectFaceVector has been deprecated. See project_face_vector for documentation

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

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

BaseRectangularMesh.r(*args, **kwargs)

r has been deprecated. See reshape for documentation

BaseRectangularMesh.reshape(x, x_type='cell_centers', out_type='cell_centers', format='V', **kwargs)[source]

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

BaseRectangularMesh.serialize()
BaseRectangularMesh.to_dict()
BaseRectangularMesh.validate()

Every object will be valid upon initialization