The GTMesh is a C++ library utilizing modern C++ paradigms as template metaprogramming
The GTMesh is a C++ library utilizing modern C++ paradigms as template metaprogramming
and type traits. The aim of GTMesh is to provide an implementation working with an unstructured mesh
and type traits. The aim of GTMesh is to provide an implementation working with an unstructured mesh
of any dimension and topology. Furthermore, the library provides additional tools developed
of any dimension and topology. Furthermore, the library provides additional tools developed
during the development of UnstructuredMesh and its functionalities.
during the development of UnstructuredMesh and its functionalities. The minimal
required C++ standard is C++14.
The tools developed as part of GTMesh:
The tools developed as part of GTMesh:
-[unstructured mesh](src/GTMesh/UnstructuredMesh/) with simple and user friendly inferface
-[unstructured mesh](src/GTMesh/UnstructuredMesh/) with simple and user friendly inferface
- user friendly, simple and generic [debugging tool](src/GTMesh/Debug/)
- user friendly, simple and generic [debugging tool](src/GTMesh/Debug/)
-[Traits](src/GTMesh/Traits/), a tool describing C++ data structures and
-[Traits](src/GTMesh/Traits/), a tool describing C++ data structures and
## Basic Tutorial
Inicialization of the `UnstructuredMesh` object:
The `UnstructuredMesh` class has four template parameters, where the last is
variadic.
|Name|Type|Description|
|---|----|---|
|`Dimension`|`unsigned int`|Specifies the dimension of the stored mesh.|
|`IndexType`|`typename`|The type of the indices used in inner data structures.|
|`Real`|`typename`|The type of the coordinates of vertices.|
|`...Reserve`|`unsigned int`|Variadic parameter prescribing number of sub-elements of elements with dimension between 1 and Dimension-1. By default 0 is assumed, which implies dynamically allocated memory.|
The following code listing presents declaration of the `UnstructuredMesh`
object:
```c++
// 2D unstructured mesh size_t references and double precision coordinates
UnstructuredMesh<2,size_t,double>mesh2D;
// 3D unstructured mesh size_t references and double precision coordinates
// with maximum nuber of face sub-elements prescibed to 6
UnstructuredMesh<3,size_t,double,6>mesh3D;
// with dynamically allocated sub-elements of faces,
// i.e. face could have any number of edges
UnstructuredMesh<3,size_t,double>mesh3D;
// 5D unstructured mesh size_t references and double precision coordinates
// maximum number of cell boundary sub-elements prescibed to 4
// maximum number of sub-elements of elements of dimension 3 prescibed to 4
// maximum number of sub-elements of elements of dimension 2 prescibed to 6
UnstructuredMesh<5,size_t,double,4,4,6>mesh5D;
```
## Loading of mesh from a file
The file formats supproted by GTMesh are VTK (2D and 3D) and FPMA (3D only).
So far, only ASCII format of VTK file is supported.
There are two ways of addressing the inner arrays. The first is by its position
and the second is by dimension, the array is mapped to:
-`flags.getDataByPos<0>()` returns the array mapped as first (i.e., mapped to the 3rd dimension),
-`flags.getDataByDim<1>()` returns the array mapped to the 1st dimension (i.e., the array mapped as the 3rd).
Then, the data mapped to the first cell can be accessed by `flags.getDataByPos<0>()[0]`
or equivalently `flags.getDataByDim<3>()[0]`.
Finally, the data in `MeshDataContainer` can be adressed using the elements of
the mesh.
```c++
for(auto&cell:mesh.getCells()){
flags[cell]=cell.getIndex();// Set the cell flag to the cell index
}
```
## Mesh algorithms
The `UnstructuredMesh` class provides the following algorithms:
### Functions working with the mesh topology:
|Function name|Functionality|
|----|----|
|`apply`|Applies a given function to all connected elements of dimension one to elements of dimension two, where the dimensions are set as template parameters.|
|`color`|Generates a proper coloring of the mesh elements of dimension one connected by adjacency with elements of dimension two.|
|`connections`|Generates a MeshDataContainer containing the indexes of elements connected to another elements.|
|`neighbors`|Determines the neighborhood of elements based on 3 dimensions (start, connecting, target).|
### Functions calculating properties of mesh elements:
|Function name|Functionality|
|---|---|
|`computeElementCenters`|Calculates the centers of the mesh elements.|
|`initializeCenters`|Calculates the centers of the mesh elements and sets the centers of cells and faces up.|
|`computeElementMeasures`|Calculates measures of all elements except vertices in 2D and 3D meshes.|
|`computeFaceNormals`|Calculates normal vectors of faces in 2D and 3D meshes.|
Note: All these algorithms works in general dimension, e.g., 4D. In case of 3D
and 2D mesh, it is necessary for the centers of the mesh elements to be initialized
in order to the functions `computeElementMeasures` and `computeFaceNormals` work
properly.
The usage of the mesh algorithms is the following: