FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
entity_counter.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/shape.hpp>
10
11namespace FEAT
12{
13 namespace Geometry
14 {
16 namespace Intern
17 {
26 template<
27 template<typename,int> class RefineTraits_,
28 typename Shape_,
29 int face_dim_,
30 int cell_dim_ = Shape_::dimension>
31 struct EntityCounter
32 {
33 static_assert(face_dim_ >= 0, "invalid face dimension");
34 static_assert(face_dim_ < cell_dim_, "invalid cell/face dimension");
35 static_assert(cell_dim_ <= Shape_::dimension, "invalid cell dimension");
36
37 static String name()
38 {
39 return "EntityCounter<" + Shape_::name() + "," + stringify(face_dim_) + "," + stringify(cell_dim_) + ">";
40 }
41
42 static Index count(const Index num_entities[])
43 {
44 typedef typename Shape::FaceTraits<Shape_, cell_dim_>::ShapeType CellType;
45 return EntityCounter<RefineTraits_, Shape_, face_dim_, cell_dim_-1>::count(num_entities) +
46 RefineTraits_<CellType, face_dim_>::count * num_entities[cell_dim_];
47 }
48
49 static void offset(Index offsets[], const Index num_entities[])
50 {
51 EntityCounter<RefineTraits_, Shape_, face_dim_, cell_dim_-1>::offset(offsets, num_entities);
52 offsets[cell_dim_] = EntityCounter<RefineTraits_, Shape_, face_dim_, cell_dim_-1>::count(num_entities);
53 }
54 }; // struct EntityCounter<...>
55
56 template<
57 template<typename,int> class RefineTraits_,
58 typename Shape_,
59 int cell_dim_>
60 struct EntityCounter<RefineTraits_, Shape_, cell_dim_, cell_dim_>
61 {
62 static_assert(cell_dim_ >= 0, "invalid cell/face dimension");
63 static_assert(cell_dim_ <= Shape_::dimension, "invalid cell dimension");
64
65 static String name()
66 {
67 return "EntityCounter<" + Shape_::name() + "," + stringify(cell_dim_) + ">";
68 }
69
70 static Index count(const Index num_entities[])
71 {
72 typedef typename Shape::FaceTraits<Shape_, cell_dim_>::ShapeType CellType;
73 return RefineTraits_<CellType, cell_dim_>::count * num_entities[cell_dim_];
74 }
75
76 static void offset(Index offsets[], const Index* /*num_entities[]*/)
77 {
78 offsets[cell_dim_] = 0;
79 }
80 }; // struct EntityCounter<Shape_, cell_dim_, cell_dim_>
81
90 template<
91 template<typename,int> class RefineTraits_,
92 typename Shape_,
93 int face_dim_ = Shape_::dimension>
94 struct EntityCountWrapper
95 {
96 static_assert(face_dim_ > 0, "invalid face dimension");
97 static_assert(face_dim_ <= Shape_::dimension, "invalid face dimension");
98
104 static String name()
105 {
106 return "EntityCounterWrapper<" + Shape_::name() + "," + stringify(face_dim_) + ">";
107 }
108
117 static void query(Index num_entities[])
118 {
119 EntityCountWrapper<RefineTraits_, Shape_, face_dim_-1>::query(num_entities);
120 num_entities[face_dim_] = EntityCounter<RefineTraits_, Shape_, face_dim_>::count(num_entities);
121 }
122 }; // struct EntityCounter<...>
123
124 template<
125 template<typename,int> class RefineTraits_,
126 typename Shape_>
127 struct EntityCountWrapper<RefineTraits_, Shape_, 0>
128 {
129 static String name()
130 {
131 return "EntityCounterWrapper<" + Shape_::name() + ",0>";
132 }
133
134 static void query(Index num_entities[])
135 {
136 num_entities[0] = EntityCounter<RefineTraits_, Shape_, 0>::count(num_entities);
137 }
138 }; // struct EntityCountWrapper<Shape_, 0>
139 } // namespace Intern
141 } // namespace Geometry
142} // namespace FEAT
FEAT namespace.
Definition: adjactor.hpp:12
String stringify(const T_ &item)
Converts an item into a String.
Definition: string.hpp:944
std::uint64_t Index
Index data type.