1#ifndef DUNE_FEM_ADAPTIVELEAFINDEXSET_HH
2#define DUNE_FEM_ADAPTIVELEAFINDEXSET_HH
13#include <dune/fem/common/forloop.hh>
15#include <dune/fem/gridpart/codimindexset.hh>
16#include <dune/fem/gridpart/common/gridpart.hh>
17#include <dune/fem/gridpart/common/persistentindexset.hh>
18#include <dune/fem/io/file/iointerface.hh>
19#include <dune/fem/version.hh>
30 template <
class Gr
idPartImp >
31 class AdaptiveLeafIndexSet;
32 template <
class Gr
idPartImp >
33 class IntersectionAdaptiveLeafIndexSet;
34 template <
class Gr
idPartImp >
35 class DGAdaptiveLeafIndexSet;
46 template<
class Gr
idPart,
class IndexSet >
47 class AdaptiveIndexSetBaseTraits
51 typedef IndexSet IndexSetType;
54 typedef GridPart GridPartType;
56 typedef typename GridPartType :: GridType GridType;
59 static const int dimension = GridPartType :: dimension;
65 typedef typename GridPartType :: template Codim< codim > :: EntityType Entity;
69 typedef CodimIndexSet< GridType > CodimIndexSetType;
71 typedef typename CodimIndexSetType :: IndexType IndexType;
74 typedef std::vector< GeometryType > Types;
96 template <
class TraitsImp >
98 :
public PersistentAdaptiveIndexSet< TraitsImp >
101 typedef PersistentAdaptiveIndexSet< TraitsImp > BaseType;
104 typedef typename TraitsImp :: GridPartType GridPartType;
105 typedef typename GridPartType :: GridType GridType;
107 typedef typename TraitsImp :: CodimIndexSetType CodimIndexSetType ;
109 typedef typename GridType::template Codim< 0 >::Entity GridElementType;
128 typedef typename BaseType :: Types
Types;
142 template<
int codim ,
bool gr
idHasCodim >
143 struct CountElementsBase
148 count = indexSet.template countElements< codim >(
type, std::integral_constant<bool,true>() );
152 template<
int codim >
153 struct CountElementsBase< codim, false >
158 count = indexSet.template countElements< codim >(
type, std::integral_constant<bool,false>() );
162 template<
int codim >
164 :
public CountElementsBase< codim, Dune::Fem::GridPartCapabilities::hasEntity< GridPartType, codim > :: v >
169 template<
int codim >
170 struct InsertSubEntities
172 static void apply (
const ThisType &indexSet,
const GridElementType &element )
175 if( ! indexSet.codimAvailable( codim ) ) return ;
178 if( !indexSet.codimUsed( codim ) )
return;
180 CodimIndexSetType &codimSet = indexSet.codimLeafSet( codim );
182 const int count = element.subEntities( codim );
183 for(
int i = 0; i < count; ++i )
185 codimSet.insertSubEntity( element, i );
190 template<
int codim ,
bool gr
idHasCodim >
191 struct InsertGhostSubEntitiesBase
193 static void apply ( ThisType &indexSet,
const GridElementType &element,
194 const bool skipGhosts )
197 if( ! indexSet.codimAvailable( codim ) ) return ;
200 if( !indexSet.codimUsed( codim ) )
return;
202 CodimIndexSetType &codimSet = indexSet.codimLeafSet( codim );
204 for(
unsigned int i = 0; i < element.subEntities( codim ); ++i )
206 if( !skipGhosts || (element.partitionType() !=
GhostEntity) )
207 codimSet.insertGhost( element.template subEntity< codim >( i ) );
212 template<
int codim >
213 struct InsertGhostSubEntitiesBase< codim, false >
215 static void apply ( ThisType &indexSet,
const GridElementType &element,
216 const bool skipGhosts )
220 template<
int codim >
221 struct InsertGhostSubEntities
222 :
public InsertGhostSubEntitiesBase< codim, Dune::Capabilities::hasEntity < GridType, codim > :: v >
226 template<
int codim ,
bool gr
idHasCodim >
227 struct CallSetUpCodimSetBase
229 static void apply (
const int cd,
const ThisType &indexSet )
232 if( ! indexSet.codimAvailable( codim ) ) return ;
234 if( cd == codim && ! indexSet.codimUsed( cd ) )
235 indexSet.template setupCodimSet< codim >(std::integral_constant<bool,true>());
239 template<
int codim >
240 struct CallSetUpCodimSetBase< codim, false >
242 static void apply (
const int cd,
const ThisType &indexSet )
244 if( cd == codim && ! indexSet.codimUsed( cd ) )
245 indexSet.template setupCodimSet< codim >(std::integral_constant<bool,false>());
249 template<
int codim >
250 struct CallSetUpCodimSet
251 :
public CallSetUpCodimSetBase< codim, Dune::Capabilities::hasEntity < GridType, codim > :: v >
260 template <
int codim,
bool gr
idHasCodim >
261 struct GetSubEntityBase
263 typedef typename GridPartType :: template Codim< codim > :: EntityType Entity;
264 static Entity subEntity(
const ElementType& element,
const int subEn )
266 return element.template subEntity< codim > ( subEn );
270 template <
int codim >
271 struct GetSubEntityBase< codim, false >
273 typedef typename GridPartType :: template
Codim< 0 > :: EntityType Entity;
274 static Entity subEntity(
const ElementType& element,
const int subEn )
276 DUNE_THROW(NotImplemented,
"stupid grid without entities of codim 1 used");
281 :
public GetSubEntityBase< 1, Dune::Capabilities::hasEntity < GridType, 1 > :: v >
286 typedef typename GetFaceEntity :: Entity FaceType;
290 ! Capabilities::isLocallyAdaptive<GridType>::v };
293 enum { myType = (
numCodimensions == 1 ) ? ( (CartesianNonAdaptiveGrid) ? -1 : 665 ) : 6 };
302 const GridPartType& gridPart_;
305 std::unique_ptr< const GridPartType > gridPartPtr_;
308 mutable std::unique_ptr< CodimIndexSetType > codimLeafSet_[
numCodimensions ];
311 std::vector< std::vector< GeometryType > > geomTypes_;
317 mutable bool compressed_;
320 using BaseType::grid_;
321 using BaseType::dofManager_;
324 bool codimAvailable(
const int codim )
const
326 return (codim < numCodimensions && codim >= 0);
330 bool codimUsed(
const int codim )
const
332 return codimAvailable( codim ) && codimLeafSet_[ codim ] ;
335 CodimIndexSetType& codimLeafSet(
const int codim )
const
337 assert( codimUsed( codim ) );
338 return *codimLeafSet_[ codim ];
342 void requestCodimensions (
const std::vector< int >& codimensions )
const
345 for(
const auto& codim : codimensions )
348 Fem::ForLoop< CallSetUpCodimSet, 1, dimension >::apply( codim, *
this );
354 :
AdaptiveIndexSetBase( *(new GridPartType( const_cast< GridType& > (*
grid), typename GridPartType::NoIndexSetType() )) )
357 gridPartPtr_.reset( &gridPart_ );
364 , sequence_( dofManager_.sequence() )
368 codimLeafSet_[ 0 ].reset(
new CodimIndexSetType( grid_, 0 ) );
374 codimLeafSet_[ codim ].reset(
new CodimIndexSetType( grid_, 1 ) );
379 auto macroView = grid_.levelGridView( 0 );
388 template <
class MacroIndexSet>
394 for(
int codim=0; codim <=
dimension; ++codim )
396 const int size = indexSet.types( codim ).size();
398 geomTypes_[ codim ].resize(
size );
399 std::copy_n( indexSet.types( codim ).begin(),
size, geomTypes_[ codim ].begin() );
411 virtual std::string
name ()
const
413 return "AdaptiveIndexSetBase";
436 if( codimAvailable( codim ) && onlySingleGeometryType )
438 if( codimUsed( codim ) )
439 return type ==
geomTypes( codim )[ 0 ] ? codimLeafSet( codim ).size() : 0;
444 Fem::ForLoop< CountElements, 0, dimension > :: apply( *
this,
type, count );
454 return codimLeafSet( codim ).size();
460 for(
size_t i=0; i<
types; ++i )
468 const std::vector <GeometryType> &
geomTypes (
const int codim)
const
470 assert( codim >= 0 && codim <
int(geomTypes_.size()) );
471 return geomTypes_[ codim ];
481 template <
class EntityType>
484 enum { codim = EntityType::codimension };
485 if( codimAvailable( codim ) )
487 assert( codimUsed( codim ) );
488 return codimLeafSet( codim ).exists( gridEntity( en ) );
505 insertIndex( entity );
511 removeIndex( entity );
523 if( CartesianNonAdaptiveGrid &&
524 grid_.comm().size() > 1 )
530 markAllBelowOld<Interior_Partition>();
533 markAllBelowOld< pitype >();
541 markAllBelowOld< pitype > ();
547 if( grid_.comm().size() > 1 )
550 markAllUsed<Ghost_Partition>();
566 template<
class Entity >
569 return index< Entity :: codimension >( entity );
573 template<
int codim >
575 index (
const typename GridPartType::template Codim< codim >::EntityType &entity )
const
577 if( codimAvailable( codim ) )
579 if( (codim != 0) && ! codimUsed( codim ) )
582 return codimLeafSet( codim ).index( gridEntity( entity ) );
595 if( codimAvailable( codim ) )
598 setupIntersections();
601 FaceType face = getIntersectionFace( intersection );
603 return codimLeafSet( codim ).index( gridEntity( face ) );
607 DUNE_THROW( NotImplemented, (
name() +
" does not support indices for intersections, intersectionCodim = ") << codim );
615 int subNumber,
unsigned int codim )
const
617 DUNE_THROW( NotImplemented, (
name() +
" does not support subIndices for intersections, intersectionCodim = ") << codim );
622 template<
class Entity >
625 return subIndex< Entity::codimension >( entity, subNumber, codim );
631 int subNumber,
unsigned int codim )
const
633 assert( (
int( codim ) >= cd) && (
int( codim ) <=
dimension) );
634 if( !codimAvailable( codim ) )
637 if( (codim != 0) && ! codimUsed( codim ) )
639 Fem::ForLoop< CallSetUpCodimSet, 1, dimension >::apply( codim, *
this );
642 const CodimIndexSetType &codimSet = codimLeafSet( codim );
643 const IndexType idx = codimSet.subIndex( gridEntity( entity ), subNumber );
644 assert( (idx >= 0) && (idx <
IndexType( codimSet.size() )) );
674 if( codimAvailable( codim ) && codimUsed( codim ) )
676 return codimLeafSet( codim ).numberOfHoles();
693 if( codimAvailable( codim ) )
695 assert( codimUsed( codim ) );
696 return codimLeafSet( codim ).oldIndex( hole );
716 if( codimAvailable( codim ) )
718 assert( codimUsed( codim ) );
719 return codimLeafSet( codim ).newIndex( hole );
737 void insertIndex (
const GridElementType &entity );
740 void insertIntersections (
const GridElementType &entity )
const;
743 void insertTemporary (
const GridElementType &entity );
746 void removeIndex (
const GridElementType &entity );
749 void checkHierarchy (
const GridElementType &entity,
bool wasNew );
752 template <PartitionIteratorType pt>
766 template <PartitionIteratorType pt>
767 void markAllBelowOld ();
770 template<
int codim >
771 void setupCodimSet (
const std::integral_constant<bool,true> &hasEntities)
const;
772 template<
int codim >
773 void setupCodimSet (
const std::integral_constant<bool,false> &hasEntities)
const;
776 void setupIntersections ()
const;
780 template<
int codim >
782 template<
int codim >
787 template<
class StreamTraits >
791 template<
class StreamTraits >
798 return getIntersectionFace( intersection, inside );
804 if( ! intersection.conforming() && intersection.neighbor() )
808 if( inside.level() < outside.level() )
809 return GetFaceEntity :: subEntity( outside, intersection.indexInOutside() );
813 return GetFaceEntity :: subEntity( inside, intersection.indexInInside() );
817 template<
class TraitsImp >
821 codimLeafSet( 0 ).resize();
824 if( numCodimensions > 1 )
826 for(
int codim = 1; codim < numCodimensions; ++codim )
828 if( codimUsed( codim ) )
829 codimLeafSet( codim ).resize();
836 template<
class TraitsImp >
841 for(
int codim = 0; codim < numCodimensions; ++codim )
843 if( codimUsed( codim ) )
844 codimLeafSet( codim ).clearHoles();
851 if( (grid_.comm().size() == 1) || (sequence_ == dofManager_.sequence()) )
856 for(
int codim = 0; codim < numCodimensions; ++codim )
858 if( codimUsed( codim ) )
859 codimLeafSet( codim ).prepareCompress();
866 bool haveToCopy = codimLeafSet( 0 ).compress();
867 for(
int codim = 1; codim < numCodimensions; ++codim )
869 if( codimUsed( codim ) )
870 haveToCopy |= codimLeafSet( codim ).compress();
876 sequence_ = dofManager_.sequence();
882 template<
class TraitsImp >
891 codimLeafSet( 0 ).insertGhost( entity );
894 if( numCodimensions > 1 )
895 Fem::ForLoop< InsertGhostSubEntities, 1, dimension >::apply( *
this, entity, skipGhosts );
900 codimLeafSet( 0 ).insert( entity );
902 if( numCodimensions > 1 )
903 Fem::ForLoop< InsertSubEntities, 1, dimension >::apply( *
this, entity );
907 assert( codimLeafSet( 0 ).exists( entity ) );
910 if( intersectionCodimension > 0 )
912 insertIntersections( entity );
919 template<
class TraitsImp >
921 AdaptiveIndexSetBase< TraitsImp >::insertIntersections (
const GridElementType &gridElement )
const
923 codimLeafSet( intersectionCodimension ).resize();
925 const ElementType &element = gridPart_.convert( gridElement );
926 const IntersectionIteratorType endiit = gridPart_.iend( element );
927 for( IntersectionIteratorType iit = gridPart_.ibegin( element );
928 iit != endiit ; ++ iit )
931 const IntersectionType& intersection = *iit ;
934 FaceType face = getIntersectionFace( intersection, element );
937 codimLeafSet( intersectionCodimension ).insert( gridEntity( face ) );
941 template<
class TraitsImp >
943 AdaptiveIndexSetBase< TraitsImp >::insertTemporary(
const GridElementType &entity )
945 insertIndex( entity );
946 codimLeafSet( 0 ).markForRemoval( entity );
949 template<
class TraitsImp >
951 AdaptiveIndexSetBase< TraitsImp >::removeIndex(
const GridElementType &entity )
954 codimLeafSet( 0 ).markForRemoval( entity );
963 template<
class TraitsImp >
965 AdaptiveIndexSetBase< TraitsImp >
966 ::checkHierarchy (
const GridElementType &entity,
bool wasNew )
970 if( entity.isLeaf() )
972 insertIndex( entity );
976 bool isNew = wasNew ;
977 typedef typename GridType::HierarchicIterator HierarchicIterator;
983 insertTemporary( entity );
988 isNew = codimLeafSet( 0 ).validIndex( entity );
992 const int childLevel = entity.level() + 1;
993 const HierarchicIterator end = entity.hend( childLevel );
994 for( HierarchicIterator it = entity.hbegin( childLevel ); it != end; ++it )
995 checkHierarchy( *it, isNew );
999 template<
class TraitsImp >
1000 template< PartitionIteratorType pt >
1002 AdaptiveIndexSetBase< TraitsImp >::markAllUsed ()
1008 for(
int codim = 0; codim < numCodimensions; ++codim )
1010 if( codimUsed( codim ) )
1011 codimLeafSet( codim ).resetUsed();
1014 typedef typename GridPartType
1015 ::template
Codim< 0 > :: template Partition< pt > :: IteratorType Iterator;
1017 const Iterator end = gridPart_.template end< 0, pt >();
1018 for( Iterator it = gridPart_.template begin< 0, pt >(); it != end; ++it )
1019 insertIndex( gridEntity( *it ) );
1022 template<
class TraitsImp >
1029 if( CartesianNonAdaptiveGrid )
1032 for(
int codim = 0; codim < numCodimensions; ++codim )
1034 if( codimUsed( codim ) )
1037 codimLeafSet( codim ).clear();
1043 template<
class TraitsImp >
1052 if( CartesianNonAdaptiveGrid &&
1053 grid_.comm().size() > 1 )
1056 markAllUsed<Interior_Partition> ();
1058 markAllUsed< pitype >();
1064 markAllUsed< pitype > ();
1068 template<
class TraitsImp >
1069 template< PartitionIteratorType pt >
1074 for(
int codim = 0; codim < numCodimensions; ++codim )
1076 if( codimUsed( codim ) )
1077 codimLeafSet( codim ).resetUsed();
1081 auto macroView = grid_.levelGridView( 0 );
1083 const auto macroend = macroView.template end< 0, pt >();
1084 for(
auto macroit = macroView.template begin< 0, pt >();
1085 macroit != macroend; ++macroit )
1087 checkHierarchy( *macroit,
false );
1092 template<
class TraitsImp >
1093 template<
int codim >
1095 AdaptiveIndexSetBase< TraitsImp >::setupCodimSet (
const std::integral_constant<bool,true>&)
const
1098 if( ! codimAvailable( codim ) ) return ;
1101 if( ! codimLeafSet_[ codim ] )
1103 codimLeafSet_[ codim ].reset(
new CodimIndexSetType( grid_, codim ) );
1107 codimLeafSet( codim ).resize();
1110 typedef typename GridPartType
1111 ::template Codim< codim >::template Partition< pitype > :: IteratorType Iterator;
1113 const Iterator end = gridPart_.template end< codim, pitype >();
1114 for( Iterator it = gridPart_.template begin< codim, pitype >(); it != end; ++it )
1115 codimLeafSet( codim ).insert( gridEntity( *it ) );
1118 template<
class TraitsImp >
1119 template<
int codim >
1121 AdaptiveIndexSetBase< TraitsImp >::setupCodimSet (
const std::integral_constant<bool,false>&)
const
1124 if( ! codimAvailable( codim ) ) return ;
1127 if( ! codimLeafSet_[ codim ] )
1129 codimLeafSet_[ codim ].reset(
new CodimIndexSetType( grid_, codim ) );
1133 codimLeafSet( codim ).resize();
1135 typedef typename GridPartType
1136 ::template Codim< 0 >::template Partition< pitype > :: IteratorType Iterator;
1138 const Iterator end = gridPart_.template end< 0, pitype >();
1139 for( Iterator it = gridPart_.template begin< 0, pitype >(); it != end; ++it )
1141 const ElementType& element = *it ;
1142 const GridElementType &gridElement = gridEntity( element );
1143 InsertSubEntities< codim >::apply( *
this, gridElement );
1148 template<
class TraitsImp >
1150 AdaptiveIndexSetBase< TraitsImp >::setupIntersections()
const
1153 if( intersectionCodimension < 0 ) return ;
1156 if( codimUsed( intersectionCodimension ) ) return ;
1159 codimLeafSet( intersectionCodimension ).resize();
1162 typedef typename GridPartType
1163 ::template Codim< 0 >::template Partition< pitype > :: IteratorType Iterator;
1165 const Iterator end = gridPart_.template end< 0, pitype >();
1166 for( Iterator it = gridPart_.template begin< 0, pitype >(); it != end; ++it )
1169 insertIntersections( gridEntity( *it ) );
1173 template<
class TraitsImp >
1174 template<
int codim >
1176 AdaptiveIndexSetBase< TraitsImp >::countElements ( GeometryType type,
const std::integral_constant<bool,true>& )
const
1178 typedef typename GridPartType
1179 ::template Codim< codim > :: template Partition< pitype > :: IteratorType Iterator;
1181 const Iterator begin = gridPart_.template begin< codim, pitype >();
1182 const Iterator end = gridPart_.template end< codim, pitype >();
1183 IndexType count = 0;
1184 for( Iterator it = begin; it != end; ++it )
1186 if( it->type() == type )
1194 template<
class TraitsImp >
1195 template<
int codim >
1197 AdaptiveIndexSetBase< TraitsImp >::countElements ( GeometryType type,
const std::integral_constant<bool,false>& )
const
1199 if( ! codimLeafSet_[ codim ] )
1203 assert( codimAvailable( codim ) );
1206 codimLeafSet( codim ).resize();
1208 typedef typename GridPartType
1209 ::template Codim< 0 >::template Partition< pitype > :: IteratorType Iterator;
1211 typedef typename GridPartType::ctype ctype;
1213 const Iterator end = gridPart_.template end< 0, pitype >();
1214 IndexType count = 0;
1215 for( Iterator it = gridPart_.template begin< 0, pitype >(); it != end; ++it )
1217 const ElementType& element = *it ;
1218 const GridElementType &gridElement = gridEntity( element );
1219 const int subEntities = gridElement.subEntities( codim );
1220 for (
int i=0; i < subEntities; ++i)
1222 if (! codimLeafSet( codim ).exists( gridElement, i) )
1224 codimLeafSet( codim ).insertSubEntity( gridElement,i );
1226 general( gridElement.type() ).type( i, codim ) == type )
1238 template<
class TraitsImp >
1239 template<
class StreamTraits >
1244 const std::string myname( name() );
1248 out << numCodimensions ;
1251 for(
int i = 0; i < numCodimensions; ++i )
1252 out << codimUsed( i );
1255 for(
int i = 0; i < numCodimensions; ++i )
1257 if( codimUsed( i ) )
1258 codimLeafSet( i ).write( out );
1266 template<
class TraitsImp >
1267 template<
class StreamTraits >
1273 std::string storedName;
1276 std::string myname( name() );
1278 if( myname != storedName )
1280 size_t length = std::min( myname.size(), storedName.size() );
1282 std::string found = storedName.substr(0, length-1 );
1284 "AdaptiveIndexSetBase::read: got " << found
1285 <<
" (expected " << myname <<
")." );
1295 if( numCodim != numCodimensions )
1299 for(
int i = 0; i < numCodimensions; ++i )
1301 bool codimInUse = false ;
1303 if( codimInUse && ! codimLeafSet_[ i ] )
1305 codimLeafSet_[ i ].reset(
new CodimIndexSetType( grid_, (i == intersectionCodimension ) ? 1 : i ) );
1309 for(
int i = 0; i < numCodimensions; ++i )
1311 if( codimUsed( i ) )
1312 codimLeafSet( i ).read( in );
1316 if( grid_.comm().size() > 1 )
1317 compressed_ =
false;
1331 template<
class Gr
idPartImp >
1332 struct AdaptiveLeafIndexSetTraits
1333 :
public AdaptiveIndexSetBaseTraits< GridPartImp, AdaptiveLeafIndexSet< GridPartImp > >
1336 enum { numCodimensions = GridPartImp :: dimension + 1 };
1338 enum { startingCodimension = 0 };
1340 enum { intersectionCodimension = -1 };
1354 template <
class Gr
idPartImp >
1359 typedef AdaptiveLeafIndexSetTraits< GridPartImp > Traits;
1362 typedef typename BaseType :: GridType GridType;
1363 typedef typename BaseType :: GridPartType GridPartType;
1378 return "AdaptiveLeafIndexSet";
1386 if( this->grid_.comm().size() == 1 )
1388 for(
int codim = Traits::startingCodimension; codim < Traits::numCodimensions; ++codim )
1389 assert( this->codimUsed( codim ) ?
1390 size_t(this->
size( codim )) ==
size_t(this->grid_.size( codim )) :
true );
1405 template<
class Gr
idPartImp >
1406 struct IntersectionAdaptiveLeafIndexSetTraits
1407 :
public AdaptiveIndexSetBaseTraits< GridPartImp, IntersectionAdaptiveLeafIndexSet< GridPartImp > >
1410 enum { numCodimensions = GridPartImp :: dimension + 2 };
1412 enum { intersectionCodimension = numCodimensions - 1 };
1414 enum { startingCodimension = 0 };
1428 template <
class Gr
idPartImp >
1429 class IntersectionAdaptiveLeafIndexSet
1430 :
public AdaptiveIndexSetBase< IntersectionAdaptiveLeafIndexSetTraits< GridPartImp > >
1432 typedef AdaptiveIndexSetBase< IntersectionAdaptiveLeafIndexSetTraits< GridPartImp > > BaseType;
1433 typedef IntersectionAdaptiveLeafIndexSetTraits< GridPartImp > Traits;
1436 typedef typename BaseType :: GridType GridType;
1437 typedef typename BaseType :: GridPartType GridPartType;
1439 IntersectionAdaptiveLeafIndexSet (
const GridType* grid)
1444 IntersectionAdaptiveLeafIndexSet (
const GridPartType& gridPart)
1445 : BaseType(gridPart)
1449 virtual std::string name ()
const
1451 return "IntersectionAdaptiveLeafIndexSet";
1459 if( this->grid_.comm().size() == 1 )
1461 for(
int codim = Traits::startingCodimension; codim < Traits::numCodimensions; ++codim )
1462 if( codim != Traits::intersectionCodimension )
1463 assert(
size_t(this->
size( codim )) ==
size_t(this->grid_.size( codim )) );
1477 template<
class Gr
idPartImp >
1478 struct DGAdaptiveLeafIndexSetTraits
1479 :
public AdaptiveIndexSetBaseTraits< GridPartImp, DGAdaptiveLeafIndexSet< GridPartImp > >
1482 enum { numCodimensions = 1 };
1484 enum { startingCodimension = 0 };
1486 enum { intersectionCodimension = -1 };
1499 template <
class Gr
idPartImp >
1504 typedef DGAdaptiveLeafIndexSetTraits< GridPartImp > Traits;
1507 typedef typename BaseType :: GridType GridType;
1508 typedef typename BaseType :: GridPartType GridPartType;
1521 return "DGAdaptiveLeafIndexSet";
1529 if( this->grid_.comm().size() == 1 )
1530 assert(
size_t(this->
size( 0 )) ==
size_t(this->grid_.size( 0 )) );
Wrapper class for entities.
Definition: entity.hh:66
consecutive, persistent index set for the leaf level based on the grid's hierarchy index set
Definition: adaptiveleafindexset.hh:99
IndexType subIndex(const typename GridPartType::template Codim< cd >::EntityType &entity, int subNumber, unsigned int codim) const
return index for given subentity */
Definition: adaptiveleafindexset.hh:630
IndexType numberOfHoles(GeometryType type) const
return number of holes for given type */
Definition: adaptiveleafindexset.hh:655
AdaptiveIndexSetBase(const GridPartType &gridPart)
Constructor.
Definition: adaptiveleafindexset.hh:361
virtual std::string name() const
return name of index set
Definition: adaptiveleafindexset.hh:411
void insertEntity(const GridElementType &entity)
please doc me */
Definition: adaptiveleafindexset.hh:501
IndexType index(const Entity &entity) const
return number of entities of given type */
Definition: adaptiveleafindexset.hh:567
bool read(InStreamInterface< StreamTraits > &in)
please doc me */
Definition: adaptiveleafindexset.hh:1269
BaseType::template Codim< 0 >::Entity ElementType
type of codimension 0 Entity
Definition: adaptiveleafindexset.hh:131
IndexType subIndex(const Entity &entity, int subNumber, unsigned int codim) const
return index for given subentity */
Definition: adaptiveleafindexset.hh:623
IndexType index(const typename GridPartType::template Codim< codim >::EntityType &entity) const
return number of entities of given type */
Definition: adaptiveleafindexset.hh:575
void setupIndexSet()
mark all indices of interest
Definition: adaptiveleafindexset.hh:1045
void resize()
please doc me */
Definition: adaptiveleafindexset.hh:518
IndexType numberOfHoles(const int codim) const
return number of holes of the sets indices
Definition: adaptiveleafindexset.hh:672
Types types(const int codim) const
return range of geometry types */
Definition: adaptiveleafindexset.hh:475
AdaptiveIndexSetBase(const GridType *grid)
Constructor.
Definition: adaptiveleafindexset.hh:353
void removeEntity(const GridElementType &entity)
please doc me */
Definition: adaptiveleafindexset.hh:509
static const int intersectionCodimension
intersection codimension (numCodim-1 if enabled, otherwise -1)
Definition: adaptiveleafindexset.hh:119
IndexType oldIndex(const IndexType hole, const int codim) const
return old index, for dof manager only
Definition: adaptiveleafindexset.hh:691
const GridPartType & gridPart() const
return const reference to the grid part
Definition: adaptiveleafindexset.hh:417
IndexType newIndex(IndexType hole, GeometryType type) const
return new index for given hole and type */
Definition: adaptiveleafindexset.hh:706
IndexType newIndex(const IndexType hole, const int codim) const
return new index, for dof manager only returns index
Definition: adaptiveleafindexset.hh:714
void resizeVectors()
reallocate the vector for new size
Definition: adaptiveleafindexset.hh:819
GridPartType::IntersectionType IntersectionType
type of intersections
Definition: adaptiveleafindexset.hh:137
IndexType oldIndex(IndexType hole, GeometryType type) const
return old index for given hole and type */
Definition: adaptiveleafindexset.hh:683
static const int dimension
grid dimension */
Definition: adaptiveleafindexset.hh:113
bool contains(const EntityType &en) const
return true if entity has index */
Definition: adaptiveleafindexset.hh:482
bool write(OutStreamInterface< StreamTraits > &out) const
please doc me */
Definition: adaptiveleafindexset.hh:1241
void clear()
clear index set (only for structured grids)
Definition: adaptiveleafindexset.hh:1024
BaseType::IndexType IndexType
index type */
Definition: adaptiveleafindexset.hh:125
BaseType::Types Types
geometry type range type */
Definition: adaptiveleafindexset.hh:128
static const int numCodimensions
number of supported codimensions
Definition: adaptiveleafindexset.hh:116
IndexType size(int codim) const
return number of entities of given type */
Definition: adaptiveleafindexset.hh:449
const std::vector< GeometryType > & geomTypes(const int codim) const
*/
Definition: adaptiveleafindexset.hh:468
void setupGeomTypes(const MacroIndexSet &indexSet)
Definition: adaptiveleafindexset.hh:389
IndexType size(GeometryType type) const
return number of entities of given type */
Definition: adaptiveleafindexset.hh:429
bool compress()
please doc me */
Definition: adaptiveleafindexset.hh:838
int type() const
return type of index set, for GrapeDataIO
Definition: adaptiveleafindexset.hh:405
static const bool hasSingleGeometryType
true if only one geometry type is available
Definition: adaptiveleafindexset.hh:122
GridPartType::IntersectionIteratorType IntersectionIteratorType
type of intersection iterator
Definition: adaptiveleafindexset.hh:134
consecutive, persistent index set for the leaf level based on the grid's hierarchy index set
Definition: adaptiveleafindexset.hh:1357
virtual std::string name() const
return name of index set
Definition: adaptiveleafindexset.hh:1376
AdaptiveLeafIndexSet(const GridType *grid)
Constructor.
Definition: adaptiveleafindexset.hh:1366
AdaptiveLeafIndexSet(const GridPartType &gridPart)
Constructor.
Definition: adaptiveleafindexset.hh:1371
consecutive, persistent index set for the leaf level based on the grid's hierarchy index set
Definition: adaptiveleafindexset.hh:1502
DGAdaptiveLeafIndexSet(const GridType *grid)
Constructor.
Definition: adaptiveleafindexset.hh:1510
virtual std::string name() const
return name of index set
Definition: adaptiveleafindexset.hh:1519
abstract interface for an input stream
Definition: streams.hh:190
Traits::IndexType IndexType
index type
Definition: indexset.hh:136
abstract interface for an output stream
Definition: streams.hh:48
const GridType & grid() const
return const reference to the grid
Definition: persistentindexset.hh:161
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:375
Default exception for dummy implementations.
Definition: exceptions.hh:357
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
Dune namespace
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: capabilities.hh:58
Specialize with 'true' for if the codimension 0 entity of the grid has only one possible geometry typ...
Definition: capabilities.hh:27
Specialize with 'true' if the grid is a Cartesian grid. Cartesian grids satisfy the following propert...
Definition: capabilities.hh:48
Class providing access to the singletons of the reference elements.
Definition: referenceelements.hh:128