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_ );
 
  362        : BaseType( gridPart.grid() )
 
  363        , gridPart_( 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";
 
  430        if( codimAvailable( codim ) && onlySingleGeometryType )
 
  432          if( codimUsed( codim ) )
 
  433            return type == 
geomTypes( codim )[ 0 ] ? codimLeafSet( codim ).size() : 0;
 
  438        Fem::ForLoop< CountElements, 0, dimension > :: apply( *
this, 
type, count );
 
  448          return codimLeafSet( codim ).size();
 
  454        for( 
size_t i=0; i<
types; ++i )
 
  462      const std::vector <GeometryType> & 
geomTypes (
const int codim)
 const 
  464        assert( codim >= 0 && codim < 
int(geomTypes_.size()) );
 
  465        return geomTypes_[ codim ];
 
  475      template <
class EntityType>
 
  478        enum { codim = EntityType::codimension };
 
  479        if( codimAvailable( codim ) )
 
  481          assert( codimUsed( codim ) );
 
  482          return codimLeafSet( codim ).exists( gridEntity( en ) );
 
  499        insertIndex( entity );
 
  505        removeIndex( entity );
 
  517        if( CartesianNonAdaptiveGrid  &&
 
  518            grid_.comm().size() > 1 )
 
  524          markAllBelowOld<Interior_Partition>();
 
  527            markAllBelowOld< pitype >();
 
  535          markAllBelowOld< pitype > ();
 
  541            if( grid_.comm().size() > 1 )
 
  544              markAllUsed<Ghost_Partition>();
 
  560      template< 
class Entity >
 
  563        return index< Entity :: codimension >( entity );
 
  567      template< 
int codim >
 
  569      index ( 
const typename GridPartType::template Codim< codim >::EntityType &entity )
 const 
  571        if( codimAvailable( codim ) )
 
  573          if( (codim != 0) && ! codimUsed( codim ) )
 
  576          return codimLeafSet( codim ).index( gridEntity( entity ) );
 
  589        if( codimAvailable( codim ) )
 
  592          setupIntersections();
 
  595          FaceType face = getIntersectionFace( intersection );
 
  597          return codimLeafSet( codim ).index( gridEntity( face ) );
 
  601          DUNE_THROW( NotImplemented, (
name() + 
" does not support indices for intersections, intersectionCodim = ") << codim );
 
  609                 int subNumber, 
unsigned int codim )
 const 
  611        DUNE_THROW( NotImplemented, (
name() + 
" does not support subIndices for intersections, intersectionCodim = ") << codim );
 
  616      template< 
class Entity >
 
  619        return subIndex< Entity::codimension >( entity, subNumber, codim );
 
  625                           int subNumber, 
unsigned int codim )
 const 
  627        assert( (
int( codim ) >= cd) && (
int( codim ) <= 
dimension) );
 
  628        if( !codimAvailable( codim ) )
 
  631        if( (codim != 0) && ! codimUsed( codim ) )
 
  633          Fem::ForLoop< CallSetUpCodimSet, 1, dimension >::apply( codim, *
this );
 
  636        const CodimIndexSetType &codimSet = codimLeafSet( codim );
 
  637        const IndexType idx = codimSet.subIndex( gridEntity( entity ), subNumber );
 
  638        assert( (idx >= 0) && (idx < 
IndexType( codimSet.size() )) );
 
  668        if( codimAvailable( codim ) && codimUsed( codim ) )
 
  670          return codimLeafSet( codim ).numberOfHoles();
 
  687        if( codimAvailable( codim ) )
 
  689          assert( codimUsed( codim ) );
 
  690          return codimLeafSet( codim ).oldIndex( hole );
 
  710        if( codimAvailable( codim ) )
 
  712          assert( codimUsed( codim ) );
 
  713          return codimLeafSet( codim ).newIndex( hole );
 
  731      void insertIndex ( 
const GridElementType &entity );
 
  734      void insertIntersections ( 
const GridElementType &entity ) 
const;
 
  737      void insertTemporary ( 
const GridElementType &entity );
 
  740      void removeIndex ( 
const GridElementType &entity );
 
  743      void checkHierarchy ( 
const GridElementType &entity, 
bool wasNew );
 
  746      template <PartitionIteratorType pt>
 
  760      template <PartitionIteratorType pt>
 
  761      void markAllBelowOld ();
 
  764      template< 
