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;
34 auto const& gv = basis.gridView();
35 auto lv = basis.localView();
38 using GridView =
typename Basis::GridView;
39 using Grid =
typename GridView::Grid;
40 using DataHandle = UniqueBorderPartition<Grid>;
41 DataHandle borderEntities(gv.comm().rank(), gv.grid());
42 for (
int i = 0; i < borderEntities.numIterations(); ++i) {
43 gv.communicate(borderEntities,
44 Dune::InterfaceType::InteriorBorder_All_Interface,
45 Dune::CommunicationDirection::ForwardCommunication);
48 std::vector<bool> visited(basis.dimension(),
false);
49 GlobalBasisIdSet<Basis> dofIdSet(basis);
50 parallelIndexSet.beginResize();
51 for (
auto const& e : elements(gv))
55 for (std::size_t i = 0; i < dofIdSet.size(); ++i)
57 auto localIndex = lv.index(i);
58 if (!visited[localIndex]) {
59 auto globalId = dofIdSet.id(i);
60 using PType = Dune::PartitionType;
61 PType pt = dofIdSet.partitionType(i);
64 case PType::InteriorEntity:
65 parallelIndexSet.add(globalId, LI(localIndex, Attribute::owner,
true));
67 case PType::BorderEntity:
68 if (borderEntities.contains(dofIdSet.entityId(i)))
69 parallelIndexSet.add(globalId, LI(localIndex, Attribute::owner,
true));
71 parallelIndexSet.add(globalId, LI(localIndex, Attribute::overlap,
true));
73 case PType::OverlapEntity:
74 parallelIndexSet.add(globalId, LI(localIndex, Attribute::overlap,
true));
76 case PType::FrontEntity:
77 case PType::GhostEntity:
78 parallelIndexSet.add(globalId, LI(localIndex, Attribute::copy,
true));
81 error_exit(
"Unknown partition type.");
84 visited[localIndex] =
true;
90 parallelIndexSet.endResize();
95 parallelIndexSet.beginResize();
96 for (std::size_t localIndex = 0; localIndex < basis.dimension(); ++localIndex)
98 GI globalId{std::size_t(localIndex)};
99 parallelIndexSet.add(globalId, LI(localIndex, Attribute::owner,
true));
101 parallelIndexSet.endResize();
104 assert(parallelIndexSet.size() == basis.dimension());
106 info(2,
"build ParallelIndexSet needed {} seconds", t.elapsed());
Definition: AdaptBase.hpp:6
static int mpiSize()
Return the MPI_Size of the group created by Dune::MPIHelper.
Definition: Environment.hpp:74