2 #ifndef DUNE_FEM_STENCIL_HH 3 #define DUNE_FEM_STENCIL_HH 9 #include <dune/grid/common/gridenums.hh> 30 template <
class DomainSpace,
class RangeSpace>
34 typedef typename DomainSpace::IteratorType DomainIteratorType;
35 typedef typename DomainSpace::BlockMapperType DomainBlockMapper;
38 typedef typename RangeSpace::IteratorType RangeIteratorType;
39 typedef typename RangeSpace::BlockMapperType RangeBlockMapper;
59 Stencil(
const DomainSpace &dSpace,
const RangeSpace &rSpace)
60 : domainBlockMapper_( dSpace.blockMapper() )
61 , rangeBlockMapper_( rSpace.blockMapper() )
72 void fill (
const DomainEntityType &dEntity,
const RangeEntityType &rEntity,
77 bool doFill = (dEntity.partitionType()!=GhostEntity) || fillGhost;
78 rangeBlockMapper_.mapEach(rEntity,
79 MFunctor( domainBlockMapper_, dEntity, FillFunctor(globalStencil_,doFill) ) );
87 const LocalStencilType &
localStencil(
const DomainGlobalKeyType &key)
const 89 return globalStencil_[key];
95 return globalStencil_;
102 typedef typename GlobalStencilType::const_iterator StencilIteratorType;
104 StencilIteratorType end = glStencil.end();
105 for ( StencilIteratorType it = glStencil.begin(); it != end; ++it)
106 ret =
std::max(ret,(
int)it->second.size());
114 typedef DomainGlobalKeyType GlobalKey;
115 FillFunctor(GlobalStencilType &stencil,
bool fill)
120 void set(
const std::size_t,
const DomainGlobalKeyType &domainGlobal)
122 localStencil_ = &(stencil_[ domainGlobal ]);
124 void operator() (
const std::size_t,
const RangeGlobalKeyType &rangeGlobal)
127 localStencil_->insert( rangeGlobal );
130 GlobalStencilType &stencil_;
131 LocalStencilType *localStencil_;
134 const DomainBlockMapper &domainBlockMapper_;
135 const RangeBlockMapper &rangeBlockMapper_;
136 GlobalStencilType globalStencil_;
146 template <
class DomainSpace,
class RangeSpace>
169 const LocalStencilType &
localStencil(
const DomainGlobalKeyType &key)
const 171 DUNE_THROW( Dune::NotImplemented,
"SimpleStencil: exact stencil information is unavailable." );
172 return localStencil_;
176 DUNE_THROW( Dune::NotImplemented,
"SimpleStencil: global stencil is unavailable." );
181 GlobalStencilType stencil_;
182 LocalStencilType localStencil_;
193 template <
class DomainSpace,
class RangeSpace>
206 : BaseType( dSpace, rSpace )
208 for (
const auto& entity : dSpace)
209 BaseType::fill(entity,entity);
222 template <
class DomainSpace,
class RangeSpace>
235 bool onlyNonContinuousNeighbors =
false)
236 : BaseType( dSpace, rSpace )
238 for (
const auto & entity: dSpace)
240 BaseType::fill(entity,entity);
241 typedef typename DomainSpace::GridPartType GridPart;
242 typedef typename GridPart :: IntersectionIteratorType IntersectionIteratorType;
243 typedef typename IntersectionIteratorType :: Intersection IntersectionType;
245 const IntersectionIteratorType endit = dSpace.gridPart().iend( entity );
246 for( IntersectionIteratorType it = dSpace.gridPart().ibegin( entity );
249 const IntersectionType& intersection = *it;
250 if ( onlyNonContinuousNeighbors
251 && rSpace.continuous(intersection) && dSpace.continuous(intersection) )
253 if( intersection.neighbor() )
255 DomainEntityType neighbor =
make_entity( intersection.outside() );
256 BaseType::fill(neighbor,entity);
267 #endif // #if defined DUNE_FEM_STENCIL_HH a watered down stencil providing only the upper bound for the non-zero entries per row...
Definition: stencil.hh:147
BaseType::LocalStencilType LocalStencilType
Definition: stencil.hh:231
BaseType::LocalStencilType LocalStencilType
Definition: stencil.hh:202
BaseType::GlobalStencilType GlobalStencilType
Definition: stencil.hh:203
int maxNonZerosEstimate() const
Definition: stencil.hh:165
const LocalStencilType & localStencil(const DomainGlobalKeyType &key) const
Return stencil for a given row of the matrix.
Definition: stencil.hh:87
BaseType::DomainGlobalKeyType DomainGlobalKeyType
Definition: stencil.hh:229
BaseType::DomainGlobalKeyType DomainGlobalKeyType
Definition: stencil.hh:200
BaseType::DomainEntityType DomainEntityType
Definition: stencil.hh:198
default implementation for a general operator stencil
Definition: stencil.hh:31
Stencil(const DomainSpace &dSpace, const RangeSpace &rSpace)
Constructor.
Definition: stencil.hh:59
static constexpr T max(T a)
Definition: utility.hh:65
Definition: misc/functor.hh:92
Stencil contaning the entries (en,en) and (en,nb) for all entities en in the space and neighbors nb o...
Definition: stencil.hh:223
BaseType::RangeEntityType RangeEntityType
Definition: stencil.hh:228
RangeBlockMapper::GlobalKeyType RangeGlobalKeyType
Definition: stencil.hh:45
DomainBlockMapper::GlobalKeyType DomainGlobalKeyType
Definition: stencil.hh:44
DomainIteratorType::Entity DomainEntityType
Definition: stencil.hh:42
DiagonalStencil(const DomainSpace &dSpace, const RangeSpace &rSpace)
Definition: stencil.hh:205
BaseType::RangeGlobalKeyType RangeGlobalKeyType
Definition: stencil.hh:201
std::set< RangeGlobalKeyType > LocalStencilType
type for storing the stencil of one row
Definition: stencil.hh:48
int maxNonZerosEstimate() const
Return an upper bound for the maximum number of non-zero entries in all row.
Definition: stencil.hh:99
StencilType::DomainGlobalKeyType DomainGlobalKeyType
Definition: stencil.hh:153
StencilType::DomainEntityType DomainEntityType
Definition: stencil.hh:151
const LocalStencilType & localStencil(const DomainGlobalKeyType &key) const
Definition: stencil.hh:169
Dune::EntityPointer< Grid, Implementation >::Entity make_entity(const Dune::EntityPointer< Grid, Implementation > &entityPointer)
Definition: compatibility.hh:23
Stencil< DomainSpace, RangeSpace > BaseType
Definition: stencil.hh:225
StencilType::GlobalStencilType GlobalStencilType
Definition: stencil.hh:156
Stencil< DomainSpace, RangeSpace > BaseType
Definition: stencil.hh:196
BaseType::GlobalStencilType GlobalStencilType
Definition: stencil.hh:232
Definition: coordinate.hh:4
SimpleStencil(int maxNZ)
Definition: stencil.hh:158
const GlobalStencilType & globalStencil() const
Return the full stencil.
Definition: stencil.hh:93
void fill(const DomainEntityType &dEntity, const RangeEntityType &rEntity, bool fillGhost=true)
Create stencil entries for (dEntity,rEntity) pair.
Definition: stencil.hh:72
StencilType::RangeEntityType RangeEntityType
Definition: stencil.hh:152
const GlobalStencilType & globalStencil() const
Definition: stencil.hh:174
Stencil contaning the entries (en,en) for all entities in the space. Defailt for an operator over a L...
Definition: stencil.hh:194
SimpleStencil()
Definition: stencil.hh:161
std::map< DomainGlobalKeyType, LocalStencilType > GlobalStencilType
type for storing the full stencil
Definition: stencil.hh:50
StencilType::LocalStencilType LocalStencilType
Definition: stencil.hh:155
BaseType::DomainEntityType DomainEntityType
Definition: stencil.hh:227
DiagonalAndNeighborStencil(const DomainSpace &dSpace, const RangeSpace &rSpace, bool onlyNonContinuousNeighbors=false)
Definition: stencil.hh:234
StencilType::RangeGlobalKeyType RangeGlobalKeyType
Definition: stencil.hh:154
BaseType::RangeEntityType RangeEntityType
Definition: stencil.hh:199
BaseType::RangeGlobalKeyType RangeGlobalKeyType
Definition: stencil.hh:230
RangeIteratorType::Entity RangeEntityType
Definition: stencil.hh:43