10#include <kernel/lafem/dense_vector.hpp>
11#include <kernel/lafem/dense_vector_blocked.hpp>
12#include <kernel/space/lagrange1/element.hpp>
13#include <kernel/space/lagrange2/element.hpp>
14#include <kernel/util/math.hpp>
37 template<
typename ToSpace_,
typename FromSpace_>
57 template<
typename Trafo_,
int shape_dim_ = Trafo_::MeshType::shape_dim>
84 template<
typename Vector_>
85 static void recurse(Vector_& to_coeffs,
const Vector_& from_coeffs,
const ToSpace& to_space)
87 typedef typename Vector_::DataType DataType;
89 const auto& mesh = to_space.
get_trafo().get_mesh();
92 const auto& from_vertex_at_shape_idx = mesh.template get_index_set<shape_dim_, 0>();
95 typename ToSpace::template DofAssignment<shape_dim_, DataType>::Type to_dof_assignment(to_space);
97 for(
Index k(0); k < mesh.get_num_entities(shape_dim_); ++k)
99 to_dof_assignment.prepare(k);
102 for(
int j(0); j < to_dof_assignment.get_num_assigned_dofs(); ++j)
105 typename Vector_::ValueType tmp(0);
107 for(
int i(0); i < from_vertex_at_shape_idx.get_num_indices(); ++i)
109 tmp += from_coeffs(from_vertex_at_shape_idx(k,i));
113 tmp *= ( DataType(1)/DataType(from_vertex_at_shape_idx.get_num_indices()) );
116 to_coeffs(to_dof_assignment.get_index(j), tmp);
132 template<
typename Trafo_>
157 template<
typename Vector_>
158 static void recurse(Vector_& to_coeffs,
const Vector_& from_coeffs,
const ToSpace& to_space)
161 const auto& mesh = to_space.
get_trafo().get_mesh();
163 for(
Index i(0); i < mesh.get_num_entities(0); ++i)
165 to_coeffs(i, from_coeffs(i));
179 template<
typename Trafo_>
211 template<
typename DT_,
typename IT_>
242 template<
typename DT_,
typename IT_,
int blocksize_>
260 template<
typename Trafo_>
292 template<
typename DT_,
typename IT_>
299 XASSERTM(to_coeffs.
size() < from_coeffs.
size(),
"Coefficient vectors do not match!\n To_coeffs size is ");
301 for(
Index i(0); i < to_coeffs.
size(); ++i)
303 to_coeffs(i, from_coeffs(i));
330 template<
typename DT_,
typename IT_,
int blocksize_>
337 XASSERTM(to_coeffs.
size() < from_coeffs.
size(),
"Coefficient vectors do not match!\n To_coeffs size is ");
339 for(
Index i(0); i < to_coeffs.
size(); ++i)
341 to_coeffs(i, from_coeffs(i));
356 template<
typename Space_>
359 typedef Space_ ToSpace;
361 typedef Space_ FromSpace;
387 template<
typename Vector_>
389 const Vector_& from_coeffs,
390 const ToSpace& DOXY(to_space),
391 const FromSpace& DOXY(from_space))
393 to_coeffs.copy(from_coeffs,
true);
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Index size() const
Returns the containers size.
Blocked Dense data vector class template.
Index size() const
The number of elements.
Dense data vector class template.
TrafoType & get_trafo()
Returns a reference to the trafo.
Standard Lagrange-1 Finite-Element space class template.
Standard Lagrange-2 Finite-Element space class template.
std::uint64_t Index
Index data type.
static void interpolate(LAFEM::DenseVectorBlocked< DT_, IT_, blocksize_ > &to_coeffs, const LAFEM::DenseVectorBlocked< DT_, IT_, blocksize_ > &from_coeffs, const ToSpace &to_space, const FromSpace &from_space)
Interpolates a vector Lagrange1 to Lagrange2 FE function.
Space::Lagrange2::Element< Trafo_ > FromSpace
We map from Lagrange2.
Space::Lagrange1::Element< Trafo_ > ToSpace
We map to Lagrange1.
Trafo_ TrafoType
Our trafo.
static void interpolate(LAFEM::DenseVector< DT_, IT_ > &to_coeffs, const LAFEM::DenseVector< DT_, IT_ > &from_coeffs, const ToSpace &to_space, const FromSpace &from_space)
Interpolates a scalar Lagrange1 to Lagrange2 FE function.
Space::Lagrange2::Element< Trafo_ > ToSpace
We map to Lagrange2.
Trafo_ TrafoType
Our trafo.
Space::Lagrange1::Element< Trafo_ > FromSpace
We map from Lagrange1.
static void interpolate(LAFEM::DenseVectorBlocked< DT_, IT_, blocksize_ > &to_coeffs, const LAFEM::DenseVectorBlocked< DT_, IT_, blocksize_ > &from_coeffs, const ToSpace &to_space, const FromSpace &from_space)
Interpolates a vector valued Lagrange1 to Lagrange2 FE function.
static void interpolate(LAFEM::DenseVector< DT_, IT_ > &to_coeffs, const LAFEM::DenseVector< DT_, IT_ > &from_coeffs, const ToSpace &to_space, const FromSpace &from_space)
Interpolates a scalar Lagrange1 to Lagrange2 FE function.
static void interpolate(Vector_ &to_coeffs, const Vector_ &from_coeffs, const ToSpace &to_space, const FromSpace &from_space)
Interpolates a scalar/vector FE function on the same space by just copying the vector.
Interpolation operator between two finite element spaces.
static void recurse(Vector_ &to_coeffs, const Vector_ &from_coeffs, const ToSpace &to_space)
Evaluates the node functionals for shape dimension 0.
Helper class that recurses through shape dimensions and evaluates Lagrange2 DoF based on Lagrange1 Do...
static void recurse(Vector_ &to_coeffs, const Vector_ &from_coeffs, const ToSpace &to_space)
Evaluates the node functionals from shape_dim_ on down to shape dimension 0.
Space::Lagrange2::Element< Trafo_ > ToSpace
We map to Lagrange2.
Space::Lagrange1::Element< Trafo_ > FromSpace
We map from Lagrange1.