26#ifndef DUMUX_COMMON_REORDERING_DOF_MAPPER_HH
27#define DUMUX_COMMON_REORDERING_DOF_MAPPER_HH
31#include <dune/common/timer.hh>
32#include <dune/grid/common/mapper.hh>
43template<
class Gr
idView>
45:
public Dune::Mapper<typename GridView::Grid, ReorderingDofMapper<GridView>, typename GridView::IndexSet::IndexType>
47 using Index =
typename GridView::IndexSet::IndexType;
48 using ParentType =
typename Dune::Mapper<typename GridView::Grid, ReorderingDofMapper<GridView>, Index>;
49 using Element =
typename GridView::template Codim<0>::Entity;
57 template<
class Layout>
60 , indexSet_(&gridView.indexSet())
61 , codimension_(layout(indexSet_->types(0)[0], GridView::dimension) ? 0 : GridView::dimension)
73 template<
class EntityType>
74 Index index (
const EntityType& e)
const
77 return static_cast<Index
>(permutation_[indexSet_->index(e)]);
87 Index subIndex (
const Element& e,
int i,
unsigned int codim)
const
89 return indexSet_->subIndex(e, i, codim);
100 std::size_t size ()
const
102 return indexSet_->size(codimension_);
111 template<
class EntityType>
112 bool contains (
const EntityType& e, Index& result)
const
126 bool contains (
const Element& e,
int i,
int cc, Index& result)
const
128 result = indexSet_->subIndex(e, i, cc);
135 void update (
const GridView& gridView)
137 gridView_ = gridView;
138 indexSet_ = &gridView_.indexSet();
142 void update (GridView&& gridView)
144 gridView_ = std::move(gridView);
145 indexSet_ = &gridView_.indexSet();
152 [[deprecated(
"Use update(gridView) instead! Will be removed after release 3.4.")]]
164 std::vector<std::vector<Index>> graph(size());
167 if (codimension_ == 0)
169 for (
const auto& element : elements(gridView_))
171 auto eIdx = indexSet_->index(element);
172 for (
const auto& intersection : intersections(gridView_, element))
174 if (intersection.neighbor())
175 graph[eIdx].push_back(indexSet_->index(intersection.outside()));
182 for (
const auto& element : elements(gridView_))
184 auto eIdx = indexSet_->index(element);
185 for (
int vIdxLocal = 0; vIdxLocal <
element.subEntities(codimension_); ++vIdxLocal)
187 auto vIdxGlobal = indexSet_->subIndex(element, vIdxLocal, codimension_);
188 graph[vIdxGlobal].push_back(eIdx);
194 std::cout <<
"Scotch backend reordered index set of size " << size()
195 <<
" in " << watch.elapsed() <<
" seconds." << std::endl;
199 const typename GridView::IndexSet* indexSet_;
200 const int codimension_;
202 std::vector<int> permutation_;
209#warning "PTSCOTCH was not found on your system. Dumux::ReorderingDofMapper needs it to work -> fallback to MCMGMapper without reordering!"
210#include <dune/grid/common/mcmgmapper.hh>
212template<
class Gr
idView>
An interface to the scotch library for matrix reordering.
Dune::MultipleCodimMultipleGeomTypeMapper< GridView > ReorderingDofMapper
Definition: reorderingdofmapper.hh:213
static std::vector< int > computeGPSReordering(const Graph &graph, std::size_t numPasses=5)
Definition: scotchbackend.hh:63