FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
struct_num_entities.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
10
11namespace FEAT
12{
13 namespace Geometry
14 {
16 namespace Intern
17 {
26 template<
27 int shape_dim_,
28 int face_dim_>
29 struct StructNumEntities DOXY({});
30
31 template<int shape_dim_>
32 struct StructNumEntities<shape_dim_, shape_dim_>
33 {
34 static Index compute(const Index num_slices[])
35 {
36 // compute number of elements
37 Index count = num_slices[0];
38 for(int i(1); i < shape_dim_; ++i)
39 count *= (num_slices[i]);
40 return count;
41 }
42 };
43
44 template<int shape_dim_>
45 struct StructNumEntities<shape_dim_, 0>
46 {
47 static Index compute(const Index num_slices[])
48 {
49 // compute number of vertices
50 Index count = num_slices[0] + 1;
51 for(int i(1); i < shape_dim_; ++i)
52 count *= (num_slices[i] + 1);
53 return count;
54 }
55 };
56
57 template<>
58 struct StructNumEntities<2, 1>
59 {
60 static Index compute(const Index num_slices[])
61 {
62 // compute number of edges in quad mesh
63 return
64 num_slices[0] * (num_slices[1] + 1) +
65 num_slices[1] * (num_slices[0] + 1);
66 }
67 };
68
69 template<>
70 struct StructNumEntities<3, 1>
71 {
72 static Index compute(const Index num_slices[])
73 {
74 // compute number of edges in hexa mesh
75 return
76 num_slices[0] * (num_slices[1] + 1) * (num_slices[2] + 1) +
77 num_slices[1] * (num_slices[0] + 1) * (num_slices[2] + 1) +
78 num_slices[2] * (num_slices[0] + 1) * (num_slices[1] + 1);
79 }
80 };
81
82 template<>
83 struct StructNumEntities<3, 2>
84 {
85 static Index compute(const Index num_slices[])
86 {
87 // compute number of quads in hexa mesh
88 return
89 (num_slices[0] + 1) * num_slices[1] * num_slices[2] +
90 (num_slices[1] + 1) * num_slices[0] * num_slices[2] +
91 (num_slices[2] + 1) * num_slices[0] * num_slices[1];
92 }
93 };
94
103 template<
104 int shape_dim_,
105 int cell_dim_ = shape_dim_>
106 struct StructNumEntitiesWrapper
107 {
108 static void compute(Index num_entities[], const Index num_slices[])
109 {
110 StructNumEntitiesWrapper<shape_dim_, cell_dim_ - 1>::compute(num_entities, num_slices);
111 num_entities[cell_dim_] = StructNumEntities<shape_dim_, cell_dim_>::compute(num_slices);
112 }
113 };
114
115 template<int shape_dim_>
116 struct StructNumEntitiesWrapper<shape_dim_, 0>
117 {
118 static void compute(Index num_entities[], const Index num_slices[])
119 {
120 num_entities[0] = StructNumEntities<shape_dim_, 0>::compute(num_slices);
121 }
122 };
123 } // namespace Intern
125 } // namespace Geometry
126} // namespace FEAT
FEAT Kernel base header.
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.