Interpolation.hpp 1.74 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once

#include <memory>

#include <dune/functions/functionspacebases/interpolate.hh>
#include <dune/functions/gridfunctions/discreteglobalbasisfunction.hh>

#include <dune/amdis/terms/GridViewExpression.hpp>
#include <dune/amdis/terms/TermGenerator.hpp>

namespace AMDiS
{
  template <class... Args, class PreExpr>
  auto operator<<(std::shared_ptr<Dune::Functions::DiscreteGlobalBasisFunction<Args...>> const& dofvector,
                  PreExpr&& preExpr)
  {
    using DiscreteGlobalBasisFct = Dune::Functions::DiscreteGlobalBasisFunction<Args...>;
    typename ToTerm<PreExpr>::type expr = toTerm(std::forward<PreExpr>(preExpr));

    using Vector = typename DiscreteGlobalBasisFct::Vector;
    Vector vec(dofvector->basis(), "tmp");

    auto gridViewExpr = makeGridViewExpression(expr, dofvector->basis().gridView());
    Dune::Functions::interpolate(dofvector->basis(), dofvector->treePath(), vec, gridViewExpr);

    const_cast<Vector&>(dofvector->dofs()).getVector() = vec.getVector();
    return dofvector;
  }

  template <class... Args, class PreExpr>
  auto& operator<<(Dune::Functions::DiscreteGlobalBasisFunction<Args...>& dofvector,
                   PreExpr& preExpr)
  {
    using DiscreteGlobalBasisFct = Dune::Functions::DiscreteGlobalBasisFunction<Args...>;
    typename ToTerm<PreExpr>::type expr = toTerm(std::forward<PreExpr>(preExpr));

    using Vector = typename DiscreteGlobalBasisFct::Vector;
    Vector vec(dofvector.basis(), "tmp");

    auto gridViewExpr = makeGridViewExpression(expr, dofvector.basis().gridView());
    Dune::Functions::interpolate(dofvector.basis(), dofvector.treePath(), vec, gridViewExpr);

    const_cast<Vector&>(dofvector.dofs()).getVector() = vec.getVector();
    return dofvector;
  }

} // end namespace AMDiS