int codim >
 
  765      void setupCodimSet (
const std::integral_constant<bool,true> &hasEntities) 
const;
 
  766      template< 
int codim >
 
  767      void setupCodimSet (
const std::integral_constant<bool,false> &hasEntities) 
const;
 
  770      void setupIntersections () 
const;
 
  774      template< 
int codim >
 
  776      template< 
int codim >
 
  781      template< 
class StreamTraits >
 
  785      template< 
class StreamTraits >
 
  792        return getIntersectionFace( intersection, inside );
 
  798        if( ! intersection.conforming() && intersection.neighbor() )
 
  802          if( inside.level() < outside.level() )
 
  803            return GetFaceEntity :: subEntity( outside, intersection.indexInOutside() );
 
  807        return GetFaceEntity :: subEntity( inside, intersection.indexInInside() );
 
  811    template< 
class TraitsImp >
 
  815      codimLeafSet( 0 ).resize();
 
  818      if( numCodimensions > 1 )
 
  820        for( 
int codim = 1; codim < numCodimensions; ++codim )
 
  822          if( codimUsed( codim ) )
 
  823            codimLeafSet( codim ).resize();
 
  830    template< 
class TraitsImp >
 
  835      for( 
int codim = 0; codim < numCodimensions; ++codim )
 
  837        if( codimUsed( codim ) )
 
  838          codimLeafSet( codim ).clearHoles();
 
  845        if( (grid_.comm().size() == 1) || (sequence_ == dofManager_.sequence()) )
 
  850      for( 
int codim = 0; codim < numCodimensions; ++codim )
 
  852        if( codimUsed( codim ) )
 
  853          codimLeafSet( codim ).prepareCompress();
 
  860      bool haveToCopy = codimLeafSet( 0 ).compress();
 
  861      for( 
int codim = 1; codim < numCodimensions; ++codim )
 
  863        if( codimUsed( codim ) )
 
  864          haveToCopy |= codimLeafSet( codim ).compress();
 
  870      sequence_ = dofManager_.sequence();
 
  876    template< 
class TraitsImp >
 
  885        codimLeafSet( 0 ).insertGhost( entity );
 
  888        if( numCodimensions > 1 )
 
  889          Fem::ForLoop< InsertGhostSubEntities, 1, dimension >::apply( *
this, entity, skipGhosts );
 
  894        codimLeafSet( 0 ).insert( entity );
 
  896        if( numCodimensions > 1 )
 
  897          Fem::ForLoop< InsertSubEntities, 1, dimension >::apply( *
this, entity );
 
  901      assert( codimLeafSet( 0 ).exists( entity ) );
 
  904      if( intersectionCodimension > 0 )
 
  906        insertIntersections( entity );
 
  913    template< 
class TraitsImp >
 
  915    AdaptiveIndexSetBase< TraitsImp >::insertIntersections ( 
const GridElementType &gridElement )
 const 
  917      codimLeafSet( intersectionCodimension ).resize();
 
  919      const ElementType &element = gridPart_.convert( gridElement );
 
  920      const IntersectionIteratorType endiit = gridPart_.iend( element );
 
  921      for( IntersectionIteratorType iit = gridPart_.ibegin( element );
 
  922           iit != endiit ; ++ iit )
 
  925        const IntersectionType& intersection = *iit ;
 
  928        FaceType face = getIntersectionFace( intersection, element );
 
  931        codimLeafSet( intersectionCodimension ).insert( gridEntity( face ) );
 
  935    template< 
class TraitsImp >
 
  937    AdaptiveIndexSetBase< TraitsImp >::insertTemporary( 
const GridElementType &entity )
 
  939      insertIndex( entity );
 
  940      codimLeafSet( 0 ).markForRemoval( entity );
 
  943    template< 
class TraitsImp >
 
  945    AdaptiveIndexSetBase< TraitsImp >::removeIndex( 
const GridElementType &entity )
 
  948      codimLeafSet( 0 ).markForRemoval( entity );
 
  957    template< 
