FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
two_refinement_data.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8#include <kernel/geometry/raw_refinement_templates.hpp>
9#include <kernel/geometry/refinement_types.hpp>
10#include <kernel/shape.hpp>
11
12namespace FEAT::Geometry
13{
15 {
16 public:
19
26
28 template<int dim_>
30
32 template<typename Shape__>
34
36 template<int dim_>
37 using TemplateMapByDim = std::unordered_map<RefinementTypeByDim<dim_>, RawTemplate<Shape::Hypercube<dim_>>>;
38
45
52
62 template<typename Shape_>
63 static constexpr bool is_shape_compatible()
64 {
65 return std::is_same_v<Shape_, Shape::Quadrilateral> || std::is_same_v<Shape_, Shape::Hexahedron>;
66 }
67
78 template<int template_dim_, int child_dim_>
79 static constexpr int max_children()
80 {
81 static_assert(template_dim_ <= 3);
82 static_assert(child_dim_ <= 3);
83 const constexpr std::array<std::array<int, 4>, 4> children = {{
84 {0, 0, 0, 0},
85 {1, 2, 0, 0},
86 {1, 4, 4, 0},
87 {1, 6, 12, 8},
88 }};
89 return children[template_dim_][child_dim_];
90 }
91
97 template<int dim_>
99 {
100 if constexpr(dim_ == 1)
101 {
102 return raw_edges();
103 }
104 if constexpr(dim_ == 2)
105 {
106 return raw_faces();
107 }
108 if constexpr(dim_ == 3)
109 {
110 return raw_cells();
111 }
112 XABORTM("TwoRefinementRawData supplied no templates of dimension " + stringify(dim_));
113 }
114
117 {
118 using V = typename RawEntity<Shape::Hypercube<1>>::VertexType;
119 static EdgeMap result = {};
120
121 if(result.empty())
122 {
123 result.insert({RefinementTypeByDim<1>(0b00), RawEdgeTemplate()});
124 result.insert({RefinementTypeByDim<1>(0b11), RawEdgeTemplate().grid({2}, V{1.0 / 2.0})});
125 }
126 return result;
127 }
128
131 {
132 using V = typename RawEntity<Shape::Hypercube<2>>::VertexType;
133 static FaceMap result = {};
134
135 if(result.empty())
136 {
137 result.insert({RefinementTypeByDim<2>(0b0000), RawFaceTemplate()});
138 result.insert({RefinementTypeByDim<2>(0b1111), RawFaceTemplate().grid({2, 2}, V{1.0 / 2.0, 1.0 / 2.0})});
139 }
140 return result;
141 }
142
145 {
146 using V = typename RawCellTemplate::VertexType;
147 static CellMap result = {};
148
149 if(result.empty())
150 {
151 result.insert({RefinementTypeByDim<3>(0b00000000), RawCellTemplate()});
152 result.insert(
153 {RefinementTypeByDim<3>(0b11111111), RawCellTemplate().grid({2, 2, 2}, V{1.0 / 2.0, 1.0 / 2.0, 1.0 / 2.0})});
154 }
155 return result;
156 }
157 }; // class TwoRefinementData
158} // namespace FEAT::Geometry
#define XABORTM(msg)
Abortion macro definition with custom message.
Definition: assertion.hpp:192
static constexpr bool is_shape_compatible()
Shape compatability test.
static EdgeMap & raw_edges()
Returns the raw templates for edges of this template set.
static TemplateMapByDim< dim_ > & raw_templates()
Accessor for raw template maps.
static CellMap & raw_cells()
Returns the raw templates for cells of this template set.
TemplateMapByDim< 2 > FaceMap
Type of map from face refinement types to raw templates.
RawTemplate< Shape::Hypercube< 3 > > RawCellTemplate
Raw cell template type.
static FaceMap & raw_faces()
Returns the raw templates for faces of this template set.
RawTemplate< Shape::Hypercube< 1 > > RawEdgeTemplate
Raw edge template type.
TemplateMapByDim< 3 > CellMap
Type of map from cell refinement types to raw templates.
static constexpr int max_children()
Constexpr function for retrieving maximum number of children for any template of this template set.
RawTemplate< Shape::Hypercube< 2 > > RawFaceTemplate
Raw face template type.
TemplateMapByDim< 1 > EdgeMap
Type of map from edge refinement types to raw templates.
std::unordered_map< RefinementTypeByDim< dim_ >, RawTemplate< Shape::Hypercube< dim_ > > > TemplateMapByDim
Type of map from refinement type to raw templates.
Geometry namespace.
String stringify(const T_ &item)
Converts an item into a String.
Definition: string.hpp:944
Hypercube shape tag struct template.
Definition: shape.hpp:64