FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
adaptive_refinement_utils.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
9#include <kernel/shape.hpp>
10#include <kernel/util/tiny_algebra.hpp>
11
12#include <array>
13
14namespace FEAT::Geometry::Intern
15{
22 template<typename Shape_>
23 static std::array<Real, Shape::FaceTraits<Shape_, 0>::count>
24 vertex_coefficients(const Tiny::Vector<Real, Shape_::dimension>& vertex)
25 {
26 static_assert(Shape_::dimension >= 1, "Can't determine vertex coefficients for shape of this dimension!");
27 static_assert(Shape_::dimension <= 3, "Can't determine vertex coefficients for shape of this dimension!");
28
29 static constexpr int size = Shape::FaceTraits<Shape_, 0>::count;
30
31 if constexpr(Shape_::dimension == 1)
32 {
33 const Real x = vertex[0];
34
35 return std::array<Real, size>{
36 1.0 - x,
37 x,
38 };
39 }
40
41 if constexpr(Shape_::dimension == 2)
42 {
43 const Real x = vertex[0];
44 const Real y = vertex[1];
45 const Real xy = x * y;
46
47 return std::array<Real, size>{1 - x - y + xy, x - xy, y - xy, xy};
48 }
49
50 if constexpr(Shape_::dimension == 3)
51 {
52 const Real x = vertex[0];
53 const Real y = vertex[1];
54 const Real z = vertex[2];
55 const Real xy = x * y;
56 const Real xz = x * z;
57 const Real yz = y * z;
58 const Real xyz = x * y * z;
59
60 return std::array<Real, size>{
61 1 - x - y - z + xy + xz + yz - xyz,
62 x - xy - xz + xyz,
63 y - xy - yz + xyz,
64 xy - xyz,
65 z - xz - yz + xyz,
66 xz - xyz,
67 yz - xyz,
68 xyz};
69 }
70 }
71
78 template<typename VertexType_, std::size_t num_verts_>
79 VertexType_ static interpolate(
80 const std::array<VertexType_, num_verts_>& vertices,
81 const std::array<Real, num_verts_>& coeffs)
82 {
83 using CoordType = typename VertexType_::ValueType;
84 VertexType_ result(0);
85 for(Index i = 0; i < num_verts_; i++)
86 {
87 result += CoordType(coeffs[i]) * vertices[i];
88 }
89 return result;
90 }
91
92 template<typename ArrayLike_>
93 static ArrayLike_ rotate_arraylike_2d(const ArrayLike_& input)
94 {
95 ArrayLike_ result;
96
97 result[0] = input[2];
98 result[1] = input[0];
99 result[2] = input[3];
100 result[3] = input[1];
101
102 return result;
103 }
104
105 template<typename ArrayLike_>
106 static ArrayLike_ rotate_arraylike_xaxis(const ArrayLike_& input)
107 {
108 ArrayLike_ result;
109
110 result[0] = input[4];
111 result[1] = input[5];
112 result[2] = input[0];
113 result[3] = input[1];
114 result[4] = input[6];
115 result[5] = input[7];
116 result[6] = input[2];
117 result[7] = input[3];
118
119 return result;
120 }
121
122 template<typename ArrayLike_>
123 static ArrayLike_ rotate_arraylike_yaxis(const ArrayLike_& input)
124 {
125 ArrayLike_ result;
126
127 result[0] = input[1];
128 result[1] = input[5];
129 result[2] = input[3];
130 result[3] = input[7];
131 result[4] = input[0];
132 result[5] = input[4];
133 result[6] = input[2];
134 result[7] = input[6];
135
136 return result;
137 }
138
139 template<typename ArrayLike_>
140 static ArrayLike_ rotate_arraylike_zaxis(const ArrayLike_& input)
141 {
142 ArrayLike_ result;
143
144 result[0] = input[2];
145 result[1] = input[0];
146 result[2] = input[3];
147 result[3] = input[1];
148 result[4] = input[6];
149 result[5] = input[4];
150 result[6] = input[7];
151 result[7] = input[5];
152
153 return result;
154 }
155} // namespace FEAT::Geometry::Intern
FEAT Kernel base header.
double Real
Real data type.
std::uint64_t Index
Index data type.