class TraitsImp >
 
  959    AdaptiveIndexSetBase< TraitsImp >
 
  960      ::checkHierarchy ( 
const GridElementType &entity, 
bool wasNew )
 
  964      if( entity.isLeaf() )
 
  966        insertIndex( entity );
 
  970      bool isNew = wasNew ;
 
  971      typedef typename GridType::HierarchicIterator HierarchicIterator;
 
  977        insertTemporary( entity );
 
  982        isNew = codimLeafSet( 0 ).validIndex( entity );
 
  986      const int childLevel = entity.level() + 1;
 
  987      const HierarchicIterator end  = entity.hend( childLevel );
 
  988      for( HierarchicIterator it = entity.hbegin( childLevel ); it != end; ++it )
 
  989        checkHierarchy( *it, isNew );
 
  993    template< 
class TraitsImp >
 
  994    template< PartitionIteratorType pt >
 
  996    AdaptiveIndexSetBase< TraitsImp >::markAllUsed ()
 
 1002      for( 
int codim = 0; codim < numCodimensions; ++codim )
 
 1004        if( codimUsed( codim ) )
 
 1005          codimLeafSet( codim ).resetUsed();
 
 1008      typedef typename GridPartType
 
 1009        ::template 
Codim< 0 > :: template Partition< pt > :: IteratorType  Iterator;
 
 1011      const Iterator end  = gridPart_.template end< 0, pt >();
 
 1012      for( Iterator it = gridPart_.template begin< 0, pt >(); it != end; ++it )
 
 1013        insertIndex( gridEntity( *it ) );
 
 1016    template< 
class TraitsImp >
 
 1023      if( CartesianNonAdaptiveGrid )
 
 1026        for( 
int codim = 0; codim < numCodimensions; ++codim )
 
 1028          if( codimUsed( codim ) )
 
 1031            codimLeafSet( codim ).clear();
 
 1037    template< 
class TraitsImp >
 
 1046      if( CartesianNonAdaptiveGrid  &&
 
 1047          grid_.comm().size() > 1 )
 
 1050        markAllUsed<Interior_Partition> ();
 
 1052          markAllUsed< pitype >();
 
 1058        markAllUsed< pitype > ();
 
 1062    template< 
class TraitsImp >
 
 1063    template< PartitionIteratorType pt >
 
 1068      for( 
int codim = 0; codim < numCodimensions; ++codim )
 
 1070        if( codimUsed( codim ) )
 
 1071          codimLeafSet( codim ).resetUsed();
 
 1075      auto macroView = grid_.levelGridView( 0 );
 
 1077      const auto macroend = macroView.template end< 0, pt >();
 
 1078      for( 
auto macroit = macroView.template begin< 0, pt >();
 
 1079           macroit != macroend; ++macroit )
 
 1081        checkHierarchy( *macroit, 
false );
 
 1086    template< 
class TraitsImp >
 
 1087    template< 
int codim >
 
 1089    AdaptiveIndexSetBase< TraitsImp >::setupCodimSet (
const std::integral_constant<bool,true>&)
 const 
 1092      if( ! codimAvailable( codim ) ) return ;
 
 1095      if( ! codimLeafSet_[ codim ] )
 
 1097        codimLeafSet_[ codim ].reset( 
new CodimIndexSetType( grid_, codim ) );
 
 1101      codimLeafSet( codim ).resize();
 
 1104      typedef typename GridPartType
 
 1105        ::template Codim< codim >::template Partition< pitype > :: IteratorType Iterator;
 
 1107      const Iterator end = gridPart_.template end< codim, pitype >();
 
 1108      for( Iterator it = gridPart_.template begin< codim, pitype >(); it != end; ++it )
 
 1109        codimLeafSet( codim ).insert( gridEntity( *it ) );
 
 1112    template< 
class TraitsImp >
 
 1113    template< 
