CartesianMesh¶
-
class
pysit.core.
CartesianMesh
(domain, *configs)[source]¶ Bases:
pysit.core.mesh.StructuredMesh
Specification of Cartesian meshes in PySIT.
Parameters: - domain : subclass of
pysit.core.domain.DomainBase
The PySIT domain that the mesh discretizes.
- configs
A variable number of integers specifying the number of points in each dimension. One entry for each dimension.
Notes
In any iterable which depends on dimension, the z-dimension is always the last element. Thus, in 1D, the dimension is assumed to be z.
The negative direction is always referred to as the left side and the positive direction is always the right side. For example, for the z-dimension, the top is left and the bottom is right.
- A dimension parameters Bunch contains four keys:
n
: an integer number of points for the dimensiondelta
: the distance between pointslbc
: the mesh description of the left boundary conditionrbc
: the mesh description of the the right boundary condition
The parameters dictionary can be accessed by number, by letter, or in the style of an attribute of the
RectangularDomain
.Number
>>> # Assume 3D, z is last >>> my_mesh.parameters[2]
Letter
>>> my_mesh.parameters['z']
Attribute
>>> my_mesh.z
Attributes: type
: strString describing the type of mesh, e.g., structured.
- dim : int
Dimension \(d\) in \(\mathcal{R}^d\) of the domain.
- domain : subclass of
pysit.core.domain.DomainBase
The PySIT domain that the mesh discretizes.
- parameters : dict of Bunch
Dictionary containing descriptions of each dimension.
Attributes Summary
deltas
Tuple of grid deltas type
String describing the type of mesh, e.g., structured. Methods Summary
dof
(self[, include_bc])Return the number of degrees of freedom as an integer. inner_product
(self, arg1, arg2)Compute the correct scaled inner product on the mesh. mesh_coords
(self[, sparse, include_bc])Returns coordinate arrays for mesh nodes. nodes
(self[, include_bc])Returns a self.dof() X self.dim ndarray
of node locations.pad_array
(self, in_array[, out_array, …])Returns a version of in_array, padded to add nodes from the shape
(self[, include_bc, as_grid])Return the shape, the number of nodes in each dimension. unpad_array
(self, in_array[, copy])Returns a view of input array, unpadded
to the primary orAttributes Documentation
-
deltas
¶ Tuple of grid deltas
-
type
¶ String describing the type of mesh, e.g., structured.
Methods Documentation
-
dof
(self, include_bc=False)[source]¶ Return the number of degrees of freedom as an integer.
Parameters: - include_bc : bool, optional
Include the ghost/boundary condition nodes in the shape; defaults to False.
-
mesh_coords
(self, sparse=False, include_bc=False)[source]¶ Returns coordinate arrays for mesh nodes.
Makes
ndarray
arrays for each dimension, similar tomeshgrid
. Always in ([X, [Y]], Z) order. Optionally include nodes due to boundary padding and optionally return sparse arrays to save memory.Parameters: - sparse : boolean
Returns a list of [X, [Y]], Z locations but not for each grid point, rather each dimesion.
- include_bc : boolean
Optionally include physical locations of ghost/boundary points.
-
nodes
(self, include_bc=False)[source]¶ Returns a self.dof() X self.dim
ndarray
of node locations.Parameters: - include_bc : bool, optional
Optionally include node locations for the boundary padding, defaults to False.
-
pad_array
(self, in_array, out_array=None, padding_mode=None)[source]¶ - Returns a version of in_array, padded to add nodes from the
- boundary conditions or ghost nodes.
Parameters: - in_array : ndarray
Input array
- out_array : ndarray, optional
If specifed, pad into a pre-allocated array
- padding_mode : string
Padding mode option for numpy.pad.
None
indicates to pad with zeros (see Note 2).
Notes
padding_mode
options are found in thenumpy
pad()
function.- If
padding_mode
is left at its default (None
), the array will be padded with zeros without callingpad()
and will instead use a faster method. - Recommended value for
padding_mode
is ‘edge’ for repeating the edge value. - This function preserves array shape. If the input is grid shaped, the return is grid shaped. Similarly, if the input is vector shaped, the output will be vector shaped.
-
shape
(self, include_bc=False, as_grid=False)[source]¶ Return the shape, the number of nodes in each dimension.
The shape as a grid means the result is a tuple containing the number of nodes in each dimension. As a vector means a column vector, so shape is nx1, where n is the total degrees of freedom.
Parameters: - include_bc : bool, optional
Include the ghost/boundary condition nodes in the shape; defaults to False.
- as_grid : bool, optional
Return the shape as a self.dim tuple of nodes in each dimension, rather than the column vector shape (self.dof(),1); defaults to False.
-
unpad_array
(self, in_array, copy=False)[source]¶ - Returns a view of input array,
unpadded
to the primary or boundary-condition- or ghost-node-free shape.
Truncates the array, information in the padded area is discarded.
Parameters: - in_array : numpy.ndarray
Input array
- copy : boolean, optional
Optionally return a copy of the unpadded array rather than a view.
Notes
- This function preserves array shape. If the input is grid shaped, the return is grid shaped. Similarly, if the input is vector shaped, the output will be vector shaped.
- Returns a view of input array,
- domain : subclass of