9#include <kernel/assembly/base.hpp>
10#include <kernel/lafem/dense_vector.hpp>
11#include <kernel/lafem/dense_vector_blocked.hpp>
25 int max_dofs_ = Space_::template NodeFunctional<shape_dim_, typename Vector_::DataType>::Type::max_assigned_dofs>
26 struct InterpolatorCore
29 static void project(Vector_& vector,
const Function_& function,
const Space_& space)
31 typedef typename Vector_::DataType DataType;
34 typedef typename Space_::template NodeFunctional<shape_dim_, DataType>::Type NodeFunc;
36 typedef typename NodeFunc::template Value<Function_>::Type ValueType;
38 const Index num_entities = space.get_mesh().get_num_entities(shape_dim_);
40 Memory::TypedView<ValueType> vals = vector.elements_view_rw();
42 FEAT_PRAGMA_OMP(parallel)
45 NodeFunc node_func(space);
48 Tiny::Vector<ValueType, max_dofs_> node_data;
51 typedef typename Space_::template DofAssignment<shape_dim_, DataType>::Type DofAssignType;
52 DofAssignType dof_assign(space);
60 for(Index i = 0; i < num_entities; ++i)
64 node_func(node_data, function);
68 dof_assign.prepare(i);
71 const int num_dofs = dof_assign.get_num_assigned_dofs();
72 for(
int j(0); j < num_dofs; ++j)
74 vals[dof_assign.get_index(j)] += node_data[j];
84 template<
typename Vector_,
typename Function_,
typename Space_,
int shape_dim_>
85 struct InterpolatorCore<Vector_, Function_, Space_, shape_dim_, 0>
87 static void project(Vector_&,
const Function_&,
const Space_&)
93 template<
typename Space_,
int shape_dim_ = Space_::shape_dim>
94 class InterpolatorWrapper
97 template<
typename Vector_,
typename Function_>
98 static void project(Vector_& vector,
const Function_& function,
const Space_& space)
101 InterpolatorWrapper<Space_, shape_dim_ - 1>::project(vector, function, space);
104 InterpolatorCore<Vector_, Function_, Space_, shape_dim_>::project(vector, function, space);
108 template<
typename Space_>
109 class InterpolatorWrapper<Space_, 0>
112 template<
typename Vector_,
typename Function_>
113 static void project(Vector_& vector,
const Function_& function,
const Space_& space)
116 InterpolatorCore<Vector_, Function_, Space_, 0>::project(vector, function, space);
154 const Function_& function,
157 typedef typename Space_::TrafoType TrafoType;
158 typedef typename Function_::ImageType ImageType;
161 static_assert(Function_::domain_dim == TrafoType::world_dim,
"invalid function domain dimension");
162 static_assert(ImageType::is_scalar,
"only scalar functions can be interpolated to scalar vectors");
166 Intern::InterpolatorWrapper<Space_>::project(vector, function, space);
191 const Function_& function,
194 typedef typename Space_::TrafoType TrafoType;
195 typedef typename Function_::ImageType ImageType;
198 static_assert(Function_::domain_dim == TrafoType::world_dim,
"invalid function domain dimension");
199 static_assert(ImageType::is_vector,
"only vector fields can be interpolated to blocked vectors");
200 static_assert(ImageType::image_dim == block_size_,
"invalid vector field size");
204 Intern::InterpolatorWrapper<Space_>::project(vector, function, space);
Interpolator class template.
static void project(LAFEM::DenseVector< DT_, IT_ > &vector, const Function_ &function, const Space_ &space)
Interpolates a scalar function.
static void project(LAFEM::DenseVectorBlocked< DT_, IT_, block_size_ > &vector, const Function_ &function, const Space_ &space)
Interpolates a vector field.
Blocked Dense data vector class template.
Dense data vector class template.
std::uint64_t Index
Index data type.