AMDiS 2.11-git
The Adaptive Multi-Dimensional Simulation Toolbox
 
Loading...
Searching...
No Matches
GlobalBasis.hpp
1#pragma once
2
3#include <algorithm>
4#include <list>
5#include <memory>
6#include <type_traits>
7#include <utility>
8
9#include <dune/common/concept.hh>
10#include <dune/common/reservedvector.hh>
11#include <dune/common/shared_ptr.hh>
12#include <dune/common/typeutilities.hh>
13#include <dune/common/version.hh>
14#include <dune/functions/common/multiindex.hh>
15#include <dune/functions/common/type_traits.hh>
16#include <dune/functions/functionspacebases/concepts.hh>
17#include <dune/functions/functionspacebases/defaultglobalbasis.hh>
18#include <dune/grid/common/adaptcallback.hh>
19
20#include <amdis/AdaptiveGrid.hpp>
21#include <amdis/Observer.hpp>
22#include <amdis/Output.hpp>
23#include <amdis/common/Concepts.hpp>
24#include <amdis/common/TypeTraits.hpp>
25#include <amdis/functions/FlatPreBasis.hpp>
26#include <amdis/functions/LocalView.hpp>
27#include <amdis/linearalgebra/IndexDistribution.hpp>
28#include <amdis/linearalgebra/Traits.hpp>
29#include <amdis/typetree/MultiIndex.hpp>
30
31namespace AMDiS
32{
42 template <class PB>
44 : public Dune::Functions::DefaultGlobalBasis<PB>
45 , public Notifier<event::adapt>
46 , private Observer<event::adapt>
47 {
48 using Self = GlobalBasis<PB>;
49 using Super = Dune::Functions::DefaultGlobalBasis<PB>;
50
51 public:
53 using PreBasis = PB;
54
56 using GridView = typename PreBasis::GridView;
57 using Grid = typename GridView::Grid;
58
61
64
65 struct DummyImpl {};
66 using ADH = Dune::AdaptDataHandle<Grid, DummyImpl>;
67
68 public:
70
77 template <class PB_>
78 GlobalBasis(PB_ const& preBasis)
79 : Super(flatPreBasis(preBasis))
80 , Observer<event::adapt>(preBasis.gridView().grid())
81 , indexDist_(static_cast<Super const&>(*this))
82 {}
83
85 template <class PBF>
86 GlobalBasis(GridView const& gridView, PBF const& preBasisFactory)
87 : GlobalBasis(preBasisFactory(gridView))
88 {}
89
91 GlobalBasis(GlobalBasis const&) = delete;
92
95
96 public:
98
102 void update(GridView const& gv)
103 {
104 Super::preBasis().update(gv);
105 Super::preBasis().initializeIndices();
106 indexDist_.update(*this);
107 }
108
111 {
112 return LocalView(*this);
113 }
114
116 std::shared_ptr<LocalView> localViewPtr() const
117 {
118 return std::make_shared<LocalView>(*this);
119 }
120
122 auto entitySet() const
123 {
124 return elements(this->gridView(), BackendTraits::PartitionSet{});
125 }
126
128 GlobalBasis const& rootBasis() const
129 {
130 return *this;
131 }
132
134
138 IndexDist const& indexDistribution() const { return indexDist_; }
139 IndexDist& indexDistribution() { return indexDist_; }
140
141 ADH globalRefineCallback() const
142 {
143 // TODO(FM): Implement
144 error_exit("Not implemented: GlobalBasis::globalRefineCallback()");
145 return ADH{};
146 }
147
148 protected:
150 void updateImpl(event::adapt e) override
151 {
152 if (e.value) {
153 update(Super::gridView());
155 }
156 }
157
159
160 protected:
161 IndexDist indexDist_;
162 };
163
164
165 // Deduction guides
166 template <class GV, class PBF>
167 GlobalBasis(GV const& gridView, PBF const& preBasisFactory)
168 -> GlobalBasis<std::decay_t<decltype(flatPreBasis(preBasisFactory(gridView)))>>;
169
170 template <class PB>
171 GlobalBasis(PB const& preBasis)
172 -> GlobalBasis<std::decay_t<decltype(flatPreBasis(preBasis))>>;
173
174} // end namespace AMDiS
Dummy implementation for sequential index "distribution".
Definition IndexDistribution.hpp:7
Global basis defined on a pre-basis.
Definition GlobalBasis.hpp:47
IndexDist const & indexDistribution() const
Return the index distribution.
Definition GlobalBasis.hpp:138
GlobalBasis(GlobalBasis const &)=delete
Copy constructor.
void update(GridView const &gv)
Update the stored grid view.
Definition GlobalBasis.hpp:102
LocalView localView() const
Return local view for basis.
Definition GlobalBasis.hpp:110
AMDiS::LocalView< Self > LocalView
Type of the local view on the restriction of the basis to a single element.
Definition GlobalBasis.hpp:60
PB PreBasis
Pre-basis providing the implementation details.
Definition GlobalBasis.hpp:53
auto entitySet() const
Return the set of entities this basis can be bound to.
Definition GlobalBasis.hpp:122
GlobalBasis const & rootBasis() const
Return *this because we are not embedded in a larger basis.
Definition GlobalBasis.hpp:128
GlobalBasis(GridView const &gridView, PBF const &preBasisFactory)
Construct this global basis with a preBasisFactory.
Definition GlobalBasis.hpp:86
GlobalBasis(GlobalBasis &&)=default
Move constructor.
void updateImpl(event::adapt e) override
Updates the underlying basis when event::adapt is triggered by the observed grid.
Definition GlobalBasis.hpp:150
typename PreBasis::GridView GridView
The grid view that the FE space is defined on.
Definition GlobalBasis.hpp:56
std::shared_ptr< LocalView > localViewPtr() const
Return local view as shared_ptr to prevent from copy construction.
Definition GlobalBasis.hpp:116
BackendTraits::IndexDist< Self > IndexDist
Type of the communicator.
Definition GlobalBasis.hpp:63
GlobalBasis(PB_ const &preBasis)
Construct this global basis with given name and grid, and constructing a preBasis.
Definition GlobalBasis.hpp:78
The restriction of a finite element basis to a single element.
Definition LocalView.hpp:16
Mixin for signaling of certain events.
Definition Observer.hpp:57
Implementation of the ObserverInterface.
Definition Observer.hpp:104
Definition GlobalBasis.hpp:65
Definition Observer.hpp:25