Containers

Mesh

A finite element mesh is a discretisation of a domain \(\Omega\) using different types of elements. The next figure is an example of a mesh composed of different types of elements (quadrangles, triangles, bars and point elements).

alternate text

Fig. 1 A finite element mesh.

Many real life finite element problems use mixed elements to correctly mesh the domain. Also to correctly represent all the quantities needed for the definition of a problem (like material properties and external forces) it is necessary to define subgroups of elements and points. So a real mesh structure can not be reduced only to the points and the elements. Also to keep track of mesh transformations (i.e. extraction, mirroring) a suitable structure is necessary.

In general the operations on meshes (i.e. extraction, integration, export to file) can be grouped by type of elements so it is not necessary to have a very low level class like “Point class” or “Element Class”. In Muscat all homogeneous entities (all triangles for example) are grouped in high level (data oriented) classes. This enable us to work on big chunks of data and leverage the full power of a high level language.

The Muscat.Containers.Mesh.Mesh class of Muscat keeps all this information in a compact but relatively simple structure.

alternate text

Fig. 2 Containers Structure of a Muscat Mesh.

alternate text

Fig. 3 Decomposition of a mesh by nodes and elements.

Nodes

The nodes (Muscat.Containers.Mesh.Mesh.nodes) (or points) in a mesh are defined by:

The Muscat.Containers.Mesh.Mesh.nodes attribute is a matrix storing the positions of the nodes (one node per row). It therefore is of size Nb Nodes x Space Dimensionality. The size of Muscat.Containers.Mesh.Mesh.originalIDNodes must be equal to the number of nodes in the mesh.

The role of the Muscat.Containers.Mesh.Mesh.originalIDNodes is double. In the case when the origin of the mesh is a file from disk, it is used to store the “node number” (a concept present in many file formats). In the case when the mesh is a transformation of an initial mesh (extraction for example) the originalIDNodes is used to track the origin (the index) of each entity. As muscat is not copying every information from the initial mesh during tranformation (the NodeTags for example), this last case allows one to retrieve information further in the process if necessary.

Elements

The storage of elements is more complex because the information is heterogeneous (e.g. the number of nodes per element is different depending on the type of element).

Each type of element is only defined by its geometrical definition (i.e. linear triangle with 3 points). The mesh in Muscat does not store any information about the physics or any finite element implementation detail (i.e. reduce integration, degree of interpolation of the solution field), making the definition of the mesh relatively simple.

The mesh attribute Muscat.Containers.Mesh.Mesh.elements (of type Muscat.Containers.ElementsContainers.AllElements), analog to a dictionary in python, stores for each element type an Muscat.Containers.ElementsContainers.ElementsContainer object. The purpose of the Container is to store the list of information related to a specific type of element. In other words, a mesh will contain as many ElementContainer as it contains types of elements.

The class Muscat.Containers.ElementsContainers.AllElements implements the mapping interface. The keys are of type Muscat.Containers.ElementsContainers.ElementContainerLike and the corresponding values are of type (Muscat.Containers.ElementsContainers.ElementsContainer or Muscat.Containers.ElementsContainers.StructuredElementsContainer) containing the connectivity, originalIds and the tags. Once again, there is in every container an originalIds attribute refering to the element id of the container of the origin mesh. The element i is attached to the element of the origin mesh originalIds[i].

The next figure shows the names and the numbering for all the elements supported by Muscat. The vtk numbering is used to facilitate the interoperability with others libraries.

Element names and numbering

Fig. 4 Elements name and numbering (the numbering is the same as vtk for compatibility).

Child elements

The module Muscat.Containers.ElementsDescription contains information about every element supported in Muscat. The geometrical support, the dimensionality, if it linear, and most important the faces. The faces of an element are the elements that form it boundary (i.e. triangles for tetrahedrons).

Each element \(e\) have child elements. They can be classified depending on their dimensionality:

  • for a 3D element (i.e tetrahedrons):

    • Faces L1: This correspond to 2D faces (triangles in 3D)

    • Faces L2: This correspond to 1D lines (bars in 3D)

    • Faces L3: This correspond to 0D points (points in 3D)

  • for a 2D element (i.e triangles):

    • Faces L1: This correspond to 1D lines (bars in 2D or 3D depending on the ambient space)

    • Faces L2: This correspond to 0D points (points in 2D or 3D depending on the ambient space)

  • for a 1D element (i.e bars):

    • Faces L1: This correspond to 0D points (points in 2D or 3D depending on the ambient space)

are sorted by dimensionality \(d-i\) for \(i \in [1\dots0]\) each face () can be seen as a child element.

2 elements with projected points

Fig. 5 Examples of elements and their children

Nodes Tags and Element Tags

Tags Muscat.Containers.Tags.Tag are used to track subsets of nodes or elements in the mesh. Each tag is defined by a string (the name) and the indices of the entities to be captured by the tag. Internally the class Muscat.Containers.Tags.Tag uses a memory buffer and a counter to reduce the number of memory allocation in the case of incrementally adding indices to the tag.

The class Muscat.Containers.Tags.Tags offers a dictionary like interface to easy the interaction with a group of tags.

Node tags are defined at the root of the mesh. Element tags are defined locally by element types (for each ElementContainer). They both inherit the Tag class. Therefore, the Node tags associate a string to a vector of indices of some nodes of the mesh and the Element tags associate a string to a vector of indices for every container of the mesh. This means every ElementContainer has his own Element Tags independent of the others (using local indices).

alternate text

Fig. 6 Example of tags inside a Quadrangle_4 ElementContainer.

Nodes and Elements Fields

Thess are simple python dictionaries with keys of type str and values of type numpy array. Can be 1D arrays, with size number of nodes/elements, for scalars. Or 2D arrays, with size (number of nodes/elements, number of components), for vectors.

Properties

The mesh class contains a dictionary named Muscat.Containers.Mesh.Mesh.props to store user data related to the mesh itself. The values of the dictionary are copied (and sometimes droped) as derivative meshed are generated.

Some keys have special meaning:
  • “IsConstantRectilinear” : True if the mesh is constant Rectilinear

  • “spacing” : a np.array with the spacing in each direction

  • “origin” : a np.array with the origin of the mesh

  • “dimensions” : a np.array with the number of cells in each direction