FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
structured_mesh.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/factory.hpp>
10#include <kernel/geometry/struct_index_set.hpp>
11#include <kernel/geometry/intern/structured_vertex_refiner.hpp>
12
13namespace FEAT
14{
15 namespace Geometry
16 {
29 template<
30 int shape_dim_,
31 int num_coords_ = shape_dim_,
32 typename Coord_ = Real>
34 {
35 static_assert(shape_dim_ > 0, "invalid shape dimension");
36 static_assert(num_coords_ >= shape_dim_, "invalid number of coordinates");
37
38 public:
41
43 typedef Coord_ CoordType;
44
47
49 typedef StructIndexSetHolder<shape_dim_> IndexSetHolderType;
50
52 static constexpr int shape_dim = shape_dim_;
54 static constexpr int world_dim = num_coords_;
55
57 static constexpr bool is_structured = true;
58
68 template<
69 int cell_dim_,
70 int face_dim_>
71 struct IndexSet
72 {
73 static_assert(cell_dim_ <= shape_dim, "invalid cell dimension");
74 static_assert(face_dim_ < cell_dim_, "invalid face/cell dimension");
75 static_assert(face_dim_ >= 0, "invalid face dimension");
76
79 }; // struct IndexSet<...>
80
81 protected:
86
89
92
93 private:
94 StructuredMesh& operator=(const StructuredMesh&);
95
96 public:
104 explicit StructuredMesh(const Index num_slices[]) :
105 _vertex_set(Intern::StructNumEntities<shape_dim_, 0>::compute(num_slices)),
106 _index_set_holder(num_slices)
107 {
108 XASSERT(num_slices != nullptr);
109
110 // store slice counts
111 for(int i(0); i < shape_dim; ++i)
112 {
113 XASSERT(num_slices[i] > 0);
114 _num_slices[i] = num_slices[i];
115 }
116
117 // calculate number of entities
118 Intern::StructNumEntitiesWrapper<shape_dim_>::compute(_num_entities, _num_slices);
119 }
120
129 Intern::StructNumEntities<shape_dim_, 0>::compute(
130 Intern::NumSlicesWrapper<shape_dim>(factory).num_slices)),
131 _index_set_holder(Intern::NumSlicesWrapper<shape_dim>(factory).num_slices)
132 {
133 // store slice count
134 Intern::NumSlicesWrapper<shape_dim>::apply(factory, _num_slices);
135
136 // calculate number of entities
137 Intern::StructNumEntitiesWrapper<shape_dim_>::compute(_num_entities, _num_slices);
138
139 // fill vertex set
140 factory.fill_vertex_set(_vertex_set);
141 }
142
152 {
153 for(int i(0); i < shape_dim_; ++i)
154 {
155 _num_slices[i] = other.get_num_slices(i);
156 }
157
158 // calculate number of entities
159 Intern::StructNumEntitiesWrapper<shape_dim_>::compute(_num_entities, _num_slices);
160 }
161
164 {
165 }
166
168 std::size_t bytes() const
169 {
170 return _vertex_set.bytes() + _index_set_holder.bytes();
171 }
172
182 Index get_num_slices(int dir) const
183 {
184 XASSERT(dir >= 0);
185 XASSERT(dir < shape_dim);
186 return _num_slices[dir];
187 }
188
190 const Index* get_num_slices() const
191 {
192 return _num_slices;
193 }
194
204 Index get_num_entities(int dim) const
205 {
206 XASSERT(dim >= 0);
207 XASSERT(dim <= shape_dim);
208 return _num_entities[dim];
209 }
210
216 {
217 return _num_entities[0];
218 }
219
225 {
226 return _num_entities[shape_dim];
227 }
228
231 {
232 return _vertex_set;
233 }
234
237 {
238 return _vertex_set;
239 }
240
253 template<
254 int cell_dim_,
255 int face_dim_>
257 {
258 return _index_set_holder.template get_index_set<cell_dim_, face_dim_>();
259 }
260
262 IndexSetHolderType& get_index_set_holder()
263 {
264 return _index_set_holder;
265 }
266
267 const IndexSetHolderType& get_index_set_holder() const
268 {
269 return _index_set_holder;
270 }
271
272 IndexSetHolderType* get_topology()
273 {
274 return &_index_set_holder;
275 }
276
277 const IndexSetHolderType* get_topology() const
278 {
279 return &_index_set_holder;
280 }
282
288 static String name()
289 {
290 return "StructuredMesh<...>";
291 }
292 }; // class StructuredMesh<...>
293
294 /* ************************************************************************************************************* */
295
301 template<
302 int shape_dim_,
303 int num_coords_,
304 typename Coord_>
305 class Factory< StructuredMesh<shape_dim_, num_coords_, Coord_> >
306 {
307 public:
312
313 public:
315 virtual ~Factory()
316 {
317 }
318
328 virtual Index get_num_slices(int dir) = 0;
329
336 virtual void fill_vertex_set(VertexSetType& vertex_set) = 0;
337 }; // class Factory<StructuredMesh<...>>
338
339 /* ************************************************************************************************************* */
340
346 template<
347 int shape_dim_,
348 int num_coords_,
349 typename Coord_>
350 class StandardRefinery<StructuredMesh<shape_dim_, num_coords_, Coord_> > :
351 public Factory< StructuredMesh<shape_dim_, num_coords_, Coord_> >
352 {
353 public:
360
362 static constexpr int shape_dim = ShapeType::dimension;
363
364 protected:
368 Index _num_slices_coarse[shape_dim];
369
370 public:
377 explicit StandardRefinery(const MeshType& coarse_mesh) :
378 _coarse_mesh(coarse_mesh)
379 {
380 for(int i(0); i < shape_dim; ++i)
381 {
382 _num_slices_coarse[i] = coarse_mesh.get_num_slices(i);
383 }
384 }
385
395 virtual Index get_num_slices(int dir) override
396 {
397 return 2 * _coarse_mesh.get_num_slices(dir);
398 }
399
406 virtual void fill_vertex_set(VertexSetType& vertex_set) override
407 {
408 // refine vertices
409 Intern::StructuredVertexRefiner<ShapeType, VertexSetType>
410 ::refine(vertex_set, _coarse_mesh.get_vertex_set(), _num_slices_coarse);
411 }
412 }; // class StandardRefinery<StructuredMesh<...>>
413 } // namespace Geometry
414} // namespace FEAT
#define XASSERT(expr)
Assertion macro definition.
Definition: assertion.hpp:262
virtual Index get_num_slices(int dir)=0
Returns the number of slices.
virtual void fill_vertex_set(VertexSetType &vertex_set)=0
Fills the vertex set.
StructuredMesh< shape_dim_, num_coords_, Coord_ > MeshType
mesh type
Mesh Factory class template.
Definition: factory.hpp:33
StructuredMesh< shape_dim_, num_coords_, Coord_ > MeshType
mesh type
virtual void fill_vertex_set(VertexSetType &vertex_set) override
Fills the vertex set.
virtual Index get_num_slices(int dir) override
Returns the number of slices.
Standard Refinery class template.
Definition: factory.hpp:58
Structured Index-Set class template.
Structured mesh class template.
Index get_num_slices(int dir) const
Returns the number of slices.
const Index * get_num_slices() const
Returns the num_slices array.
Shape::Hypercube< shape_dim_ > ShapeType
Shape type.
StructuredMesh(Factory< StructuredMesh > &factory)
Factory constructor.
Index get_num_entities(int dim) const
Returns the number of entities.
static constexpr int world_dim
world dimension
StructuredMesh(const StructuredMesh &other)
Copy Constructor.
VertexSetType _vertex_set
the vertex set of the mesh.
VertexSetType & get_vertex_set()
Returns a reference to the vertex set of the mesh.
Index _num_entities[shape_dim+1]
number of entities for each dimension
Index get_num_elements() const
Returns the number of elements.
static String name()
Returns the name of the class.
Coord_ CoordType
Coordinate type.
Index _num_slices[shape_dim]
number of slices for each direction
static constexpr bool is_structured
the mesh is structured
IndexSetHolderType _index_set_holder
index set holder
StructIndexSetHolder< shape_dim_ > IndexSetHolderType
index set holder type
static constexpr int shape_dim
shape dimension
VertexSet< num_coords_, Coord_ > VertexSetType
vertex set type
StructuredMesh(const Index num_slices[])
Constructor.
Index get_num_vertices() const
Returns the number of vertices.
virtual ~StructuredMesh()
virtual destructor
const VertexSetType & get_vertex_set() const
Returns a reference to the vertex set of the mesh.
const StructIndexSet< shape_dim_, cell_dim_, face_dim_ > & get_index_set() const
Returns a reference to an index set.
String class implementation.
Definition: string.hpp:46
@ other
generic/other permutation strategy
FEAT namespace.
Definition: adjactor.hpp:12
double Real
Real data type.
std::uint64_t Index
Index data type.
Index set type class template.
StructIndexSet< shape_dim_, cell_dim_, face_dim_ > Type
index set type
Fixed-Sized Vertex Set class template.
Definition: vertex_set.hpp:37
std::size_t bytes() const
Definition: vertex_set.hpp:145
Hypercube shape tag struct template.
Definition: shape.hpp:64