NiHu
2.0
|
This document explains how NiHu stores its geometries.
The lowest level of geometrical representations is the definition of coordinate spaces like the three-dimensional real space \( \mathbb{R}^{3} \). Coordinate spaces are defined in class NiHu::space, implemented in the source file space.hpp. The class has two obvious template parameters, scalar
, representing the type of a coordinate and dimension
representing the dimensionality of the coordinate space.
Class NiHu::space - like most of NiHu's template classes - implements a self-returning metafunction. This means that the class contains a public typedef
called type
that returns class NiHu::space itself. This technique is useful for simplifying NiHu's TMP syntax, as will be demonstrated later. As an other typical NiHu concept, class NiHu::space contains its template arguments in the form of a public typedef
and an enum
, making the arguments available from the class.
Class NiHu::space further defines the location vector type location_t
of the coordinate space in the form of an Eigen vector type.
A few commonly used coordinate spaces are predefined in NiHu's component library. These typedefs are rather straightforward:
For a simple usage example consider the following code snippet:
Class NiHu::domain, implemented in domain.hpp represents polygon-shaped subdomains of a coordinate space. These domains are used in NiHu as the reference domains \( \mathcal{D} \) of the coordinate transforms defining element geometries.
The class is a template with two arguments:
Space
describes the coordinate space of the domain, and NumCorners
describes the number of domain corners. The class is a self-returning metafunction, and defines its template arguments as a nested type and an enum.
The class further stores its corners (locations in the parameter space), as well as the domain's center in static members. The class provides static methods to return
Each domain is assigned a numeric identifier by the metafunction NiHu::domain_traits::id. The default value of this id is
10 * dimension + NumCorners
thus the id of line_domain
is 12, and the id of tria_domain is 23. Each domain is assigned a textual identifier by metafunction NiHu::domain_traits::name. This textual id is useful for debugging and performance diagnostics.
The component library contains the definition of a few commonly used standard domains:
with the textual identifiers
Interpolation functions or shape functions \( L_i(\xi) \) are used to define the element's coordinate transform. \( x(\xi) = \sum x_i L_i(\xi) \). They are implemented in the header file shapeset.hpp.
Shape function sets are implemented using the CRTP pattern with traits metafunctions. All shape set classes are derived from shape_set_base that defines their interface. The traits of a derived shape set class are implemented in namespace NiHu::shape_set_traits in the form of separate metafunctions. The base class template NiHu::shape_set_base gets the necessary type information from the traits metafunctions of the derived classes to define the specific interface.
The interface consists of the following functions:
The function template eval_shape can return the shape functions their gradient vectors or second derivatives as follows:
For increased efficiency, NiHu checks during compilation if the shape functions and derivatives are
For the case of a general \( \xi \)-dependent shape function, the result is computed on the fly and is returned by value. For the case of a constant function (like the gradient of linear interpolation functions) the shape functions are precomputed during program initialisation, stored in static members, and the function returns a constant reference. For the case of a zero matrix (like the second derivatives of linear interpolation functions) an efficient Eigen::Zero type matrix is returned.
The value types of the shape function vectors and matrices, as well as the actual return types of function eval_shape are defined in the metafunctions shape_set_traits::shape_value_type and shape_set_traits::shape_return_type.
Similar to class NiHu::space and NiHu::domain, each shape set is assiged a numeric and a textual identifier by the metafunctions NiHu::shape_set_traits::id and NiHu::shape_set_traits::name. The numeric id has a default value of
100 * domain_traits::id + NumNodes
thus, the automatic id of a 2D 3-noded triangle interpolation function set is 2303.
NiHu's component library predefines the following shape functions:
Usage of interpolation functions is demonstrated with the following example:
The example interpolates a biquadratic function over the standard quad domain and prints out its values.