Shapes#

modepy.shapes provides a generic description of the supported shapes (i.e. reference elements).

class modepy.Shape(dim: int)[source]#
dim: int#

Spatial dimension of the shape.

abstract property nvertices: int#

Number of vertices.

abstract property nfaces: int#

Number of faces.

class modepy.Face(volume_shape: Shape, face_index: int, volume_vertex_indices: Tuple[int, ...], map_to_volume: Callable[[ndarray], ndarray])[source]#

Mix-in to be used with a concrete Shape subclass to represent geometry information about a face of a shape.

volume_shape: Shape#

The volume Shape to which the face belongs.

face_index: int#

The face index in volume_shape of this face.

volume_vertex_indices: Tuple[int, ...]#

A tuple of indices into the vertices returned by unit_vertices_for_shape() for the volume_shape.

map_to_volume: Callable[[ndarray], ndarray]#

A Callable that takes an array of size (dim, nnodes) of unit nodes on the face represented by face_vertices and maps them to the volume_shape.

modepy.unit_vertices_for_shape(shape: Shape) ndarray[source]#
modepy.unit_vertices_for_shape(shape: TensorProductShape)
modepy.unit_vertices_for_shape(shape: Simplex)
Returns:

an ndarray of shape (dim, nvertices).

modepy.faces_for_shape(shape: Shape) Tuple[Face, ...][source]#
modepy.faces_for_shape(shape: Simplex)
modepy.faces_for_shape(shape: Hypercube)
Returns:

a tuple of Faces representing the faces of shape.

modepy.face_normal(face: Face, normalize: bool = True) ndarray[source]#

New in version 2021.2.1.

Tensor Product Shapes#

class modepy.TensorProductShape(bases: Tuple[Shape, ...])[source]#

Bases: Shape

A shape formed as a tensor product of other shapes.

For example, the tensor product of a line segment and a triangle (2D simplex) results in a prism shape. Special cases include the Hypercube.

bases: Tuple[Shape, ...]#

A tuple of base shapes that form the tensor product.

property nvertices: int#

Number of vertices.

property nfaces: int#

Number of faces.

Simplices#

class modepy.Simplex(dim: int)[source]#

Bases: Shape

An n-dimensional simplex (lines, triangle, tetrahedron, etc.).

property nfaces: int#

Number of faces.

property nvertices: int#

Number of vertices.

Coordinates on the triangle#

Bi-unit coordinates \((r, s)\) (also called ‘unit’ coordinates):

^ s
|
C
|\
| \
|  O
|   \
|    \
A-----B--> r

Vertices in bi-unit coordinates:

O = ( 0,  0)
A = (-1, -1)
B = ( 1, -1)
C = (-1,  1)

Equilateral coordinates \((x, y)\):

      C
     / \
    /   \
   /     \
  /   O   \
 /         \
A-----------B

Vertices in equilateral coordinates:

O = ( 0,          0)
A = (-1, -1/sqrt(3))
B = ( 1, -1/sqrt(3))
C = ( 0,  2/sqrt(3))

Coordinates on the tetrahedron#

Bi-unit coordinates \((r, s, t)\) (also called ‘unit’ coordinates):

           ^ s
           |
           C
          /|\
         / | \
        /  |  \
       /   |   \
      /   O|    \
     /   __A-----B---> r
    /_--^ ___--^^
   ,D--^^^
t L

(squint, and it might start making sense…)

Vertices in bi-unit coordinates \((r, s, t)\):

O = ( 0,  0,  0)
A = (-1, -1, -1)
B = ( 1, -1, -1)
C = (-1,  1, -1)
D = (-1, -1,  1)

Vertices in equilateral coordinates \((x, y, z)\):

O = ( 0,          0,          0)
A = (-1, -1/sqrt(3), -1/sqrt(6))
B = ( 1, -1/sqrt(3), -1/sqrt(6))
C = ( 0,  2/sqrt(3), -1/sqrt(6))
D = ( 0,          0,  3/sqrt(6))

Hypercubes#

class modepy.Hypercube(dim: int)[source]#

Bases: TensorProductShape

An n-dimensional hypercube (line, square, hexahedron, etc.).

Coordinates on the square#

Bi-unit coordinates on \((r, s)\) (also called ‘unit’ coordinates):

^ s
|
C---------D
|         |
|         |
|    O    |
|         |
|         |
A---------B --> r

Vertices in bi-unit coordinates:

O = ( 0,  0)
A = (-1, -1)
B = ( 1, -1)
C = (-1,  1)
D = ( 1,  1)

Coordinates on the cube#

Bi-unit coordinates on \((r, s, t)\) (also called ‘unit’ coordinates):

t
^
|
E----------G
|\         |\
| \        | \
|  \       |  \
|   F------+---H
|   |  O   |   |
A---+------C---|--> s
 \  |       \  |
  \ |        \ |
   \|         \|
    B----------D
     \
      v r

Vertices in bi-unit coordinates:

O = ( 0,  0,  0)
A = (-1, -1, -1)
B = ( 1, -1, -1)
C = (-1,  1, -1)
D = ( 1,  1, -1)
E = (-1, -1,  1)
F = ( 1, -1,  1)
G = (-1,  1,  1)
H = ( 1,  1,  1)

The order of the vertices in the hypercubes follows binary counting in tsr (i.e. in reverse axis order). For example, in 3D, A, B, C, D, ... is 000, 001, 010, 011, ....

Submeshes#

modepy.submesh_for_shape(shape: Shape, node_tuples: Sequence[Tuple[int, ...]]) Sequence[Tuple[int, ...]][source]#
modepy.submesh_for_shape(shape: Simplex, node_tuples)
modepy.submesh_for_shape(shape: TensorProductShape, node_tuples)

Return a list of tuples of indices into the node list that generate a tessellation of the reference element.

Parameters:

node_tuples

A list of tuples (i, j, …) of integers indicating node positions inside the unit element. The returned list references indices in this list.

modepy.node_tuples_for_space() may be used to generate node_tuples.

New in version 2020.3.