FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
congruency_mapping.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// includes, FEAT
9#include <kernel/geometry/intern/congruency_sampler.hpp>
10
11// includes, system
12#include <algorithm>
13
14namespace FEAT
15{
16 namespace Geometry
17 {
19 namespace Intern
20 {
34 template<
35 typename Shape_,
36 int face_dim_>
37#ifndef DOXYGEN
38 class CongruencyMapping;
39#else
40 class CongruencyMapping
41 {
42 public:
55 static int map(int orient, int idx);
56
63 template<typename IdxTuple_>
64 static void flip(IdxTuple_& idx);
65 };
66#endif // DOXYGEN
67
73 template<>
74 class CongruencyMapping<Shape::Simplex<1>, 0>
75 {
76 public:
77 static int map(int orient, int idx)
78 {
79 static const int indices[2][2] =
80 {
81 {0, 1},
82 {1, 0}
83 };
84
85 return indices[orient][idx];
86 }
87
88 template<typename IdxTuple_>
89 static void flip(IdxTuple_& idx)
90 {
91 // swap vertex 0 and 1
92 std::swap(idx[0], idx[1]);
93 }
94 };
95
101 template<>
102 class CongruencyMapping<Shape::Simplex<2>, 0>
103 {
104 public:
105 static int map(int orient, int idx)
106 {
107 static const int indices[7][3] =
108 {
109 {0, 1, 2},
110 {1, 2, 0},
111 {2, 0, 1},
112 {0, 0, 0}, // unused
113 {0, 2, 1},
114 {1, 0, 2},
115 {2, 1, 0}
116 };
117
118 return indices[orient][idx];
119 }
120
121 template<typename IdxTuple_>
122 static void flip(IdxTuple_& idx)
123 {
124 // 2 1
125 // |'\. --> |'\.
126 // 0---1 0---2
127 std::swap(idx[1], idx[2]);
128 }
129 };
130
136 template<>
137 class CongruencyMapping<Shape::Simplex<2>, 1>
138 {
139 public:
140 static int map(int orient, int idx)
141 {
142 static const int indices[7][3] =
143 {
144 {0, 1, 2},
145 {1, 2, 0},
146 {2, 0, 1},
147 {0, 0, 0}, // unused
148 {0, 2, 1},
149 {1, 0, 2},
150 {2, 1, 0}
151 };
152
153 return indices[orient][idx];
154 }
155
156 template<typename IdxTuple_>
157 static void flip(IdxTuple_& idx)
158 {
159 // 2 1
160 // |'\. --> |'\.
161 // 0---1 0---2
162 //
163 // X X
164 // 2'1. --> 0'1.
165 // X-0-X X-2-X
166 //
167 // swap edge 0 and 2
168 std::swap(idx[0], idx[2]);
169 }
170 };
171
177 template<>
178 class CongruencyMapping<Shape::Hypercube<1>, 0>
179 {
180 public:
181 static int map(int orient, int idx)
182 {
183 static const int indices[2][2] =
184 {
185 {0, 1},
186 {1, 0}
187 };
188
189 return indices[orient][idx];
190 }
191
192 template<typename IdxTuple_>
193 static void flip(IdxTuple_& idx)
194 {
195 // swap vertex 0 and 1
196 std::swap(idx[0], idx[1]);
197 }
198 };
199
205 template<>
206 class CongruencyMapping<Shape::Hypercube<2>, 0>
207 {
208 public:
209 static int map(int orient, int idx)
210 {
211 static const int indices[8][4] =
212 {
213 {0, 1, 2, 3},
214 {1, 3, 0, 2},
215 {2, 0, 3, 1},
216 {3, 2, 1, 0},
217 {0, 2, 1, 3},
218 {1, 0, 3, 2},
219 {2, 3, 0, 1},
220 {3, 1, 2, 0}
221 };
222
223 return indices[orient][idx];
224 }
225
226 template<typename IdxTuple_>
227 static void flip(IdxTuple_& idx)
228 {
229 // 2---3 0---1
230 // | | --> | |
231 // 0---1 2---3
232 std::swap(idx[0], idx[2]);
233 std::swap(idx[1], idx[3]);
234 }
235 };
236
242 template<>
243 class CongruencyMapping<Shape::Hypercube<2>, 1>
244 {
245 public:
246 static int map(int orient, int idx)
247 {
248 static const int indices[8][4] =
249 {
250 {0, 1, 2, 3},
251 {3, 2, 0, 1},
252 {2, 3, 1, 0},
253 {1, 0, 3, 2},
254 {2, 3, 0, 1},
255 {0, 1, 3, 2},
256 {1, 0, 2, 3},
257 {3, 2, 1, 0}
258 };
259
260 return indices[orient][idx];
261 }
262
263 template<typename IdxTuple_>
264 static void flip(IdxTuple_& idx)
265 {
266 // 2---3 0---1
267 // | | --> | |
268 // 0---1 2---3
269 //
270 // X-1-X X-0-X
271 // 2 3 --> 2 3
272 // X-0-X X-1-X
273 //
274 // swap edge 0 and 1
275 std::swap(idx[0], idx[1]);
276 }
277 };
278 } // namespace Intern
280 } // namespace Geometry
281} // namespace FEAT
FEAT namespace.
Definition: adjactor.hpp:12