int codim >
 
 1115    AdaptiveIndexSetBase< TraitsImp >::setupCodimSet (
const std::integral_constant<bool,false>&)
 const 
 1118      if( ! codimAvailable( codim ) ) return ;
 
 1121      if( ! codimLeafSet_[ codim ] )
 
 1123        codimLeafSet_[ codim ].reset( 
new CodimIndexSetType( grid_, codim ) );
 
 1127      codimLeafSet( codim ).resize();
 
 1129      typedef typename GridPartType
 
 1130        ::template Codim< 0 >::template Partition< pitype > :: IteratorType Iterator;
 
 1132      const Iterator end = gridPart_.template end< 0, pitype >();
 
 1133      for( Iterator it = gridPart_.template begin< 0, pitype >(); it != end; ++it )
 
 1135        const ElementType& element = *it ;
 
 1136        const GridElementType &gridElement = gridEntity( element );
 
 1137        InsertSubEntities< codim >::apply( *
this, gridElement );
 
 1142    template< 
class TraitsImp >
 
 1144    AdaptiveIndexSetBase< TraitsImp >::setupIntersections()
 const 
 1147      if( intersectionCodimension < 0 ) return ;
 
 1150      if( codimUsed( intersectionCodimension ) ) return ;
 
 1153      codimLeafSet( intersectionCodimension ).resize();
 
 1156      typedef typename GridPartType
 
 1157        ::template Codim< 0 >::template Partition< pitype > :: IteratorType Iterator;
 
 1159      const Iterator end = gridPart_.template end< 0, pitype >();
 
 1160      for( Iterator it = gridPart_.template begin< 0, pitype >(); it != end; ++it )
 
 1163        insertIntersections( gridEntity( *it ) );
 
 1167    template< 
class TraitsImp >
 
 1168    template< 
int codim >
 
 1170    AdaptiveIndexSetBase< TraitsImp >::countElements ( GeometryType type, 
const std::integral_constant<bool,true>& )
 const 
 1172      typedef typename GridPartType
 
 1173        ::template Codim< codim > :: template Partition< pitype > :: IteratorType Iterator;
 
 1175      const Iterator begin = gridPart_.template begin< codim, pitype >();
 
 1176      const Iterator end = gridPart_.template end< codim, pitype >();
 
 1177      IndexType count = 0;
 
 1178      for( Iterator it = begin; it != end; ++it )
 
 1180        if( it->type() == type )
 
 1188    template< 
class TraitsImp >
 
 1189    template< 
int codim >
 
 1191    AdaptiveIndexSetBase< TraitsImp >::countElements ( GeometryType type, 
const std::integral_constant<bool,false>& )
 const 
 1193      if( ! codimLeafSet_[ codim ] )
 
 1197      assert( codimAvailable( codim ) );
 
 1200      codimLeafSet( codim ).resize();
 
 1202      typedef typename GridPartType
 
 1203        ::template Codim< 0 >::template Partition< pitype > :: IteratorType Iterator;
 
 1205      typedef typename GridPartType::ctype ctype;
 
 1207      const Iterator end = gridPart_.template end< 0, pitype >();
 
 1208      IndexType count = 0;
 
 1209      for( Iterator it = gridPart_.template begin< 0, pitype >(); it != end; ++it )
 
 1211        const ElementType& element = *it ;
 
 1212        const GridElementType &gridElement = gridEntity( element );
 
 1213        const int subEntities = gridElement.subEntities( codim );
 
 1214        for (
int i=0; i < subEntities; ++i)
 
 1216          if (! codimLeafSet( codim ).exists( gridElement, i) )
 
 1218            codimLeafSet( codim ).insertSubEntity( gridElement,i );
 
 1220               general( gridElement.type() ).type( i, codim ) == type )
 
 1232    template< 
class TraitsImp >
 
 1233    template< 
class StreamTraits >
 
 1238      const std::string myname( name() );
 
 1242      out << numCodimensions ;
 
 1245      for( 
int i = 0; i < numCodimensions; ++i )
 
 1246        out << codimUsed( i );
 
 1249      for( 
int i = 0; i < numCodimensions; ++i )
 
 1251        if( codimUsed( i ) )
 
 1252          codimLeafSet( i ).write( out );
 
 1260    template< 
class TraitsImp >
 
 1261    template< 
