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();
155 std::vector<std::vector<Index>> graph(size());
158 if (codimension_ == 0)
160 for (
const auto& element : elements(gridView_))
162 auto eIdx = indexSet_->index(element);
163 for (
const auto& intersection : intersections(gridView_, element))
165 if (intersection.neighbor())
166 graph[eIdx].push_back(indexSet_->index(intersection.outside()));
173 for (
const auto& element : elements(gridView_))
175 auto eIdx = indexSet_->index(element);
176 for (
int vIdxLocal = 0; vIdxLocal <
element.subEntities(codimension_); ++vIdxLocal)
178 auto vIdxGlobal = indexSet_->subIndex(element, vIdxLocal, codimension_);
179 graph[vIdxGlobal].push_back(eIdx);
185 std::cout <<
"Scotch backend reordered index set of size " << size()
186 <<
" in " << watch.elapsed() <<
" seconds." << std::endl;
190 const typename GridView::IndexSet* indexSet_;
191 const int codimension_;
193 std::vector<int> permutation_;
200#warning "PTSCOTCH was not found on your system. Dumux::ReorderingDofMapper needs it to work -> fallback to MCMGMapper without reordering!"
201#include <dune/grid/common/mcmgmapper.hh>
203template<
class Gr
idView>
An interface to the scotch library for matrix reordering.
Dune::MultipleCodimMultipleGeomTypeMapper< GridView > ReorderingDofMapper
Definition: reorderingdofmapper.hh:204
static std::vector< int > computeGPSReordering(const Graph &graph, std::size_t numPasses=5)
Definition: scotchbackend.hh:169