AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
IndexDistribution.hpp
1#pragma once
2
3#include <memory>
4#include <optional>
5#include <string>
6
7#include <dune/istl/owneroverlapcopy.hh>
8#include <dune/istl/solvercategory.hh>
9#include <dune/istl/paamg/pinfo.hh>
10
11#include <amdis/Environment.hpp>
12#include <amdis/functions/GlobalIdSet.hpp>
13#include <amdis/linearalgebra/IndexDistribution.hpp>
14#include <amdis/linearalgebra/ParallelIndexSet.hpp>
15
16namespace AMDiS
17{
20 {
21 using Impl = Dune::Amg::SequentialInformation;
22
23 public:
25
27
28 template <class Basis>
30 {}
31
32 typename Dune::SolverCategory::Category category() const
33 {
34 return Dune::SolverCategory::sequential;
35 }
36
37 Impl const& impl() const
38 {
39 return impl_;
40 }
41
42 Sequential const& sequential() const
43 {
44 return *this;
45 }
46
47 template <class Basis>
48 void update(Basis const&) { /* do nothing */ }
49
50 private:
51 Impl impl_;
52 };
53
54
55 template <class G, class L, class Comm>
57 {
59 };
60
61#if HAVE_MPI
63 template <class GlobalId, class LocalIndex>
64 class ISTLIndexDistribution
65 {
66 using Impl = Dune::OwnerOverlapCopyCommunication<GlobalId, LocalIndex>;
67
68 public:
69 using Sequential = SequentialISTLIndexDistribution;
70 using IndexSet = typename Impl::ParallelIndexSet;
71 using RemoteIndices = typename Impl::RemoteIndices;
72
73 public:
74 template <class Basis>
75 ISTLIndexDistribution(Basis const& basis);
76
77 IndexSet const& indexSet() const
78 {
79 assert(bool(impl_));
80 return impl_->indexSet();
81 }
82
83 RemoteIndices const& remoteIndices() const
84 {
85 assert(bool(impl_));
86 return impl_->remoteIndices();
87 }
88
89 typename Dune::SolverCategory::Category category() const
90 {
91 return cat_;
92 }
93
94 Impl const& impl() const
95 {
96 assert(bool(impl_));
97 return *impl_;
98 }
99
100 Sequential sequential() const
101 {
102 return Sequential{};
103 }
104
105 template <class Basis>
106 void update(Basis const& basis)
107 {
108 impl_ = std::make_unique<Impl>(MPI_Comm(basis.gridView().comm()), cat_);
109
110 auto& pis = impl_->indexSet();
111 buildParallelIndexSet(basis, pis);
112
113 auto& ris = impl_->remoteIndices();
114 ris.setIndexSets(pis, pis, impl_->communicator());
115 ris.template rebuild<true>();
116 }
117
118 private:
119 typename Dune::SolverCategory::Category cat_;
120 std::unique_ptr<Impl> impl_ = nullptr;
121 };
122
123 template <class G, class L>
124 struct ISTLIndexDistributionType<G,L,Dune::Communication<MPI_Comm>>
125 {
126 using type = ISTLIndexDistribution<G,L>;
127 };
128
129#endif
130
131 template <class B>
132 using ISTLIndexDistribution_t
133 = typename ISTLIndexDistributionType<GlobalIdType_t<B>, typename B::size_type, typename B::GridView::CollectiveCommunication>::type;
134
135} // end namespace AMDiS
136
137#include <amdis/linearalgebra/istl/IndexDistribution.inc.hpp>
Dummy implementation for ISTL-specific index distribution when no MPI is found.
Definition: IndexDistribution.hpp:20
Definition: IndexDistribution.hpp:57