FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
node_functional.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#include <kernel/space/node_functional_base.hpp>
11
12namespace FEAT
13{
14 namespace Space
15 {
16 namespace CaiDouSanSheYe
17 {
18 template<
19 typename Space_,
20 typename Shape_,
21 int codim_,
22 typename DataType_>
24 public NodeFunctionalNull<Space_, DataType_>
25 {
26 public:
27 explicit NodeFunctional(const Space_& space) :
29 {
30 }
31 };
32
38 template<
39 typename Space_,
40 int shape_dim_,
41 typename DataType_>
42 class NodeFunctional<Space_, Shape::Hypercube<shape_dim_>, 1, DataType_> :
43 public NodeFunctionalBase<Space_, DataType_>
44 {
45 public:
47 static constexpr int max_assigned_dofs = 1;
48
49 template<typename Function_>
50 struct Value
51 {
53 };
54
55 protected:
56 typedef typename Space_::TrafoType TrafoType;
57 typedef typename Space_::ShapeType ShapeType;
58 typedef typename Shape::FaceTraits<ShapeType, ShapeType::dimension-1>::ShapeType FacetType;
59 typedef typename TrafoType::template Evaluator<FacetType, DataType_>::Type TrafoEvalType;
60 typedef typename TrafoEvalType::EvalTraits TrafoEvalTraits;
61 typedef typename TrafoEvalTraits::DataType DataType;
62 typedef typename TrafoEvalTraits::DomainPointType DomainPointType;
63
64 static constexpr int image_dim = TrafoEvalTraits::image_dim;
65
66 typedef typename TrafoEvalType::template ConfigTraits<TrafoTags::img_point>::EvalDataType TrafoEvalData;
67
68 TrafoEvalType _trafo_eval;
69 DomainPointType _barycentre;
70
71 public:
72 explicit NodeFunctional(const Space_& space) :
73 BaseClass(space),
74 _trafo_eval(space.get_trafo())
75 {
76 _barycentre.format();
77 }
78
79 void prepare(Index cell_index)
80 {
81 BaseClass::prepare(cell_index);
82 _trafo_eval.prepare(cell_index);
83 }
84
85 void finish()
86 {
87 _trafo_eval.finish();
89 }
90
91 int get_num_assigned_dofs() const
92 {
93 return max_assigned_dofs;
94 }
95
96 template<typename NodeData_, typename Function_>
97 void operator()(NodeData_& node_data, const Function_& function) const
98 {
99 static_assert(std::is_base_of<Analytic::Function, Function_>::value, "invalid function object");
100
101 // declare our evaluation traits
102 typedef Analytic::EvalTraits<DataType_, Function_> FuncEvalTraits;
103
104 // declare function evaluator
105 typename Function_::template Evaluator<FuncEvalTraits> func_eval(function);
106
107 // compute trafo data
108 TrafoEvalData trafo_data;
109 _trafo_eval(trafo_data, _barycentre);
110
111 // evaluate function
112 node_data[0] = func_eval.value(trafo_data.img_point);
113 }
114 };
115
116
122 template<
123 typename Space_,
124 int shape_dim_,
125 typename DataType_>
126 class NodeFunctional<Space_, Shape::Hypercube<shape_dim_>, 0, DataType_> :
127 public NodeFunctionalBase<Space_, DataType_>
128 {
129 public:
131 static constexpr int max_assigned_dofs = 1;
132
133 template<typename Function_>
134 struct Value
135 {
137 };
138
139 protected:
140 typedef typename Space_::TrafoType TrafoType;
141 typedef typename Space_::ShapeType ShapeType;
142 typedef typename TrafoType::template Evaluator<ShapeType, DataType_>::Type TrafoEvalType;
143 typedef typename TrafoEvalType::EvalTraits TrafoEvalTraits;
144 typedef typename TrafoEvalTraits::DataType DataType;
145 typedef typename TrafoEvalTraits::DomainPointType DomainPointType;
146
147 //static constexpr int image_dim = TrafoEvalTraits::image_dim;
148
149 typedef typename TrafoEvalType::template ConfigTraits<TrafoTags::img_point>::EvalDataType TrafoEvalData;
150
151 TrafoEvalType _trafo_eval;
152
153 public:
154 explicit NodeFunctional(const Space_& space) :
155 BaseClass(space),
156 _trafo_eval(space.get_trafo())
157 {
158 }
159
160 void prepare(Index cell_index)
161 {
162 BaseClass::prepare(cell_index);
163 _trafo_eval.prepare(cell_index);
164 }
165
166 void finish()
167 {
168 _trafo_eval.finish();
170 }
171
172 int get_num_assigned_dofs() const
173 {
174 return max_assigned_dofs;
175 }
176
177 template<typename NodeData_, typename Function_>
178 void operator()(NodeData_& node_data, const Function_& function) const
179 {
180 static_assert(std::is_base_of<Analytic::Function, Function_>::value, "invalid function object");
181
182 // declare our evaluation traits
183 typedef Analytic::EvalTraits<DataType_, Function_> FuncEvalTraits;
184
185 // declare function evaluator
186 typename Function_::template Evaluator<FuncEvalTraits> func_eval(function);
187 typename FuncEvalTraits::ValueType value(DataType_(0));
188
189 TrafoEvalData trafo_data;
190
191 // 2-point Gauss quadrature point
192 const DataType g2 = DataType(FEAT_F128C(0.57735026918962576450914878050195745564760175127));
193
194 DomainPointType dom_point;
195
196 // integrate f(x,y)*x*y on the reference element
197 for(int i(0); i < (1 << shape_dim_); ++i)
198 {
199 // set cubature shape_dim_
200 DataType_ aux = DataType(1);
201 for(int j(0); j < shape_dim_; ++j)
202 aux *= (dom_point[j] = Shape::ReferenceCell<ShapeType>::template vertex<DataType>(i, j) * g2);
203 _trafo_eval(trafo_data, dom_point);
204 value += aux * func_eval.value(trafo_data.img_point);
205 }
206
207 // set integral mean
208 node_data[0] = (DataType_(1) / DataType_(1 << shape_dim_)) * value;
209 }
210 };
211 } // namespace CaiDouSanSheYe
212 } // namespace Space
213} // namespace FEAT
FEAT Kernel base header.
Cai-Douglas-Santos-Sheen-Ye Element Evaluator class template declaration.
Definition: evaluator.hpp:34
Node-functional base class template.
void finish()
Releases the node-functional from the current cell.
void prepare(Index cell_index)
Prepares the node-functional for a given cell.
Null-Node-Functional class template.
int get_num_assigned_dofs() const
Returns the number of assigned dofs on the current cell.
NodeFunctionalBase< Space_, DataType_ > BaseClass
base-class typedef
void operator()(NodeData_ &node_data, const Function_ &function) const
Evaluation operator.
FEAT namespace.
Definition: adjactor.hpp:12
@ value
specifies whether the space should supply basis function values
std::uint64_t Index
Index data type.
@ dom_point
specifies whether the trafo should supply domain point coordinates
Face traits tag struct template.
Definition: shape.hpp:106