class StreamTraits >
 
 1267        std::string storedName;
 
 1270        std::string myname( name() );
 
 1272        if( myname != storedName )
 
 1274          size_t length = std::min( myname.size(), storedName.size() );
 
 1276          std::string found = storedName.substr(0, length-1 );
 
 1278                      "AdaptiveIndexSetBase::read: got  " << found
 
 1279                      << 
" (expected " << myname << 
")." );
 
 1289      if( numCodim != numCodimensions )
 
 1293      for( 
int i = 0; i < numCodimensions; ++i )
 
 1295        bool codimInUse = false ;
 
 1297        if( codimInUse && ! codimLeafSet_[ i ] )
 
 1299          codimLeafSet_[ i ].reset( 
new CodimIndexSetType( grid_, (i == intersectionCodimension ) ? 1 : i  ) );
 
 1303      for( 
int i = 0; i < numCodimensions; ++i )
 
 1305        if( codimUsed( i ) )
 
 1306          codimLeafSet( i ).read( in );
 
 1310      if( grid_.comm().size() > 1 )
 
 1311        compressed_ = 
false;
 
 1325    template< 
class Gr
idPartImp >
 
 1326    struct AdaptiveLeafIndexSetTraits
 
 1327    : 
public AdaptiveIndexSetBaseTraits< GridPartImp, AdaptiveLeafIndexSet< GridPartImp > >
 
 1330      enum { numCodimensions = GridPartImp :: dimension + 1 };
 
 1332      enum { startingCodimension = 0 };
 
 1334      enum { intersectionCodimension = -1 };
 
 1348    template < 
class Gr
idPartImp >
 
 1353      typedef AdaptiveLeafIndexSetTraits< GridPartImp > Traits;
 
 1356      typedef typename BaseType :: GridType GridType;
 
 1357      typedef typename BaseType :: GridPartType GridPartType;
 
 1372        return "AdaptiveLeafIndexSet";
 
 1380        if( this->grid_.comm().size() == 1 )
 
 1382          for( 
int codim = Traits::startingCodimension; codim < Traits::numCodimensions; ++codim )
 
 1383            assert( this->codimUsed( codim ) ?
 
 1384                size_t(this->
size( codim )) == 
size_t(this->grid_.size( codim )) : 
true );
 
 1399    template< 
class Gr
idPartImp >
 
 1400    struct IntersectionAdaptiveLeafIndexSetTraits
 
 1401    : 
public AdaptiveIndexSetBaseTraits< GridPartImp, IntersectionAdaptiveLeafIndexSet< GridPartImp > >
 
 1404      enum { numCodimensions = GridPartImp :: dimension + 2 };
 
 1406      enum { intersectionCodimension = numCodimensions - 1 };
 
 1408      enum { startingCodimension = 0 };
 
 1422    template < 
class Gr
idPartImp >
 
 1423    class IntersectionAdaptiveLeafIndexSet
 
 1424    : 
public AdaptiveIndexSetBase< IntersectionAdaptiveLeafIndexSetTraits< GridPartImp > >
 
 1426      typedef AdaptiveIndexSetBase< IntersectionAdaptiveLeafIndexSetTraits< GridPartImp > > BaseType;
 
 1427      typedef IntersectionAdaptiveLeafIndexSetTraits< GridPartImp > Traits;
 
 1430      typedef typename BaseType :: GridType     GridType;
 
 1431      typedef typename BaseType :: GridPartType GridPartType;
 
 1433      IntersectionAdaptiveLeafIndexSet (
const GridType* grid)
 
 1438      IntersectionAdaptiveLeafIndexSet (
const GridPartType& gridPart)
 
 1439        : BaseType(gridPart)
 
 1443      virtual std::string name ()
 const 
 1445        return "IntersectionAdaptiveLeafIndexSet";
 
 1453        if( this->grid_.comm().size() == 1 )
 
 1455          for( 
int codim = Traits::startingCodimension; codim < Traits::numCodimensions; ++codim )
 
 1456            if( codim != Traits::intersectionCodimension )
 
 1457              assert( 
size_t(this->
size( codim )) == 
size_t(this->grid_.size( codim )) );
 
 1471    template< 
