Cell Classes#
This document summarizes the classes denoted to store and handle data about polygonal cells in 1, 2 or 3 dimensions.
Base Classes#
- class polymesh.cell.PolyCell(*args, i: ndarray | None = None, **kwargs)[source]#
A subclass of
polymesh.celldata.CellDataas a base class for all kinds of geometrical entities.- area(*args, **kwargs) float[source]#
Returns the total area of the cells in the database. Only for 2d entities.
- areas(*args, **kwargs) ndarray[source]#
Ought to return the areas of the individuall cells in the database.
- centers(target: ReferenceFrame | None = None) ndarray[source]#
Returns the centers of the cells.
- coords(*args, **kwargs) ndarray[source]#
Returns the coordinates of the cells in the database as a 3d numpy array.
- extract_surface(detach: bool = False)[source]#
Extracts the surface of the mesh. Only for 3d meshes.
- classmethod generate_class_functions(return_symbolic: bool = True, update: bool = True) Tuple[source]#
Generates functions to evaulate shape functions, their derivatives and the shape function matrices using SymPy. For this to work, the ‘polybase’ and ‘lcoords’ class methods must be implemented.
- glob_to_loc(x: Iterable | ndarray) ndarray[source]#
Returns the local coordinates of the input points for each cell in the block. The input ‘x’ can describe a single (1d array), or several positions at once (2d array).
Notes
This function is useful when detecting if two bodies touch each other or not, and if they do, where.
- Parameters:
x (Iterable or numpy.ndarray) – A single point in 3d space as an 1d array, or a collection of points as a 2d array.
- Returns:
A NumPy array of shape (nE, nP, nD), where nP is the number of points in ‘x’, nE is the number of cells in the block and nD is the number of spatial dimensions.
- Return type:
- jacobian(*, jac: ndarray | None = None, **kwargs) float | ndarray[source]#
Returns the jacobian determinant for one or more cells.
- Parameters:
jac (numpy.ndarray, Optional) – One or more Jacobian matrices. Default is None.
**kwargs (dict) – Forwarded to
jacobian_matrix()if the jacobian is not provided by the parameter ‘jac’.
- Returns:
Value of the Jacobian for one or more cells.
- Return type:
See also
- jacobian_matrix(*, dshp: ndarray | None = None, **__) ndarray[source]#
Returns the jacobian matrices.
- Parameters:
dshp (numpy.ndarray) – 3d array of shape function derivatives for the master cell, evaluated at some points. The array must have a shape of (nG, nNE, nD), where nG, nNE and nD are he number of evaluation points, nodes per cell and spatial dimensions.
- Returns:
A 4d array of shape (nE, nG, nD, nD), where nE, nG and nD are the number of elements, evaluation points and spatial dimensions. The number of evaluation points in the output is governed by the parameter ‘dshp’.
- Return type:
- classmethod lcenter() ndarray[source]#
Ought to return the local coordinates of the center of the master element.
- Return type:
- classmethod lcoords() ndarray[source]#
Ought to return local coordinates of the master element.
- Return type:
- loc_to_glob(x: Iterable | ndarray) ndarray[source]#
Returns the global coordinates of the input points for each cell in the block. The input ‘x’ can describe a single (1d array), or several local positions at once (2d array).
Notes
This function is useful when detecting if two bodies touch each other or not, and if they do, where.
- Parameters:
x (Iterable or numpy.ndarray) – A single point as an 1d array, or a collection of points as a 2d array.
- Returns:
A NumPy array of shape (nE, nP, nD), where nP is the number of points in ‘x’, nE is the number of cells in the block and nD is the number of spatial dimensions.
- Return type:
- local_coordinates(*, target: CartesianFrame | None = None) ndarray[source]#
Returns local coordinates of the cells as a 3d float numpy array.
- Parameters:
target (CartesianFrame, Optional) – A target frame. If provided, coordinates are returned in this frame, otherwise they are returned in the local frames of the cells. Default is None.
- locate(x: Iterable | ndarray, lazy: bool = True, tol: float = 1e-12, k: int = 4) Tuple[ndarray][source]#
Locates a set of points inside the cells of the block.
- Parameters:
x (Iterable or numpy.ndarray) – The coordinates of the points that we want to investigate.
tol (float, Optional) – Floating point tolerance for detecting boundaries. Default is 1e-12.
lazy (bool, Optional) – If False, the ckeck is performed for all cells in the block. If True, it is used in combination with parameter ‘k’ and the check is only performed for the k nearest neighbours of the input points. Default is True.
k (int, Optional) – The number of neighbours for the case when ‘lazy’ is true. Default is 4.
- Returns:
numpy.ndarray – The indices of ‘x’ that are inside a cell of the block.
numpy.ndarray – The block-local indices of the cells that include the points with the returned indices.
numpy.ndarray – The parametric coordinates of the located points inside the including cells.
- measure(*args, **kwargs) float[source]#
Ought to return the net measure for the cells in the database as a group.
- pip(x: Iterable | ndarray, tol: float = 1e-12, lazy: bool = True, k: int = 4) bool | ndarray[source]#
Returns an 1d boolean integer array that tells if the points specified by ‘x’ are included in any of the cells in the block.
- Parameters:
x (Iterable or numpy.ndarray) – The coordinates of the points that we want to investigate.
tol (float, Optional) – Floating point tolerance for detecting boundaries. Default is 1e-12.
lazy (bool, Optional) – If False, the ckeck is performed for all cells in the block. If True, it is used in combination with parameter ‘k’ and the check is only performed for the k nearest neighbours of the input points. Default is True.
k (int, Optional) – The number of neighbours for the case when ‘lazy’ is true. Default is 4.
- Returns:
A single or NumPy array of booleans for every input point.
- Return type:
- points_involved() PointCloud[source]#
Returns the points involved in the cells of the block.
- points_of_cells(*, points: float | Iterable | None = None, cells: int | Iterable | None = None, target: str | CartesianFrame = 'global') ndarray[source]#
Returns the points of the cells as a NumPy array.
- classmethod polybase() Tuple[List][source]#
Ought to retrun the polynomial base of the master element.
- Returns:
list – A list of SymPy symbols.
list – A list of monomials.
- rewire(imap: ndarray | MutableMapping | None = None, invert: bool = False) PolyCell[source]#
Rewires the topology of the block according to the mapping described by the argument imap. The mapping of the j-th node of the i-th cell happens the following way:
topology_new[i, j] = imap[topology_old[i, j]]
The object is returned for continuation.
- Parameters:
imap (MapLike) – Mapping from old to new node indices (global to local).
invert (bool, Optional) – If True the argument imap describes a local to global mapping and an inversion takes place. In this case, imap must be a numpy array. Default is False.
- classmethod shape_function_derivatives(pcoords: ndarray) ndarray[source]#
Evaluates shape function derivatives wrt. the master element.
- Parameters:
pcoords (numpy.ndarray) – Locations of the evaluation points.
- Returns:
An array of shape (nP, nNE, nD), where nP, nNE and nD are the number of evaluation points, nodes and spatial dimensions.
- Return type:
- classmethod shape_function_matrix(pcoords: ndarray, N: int | None = None) ndarray[source]#
Evaluates the shape function matrix at the specified locations.
- Parameters:
pcoords (numpy.ndarray) – Locations of the evaluation points.
N (int, Optional) – Number of unknowns per node.
- Returns:
An array of shape (nP, nDOF, nDOF * nNE) where nP, nDOF and nNE are the number of evaluation points, degrees of freedom per node and nodes per cell.
- Return type:
- classmethod shape_function_values(pcoords: ndarray) ndarray[source]#
Evaluates the shape functions at the specified locations.
- Parameters:
pcoords (numpy.ndarray) – Locations of the evaluation points.
- Returns:
An array of shape (nP, nNE) where nP and nNE are the number of evaluation points and shape functions. If there is only one evaluation point, the returned array is one dimensional.
- Return type:
- source_frame() ReferenceFrame[source]#
Returns the frame of the hosting pointcloud.
- source_points() PointCloud[source]#
Returns the hosting pointcloud.
- topology() TopologyArray[source]#
Returns the numerical representation of the topology of the cells.
- class polymesh.cell.PolyCell1d(*args, i: ndarray | None = None, **kwargs)[source]#
Base class for 1d cells
- class polymesh.cell.PolyCell2d(*args, i: ndarray | None = None, **kwargs)[source]#
Base class for 2d cells
- classmethod lcenter() ndarray[source]#
Ought to return the local coordinates of the center of the master element.
- Return type:
- local_coordinates(*_, target: CartesianFrame | None = None) ndarray[source]#
Returns the local coordinates of the cells of the block.
- pip(x: Iterable | ndarray, tol: float = 1e-12) bool | ndarray[source]#
Returns an 1d boolean integer array that tells if the points specified by ‘x’ are included in any of the cells in the block.
- Parameters:
x (Iterable or numpy.ndarray) – The coordinates of the points that we want to investigate.
- Returns:
A single or NumPy array of booleans for every input point.
- Return type:
- thickness() ndarray[source]#
Returns the thicknesses of the cells. If not set, a thickness of 1.0 is returned for each cell.
- class polymesh.cell.PolyCell3d(*args, **kwargs)[source]#
Base class for 3d cells
- boundary(detach: bool = False) Tuple[ndarray][source]#
Returns the boundary of the block as 2 NumPy arrays.
- locate(x: Iterable | ndarray, lazy: bool = True, tol: float = 1e-12, k: int = 4) Tuple[ndarray][source]#
Locates a set of points inside the cells of the block.
- Parameters:
x (Iterable or numpy.ndarray) – The coordinates of the points that we want to investigate.
tol (float, Optional) – Floating point tolerance for detecting boundaries. Default is 1e-12.
lazy (bool, Optional) – If False, the ckeck is performed for all cells in the block. If True, it is used in combination with parameter ‘k’ and the check is only performed for the k nearest neighbours of the input points. Default is True.
k (int, Optional) – The number of neighbours for the case when ‘lazy’ is true. Default is 4.
- Returns:
numpy.ndarray – The indices of ‘x’ that are inside one of the cells of the block.
numpy.ndarray – The block-local indices of the cells that include the points with the returned indices.
numpy.ndarray – The master coordinates of the located points inside the including cells.
- pip(x: Iterable | ndarray, tol: float = 1e-12, lazy: bool = True, k: int = 4) bool | ndarray[source]#
Returns an 1d boolean integer array that tells if the points specified by ‘x’ are included in any of the cells in the block.
- Parameters:
x (Iterable or numpy.ndarray) – The coordinates of the points that we want to investigate.
tol (float, Optional) – Floating point tolerance for detecting boundaries. Default is 1e-12.
lazy (bool, Optional) – If False, the ckeck is performed for all cells in the block. If True, it is used in combination with parameter ‘k’ and the check is only performed for the k nearest neighbours of the input points. Default is True.
k (int, Optional) – The number of neighbours for the case when ‘lazy’ is true. Default is 4.
- Returns:
A single or NumPy array of booleans for every input point.
- Return type:
- classmethod tetmap() Iterable[source]#
Returns a mapper to transform topology and other data to a collection of T3 triangles.
- to_pv(detach: bool = False) UnstructuredGrid | PolyData[source]#
Returns the block as a pyVista object.
- to_tetrahedra(flatten: bool = True) ndarray[source]#
Returns the topology as a collection of TET4 tetrahedra.
- Parameters:
flatten (bool, Optional) – If True, the topology is returned as a 2d array. If False, the length of the first axis equals the number of cells in the block, the length of the second axis equals the number of tetrahedra per cell.
- class polymesh.line.Line(*args, **kwargs)[source]#
Base class for all lines.
- jacobian(*args, jac: ndarray | None = None, **kwargs)[source]#
Calculates jacobian determinants.
- Parameters:
jac (numpy.ndarray) – Array of jacobian matrices derivatives.
See also
- jacobian_matrix(*args, dshp: ndarray | None = None, **kwargs)[source]#
Calculates jacobian matrices.
- Parameters:
dshp (numpy.ndarray) – Array of shape function derivatives.
- class polymesh.line.NonlinearLine(*args, **kwargs)[source]#
Base class for general nonlinear lines.
See also
- class polymesh.line.QuadraticLine(*args, **kwargs)[source]#
Base class for quadratic 3-noded lines.
See also
- class polymesh.polygon.BiQuadraticQuadrilateral(*args, i: ndarray | None = None, **kwargs)[source]#
9-noded biquadratic quadrilateral.
- class polymesh.polygon.PolyGon(*args, i: ndarray | None = None, **kwargs)[source]#
Base class for polygons.
- class polymesh.polygon.Quadrilateral(*args, i: ndarray | None = None, **kwargs)[source]#
Basic 4-noded bilinear quadrilateral.
- class polymesh.polyhedron.BiquadraticWedge(*args, **kwargs)[source]#
Class for 6-noded biquadratic wedges.
- class polymesh.polyhedron.QuadraticTetraHedron(*args, **kwargs)[source]#
Class for 10-noded quadratic tetrahedra.
- class polymesh.polyhedron.TetraHedron(*args, **kwargs)[source]#
Class for 4-noded tetrahedra.
- classmethod tetmap() ndarray[source]#
Returns a mapper to transform topology and other data to a collection of T3 triangles.
- to_tetrahedra(flatten: bool = True) ndarray[source]#
Returns the topology as a collection of TET4 tetrahedra.
- Parameters:
flatten (bool, Optional) – If True, the topology is returned as a 2d array. If False, the length of the first axis equals the number of cells in the block, the length of the second axis equals the number of tetrahedra per cell.
Lagrange Cells#
- class polymesh.cells.l2.L2(*args, **kwargs)[source]#
2-Node line element.
See also
- classmethod lcenter() ndarray[source]#
Returns the local coordinates of the center of the cell.
- Return type:
- class polymesh.cells.l3.L3(*args, **kwargs)[source]#
3-Node line element.
See also
- classmethod lcenter() ndarray[source]#
Returns the local coordinates of the center of the cell.
- Return type:
- class polymesh.cells.t3.T3(*args, **kwargs)[source]#
A class to handle 3-noded triangles.
See also
- classmethod lcenter() ndarray[source]#
Returns the local coordinates of the center of the cell.
- Return type:
- class polymesh.cells.t6.T6(*args, **kwargs)[source]#
A class to handle 6-noded triangles.
See also
- classmethod lcenter() ndarray[source]#
Returns the local coordinates of the center of the cell.
- Return type:
- class polymesh.cells.q4.Q4(*args, i: ndarray | None = None, **kwargs)[source]#
Polygon class for 4-noded bilinear quadrilaterals.
See also
- classmethod lcenter() ndarray[source]#
Returns the local coordinates of the center of the cell.
- Return type:
- class polymesh.cells.q9.Q9(*args, i: ndarray | None = None, **kwargs)[source]#
Polygon class for 9-noded biquadratic quadrilaterals.
See also
- dshpfnc()#
Returns the first orderderivatives of the shape functions, evaluated at multiple points, according to ‘pcoords’.
— (nP, nNE, 2)
- classmethod lcenter() ndarray[source]#
Returns the local coordinates of the center of the cell.
- Return type:
- class polymesh.cells.tet4.TET4(*args, **kwargs)[source]#
4-node isoparametric hexahedron.
See also
- classmethod lcenter() ndarray[source]#
Ought to return the local coordinates of the center of the master element.
- Return type:
- class polymesh.cells.tet10.TET10(*args, **kwargs)[source]#
10-node isoparametric hexahedron.
See also
- classmethod lcenter()[source]#
Ought to return the local coordinates of the center of the master element.
- Return type:
- classmethod lcoords()[source]#
Ought to return local coordinates of the master element.
- Return type:
- class polymesh.cells.h8.H8(*args, **kwargs)[source]#
8-node isoparametric hexahedron.
top 7--6 | | 4--5 bottom 3--2 | | 0--1
See also
- classmethod lcenter() ndarray[source]#
Returns the local coordinates of the center of the cell.
- Return type:
- classmethod polybase() Tuple[List][source]#
Retruns the polynomial base of the master element.
- Returns:
list – A list of SymPy symbols.
list – A list of monomials.
- class polymesh.cells.h27.H27(*args, **kwargs)[source]#
27-node isoparametric triquadratic hexahedron.
top 7---14---6 | | | 15--25--13 | | | 4---12---5 middle 19--23--18 | | | 20--26--21 | | | 16--22--17 bottom 3---10---2 | | | 11--24---9 | | | 0----8---1
See also
- classmethod lcenter() ndarray[source]#
Returns the local coordinates of the center of the cell.
- Return type:
- classmethod polybase() Tuple[List][source]#
Retruns the polynomial base of the master element.
- Returns:
list – A list of SymPy symbols.
list – A list of monomials.