1#ifndef DUNE_FEM_STENCIL_HH
2#define DUNE_FEM_STENCIL_HH
11#include <dune/grid/common/gridenums.hh>
12#include <dune/grid/common/rangegenerators.hh>
33 template <
class DomainSpace,
class RangeSpace>
37 typedef typename DomainSpace::IteratorType DomainIteratorType;
38 typedef typename DomainSpace::BlockMapperType DomainBlockMapper;
41 typedef typename RangeSpace::IteratorType RangeIteratorType;
42 typedef typename RangeSpace::BlockMapperType RangeBlockMapper;
63 Stencil(
const DomainSpace &dSpace,
const RangeSpace &rSpace)
79 if( (dEntity.partitionType() == GhostEntity) && !fillGhost )
82 rangeBlockMapper_.mapEach( rEntity, [
this, &dEntity ] (
int localRow,
auto globalRow ) {
107 [](
int ret,
const auto& entry ){
return std::max( ret,
static_cast<int>( entry.second.size() ) ); } );
114 struct RowFillFunctor
122 localStencil_.insert( domainGlobal );
142 template <
class DomainSpace,
class RangeSpace>
167 DUNE_THROW( Dune::NotImplemented,
"SimpleStencil: exact stencil information is unavailable." );
172 DUNE_THROW( Dune::NotImplemented,
"SimpleStencil: global stencil is unavailable." );
189 template <
class DomainSpace,
class RangeSpace,
class LocalStencil>
207 typedef std::pair< DomainGlobalKeyType, const LocalStencilType& >
ItemType;
268 bool fillGhost=
true )
286 maxNNZ =
std::max( maxNNZ,
int(row.size()) );
304 template <
class DomainSpace,
class RangeSpace,
class Partition = Dune::Partitions::InteriorBorder>
320 for (
const auto& entity : elements( dSpace.gridPart(),
PartitionType{} ) )
334 template <
class DomainSpace,
class RangeSpace,
class Partition = Dune::Partitions::InteriorBorder>
348 bool onlyNonContinuousNeighbors =
false)
351 for (
const auto & entity: elements( dSpace.gridPart(),
PartitionType{} ) )
354 for (
const auto & intersection: intersections(dSpace.gridPart(), entity) )
356 if ( onlyNonContinuousNeighbors
357 && rSpace.continuous(intersection) && dSpace.continuous(intersection) )
359 if( intersection.neighbor() )
361 auto neighbor = intersection.outside();
double max(const Dune::Fem::Double &v, const double p)
Definition: double.hh:965
Definition: bindguard.hh:11
Definition: utility.hh:162
default implementation for a general operator stencil
Definition: stencil.hh:35
const RangeBlockMapper & rangeBlockMapper_
Definition: stencil.hh:131
GlobalStencilType globalStencil_
Definition: stencil.hh:132
int rows() const
Definition: stencil.hh:110
RangeIteratorType::Entity RangeEntityType
Definition: stencil.hh:46
DomainBlockMapper::GlobalKeyType DomainGlobalKeyType
Definition: stencil.hh:47
std::map< RangeGlobalKeyType, LocalStencilType > GlobalStencilType
type for storing the full stencil
Definition: stencil.hh:54
RangeBlockMapper::GlobalKeyType RangeGlobalKeyType
Definition: stencil.hh:48
const GlobalStencilType & globalStencil() const
Return the full stencil.
Definition: stencil.hh:98
DomainIteratorType::Entity DomainEntityType
Definition: stencil.hh:45
void fill(const DomainEntityType &dEntity, const RangeEntityType &rEntity, bool fillGhost=true)
Create stencil entries for (dEntity,rEntity) pair.
Definition: stencil.hh:76
int maxNonZerosEstimate() const
Return an upper bound for the maximum number of non-zero entries in all row.
Definition: stencil.hh:104
Stencil(const DomainSpace &dSpace, const RangeSpace &rSpace)
Constructor.
Definition: stencil.hh:63
const LocalStencilType & localStencil(const RangeGlobalKeyType &key) const
Return stencil for a given row of the matrix.
Definition: stencil.hh:92
const DomainBlockMapper & domainBlockMapper_
Definition: stencil.hh:130
int cols() const
Definition: stencil.hh:111
std::set< DomainGlobalKeyType > LocalStencilType
type for storing the stencil of one row
Definition: stencil.hh:51
a watered down stencil providing only the upper bound for the non-zero entries per row.
Definition: stencil.hh:144
StencilType::RangeGlobalKeyType RangeGlobalKeyType
Definition: stencil.hh:150
int maxNZ_
Definition: stencil.hh:176
StencilType::RangeEntityType RangeEntityType
Definition: stencil.hh:148
LocalStencilType localStencil_
Definition: stencil.hh:178
const LocalStencilType & localStencil(const DomainGlobalKeyType &key) const
Definition: stencil.hh:165
GlobalStencilType stencil_
Definition: stencil.hh:177
SimpleStencil()
Definition: stencil.hh:157
int maxNonZerosEstimate() const
Definition: stencil.hh:161
SimpleStencil(int maxNZ)
Definition: stencil.hh:154
const GlobalStencilType & globalStencil() const
Definition: stencil.hh:170
StencilType::DomainEntityType DomainEntityType
Definition: stencil.hh:147
StencilType::GlobalStencilType GlobalStencilType
Definition: stencil.hh:152
StencilType::LocalStencilType LocalStencilType
Definition: stencil.hh:151
StencilType::DomainGlobalKeyType DomainGlobalKeyType
Definition: stencil.hh:149
a simple wrapper class for sparsity patterns provide as vector< set< size_t > >
Definition: stencil.hh:191
void fill(const DomainEntityType &dEntity, const RangeEntityType &rEntity, bool fillGhost=true)
Create stencil entries for (dEntity,rEntity) pair.
Definition: stencil.hh:267
int maxNZ_
Definition: stencil.hh:292
StencilType::DomainEntityType DomainEntityType
Definition: stencil.hh:195
std::vector< LocalStencilType > GlobalStencilType
Definition: stencil.hh:203
const LocalStencilType & localStencil(const DomainGlobalKeyType &key) const
Definition: stencil.hh:250
const ThisType & globalStencil() const
Definition: stencil.hh:255
StencilType::RangeGlobalKeyType RangeGlobalKeyType
Definition: stencil.hh:198
StencilType::DomainGlobalKeyType DomainGlobalKeyType
Definition: stencil.hh:197
int computeNNZ() const
Definition: stencil.hh:281
LocalStencil LocalStencilType
Definition: stencil.hh:200
Iterator find(const DomainGlobalKeyType &key) const
Definition: stencil.hh:274
StencilWrapper(const GlobalStencilType &stencil)
Definition: stencil.hh:239
StencilType::RangeEntityType RangeEntityType
Definition: stencil.hh:196
Iterator begin() const
Definition: stencil.hh:272
int maxNonZerosEstimate() const
Definition: stencil.hh:245
const GlobalStencilType & stencil_
Definition: stencil.hh:291
Iterator end() const
Definition: stencil.hh:273
Definition: stencil.hh:206
bool operator==(const Iterator &other) const
Definition: stencil.hh:228
const GlobalStencilType & stencil_
Definition: stencil.hh:210
bool operator!=(const Iterator &other) const
Definition: stencil.hh:233
Iterator(const DomainGlobalKeyType &init, const GlobalStencilType &stencil)
Definition: stencil.hh:213
ItemType operator*() const
Definition: stencil.hh:222
std::pair< DomainGlobalKeyType, const LocalStencilType & > ItemType
Definition: stencil.hh:207
DomainGlobalKeyType index_
Definition: stencil.hh:209
Iterator & operator++()
Definition: stencil.hh:216
Stencil contaning the entries (en,en) for all entities in the space. Defailt for an operator over a L...
Definition: stencil.hh:306
BaseType::DomainGlobalKeyType DomainGlobalKeyType
Definition: stencil.hh:312
BaseType::GlobalStencilType GlobalStencilType
Definition: stencil.hh:315
BaseType::RangeEntityType RangeEntityType
Definition: stencil.hh:311
BaseType::DomainEntityType DomainEntityType
Definition: stencil.hh:310
DiagonalStencil(const DomainSpace &dSpace, const RangeSpace &rSpace)
Definition: stencil.hh:317
Partition PartitionType
Definition: stencil.hh:309
BaseType::LocalStencilType LocalStencilType
Definition: stencil.hh:314
BaseType::RangeGlobalKeyType RangeGlobalKeyType
Definition: stencil.hh:313
Stencil< DomainSpace, RangeSpace > BaseType
Definition: stencil.hh:307
Stencil contaning the entries (en,en) and (en,nb) for all entities en in the space and neighbors nb o...
Definition: stencil.hh:336
BaseType::RangeEntityType RangeEntityType
Definition: stencil.hh:341
BaseType::DomainGlobalKeyType DomainGlobalKeyType
Definition: stencil.hh:342
DiagonalAndNeighborStencil(const DomainSpace &dSpace, const RangeSpace &rSpace, bool onlyNonContinuousNeighbors=false)
Definition: stencil.hh:347
Stencil< DomainSpace, RangeSpace > BaseType
Definition: stencil.hh:337
BaseType::LocalStencilType LocalStencilType
Definition: stencil.hh:344
BaseType::GlobalStencilType GlobalStencilType
Definition: stencil.hh:345
Partition PartitionType
Definition: stencil.hh:339
BaseType::DomainEntityType DomainEntityType
Definition: stencil.hh:340
BaseType::RangeGlobalKeyType RangeGlobalKeyType
Definition: stencil.hh:343