DirichletBC.inc.hpp 2.01 KB
Newer Older
1
2
#pragma once

3
#include <dune/functions/functionspacebases/boundarydofs.hh>
4
#include <dune/functions/functionspacebases/interpolate.hh>
5
#include <dune/functions/functionspacebases/subspacebasis.hh>
6
7
8

namespace AMDiS
{
9
10
11
12
  template <class WorldVector, class Range>
    template <class RowBasis>
  void DirichletBC<WorldVector, Range>::initImpl(
      RowBasis const& rowBasis, Dune::TypeTree::LeafNodeTag)
13
  {
14
15
16
17
18
19
20
    using Dune::Functions::forEachBoundaryDOF;
    using LV = typename RowBasis::LocalView;
    using I = typename RowBasis::GridView::Intersection;
    dirichletNodes_.resize(rowBasis.dimension());
    forEachBoundaryDOF(rowBasis, [&](int localIndex, LV const& localView, I const& intersection) {
      dirichletNodes_[localView.index(localIndex)] = predicate_(intersection.geometry().center());
    });
21
  }
22

23
24
25
26
27
  template <class WorldVector, class Range>
    template <class RowBasis>
  void DirichletBC<WorldVector, Range>::initImpl(
      RowBasis const& rowBasis, Dune::TypeTree::PowerNodeTag)
  {
28
29
30
    using Dune::Functions::subspaceBasis;
    using Node = typename RowBasis::LocalView::Tree;
    using ChildNode = typename Node::template Child<0>::type;
31

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    auto tp = rowBasis.prefixPath();
    auto const& basis = rowBasis.rootBasis();
    for (std::size_t i = 0; i < degree(rowBasis.localView().tree()); ++i)
      initImpl(subspaceBasis(basis, push_back(tp,i)), typename ChildNode::NodeTag{});
  }

  template <class WorldVector, class Range>
    template <class RowBasis>
  void DirichletBC<WorldVector, Range>::initImpl(
      RowBasis const& rowBasis, Dune::TypeTree::CompositeNodeTag)
  {
    using Dune::Functions::subspaceBasis;
    using Node = typename RowBasis::LocalView::Tree;
    auto tp = rowBasis.prefixPath();
    auto const& basis = rowBasis.rootBasis();
    forEach(range_<0,Node::CHILDREN>, [&,this](auto const _i) {
      using ChildNode = typename Node::template Child<decltype(_i)::value>::type;
      this->initImpl(subspaceBasis(basis, push_back(tp,_i)), typename ChildNode::NodeTag{});
    });
51
52
  }

53
} // end namespace AMDiS