class Gr
idPartImp >
 
 1472    struct DGAdaptiveLeafIndexSetTraits
 
 1473    : 
public AdaptiveIndexSetBaseTraits< GridPartImp, DGAdaptiveLeafIndexSet< GridPartImp > >
 
 1476      enum { numCodimensions = 1 };
 
 1478      enum { startingCodimension = 0 };
 
 1480      enum { intersectionCodimension = -1 };
 
 1493    template < 
class Gr
idPartImp >
 
 1498      typedef DGAdaptiveLeafIndexSetTraits< GridPartImp > Traits;
 
 1501      typedef typename BaseType :: GridType     GridType;
 
 1502      typedef typename BaseType :: GridPartType GridPartType;
 
 1509        : BaseType(gridPart)
 
 1515        return "DGAdaptiveLeafIndexSet";
 
 1523        if( this->grid_.comm().size() == 1 )
 
 1524          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:624
 
IndexType numberOfHoles(GeometryType type) const
return number of holes for given type */
Definition: adaptiveleafindexset.hh:649
 
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:495
 
IndexType index(const Entity &entity) const
return number of entities of given type */
Definition: adaptiveleafindexset.hh:561
 
bool read(InStreamInterface< StreamTraits > &in)
please doc me */
Definition: adaptiveleafindexset.hh:1263
 
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:617
 
IndexType index(const typename GridPartType::template Codim< codim >::EntityType &entity) const
return number of entities of given type */
Definition: adaptiveleafindexset.hh:569
 
void setupIndexSet()
mark all indices of interest
Definition: adaptiveleafindexset.hh:1039
 
void resize()
please doc me */
Definition: adaptiveleafindexset.hh:512
 
IndexType numberOfHoles(const int codim) const
return number of holes of the sets indices
Definition: adaptiveleafindexset.hh:666
 
Types types(const int codim) const
return range of geometry types */
Definition: adaptiveleafindexset.hh:469
 
AdaptiveIndexSetBase(const GridType *grid)
Constructor.
Definition: adaptiveleafindexset.hh:353
 
void removeEntity(const GridElementType &entity)
please doc me */
Definition: adaptiveleafindexset.hh:503
 
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:685
 
IndexType newIndex(IndexType hole, GeometryType type) const
return new index for given hole and type */
Definition: adaptiveleafindexset.hh:700
 
IndexType newIndex(const IndexType hole, const int codim) const
return new index, for dof manager only returns index
Definition: adaptiveleafindexset.hh:708
 
void resizeVectors()
reallocate the vector for new size
Definition: adaptiveleafindexset.hh:813
 
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:677
 
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:476
 
bool write(OutStreamInterface< StreamTraits > &out) const
please doc me */
Definition: adaptiveleafindexset.hh:1235
 
void clear()
clear index set (only for structured grids)
Definition: adaptiveleafindexset.hh:1018
 
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:443
 
const std::vector< GeometryType > & geomTypes(const int codim) const
*/
Definition: adaptiveleafindexset.hh:462
 
void setupGeomTypes(const MacroIndexSet &indexSet)
Definition: adaptiveleafindexset.hh:389
 
IndexType size(GeometryType type) const
return number of entities of given type */
Definition: adaptiveleafindexset.hh:423
 
bool compress()
please doc me */
Definition: adaptiveleafindexset.hh:832
 
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:1351
 
virtual std::string name() const
return name of index set
Definition: adaptiveleafindexset.hh:1370
 
AdaptiveLeafIndexSet(const GridType *grid)
Constructor.
Definition: adaptiveleafindexset.hh:1360
 
AdaptiveLeafIndexSet(const GridPartType &gridPart)
Constructor.
Definition: adaptiveleafindexset.hh:1365
 
consecutive, persistent index set for the leaf level based on the grid's hierarchy index set
Definition: adaptiveleafindexset.hh:1496
 
DGAdaptiveLeafIndexSet(const GridType *grid)
Constructor.
Definition: adaptiveleafindexset.hh:1504
 
virtual std::string name() const
return name of index set
Definition: adaptiveleafindexset.hh:1513
 
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
 
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