DiscreteFunction.hpp 1.35 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
#pragma once

#include <memory>

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

#include <dune/amdis/utility/RangeType.hpp>

namespace AMDiS
{
  namespace Impl
  {
    template <class GlobalBasis, class TP, class Vector = DOFVector<GlobalBasis>>
    struct DiscreteFunction
    {
      using Tree = typename GlobalBasis::LocalView::Tree;
      using Node = typename Dune::TypeTree::ChildForTreePath<Tree, TP>;
      using Range = AMDiS::RangeType<Node>;
      using NTRM = Dune::Functions::DefaultNodeToRangeMap<Node>;

      using type = Dune::Functions::DiscreteGlobalBasisFunction<GlobalBasis,TP,Vector,NTRM,Range>;
    };

  } // end namespace Impl


  template <class GlobalBasis, class TreePath, class Vector>
29
30
31
  auto makeDiscreteFunctionPtr(std::shared_ptr<GlobalBasis> const& basis,
                               TreePath const& tp,
                               std::shared_ptr<Vector> const& vec)
32
33
34
35
36
37
38
39
40
  {
    using NTRM = typename Impl::DiscreteFunction<GlobalBasis,TreePath,Vector>::NTRM;
    using DiscreteFunction = typename Impl::DiscreteFunction<GlobalBasis,TreePath,Vector>::type;

    auto nodeToRange = std::make_shared<NTRM>(makeDefaultNodeToRangeMap(*basis, tp));
    return std::make_shared<DiscreteFunction>(basis, tp, vec, nodeToRange);
  }

} // end namespace AMDiS