1#ifndef DUNE_FEM_GRIDPART_FILTER_BASICFILTERWRAPPER_HH
2#define DUNE_FEM_GRIDPART_FILTER_BASICFILTERWRAPPER_HH
7#include <dune/grid/common/gridenums.hh>
9#include <dune/fem/gridpart/filter/filter.hh>
20 template<
class >
class FilterDefaultImplementation;
21 template<
class,
class >
class BasicFilterWrapper;
27 template<
class Gr
idPartImp,
class BasicFilterImp >
28 struct BasicFilterWrapperTraits
31 typedef GridPartImp GridPartType;
34 typedef BasicFilterImp BasicFilterType;
37 typedef BasicFilterWrapper< GridPartType, BasicFilterType > FilterType;
55 template<
class Gr
idPartImp,
class BasicFilterImp >
56 class BasicFilterWrapper
57 :
public FilterDefaultImplementation< BasicFilterWrapperTraits< GridPartImp, BasicFilterImp > >
60 typedef BasicFilterImp BasicFilterType;
63 typedef GridPartImp GridPartType;
66 typedef BasicFilterWrapperTraits< GridPartType, BasicFilterType > Traits;
69 typedef BasicFilterWrapper< GridPartType, BasicFilterType > ThisType;
72 typedef FilterDefaultImplementation< Traits > BaseType;
74 static const int dimension = GridPartType::GridType::dimension;
76 static const int nCodim = dimension+1;
78 template<
int codim,
class Gr
idPart,
class BasicFilter >
85 static inline bool value (
const EntityType & entity,
86 const GridPart & gridPart,
87 const BasicFilter & filter,
90 if(
contains.size() !=
size_t(gridPart.indexSet().size(codim)) )
91 update< All_Partition >( gridPart, filter,
contains );
95 const IndexSetType & indexSet = gridPart.indexSet();
96 size_t index = size_t( indexSet.index( entity ) );
102 template< PartitionIteratorType pitype >
103 static inline void update (
const GridPart & gridPart,
104 const BasicFilter & filter,
111 const IndexSetType & indexSet = gridPart.indexSet();
114 contains.resize( indexSet.size( codim ) );
120 typedef typename GridPart::template
Codim< 0 >::template Partition< pitype >::IteratorType IteratorType;
123 IteratorType it = gridPart.template begin< 0, pitype >();
124 const IteratorType end = gridPart.template end< 0, pitype >();
125 for( ; it != end; ++it )
127 const typename IteratorType::Entity & entity = *it;
130 if( !filter.contains( entity ) )
133 const int count = entity.subEntities( codim );
134 for(
int i = 0; i < count; ++i )
136 size_t subIndex = size_t( indexSet.subIndex( entity, i , codim ) );
143 template<
class Gr
idPart,
class BasicFilter >
144 struct Contains< 0, GridPart, BasicFilter >
147 typedef typename ThisType::template Codim< 0 >::EntityType EntityType;
150 static inline bool value (
const EntityType & entity,
152 const BasicFilter & filter,
153 std::vector< bool > & )
155 return filter.contains( entity );
161 typedef typename Traits::FilterType FilterType;
166 typedef typename Traits::template Codim< cd >::EntityType EntityType;
170 typedef typename Traits::EntityType EntityType;
173 BasicFilterWrapper (
const GridPartType & gridPart,
const BasicFilterType & filter )
174 : gridPart_( gridPart ),
179 template<
typename ... Args >
180 BasicFilterWrapper (
const GridPartType & gridPart, Args && ... args )
181 : gridPart_( gridPart ),
186 BasicFilterWrapper (
const ThisType & other )
187 : gridPart_( other.gridPart_ ),
188 filter_( other.filter_ )
194 ThisType & operator= (
const ThisType & other )
196 gridPart_ = other.gridPart_;
197 filter_ = other.filter_;
203 template<
class Intersection >
204 bool interiorIntersection(
const Intersection &intersection )
const
206 return filter().interiorIntersection( intersection );
211 bool contains (
const typename Codim< cd >::EntityType & entity )
const
213 return Contains< cd, GridPartType, BasicFilterType >::value( entity, gridPart_, filter_, contains_[ cd ] );
217 template<
class Entity >
218 bool contains (
const Entity & entity )
const
221 return contains< cc >( entity );
225 template<
class Intersection >
226 bool intersectionBoundary(
const Intersection & intersection )
const
228 return filter().intersectionBoundary( intersection );
232 template<
class Intersection >
233 int intersectionBoundaryId (
const Intersection & intersection )
const
235 return filter().intersectionBoundaryId( intersection );
239 template<
class Intersection >
240 bool intersectionNeighbor (
const Intersection & intersection )
const
242 return filter().intersectionNeighbor( intersection );
248 for(
int codim = 0; codim < nCodim; ++codim )
249 contains_[ codim ].clear();
254 const BasicFilterType & filter ()
const
259 const GridPartType & gridPart_;
260 BasicFilterType filter_;
261 mutable std::vector< bool > contains_[ nCodim ];
static constexpr int codimension
Know your own codimension.
Definition: entity.hh:106
consecutive, persistent index set for the leaf level based on the grid's hierarchy index set
Definition: adaptiveleafindexset.hh:1351
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::bool_constant<((II==value)||...)> contains(std::integer_sequence< T, II... >, std::integral_constant< T, value >)
Checks whether or not a given sequence contains a value.
Definition: integersequence.hh:137
Static tag representing a codimension.
Definition: dimension.hh:24
entity types
Definition: basicfilterwrapper.hh:42
GridPartType::template Codim< cd >::EntityType EntityType
entity type for given codimension
Definition: basicfilterwrapper.hh:44