14#ifndef DUMUX_COMMON_REORDERING_DOF_MAPPER_HH 
   15#define DUMUX_COMMON_REORDERING_DOF_MAPPER_HH 
   19#include <dune/common/timer.hh> 
   20#include <dune/grid/common/mapper.hh> 
   31template<
class Gr
idView>
 
   33: 
public Dune::Mapper<typename GridView::Grid, ReorderingDofMapper<GridView>, typename GridView::IndexSet::IndexType>
 
   35    using Index = 
typename GridView::IndexSet::IndexType;
 
   36    using ParentType = 
typename Dune::Mapper<typename GridView::Grid, ReorderingDofMapper<GridView>, Index>;
 
   37    using Element = 
typename GridView::template Codim<0>::Entity;
 
   45    template<
class Layout>
 
   48    , indexSet_(&gridView.indexSet())
 
   49    , codimension_(layout(indexSet_->types(0)[0], GridView::dimension) ? 0 : GridView::dimension)
 
   61    template<
class EntityType>
 
   62    Index index (
const EntityType& e)
 const 
   65        return static_cast<Index
>(permutation_[indexSet_->index(e)]);
 
   75    Index subIndex (
const Element& e, 
int i, 
unsigned int codim)
 const 
   77        return indexSet_->subIndex(e, i, codim);
 
   88    std::size_t size ()
 const 
   90        return indexSet_->size(codimension_);
 
   99    template<
class EntityType>
 
  100    bool contains (
const EntityType& e, Index& result)
 const 
  114    bool contains (
const Element& e, 
int i, 
int cc, Index& result)
 const 
  116        result = indexSet_->subIndex(e, i, cc);
 
  123    void update (
const GridView& gridView)
 
  125        gridView_ = gridView;
 
  126        indexSet_ = &gridView_.indexSet();
 
  130    void update (GridView&& gridView)
 
  132        gridView_ = std::move(gridView);
 
  133        indexSet_ = &gridView_.indexSet();
 
  143        std::vector<std::vector<Index>> graph(size());
 
  146        if (codimension_ == 0)
 
  148            for (
const auto& element : elements(gridView_))
 
  150                auto eIdx = indexSet_->index(element);
 
  151                for (
const auto& intersection : intersections(gridView_, element))
 
  153                    if (intersection.neighbor())
 
  154                        graph[eIdx].push_back(indexSet_->index(intersection.outside()));
 
  161            for (
const auto& element : elements(gridView_))
 
  163                auto eIdx = indexSet_->index(element);
 
  164                for (
int vIdxLocal = 0; vIdxLocal < 
element.subEntities(codimension_); ++vIdxLocal)
 
  166                    auto vIdxGlobal = indexSet_->subIndex(element, vIdxLocal, codimension_);
 
  167                    graph[vIdxGlobal].push_back(eIdx);
 
  173        std::cout << 
"Scotch backend reordered index set of size " << size()
 
  174                  << 
" in " << watch.elapsed() << 
" seconds." << std::endl;
 
  178    const typename GridView::IndexSet* indexSet_;
 
  179    const int codimension_;
 
  181    std::vector<int> permutation_;
 
  188#warning "PTSCOTCH was not found on your system. Dumux::ReorderingDofMapper needs it to work -> fallback to MCMGMapper without reordering!" 
  189#include <dune/grid/common/mcmgmapper.hh> 
  191template<
class Gr
idView>
 
static std::vector< int > computeGPSReordering(const Graph &graph, std::size_t numPasses=5)
Definition scotchbackend.hh:154
Dune::MultipleCodimMultipleGeomTypeMapper< GridView > ReorderingDofMapper
Definition reorderingdofmapper.hh:192
An interface to the scotch library for matrix reordering.