Skip to content
Snippets Groups Projects

Use global index sets by the dune-parmg module

Merged Sander, Oliver requested to merge lisa-parallel into master
5 files
+ 108
125
Compare changes
  • Side-by-side
  • Inline
Files
5
+ 69
0
#ifndef DUNE_GFE_PARALLEL_GLOBALMAPPER_HH
#define DUNE_GFE_PARALLEL_GLOBALMAPPER_HH
#if HAVE_DUNE_PARMG
#include <dune/parmg/parallel/dofmap.hh>
#include <dune/parmg/parallel/globaldofindex.hh>
#include <dune/parmg/parallel/datahandle.hh>
#endif
namespace Dune {
template <class Basis>
class GlobalMapper
{
public:
using GridView = typename Basis::GridView;
/** \brief The integer number type used for indices */
using Index = typename GridView::IndexSet::IndexType;
#if HAVE_DUNE_PARMG
typedef Dune::ParMG::EntitiesToDofsMap<Basis> DofMap;
typedef Dune::ParMG::EntityMasterRank<typename Basis::GridView> Master;
typedef std::vector<char> DofMaster;
GlobalMapper(const GridView& gridView_)
{
Basis b = gridView_;
DofMap dofmap = Dune::ParMG::entitiesToDofsMap(&b);
Master m = Dune::ParMG::entityMasterRank(gridView_, [&](int, int codim) -> bool {
return dofmap.codimSet().test(codim);
});
DofMaster dofmaster = Dune::ParMG::dofMaster(b, m);
coarseGlobalDof_ = globalDof(b,m, dofmap);
// total number of degrees of freedom
size_ = coarseGlobalDof_.size;
}
#else
GlobalMapper(const GridView& gridView_)
{
// Total number of degrees of freedom
size_ = gridView.size();
}
#endif
/** \brief Given a local index, retrieve its index globally unique over all processes. */
Index index(const int& localIndex) const {
#if HAVE_DUNE_PARMG
return coarseGlobalDof_.globalDof[localIndex];
#else
return localIndex;
#endif
}
std::size_t size() const
{
return size_;
}
#if HAVE_DUNE_PARMG
ParMG::GlobalDof coarseGlobalDof_;
#endif
std::size_t size_;
};
}
#endif // DUNE_GFE_PARALLEL_GLOBALMAPPER_HH
Loading