1#ifndef DUNE_FEM_SPACE_MAPPER_PARALLEL_HH
2#define DUNE_FEM_SPACE_MAPPER_PARALLEL_HH
12#include <dune/grid/common/datahandleif.hh>
24 namespace __ParallelDofMapper
30 template<
class Gr
idPart,
class BaseMapper,
class GlobalKey >
32 :
public CommDataHandleIF< BuildDataHandle< GridPart, BaseMapper, GlobalKey >, GlobalKey >
39 bool fixedSize (
int dim,
int codim )
const {
return false; }
41 template<
class Buffer,
class Entity >
42 void gather ( Buffer &buffer,
const Entity &entity )
const
44 baseMapper_.mapEachEntityDof( entity, [
this, &buffer ] (
int,
auto index ) {
50 template<
class Buffer,
class Entity >
51 void scatter ( Buffer &buffer,
const Entity &entity, std::size_t n )
56 assert( n ==
static_cast< std::size_t
>(
baseMapper_.numEntityDofs( entity ) ) );
57 baseMapper_.mapEachEntityDof( entity, [
this, &buffer ] (
int,
auto index ) {
63 template<
class Entity >
64 std::size_t
size (
const Entity &entity )
const
67 baseMapper_.mapEachEntityDof( entity, [
this, &
size ] (
int,
auto index )
85 template<
class Gr
idPart,
class BaseMapper,
class GlobalKey = std::
size_t >
111 template<
class Functor >
114 baseMapper().mapEach( element, [
this, f ] (
auto local,
auto i ) { f( local, mapping_[ i ] ); } );
117 void map (
const ElementType &element, std::vector< GlobalKeyType > &indices )
const
119 indices.resize(
numDofs( element ) );
120 mapEach( element, [ &indices ] (
int local,
GlobalKeyType global ) { indices[ local ] = global; } );
125 baseMapper().onSubEntity( element, i, c, indices );
133 template<
class Entity,
class Functor >
136 baseMapper().mapEachEntityDof( entity, [
this, f ] (
auto local,
auto i ) { f( local, mapping_[ i ] ); } );
139 template<
class Entity >
140 void mapEntityDofs (
const Entity &entity, std::vector< GlobalKeyType > &indices )
const
146 template<
class Entity >
164 int numBlocks ()
const { DUNE_THROW( NotImplemented,
"Adaptive dof mapper interface not implemented." ); }
165 SizeType offSet (
int blk )
const { DUNE_THROW( NotImplemented,
"Adaptive dof mapper interface not implemented." ); }
166 SizeType oldOffSet (
int blk )
const { DUNE_THROW( NotImplemented,
"Adaptive dof mapper interface not implemented." ); }
167 SizeType numberOfHoles (
int blk )
const { DUNE_THROW( NotImplemented,
"Adaptive dof mapper interface not implemented." ); }
168 SizeType oldIndex (
SizeType hole,
int blk )
const { DUNE_THROW( NotImplemented,
"Adaptive dof mapper interface not implemented." ); }
169 SizeType newIndex (
SizeType hole,
int blk )
const { DUNE_THROW( NotImplemented,
"Adaptive dof mapper interface not implemented." ); }
180 offset_ = exScan(
gridPart().comm(), size_ );
181 size_ =
gridPart().comm().sum( size_ );
184 mapping_.resize( baseSize );
187 mapping_[ i ] = next++;
191 gridPart().communicate( dataHandle, InteriorBorder_All_Interface, ForwardCommunication );
197 const std::vector< GlobalKeyType > &
mapping ()
const {
return mapping_; }
200 template<
class Comm,
class T >
201 static T exScan (
const CollectiveCommunication< Comm > &comm, T
in )
208 static T exScan (
const CollectiveCommunication< MPI_Comm > &comm, T
in )
211 MPI_Exscan( &
in, &
out, 1, MPITraits< T >::getType(), MPI_SUM,
static_cast< MPI_Comm
>( comm ) );
218 std::vector< GlobalKeyType > mapping_;
227 namespace Capabilities
230 template<
class Gr
idPart,
class BaseMapper,
class GlobalKey >
233 static const bool v =
false;
236 template<
class Gr
idPart,
class BaseMapper,
class GlobalKey >
239 static const bool v =
true;
static PrimaryDofs< AuxiliaryDofs > primaryDofs(const AuxiliaryDofs &auxiliaryDofs)
Definition: auxiliarydofs.hh:341
void rebuild()
Definition: auxiliarydofs.hh:136
bool contains(int index) const
return true if index is contained, meaning it is a auxiliary dof
Definition: auxiliarydofs.hh:131
Definition: bindguard.hh:11
specialize with true if index set implements the interface for consecutive index sets
Definition: common/indexset.hh:42
static const bool v
Definition: common/indexset.hh:49
Definition: space/mapper/capabilities.hh:22
static const bool v
Definition: space/mapper/capabilities.hh:23
Definition: parallel.hh:33
bool fixedSize(int dim, int codim) const
Definition: parallel.hh:39
BuildDataHandle(const BaseMapper &baseMapper, const AuxiliaryDofs< GridPart, BaseMapper > &auxiliaryDofs, std::vector< GlobalKey > &mapping)
Definition: parallel.hh:34
std::vector< GlobalKey > & mapping_
Definition: parallel.hh:75
bool contains(int dim, int codim) const
Definition: parallel.hh:38
void scatter(Buffer &buffer, const Entity &entity, std::size_t n)
Definition: parallel.hh:51
std::size_t size(const Entity &entity) const
Definition: parallel.hh:64
const BaseMapper & baseMapper_
Definition: parallel.hh:73
void gather(Buffer &buffer, const Entity &entity) const
Definition: parallel.hh:42
const AuxiliaryDofs< GridPart, BaseMapper > & auxiliaryDofs_
Definition: parallel.hh:74
Definition: parallel.hh:87
ThisType & operator=(const ThisType &)=delete
SizeType offSet(int blk) const
Definition: parallel.hh:165
ParallelDofMapper(ThisType &&)=delete
void mapEach(const ElementType &element, Functor f) const
Definition: parallel.hh:112
void map(const ElementType &element, std::vector< GlobalKeyType > &indices) const
Definition: parallel.hh:117
void onSubEntity(const ElementType &element, int i, int c, std::vector< bool > &indices) const
Definition: parallel.hh:123
GridPart GridPartType
Definition: parallel.hh:91
SizeType size() const
Definition: parallel.hh:158
BaseMapperType::ElementType ElementType
Definition: parallel.hh:97
bool consecutive() const
Definition: parallel.hh:162
int numBlocks() const
Definition: parallel.hh:164
bool fixedDataSize(int codim) const
Definition: parallel.hh:156
GlobalKey GlobalKeyType
Definition: parallel.hh:95
ParallelDofMapper(const ThisType &)=delete
void mapEachEntityDof(const Entity &entity, Functor f) const
Definition: parallel.hh:134
SizeType newIndex(SizeType hole, int blk) const
Definition: parallel.hh:169
ParallelDofMapper(const GridPartType &gridPart, const BaseMapperType &baseMapper)
Definition: parallel.hh:99
unsigned int maxNumDofs() const
Definition: parallel.hh:128
SizeType numberOfHoles(int blk) const
Definition: parallel.hh:167
bool contains(int codim) const
Definition: parallel.hh:154
SizeType oldIndex(SizeType hole, int blk) const
Definition: parallel.hh:168
SizeType oldOffSet(int blk) const
Definition: parallel.hh:166
unsigned int numDofs(const ElementType &element) const
Definition: parallel.hh:129
BaseMapper BaseMapperType
Definition: parallel.hh:92
const std::vector< GlobalKeyType > & mapping() const
Definition: parallel.hh:197
void mapEntityDofs(const Entity &entity, std::vector< GlobalKeyType > &indices) const
Definition: parallel.hh:140
unsigned int numEntityDofs(const Entity &entity) const
Definition: parallel.hh:147
const GridPartType & gridPart() const
Definition: parallel.hh:194
std::size_t SizeType
Definition: parallel.hh:94
void update()
Definition: parallel.hh:173
const BaseMapperType & baseMapper() const
Definition: parallel.hh:195