5#ifndef DUNE_ALBERTAGRID_CC
6#define DUNE_ALBERTAGRID_CC
28 template<
int dim,
int dimworld >
33 "Template Parameter dimworld does not match "
34 "ALBERTA's DIM_OF_WORLD setting.");
41 template<
int dim,
int dimworld >
45 numBoundarySegments_( 0 ),
46 hIndexSet_( dofNumbering_ ),
48 levelIndexVec_( (
size_t)MAXL, 0 ),
51 leafMarkerVector_( dofNumbering_ ),
58 template<
int dim,
int dimworld >
59 template<
class Proj,
class Impl >
65 numBoundarySegments_( 0 ),
66 hIndexSet_( dofNumbering_ ),
68 levelIndexVec_( (
size_t)MAXL, 0 ),
71 leafMarkerVector_( dofNumbering_ ),
87 template<
int dim,
int dimworld >
93 numBoundarySegments_( 0 ),
94 hIndexSet_( dofNumbering_ ),
96 levelIndexVec_( (
size_t)MAXL, 0 ),
99 leafMarkerVector_( dofNumbering_ ),
104 if( projection != 0 )
121 template <
int dim,
int dimworld >
126 hIndexSet_( dofNumbering_ ),
127 idSet_( hIndexSet_ ),
128 levelIndexVec_( (
size_t)MAXL, 0 ),
131 leafMarkerVector_( dofNumbering_ ),
141 <<
"' is not in ALBERTA macro triangulation format." );
149 std::cout <<
typeName() <<
" created from macro grid file '"
154 template<
int dim,
int dimworld >
157 dofNumbering_.create( mesh_ );
159 levelProvider_.create( dofNumbering_ );
161#if DUNE_ALBERTA_CACHE_COORDINATES
162 coordCache_.create( dofNumbering_ );
167 template<
int dim,
int dimworld >
168 inline void AlbertaGrid< dim, dimworld >::removeMesh ()
170 for(
size_t i = 0; i < levelIndexVec_.size(); ++i )
172 if( levelIndexVec_[ i ] != 0 )
173 delete levelIndexVec_[ i ];
174 levelIndexVec_[ i ] = 0;
177 if( leafIndexSet_ != 0 )
178 delete leafIndexSet_;
182 hIndexSet_.release();
183 levelProvider_.release();
184#if DUNE_ALBERTA_CACHE_COORDINATES
185 coordCache_.release();
187 dofNumbering_.release();
195 template<
int dim,
int dimworld >
202 template<
int dim,
int dimworld >
203 template<
int codim, PartitionIteratorType pitype >
205 ::template Codim< codim >::template Partition<pitype>::LevelIterator
211 if( level > maxlevel_ )
222 template<
int dim,
int dimworld >
223 template<
int codim, PartitionIteratorType pitype >
225 ::template Codim< codim >::template Partition< pitype >::LevelIterator
231 return LevelIteratorImp( *
this, level );
235 template<
int dim,
int dimworld >
236 template<
int codim >
238 ::template Codim< codim >::LevelIterator
245 template<
int dim,
int dimworld >
246 template<
int codim >
248 ::template Codim< codim >::LevelIterator
255 template<
int dim,
int dimworld >
256 template<
int codim, PartitionIteratorType pitype >
258 ::template Codim< codim >::template Partition< pitype >::LeafIterator
268 return LeafIteratorImp( *
this, &
markerVector, maxlevel_ );
272 template<
int dim,
int dimworld >
273 template<
int codim, PartitionIteratorType pitype >
279 return LeafIteratorImp( *
this, maxlevel_ );
283 template<
int dim,
int dimworld >
284 template<
int codim >
293 template<
int dim,
int dimworld >
294 template<
int codim >
296 ::template Codim< codim >::LeafIterator
303 template<
int dim,
int dimworld >
309 assert( (refCount >= 0) && (refCount + maxlevel_ < MAXL) );
311 for(
int i = 0; i < refCount; ++i )
325 template<
int dim,
int dimworld >
326 template<
class DataHandle >
333 assert( (refCount >= 0) && (refCount + maxlevel_ < MAXL) );
335 for(
int i = 0; i < refCount; ++i )
347 template<
int dim,
int dimworld >
350 adaptationState_.preAdapt();
351 return adaptationState_.coarsen();
355 template <
int dim,
int dimworld >
359 if( leafIndexSet_ != 0 )
362 for(
int codim = 0; codim <= dimension; ++codim )
364 if(
int(leafIndexSet_->size( codim )) == mesh_.size( codim ) )
366 std::cerr <<
"Incorrect size of leaf index set for codimension "
367 << codim <<
"!" << std::endl;
368 std::cerr <<
"DUNE index set reports: " << leafIndexSet_->size( codim )
370 std::cerr <<
"ALBERTA mesh reports: " << mesh_.size( codim ) << std::endl;
378 levelProvider_.markAllOld();
379 adaptationState_.postAdapt();
383 template<
int dim,
int dimworld >
392 if( refCount < -
e.level() )
396 adaptationState_.unmark( getMark(
e ) );
399 adaptationState_.mark( refCount );
400 e.impl().elementInfo().setMark( refCount );
406 template<
int dim,
int dimworld >
410 return e.impl().elementInfo().getMark();
414 template<
int dim,
int dimworld >
421 hIndexSet_.preAdapt();
422 const bool refined = mesh_.refine();
423 const bool coarsened = (adaptationState_.coarsen() ? mesh_.coarsen() :
false);
424 adaptationState_.adapt();
425 hIndexSet_.postAdapt();
435 template<
int dim,
int dimworld >
436 template<
class DataHandle >
449 callbackVector.create( dofNumbering_.emptyDofSpace(),
"Adaptation Callback" );
452 if( Callback::DofVectorPointer::supportsAdaptationData )
459 if( !Callback::DofVectorPointer::supportsAdaptationData )
460 Alberta::adaptationDataHandler_ = 0;
468 template<
int dim,
int dimworld >
473 assert( (vertex >= 0) && (vertex <= dim) );
474#if DUNE_ALBERTA_CACHE_COORDINATES
482 template <
int dim,
int dimworld >
489 template<
int dim,
int dimworld >
492 return ((level >= 0) && (level <= maxlevel_) ? sizeCache_.size( level, codim ) : 0);
496 template<
int dim,
int dimworld >
499 return ((level >= 0) && (level <= maxlevel_) ? sizeCache_.size( level, type ) : 0);
503 template<
int dim,
int dimworld >
506 assert( sizeCache_.size( codim ) == mesh_.size( codim ) );
507 return mesh_.size( codim );
511 template<
int dim,
int dimworld >
514 return sizeCache_.size( type );
518 template <
int dim,
int dimworld >
519 inline const typename AlbertaGrid < dim, dimworld > :: Traits :: LevelIndexSet &
523 assert( (level >= 0) && (level < (
int)levelIndexVec_.size()) );
525 if( levelIndexVec_[ level ] == 0 )
530 return *(levelIndexVec_[ level ]);
533 template <
int dim,
int dimworld >
534 inline const typename AlbertaGrid < dim, dimworld > :: Traits :: LeafIndexSet &
537 if( leafIndexSet_ == 0 )
542 return *leafIndexSet_;
546 template <
int dim,
int dimworld >
547 inline void AlbertaGrid < dim, dimworld >::calcExtras ()
550 maxlevel_ = levelProvider_.maxLevel();
551 assert( (maxlevel_ >= 0) && (maxlevel_ < MAXL) );
554 for(
int l = 0;
l < MAXL; ++
l )
555 levelMarkerVector_[
l ].clear();
558 leafMarkerVector_.clear();
563 if( leafIndexSet_ != 0 )
565 for(
unsigned int level = 0; level < levelIndexVec_.size(); ++level )
567 if( levelIndexVec_[ level ] )
573 template<
int dim,
int dimworld >
577 if( filename.size() <= 0 )
579 return (mesh_.write( filename,
time ) && hIndexSet_.write( filename ));
583 template<
int dim,
int dimworld >
589 if( filename.size() <= 0 )
592 numBoundarySegments_ = mesh_.read( filename,
time );
597 hIndexSet_.read( filename );
609 template<
int dim,
int dimworld >
610 template<
class DataHandler >
611 struct AlbertaGrid< dim, dimworld >::AdaptationCallback
613 static const int dimension = dim;
618 static DataHandler &getDataHandler (
const DofVectorPointer &dofVector )
620 DataHandler *dataHandler;
621 if( DofVectorPointer::supportsAdaptationData )
622 dataHandler = dofVector.getAdaptationData< DataHandler >();
624 dataHandler = (DataHandler *)Alberta::adaptationDataHandler_;
625 assert( dataHandler != 0 );
629 static void interpolateVector (
const DofVectorPointer &dofVector,
632 DataHandler &dataHandler = getDataHandler( dofVector );
633 for(
int i = 0; i < patch.count(); ++i )
634 dataHandler.prolongLocal( patch, i );
637 static void restrictVector (
const DofVectorPointer &dofVector,
640 DataHandler &dataHandler = getDataHandler( dofVector );
641 for(
int i = 0; i < patch.count(); ++i )
642 dataHandler.restrictLocal( patch, i );
Include standard header files.
Definition agrid.hh:60
static void checkAlbertaDimensions()
Definition albertagrid.cc:29
static const int dimWorld
Definition misc.hh:46
static void * adaptationDataHandler_
Definition albertagrid.cc:24
ALBERTA REAL_D GlobalVector
Definition misc.hh:50
[ provides Dune::Grid ]
Definition agrid.hh:109
static std::string typeName()
Definition agrid.hh:410
GridFamily::ctype ctype
Definition agrid.hh:143
Definition albertagrid/datahandle.hh:27
unsigned int create(const MacroData< dim > ¯oData)
Definition meshpointer.hh:299
Definition dofvector.hh:179
const GlobalVector & coordinate(int vertex) const
Definition elementinfo.hh:685
void create()
Definition indexsets.cc:133
Definition albertagrid/indexsets.hh:329
Definition albertagrid/gridfamily.hh:98
Definition albertagrid/gridfamily.hh:117
Definition macrodata.hh:30
Definition albertagrid/projection.hh:80
Definition albertagrid/projection.hh:163
Definition refinement.hh:40
marker assigning subentities to one element containing them
Definition treeiterator.hh:35
A Traits struct that collects all associated types of one implementation.
Definition common/grid.hh:411