AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
LocalViewPair.hpp
1#pragma once
2
3#include <amdis/functions/LocalView.hpp>
4
5namespace AMDiS
6{
8 template <class RB, class CB>
10 {
13
14 public:
16 LocalViewPair(RB const& rowBasis, CB const& colBasis)
17 : rowLocalView_(rowBasis)
18 , colLocalView_(colBasis)
19 {}
20
22 template <class Element>
23 void bind (Element const& element)
24 {
25 rowLocalView_.bind(element);
26 colLocalView_.bind(element);
27 }
28
30 void unbind ()
31 {
32 rowLocalView_.unbind();
33 colLocalView_.unbind();
34 }
35
36 RowLocalView const& row() const
37 {
38 return rowLocalView_;
39 }
40
41 ColLocalView const& col() const
42 {
43 return colLocalView_;
44 }
45
46 protected:
47 RowLocalView rowLocalView_;
48 ColLocalView colLocalView_;
49 };
50
52 template <class B>
53 class LocalViewPair<B,B>
54 {
56
57 public:
59 LocalViewPair(B const& rowBasis, B const& colBasis)
60 : same_(&rowBasis == &colBasis)
61 , rowLocalView_(rowBasis)
62 , colLocalView_(same_
63 ? Dune::stackobject_to_shared_ptr(rowLocalView_)
64 : std::make_shared<LocalView>(colBasis))
65 {}
66
67 ~LocalViewPair() = default;
68 LocalViewPair(LocalViewPair const&) = delete;
69 LocalViewPair& operator=(LocalViewPair const&) = delete;
70 LocalViewPair(LocalViewPair&&) = delete;
71 LocalViewPair& operator=(LocalViewPair&&) = delete;
72
74 template <class Element>
75 void bind (Element const& element)
76 {
77 rowLocalView_.bind(element);
78 if (!same_)
79 colLocalView_->bind(element);
80 }
81
83 void unbind ()
84 {
85 rowLocalView_.unbind();
86 if (!same_)
87 colLocalView_->unbind();
88 }
89
90 LocalView const& row() const
91 {
92 return rowLocalView_;
93 }
94
95 LocalView const& col() const
96 {
97 return *colLocalView_;
98 }
99
100 protected:
101 bool same_ = false;
102 LocalView rowLocalView_;
103 std::shared_ptr<LocalView> colLocalView_;
104 };
105
106} // end namespace AMDiS
void bind(Element const &element)
Bind the views to a grid element.
Definition: LocalViewPair.hpp:75
LocalViewPair(B const &rowBasis, B const &colBasis)
Construct local view for a given global finite element basis.
Definition: LocalViewPair.hpp:59
void unbind()
Unbind from the current element.
Definition: LocalViewPair.hpp:83
The restriction of a finite element basis to a single element.
Definition: LocalViewPair.hpp:10
LocalViewPair(RB const &rowBasis, CB const &colBasis)
Construct local view for a given global finite element basis.
Definition: LocalViewPair.hpp:16
void bind(Element const &element)
Bind the views to a grid element.
Definition: LocalViewPair.hpp:23
void unbind()
Unbind from the current element.
Definition: LocalViewPair.hpp:30
constexpr bool LocalView
A Dune::Functions::LocalView type.
Definition: Concepts.hpp:181