10#include <kernel/util/meta_math.hpp>
11#include <kernel/util/string.hpp>
42 template<
int dimension_>
45 static_assert(dimension_ > 0,
"parameter dimension_ must be greater than 0");
53 return "Simplex<" +
stringify(dimension_) +
">";
62 template<
int dimension_>
65 static_assert(dimension_ > 0,
"parameter dimension_ must be greater than 0");
73 return "Hypercube<" +
stringify(dimension_) +
">";
111 static constexpr int count = ...
126 static constexpr int count = 1;
137 struct FaceTraits<Simplex<cell_dim_>, face_dim_>
139 static_assert(face_dim_ > 0,
"parameter face_dim_ must be greater than 0");
140 static_assert(cell_dim_ >= face_dim_,
"face_dim_ must not be greater than cell_dim_");
159 template<
int cell_dim_>
160 struct FaceTraits<Simplex<cell_dim_>, 0>
162 static_assert(cell_dim_ > 0,
"parameter cell_dim_ must be greater than 0");
168 static constexpr int count = cell_dim_ + 1;
179 struct FaceTraits<Hypercube<cell_dim_>, face_dim_>
181 static_assert(face_dim_ > 0,
"parameter face_dim_ must be greater than 0");
182 static_assert(cell_dim_ >= face_dim_,
"face_dim_ must not be greater than cell_dim_");
193 static constexpr int count = (1 << (cell_dim_ - face_dim_)) * MetaMath::Binomial<cell_dim_, face_dim_>::value;
201 template<
int cell_dim_>
202 struct FaceTraits<Hypercube<cell_dim_>, 0>
204 static_assert(cell_dim_ > 0,
"parameter cell_dim_ must be greater than 0");
210 static constexpr int count = (1 << cell_dim_);
225 template<
typename Shape_>
227 struct ReferenceCell;
246 template<
typename T_>
247 static T_
vertex(
int vertex_idx,
int coord_idx);
261 template<
typename T_>
273 template<
typename T_>
301 template<
typename T_>
302 static T_
vertex(
int,
int)
307 template<
typename T_>
313 template<
typename T_>
329 struct ReferenceCell< Shape::Simplex<dim_> >
331 template<
typename T_>
332 static T_
vertex(
int vertex_idx,
int coord_idx)
334 return (coord_idx + 1) == vertex_idx ? T_(1) : T_(0);
337 template<
typename T_>
340 return T_(1) / T_(dim_+1);
343 template<
typename T_>
365 ASSERTM((facet_index >= 0),
"facet index out of range!");
366 ASSERTM((facet_index < FaceTraits<Simplex<dim_>, dim_-1>::count),
"facet index out of range!");
367 return 1 - (dim_ == 2 ? 0 : dim_ == 3 ? (facet_index & 1) << 1 : ((facet_index & 1) ^ 1) << 1);
377 struct ReferenceCell< Shape::Hypercube<dim_> >
379 template<
typename T_>
380 static T_
vertex(
int vertex_idx,
int coord_idx)
382 return T_((((vertex_idx >> coord_idx) & 1) << 1) - 1);
385 template<
typename T_>
391 template<
typename T_>
394 return T_(1 << dim_);
414 ASSERTM((facet_index >= 0),
"facet index out of range!");
415 ASSERTM((facet_index < FaceTraits<Hypercube<dim_>,dim_-1>::count),
"facet index out of range!");
417 return 1 - (( ((facet_index >> 1) ^ facet_index ^ dim_) & 1 ) << 1);
#define ASSERTM(expr, msg)
Debug-Assertion macro definition with custom message.
String class implementation.
Hypercube< 3 > Hexahedron
3-Hypercube: Hexahedron
Hypercube< 2 > Quadrilateral
2-Hypercube: Quadrilateral
Simplex< 3 > Tetrahedron
3-Simplex: Tetrahedron
Simplex< 2 > Triangle
2-Simplex: Triangle
String stringify(const T_ &item)
Converts an item into a String.
Face traits tag struct template.
typedef ShapeType
Shape type of the face.
Hypercube shape tag struct template.
static String name()
Returns the name of the class as a String.
static constexpr int dimension
Hypercube dimension.
Reference cell traits structure.
static int facet_orientation(int facet_index)
Returns the orientation of a facet.
static T_ centre(int coord_idx)
Returns the coordinate of the reference cell centre.
static T_ vertex(int vertex_idx, int coord_idx)
Returns the coordinate of a reference cell vertex.
static T_ volume()
Returns the volume of the reference cell.
Simplex shape tag struct template.
static String name()
Returns the name of the class as a String.
static constexpr int dimension
Simplex dimension.
static String name()
Returns the name of the class as a String.
static constexpr int dimension
Vertex dimension.