6#include <dune/common/timer.hh>
8#include <amdis/Output.hpp>
9#include <amdis/linearalgebra/AttributeSet.hpp>
12#include <dune/grid/common/gridenums.hh>
13#include <dune/grid/common/partitionset.hh>
15#include <amdis/Environment.hpp>
16#include <amdis/functions/GlobalIdSet.hpp>
17#include <amdis/utility/UniqueBorderPartition.hpp>
23 template <
class Basis,
class PIS>
24 inline void buildParallelIndexSet(Basis
const& basis, PIS& parallelIndexSet)
27 using Attribute =
typename AttributeSet<PIS>::type;
28 using GI =
typename PIS::GlobalIndex;
29 using LI =
typename PIS::LocalIndex;
31 auto const& gv = basis.gridView();
34 if (gv.comm().size() > 1)
36 auto lv = basis.localView();
39 using GridView =
typename Basis::GridView;
40 using Grid =
typename GridView::Grid;
41 using DataHandle = UniqueBorderPartition<Grid>;
42 DataHandle borderEntities(gv.comm().rank(), gv.grid());
43 for (
int i = 0; i < borderEntities.numIterations(); ++i) {
44 gv.communicate(borderEntities,
45 Dune::InterfaceType::InteriorBorder_All_Interface,
46 Dune::CommunicationDirection::ForwardCommunication);
49 std::vector<bool> visited(basis.dimension(),
false);
50 GlobalBasisIdSet<Basis> dofIdSet(basis);
51 parallelIndexSet.beginResize();
52 for (
auto const& e : elements(gv))
56 for (std::size_t i = 0; i < dofIdSet.size(); ++i)
58 auto localIndex = lv.index(i);
59 if (!visited[localIndex]) {
60 auto globalId = dofIdSet.id(i);
61 using PType = Dune::PartitionType;
62 PType pt = dofIdSet.partitionType(i);
65 case PType::InteriorEntity:
66 parallelIndexSet.add(globalId, LI(localIndex, Attribute::owner,
true));
68 case PType::BorderEntity:
69 if (borderEntities.contains(dofIdSet.entityId(i)))
70 parallelIndexSet.add(globalId, LI(localIndex, Attribute::owner,
true));
72 parallelIndexSet.add(globalId, LI(localIndex, Attribute::overlap,
true));
74 case PType::OverlapEntity:
75 parallelIndexSet.add(globalId, LI(localIndex, Attribute::overlap,
true));
77 case PType::FrontEntity:
78 case PType::GhostEntity:
79 parallelIndexSet.add(globalId, LI(localIndex, Attribute::copy,
true));
82 error_exit(
"Unknown partition type.");
85 visited[localIndex] =
true;
91 parallelIndexSet.endResize();
96 parallelIndexSet.beginResize();
97 for (std::size_t localIndex = 0; localIndex < basis.dimension(); ++localIndex)
99 GI globalId{std::size_t(localIndex)};
100 parallelIndexSet.add(globalId, LI(localIndex, Attribute::owner,
true));
102 parallelIndexSet.endResize();
105 assert(parallelIndexSet.size() == basis.dimension());
107 info(2,
"build ParallelIndexSet needed {} seconds", t.elapsed());