3#ifndef DUNE_ALBERTA_LEVEL_HH 
    4#define DUNE_ALBERTA_LEVEL_HH 
   10#include <dune/grid/albertagrid/dofadmin.hh> 
   11#include <dune/grid/albertagrid/dofvector.hh> 
   22  class AlbertaGridLevelProvider
 
   24    typedef AlbertaGridLevelProvider< dim > This;
 
   26    typedef unsigned char Level;
 
   28    typedef Alberta::DofVectorPointer< Level > DofVectorPointer;
 
   29    typedef Alberta::DofAccess< dim, 0 > DofAccess;
 
   31    typedef Alberta::FillFlags< dim > FillFlags;
 
   33    static const Level isNewFlag = (1 << 7);
 
   34    static const Level levelMask = (1 << 7) - 1;
 
   39    template< Level flags >
 
   45    typedef Alberta::ElementInfo< dim > ElementInfo;
 
   46    typedef Alberta::MeshPointer< dim > MeshPointer;
 
   47    typedef Alberta::HierarchyDofNumbering< dim > DofNumbering;
 
   49    Level operator() ( 
const Alberta::Element *element )
 const 
   51      const Level *array = (Level *)level_;
 
   52      return array[ dofAccess_( element, 0 ) ] & levelMask;
 
   55    Level operator() ( 
const ElementInfo &elementInfo )
 const 
   57      return (*
this)( elementInfo.el() );
 
   60    bool isNew ( 
const Alberta::Element *element )
 const 
   62      const Level *array = (Level *)level_;
 
   63      return ((array[ dofAccess_( element, 0 ) ] & isNewFlag) != 0);
 
   66    bool isNew ( 
const ElementInfo &elementInfo )
 const 
   68      return isNew( elementInfo.el() );
 
   71    Level maxLevel ()
 const 
   73      CalcMaxLevel calcFromCache;
 
   74      level_.forEach( calcFromCache );
 
   76      CalcMaxLevel calcFromGrid;
 
   77      mesh().leafTraverse( calcFromGrid, FillFlags::nothing );
 
   78      assert( calcFromCache.maxLevel() == calcFromGrid.maxLevel() );
 
   80      return calcFromCache.maxLevel();;
 
   83    MeshPointer mesh ()
 const 
   85      return MeshPointer( level_.dofSpace()->mesh );
 
   90      ClearFlags< isNewFlag > clearIsNew;
 
   91      level_.forEach( clearIsNew );
 
   94    void create ( 
const DofNumbering &dofNumbering )
 
   96      const Alberta::DofSpace *
const dofSpace = dofNumbering.dofSpace( 0 );
 
   97      dofAccess_ = DofAccess( dofSpace );
 
   99      level_.create( dofSpace, 
"Element level" );
 
  101      level_.template setupInterpolation< Interpolation >();
 
  103      SetLocal setLocal( level_ );
 
  104      mesh().hierarchicTraverse( setLocal, FillFlags::nothing );
 
  110      dofAccess_ = DofAccess();
 
  114    DofVectorPointer level_;
 
  115    DofAccess dofAccess_;
 
  124  class AlbertaGridLevelProvider< dim >::SetLocal
 
  126    DofVectorPointer level_;
 
  127    DofAccess dofAccess_;
 
  130    explicit SetLocal ( 
const DofVectorPointer &level )
 
  132        dofAccess_( level.dofSpace() )
 
  135    void operator() ( 
const Alberta::ElementInfo< dim > &elementInfo )
 const 
  137      Level *
const array = (Level *)level_;
 
  138      array[ dofAccess_( elementInfo, 0 ) ] = elementInfo.level();
 
  148  class AlbertaGridLevelProvider< dim >::CalcMaxLevel
 
  157    void operator() ( 
const Level &dof )
 
  159      maxLevel_ = std::max( maxLevel_, Level( dof & levelMask ) );
 
  162    void operator() ( 
const Alberta::ElementInfo< dim > &elementInfo )
 
  164      maxLevel_ = std::max( maxLevel_, Level( elementInfo.level() ) );
 
  167    Level maxLevel ()
 const 
  179  template< typename AlbertaGridLevelProvider< dim >::Level flags >
 
  180  struct AlbertaGridLevelProvider< dim >::ClearFlags
 
  182    void operator() ( Level &dof )
 const 
  194  struct AlbertaGridLevelProvider< dim >::Interpolation
 
  196    static const int dimension = dim;
 
  198    typedef Alberta::Patch< dimension > Patch;
 
  200    static void interpolateVector ( 
const DofVectorPointer &dofVector,
 
  203      const DofAccess dofAccess( dofVector.dofSpace() );
 
  204      Level *array = (Level *)dofVector;
 
  206      for( 
int i = 0; i < patch.count(); ++i )
 
  208        const Alberta::Element *
const father = patch[ i ];
 
  209        assert( (array[ dofAccess( father, 0 ) ] & levelMask) < levelMask );
 
  210        const Level childLevel = (array[ dofAccess( father, 0 ) ] + 1) | isNewFlag;
 
  211        for( 
int i = 0; i < 2; ++i )
 
  213          const Alberta::Element *child = father->child[ i ];
 
  214          array[ dofAccess( child, 0 ) ] = childLevel;
 
provides a wrapper for ALBERTA's mesh structure
 
Dune namespace.
Definition: alignment.hh:10