FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
space_helper.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// base FEAT includes
10#include <kernel/shape.hpp>
11#include <kernel/trafo/standard/mapping.hpp>
12#include <kernel/geometry/conformal_mesh.hpp>
13
14// space includes
15#include <kernel/space/eval_data.hpp>
16#include <kernel/space/details.hpp>
17#include <kernel/space/lagrange2/element.hpp>
18#include <kernel/space/lagrange2/details.hpp>
19
20namespace FEAT
21{
22 namespace VoxelAssembly
23 {
24 template<typename IndexType_>
26 {
27 public:
28 typedef IndexType_ IndexType;
29 const IndexType* cell_to_dofs;
30 IndexType num_loc_dofs;
31
32 CUDA_HOST_DEVICE IndexType operator()(IndexType cell_index, IndexType vert_index) const
33 {
34 return *(cell_to_dofs + cell_index*num_loc_dofs + vert_index);
35 }
36
37 CUDA_HOST_DEVICE IndexSetWrapper(const IndexType* _cell_t, IndexType numi)
38 :
39 cell_to_dofs(_cell_t),
40 num_loc_dofs(numi)
41 {}
42
43 CUDA_HOST_DEVICE IndexSetWrapper(const IndexSetWrapper&) = delete;
44
45 };//class IndexSetWrapper
46
47 template<typename IndexType_>
49 {
50 public:
51 typedef IndexType_ IndexType;
52 const IndexType* loc_cell_to_dofs;
53
54 CUDA_HOST_DEVICE IndexType operator()(IndexType DOXY(cell_index), IndexType vert_index) const
55 {
56 return *(loc_cell_to_dofs + vert_index);
57 }
58
59 CUDA_HOST_DEVICE SharedIndexSetWrapper(const IndexType* _cell_t)
60 :
61 loc_cell_to_dofs(_cell_t)
62 {}
63
64 CUDA_HOST_DEVICE SharedIndexSetWrapper(const SharedIndexSetWrapper&) = delete;
65
66 };
67
68 template<typename VertexType_>
70 {
71 public:
72 typedef VertexType_ VertexType;
73 const VertexType* vert_array;
74
75 CUDA_HOST_DEVICE VertexType operator[](Index index) const
76 {
77 return vert_array[index];
78 }
79
80 CUDA_HOST_DEVICE VertexSetWrapper(const VertexType* _verts)
81 :
82 vert_array(_verts)
83 {}
84
85 CUDA_HOST_DEVICE VertexSetWrapper(const VertexSetWrapper&) = delete;
86
87 };//class VertexSetWrapper
88
90 template<typename Shape_>
92
93 template<typename Space_, typename DT_, typename IT_>
95
96 template<typename Shape_, typename DT_, typename IT_>
97 struct SpaceHelper<Q2StandardFE<Shape_>, DT_, IT_>
98 {
100 typedef Shape_ ShapeType;
101 typedef IT_ IndexType;
102
104 static constexpr int dim = SpaceType::world_dim;
105
107 typedef DT_ ValueType;
108
111
114
117
120
123
126
129
132
135
138
140 struct EvalTraits
141 {
142 typedef DT_ DataType;
143 typedef DataType BasisValueType;
144 typedef DataType BasisReferenceValueType;
149 static constexpr int max_local_dofs = SpaceEvalHelp::get_num_local_dofs();
150 };
151
152 typedef typename EvalTraits::DataType DataType;
153
158
159 static constexpr int num_verts = TrafoEvalHelp::num_verts;
160
162 static constexpr SpaceTags config = SpaceTags::none;
163
166 static constexpr bool reduced_data = true;
167
169 CUDA_HOST_DEVICE static inline void eval_ref_values(EvalData& data, const DomainPointType& point)
170 {
171 SpaceEvalHelp::eval_ref_values(data, point);
172 }
173
174 #ifdef __CUDACC__
176 template<typename ThreadGroup_>
177 CUDA_DEVICE static __forceinline__ void group_eval_ref_values(const ThreadGroup_& tg, EvalData& data, const DomainPointType& point)
178 {
179 SpaceEvalHelp::group_eval_ref_values(tg, data, point);
180 }
181 #endif
182
184 CUDA_HOST_DEVICE static inline void eval_ref_gradients(EvalData& data, const DomainPointType& point)
185 {
186 SpaceEvalHelp::eval_ref_gradients(data, point);
187 }
188
190 CUDA_HOST_DEVICE static inline void eval_ref_hessians(EvalData& data, const DomainPointType& point)
191 {
192 SpaceEvalHelp::eval_ref_hessians(data, point);
193 }
194
195 CUDA_HOST_DEVICE static inline void set_coefficients(Tiny::Matrix<DataType, dim, num_verts>& coeffs, const IndexSetWrapper<IndexType>& local_dofs, const VertexPointType* vertex_set, IndexType cell_index)
196 {
197 TrafoEvalHelp::set_coefficients(coeffs, VertexSetWrapper(vertex_set), local_dofs, cell_index);
198 }
199
200 #ifdef __CUDACC__
201 template<typename ThreadGroup_>
202 CUDA_DEVICE static inline void grouped_set_coefficients(const ThreadGroup_& tg, DataType* coeffs, const SharedIndexSetWrapper<IndexType>& local_dofs, const VertexPointType* vertex_set, IndexType cell_index)
203 {
204 TrafoEvalHelp::grouped_set_coefficients(tg, coeffs, VertexSetWrapper(vertex_set), local_dofs, cell_index);
205 }
206 #endif
207
208 CUDA_HOST_DEVICE static inline void map_point(typename TrafoEvalHelp::ImagePointType& img_point, const typename TrafoEvalHelp::DomainPointType& dom_point, const Tiny::Matrix<DataType, dim, num_verts>& coeffs)
209 {
210 TrafoEvalHelp::map_point(img_point, dom_point, coeffs);
211 }
212
213 CUDA_HOST_DEVICE static inline void calc_jac_mat(typename TrafoEvalHelp::JacobianMatrixType& jac_mat, const typename TrafoEvalHelp::DomainPointType& dom_point, const Tiny::Matrix<DataType, dim, num_verts>& coeffs)
214 {
215 TrafoEvalHelp::calc_jac_mat(jac_mat, dom_point, coeffs);
216 }
217
218 #ifdef __CUDACC__
219 template<typename ThreadGroup_>
220 CUDA_DEVICE static inline void grouped_calc_jac_mat(const ThreadGroup_& tg, typename TrafoEvalHelp::JacobianMatrixType& jac_mat, const typename TrafoEvalHelp::DomainPointType& dom_point, const DataType* coeffs)
221 {
222 TrafoEvalHelp::grouped_calc_jac_mat(tg, jac_mat, dom_point, coeffs);
223 }
224 #endif
225
226 CUDA_HOST_DEVICE static inline void calc_hess_ten(typename TrafoEvalHelp::HessianTensorType& hess_ten, const typename TrafoEvalHelp::DomainPointType& dom_point, const Tiny::Matrix<DataType, dim, num_verts>& coeffs)
227 {
228 TrafoEvalHelp::calc_jac_mat(hess_ten, dom_point, coeffs);
229 }
230
231 CUDA_HOST_DEVICE static inline DataType volume(const Tiny::Matrix<DataType, dim, num_verts>& coeffs)
232 {
233 return TrafoEvalHelp::volume(coeffs);
234 }
235
236 CUDA_HOST_DEVICE static inline DataType width_directed(const typename TrafoEvalHelp::ImagePointType& ray, const Tiny::Matrix<DataType, dim, num_verts>& coeffs)
237 {
238 return TrafoEvalHelp::width_directed(ray, coeffs);
239 }
240
241 CUDA_HOST_DEVICE static inline void trans_values(EvalData& data)
242 {
243 if constexpr(!reduced_data)
244 ParamEvalHelp::trans_values(data);
245 }
246
247 CUDA_HOST_DEVICE static inline void trans_gradients(EvalData& data, const typename TrafoEvalHelp::JacobianInverseType& jac_inv)
248 {
249 // if constexpr(!reduced_data)
250 ParamEvalHelp::trans_gradients(data, jac_inv);
251 // else
252 // ParamEvalHelp::inplace_trans_gradients(data, jac_inv);
253 }
254
255 CUDA_HOST_DEVICE static inline void trans_hessian(EvalData& data, const typename TrafoEvalHelp::JacobianInverseType& jac_inv, const typename TrafoEvalHelp::HessianInverseType& hess_inv)
256 {
257 ParamEvalHelp::trans_hessians(data, jac_inv, hess_inv);
258 }
259
260 };
261
262 }
263
264}
FEAT Kernel base header.
Reduced Space evaluation data structure.
Definition: eval_data.hpp:174
Standard Lagrange-2 Finite-Element space class template.
Definition: element.hpp:39
Tiny Matrix class template.
Tiny Tensor3 class template.
Tiny Vector class template.
FEAT namespace.
Definition: adjactor.hpp:12
SpaceTags
Space configuration tags enum.
Definition: eval_tags.hpp:97
std::uint64_t Index
Index data type.
@ img_point
specifies whether the trafo should supply image point coordinates
@ hess_inv
specifies whether the trafo should supply inverse hessian tensors
@ dom_point
specifies whether the trafo should supply domain point coordinates
@ hess_ten
specifies whether the trafo should supply hessian tensors
@ jac_inv
specifies whether the trafo should supply inverse jacobian matrices
@ jac_mat
specifies whether the trafo should supply jacobian matrices
Evalautator helper class for standard trafo.
Definition: details.hpp:48
static CUDA_HOST_DEVICE void eval_ref_values(EvalData &data, const DomainPointType &point)
Ref value calculation.
Tiny::Tensor3< DT_, dim, dim, dim > HessianTensorType
hessian tensor type
Space::Lagrange2::EvalHelper< DomainPointType, DT_, ShapeType > SpaceEvalHelp
The space helper detail class.
Space::EvalDataReduced< EvalTraits, config > EvalData
The eval data wrapping the basis functions.
Tiny::Vector< DT_, dim > VertexPointType
The vertex point type.
Tiny::Matrix< DT_, dim, dim > JacobianInverseType
jacobian inverse matrix type
Tiny::Tensor3< DT_, dim, dim, dim > HessianInverseType
hessian inverse tensor type
Tiny::Vector< DT_, dim > ImagePointType
The image point type.
Tiny::Matrix< DT_, dim, dim > JacobianMatrixType
jacobian matrix type
Space::ParametricEvalHelper ParamEvalHelp
Parametric eval helper.
static CUDA_HOST_DEVICE void eval_ref_gradients(EvalData &data, const DomainPointType &point)
Ref value calculation.
static CUDA_HOST_DEVICE void eval_ref_hessians(EvalData &data, const DomainPointType &point)
ref value calculation
Trafo::Standard::EvalHelper< DataType, DomainPointType, ImagePointType, JacobianMatrixType, JacobianInverseType, JacobianDeterminantType, HessianTensorType, HessianInverseType, ShapeType, dim > TrafoEvalHelp
The trafo helper detail class.
Tiny::Vector< DT_, dim > DomainPointType
The domainpoint type.