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);
140 std::vector<std::vector<Index>> graph(size());
143 if (codimension_ == 0)
145 for (
const auto& element : elements(gridView_))
147 auto eIdx = indexSet_.index(element);
148 for (
const auto& intersection : intersections(gridView_, element))
150 if (intersection.neighbor())
151 graph[eIdx].push_back(indexSet_.index(intersection.outside()));
158 for (
const auto& element : elements(gridView_))
160 auto eIdx = indexSet_.index(element);
161 for (
int vIdxLocal = 0; vIdxLocal < element.subEntities(codimension_); ++vIdxLocal)
163 auto vIdxGlobal = indexSet_.subIndex(element, vIdxLocal, codimension_);
164 graph[vIdxGlobal].push_back(eIdx);
170 std::cout <<
"Scotch backend reordered index set of size " << size()
171 <<
" in " << watch.elapsed() <<
" seconds." << std::endl;
176 const GridView gridView_;
177 const typename GridView::IndexSet& indexSet_;
178 const int codimension_;
180 std::vector<int> permutation_;
187#warning "PTSCOTCH was not found on your system. Dumux::ReorderingDofMapper needs it to work -> fallback to MCMGMapper without reordering!"
188#include <dune/grid/common/mcmgmapper.hh>
190template<
class Gr
idView>
An interface to the scotch library for matrix reordering.
Dune::MultipleCodimMultipleGeomTypeMapper< GridView > ReorderingDofMapper
Definition: reorderingdofmapper.hh:191
static std::vector< int > computeGPSReordering(const Graph &graph, std::size_t numPasses=5)
Definition: scotchbackend.hh:63