Go to the documentation of this file.
3 #ifndef DUNE_ALBERTAGRID_IMP_HH
4 #define DUNE_ALBERTAGRID_IMP_HH
11 #if HAVE_ALBERTA || DOXYGEN
23 #include <dune/common/deprecated.hh>
24 #include <dune/common/fvector.hh>
25 #include <dune/common/fmatrix.hh>
26 #include <dune/common/stdstreams.hh>
27 #include <dune/common/parallel/collectivecommunication.hh>
64 template<
class Gr
id >
135 template<
int dim,
int dimworld = Alberta::dimWorld >
138 < dim, dimworld, Alberta::Real, AlbertaGridFamily< dim, dimworld > >
142 < dim, dimworld, Alberta::Real, AlbertaGridFamily< dim, dimworld > >
154 friend class AlbertaGridIntersectionBase< const
This >;
155 friend class AlbertaGridLeafIntersection< const
This >;
157 friend class AlbertaMarkerVector< dim, dimworld >;
158 #if (__GNUC__ < 4) && !(defined __ICC)
160 friend struct AlbertaMarkerVector< dim, dimworld >::MarkSubEntities<true>;
161 friend struct AlbertaMarkerVector< dim, dimworld >::MarkSubEntities<false>;
163 friend class AlbertaGridIndexSet< dim, dimworld >;
164 friend class AlbertaGridHierarchicIndexSet< dim, dimworld >;
166 template< class, class >
167 friend class Alberta::AdaptRestrictProlongHandler;
173 typedef typename GridFamily::ctype
ctype;
199 typedef typename Traits::template Codim<0>::LeafIterator LeafIterator;
202 typedef AlbertaGridIdSet<dim,dimworld> IdSetImp;
205 struct AdaptationState
207 enum Phase { ComputationPhase, PreAdaptationPhase, PostAdaptationPhase };
216 : phase_( ComputationPhase ),
221 void mark (
int count )
226 refineMarked_ += (2 << count);
229 void unmark (
int count )
234 refineMarked_ -= (2 << count);
237 bool coarsen ()
const
239 return (coarsenMarked_ > 0);
242 int refineMarked ()
const
244 return refineMarked_;
249 if( phase_ != ComputationPhase )
250 error(
"preAdapt may only be called in computation phase." );
251 phase_ = PreAdaptationPhase;
256 if( phase_ != PreAdaptationPhase )
257 error(
"adapt may only be called in preadapdation phase." );
258 phase_ = PostAdaptationPhase;
263 if( phase_ != PostAdaptationPhase )
264 error(
"postAdapt may only be called in postadaptation phase." );
265 phase_ = ComputationPhase;
272 void error (
const std::string &message )
274 DUNE_THROW( InvalidStateException, message );
278 template<
class DataHandler >
279 struct AdaptationCallback;
282 static const int MAXL = 64;
284 typedef Alberta::ElementInfo< dimension > ElementInfo;
285 typedef Alberta::MeshPointer< dimension > MeshPointer;
286 typedef Alberta::HierarchyDofNumbering< dimension > DofNumbering;
287 typedef AlbertaGridLevelProvider< dimension > LevelProvider;
291 This &
operator= (
const This & ) =
delete;
301 AlbertaGrid (
const Alberta::MacroData< dimension > ¯oData,
305 template<
class Proj,
class Impl >
306 AlbertaGrid (
const Alberta::MacroData< dimension > ¯oData,
307 const Alberta::ProjectionFactoryInterface< Proj, Impl > &projectionFactory );
313 AlbertaGrid (
const std::string ¯oGridFileName );
323 template<
int cd, PartitionIteratorType pitype>
324 typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
328 template<
int cd, PartitionIteratorType pitype>
329 typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
330 lend (
int level)
const;
333 template<
int codim >
334 typename Traits::template Codim< codim >::LevelIterator
335 lbegin (
int level )
const;
338 template<
int codim >
339 typename Traits::template Codim< codim >::LevelIterator
340 lend (
int level )
const;
343 template<
int codim, PartitionIteratorType pitype >
345 ::template Codim< codim >::template Partition< pitype >::LeafIterator
349 template<
int codim, PartitionIteratorType pitype >
351 ::template Codim< codim >::template Partition< pitype >::LeafIterator
355 template<
int codim >
356 typename Traits::template Codim< codim >::LeafIterator
360 template<
int codim >
361 typename Traits::template Codim< codim >::LeafIterator
368 int size (
int level,
int codim)
const;
374 int size (
int codim)
const;
382 return numBoundarySegments_;
388 typedef typename Traits::LevelGridView View;
389 typedef typename View::GridViewImp ViewImp;
390 return View( ViewImp( *
this, level ) );
396 typedef typename Traits::LeafGridView View;
397 typedef typename View::GridViewImp ViewImp;
398 return View( ViewImp( *
this ) );
409 int getMark (
const typename Traits::template Codim< 0 >::Entity &e )
const;
412 bool mark (
int refCount,
const typename Traits::template Codim< 0 >::Entity &e );
417 template<
class DataHandle >
424 template<
class DataHandle >
442 std::ostringstream s;
443 s <<
"AlbertaGrid< " << dim <<
", " << dimworld <<
" >";
448 template<
class EntitySeed >
449 typename Traits::template Codim< EntitySeed::codimension >::Entity
452 typedef typename Traits::template Codim< EntitySeed::codimension >::EntityImpl EntityImpl;
469 const typename Traits :: LevelIndexSet &
levelIndexSet (
int level)
const;
472 const typename Traits :: LeafIndexSet &
leafIndexSet ()
const;
499 return dofNumbering_;
504 return levelProvider_;
509 return numberingMap_.dune2alberta( codim, i );
514 return numberingMap_.alberta2dune( codim, i );
519 return genericNumberingMap_.dune2alberta( codim, i );
524 return genericNumberingMap_.alberta2dune( codim, i );
530 writeGridXdr ( const std::
string &filename,
ctype time ) const;
535 readGridXdr ( const std::
string &filename,
ctype &time );
540 typedef std::vector<
int> ArrayType;
559 friend class AlbertaGridLeafIntersectionIterator< const
This >;
561 template<
int codim >
568 template<
int codim >
570 getTwist (
const typename Traits::template Codim< 0 >::Entity &
entity,
int subEntity )
595 const Alberta::GlobalVector &
609 size_t numBoundarySegments_;
612 Alberta::NumberingMap< dimension, Alberta::Dune2AlbertaNumbering > numberingMap_;
613 Alberta::NumberingMap< dimension, Alberta::Generic2AlbertaNumbering > genericNumberingMap_;
615 DofNumbering dofNumbering_;
617 LevelProvider levelProvider_;
627 mutable std::vector< typename GridFamily::LevelIndexSetImp * > levelIndexVec_;
631 mutable typename GridFamily::LeafIndexSetImp* leafIndexSet_;
638 mutable MarkerVector leafMarkerVector_;
641 mutable std::vector< MarkerVector > levelMarkerVector_;
643 #if DUNE_ALBERTA_CACHE_COORDINATES
644 Alberta::CoordCache< dimension > coordCache_;
648 AdaptationState adaptationState_;
659 #ifdef _ABS_NOT_DEFINED_
663 #ifdef _MIN_NOT_DEFINED_
667 #ifdef _MAX_NOT_DEFINED_
671 #ifdef obstack_chunk_alloc
672 #undef obstack_chunk_alloc
674 #ifdef obstack_chunk_free
675 #undef obstack_chunk_free
694 #endif // #ifdef ERROR
699 #endif // #ifdef ERROR_EXIT
704 #endif // #ifdef WARNING
709 #endif // #ifdef TEST
714 #endif // #ifdef TEST_EXIT
719 #endif // #ifdef DEBUG_TEST
722 #ifdef DEBUG_TEST_EXIT
723 #undef DEBUG_TEST_EXIT
724 #endif // #ifdef DEBUG_TEST_EXIT
729 #endif // #ifdef INFO
734 #endif // #ifdef PRINT_INFO
739 #endif // #ifdef PRINT_INT_VEC
742 #ifdef PRINT_REAL_VEC
743 #undef PRINT_REAL_VEC
744 #endif // #ifdef PRINT_REAL_VEC
749 #endif // #ifdef WAIT
754 #endif // #ifdef WAIT_REALLY
759 #endif // #ifdef GET_WORKSPACE
762 #ifdef FREE_WORKSPACE
763 #undef FREE_WORKSPACE
764 #endif // #ifdef FREE_WORKSPACE
769 #endif // #ifdef MAT_ALLOC
774 #endif // #ifdef MAT_FREE
779 #endif // #ifdef NAME
784 #endif // #ifdef GET_STRUCT
789 #endif // #ifdef ADD_PARAMETER
794 #endif // #ifdef GET_PARAMETER
798 #endif // HAVE_ALBERTA || DOXYGEN
Wrapper class for entities.
Definition: common/entity.hh:63
~AlbertaGrid()
desctructor
Definition: albertagrid.cc:194
friend class AlbertaGridLeafIntersection< const This >
Definition: agrid.hh:155
Different resources needed by all grid implementations.
const MeshPointer & meshPointer() const
Definition: agrid.hh:492
const GlobalIdSet & globalIdSet() const
return global IdSet
Definition: agrid.hh:475
AlbertaGridFamily< dim, dimworld > GridFamily
the grid family of AlbertaGrid
Definition: agrid.hh:171
static const int dimensionworld
Definition: agrid.hh:176
bool readGrid(const std::string &filename, ctype &time)
read Grid from file filename and store time of mesh in time
Definition: albertagrid.cc:599
const Alberta::GlobalVector & getCoord(const ElementInfo &elementInfo, int vertex) const
Definition: albertagrid.cc:469
AlbertaGridFamily< dim, dimworld >::Traits Traits
Definition: agrid.hh:179
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
const Traits ::LeafIndexSet & leafIndexSet() const
return leaf index set
Definition: albertagrid.cc:533
Provide a generic factory class for unstructured grids.
static std::string typeName()
Definition: agrid.hh:440
Provides size cache classes to implement the grids size method efficiently.
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: albertagrid.cc:204
Contains #undefs for all preprocessor macros defined by alberta.
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
returns adaptation mark for given entity, i.e. here the default implementation returns 0.
Definition: common/grid.hh:920
friend class AlbertaMarkerVector< dim, dimworld >
Definition: agrid.hh:157
Traits::GlobalIdSet GlobalIdSet
type of global id set
Definition: agrid.hh:190
@ vertex
Definition: common.hh:179
const LocalIdSet & localIdSet() const
return local IdSet
Definition: agrid.hh:481
int alberta2generic(int codim, int i) const
Definition: agrid.hh:522
friend class AlbertaLeafGridView
Definition: agrid.hh:147
const Traits ::LevelIndexSet & levelIndexSet(int level) const
return level index set for given level
Definition: albertagrid.cc:518
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
returns adaptation mark for given entity
Definition: albertagrid.cc:406
provides the GridFamily for AlbertaGrid
int size(int level, int codim) const
Number of grid entities per level and codim because lbegin and lend are none const,...
Definition: albertagrid.cc:488
int dune2alberta(int codim, int i) const
Definition: agrid.hh:507
int maxLevel() const
Definition: albertagrid.cc:481
Traits::CollectiveCommunication CollectiveCommunication
type of collective communication
Definition: agrid.hh:195
static int getTwist(const typename Traits::template Codim< 0 >::Entity &entity, int subEntity)
Definition: agrid.hh:570
GridFamily::ctype ctype
Definition: agrid.hh:173
static int getTwistInInside(const typename Traits::LeafIntersection &intersection)
Definition: agrid.hh:576
bool mark(int refCount, const typename Traits::template Codim< 0 >::Entity &e)
Marks an entity to be refined/coarsened in a subsequent adapt.
Definition: albertagrid.cc:383
Provide a generic factory class for unstructured grids.
Definition: common/gridfactory.hh:263
Traits ::template Codim< codim >::template Partition< pitype >::LeafIterator leafend() const
return LeafIterator which points behind last leaf entity
bool mark(int refCount, const typename Traits ::template Codim< 0 >::Entity &e)
Marks an entity to be refined/coarsened in a subsequent adapt.
Definition: common/grid.hh:908
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:23
AlbertaGrid()
create an empty grid
Definition: albertagrid.cc:40
struct DUNE_DEPRECATED_MSG("The MCMG layout classes have been deprecated. Pass `mcmgElementLayout()` to the constructor instead") MCMGElementLayout
Layout template for elements.
Definition: mcmgmapper.hh:49
Traits ::template Codim< codim >::template Partition< pitype >::LeafIterator leafbegin() const
return LeafIterator which points to first leaf entity
static int getTwist(const typename Traits::template Codim< codim >::Entity &entity)
Definition: agrid.hh:563
static std::conditional< std::is_reference< InterfaceType >::value, typename std::add_lvalue_reference< typename ReturnImplementationType< typename std::remove_reference< InterfaceType >::type >::ImplementationType >::type, typename std::remove_const< typename ReturnImplementationType< typename std::remove_reference< InterfaceType >::type >::ImplementationType >::type >::type getRealImplementation(InterfaceType &&i)
return real implementation of interface class
Definition: common/grid.hh:1026
[ provides Dune::Grid ]
Definition: agrid.hh:136
organizes the caching of sizes for one grid and one GeometryType
Definition: sizecache.hh:30
ALBERTA MESH * getMesh() const
Definition: agrid.hh:487
Traits::LevelIndexSet LevelIndexSet
type of level index sets
Definition: agrid.hh:184
const CollectiveCommunication & comm() const
return reference to collective communication, if MPI found this is specialisation for MPI
Definition: agrid.hh:435
Traits::LevelGridView levelGridView(int level) const
View for a grid level for All_Partition.
Definition: agrid.hh:386
bool adapt()
Refine all positive marked leaf entities, coarsen all negative marked entities if possible.
Definition: albertagrid.cc:413
void postAdapt()
clean up some markers
Definition: albertagrid.cc:354
friend class AlbertaGridTreeIterator
Definition: agrid.hh:148
const LevelProvider & levelProvider() const
Definition: agrid.hh:502
const AlbertaGridLeafIntersection< const This > & getRealIntersection(const typename Traits::LeafIntersection &intersection) const
Definition: agrid.hh:588
Interface class for the Grid's adapt method where the parameter is a AdaptDataHandleInterface.
Definition: adaptcallback.hh:30
friend class AlbertaGridHierarchicIterator
Definition: agrid.hh:149
const DofNumbering & dofNumbering() const
Definition: agrid.hh:497
std::size_t numBoundarySegments() const
number of boundary segments within the macro grid
Definition: agrid.hh:380
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
obtain Entity from EntitySeed.
Definition: agrid.hh:450
friend class AlbertaGridEntity
Definition: agrid.hh:145
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lend(int level) const
one past the end on this level
Definition: albertagrid.cc:224
int alberta2dune(int codim, int i) const
Definition: agrid.hh:512
Definition: common/grid.hh:1171
Traits::HierarchicIndexSet HierarchicIndexSet
type of hierarchic index set
Definition: agrid.hh:187
Store a reference to an entity with a minimal memory footprint.
Definition: common/entityseed.hh:23
friend class AlbertaLevelGridView
Definition: agrid.hh:146
This & operator=(const This &)=delete
Traits::LocalIdSet LocalIdSet
type of local id set
Definition: agrid.hh:192
Implementation of the IntersectionIterator for AlbertaGrid.
const HierarchicIndexSet & hierarchicIndexSet() const
Definition: agrid.hh:466
Traits::LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition: agrid.hh:394
Include standard header files.
Definition: agrid.hh:58
void globalRefine(int refCount)
uses the interface, mark on entity and refineLocal
Definition: albertagrid.cc:302
bool writeGrid(const std::string &filename, ctype time) const
write Grid to file in Xdr
Definition: albertagrid.cc:589
interfaces and wrappers needed for the callback adaptation provided by AlbertaGrid and dune-ALUGrid
bool preAdapt()
returns true, if a least one element is marked for coarsening
Definition: albertagrid.cc:346
Definition: common/geometry.hh:24
static const int dimension
Definition: agrid.hh:175
Traits::LeafIndexSet LeafIndexSet
type of leaf index set
Definition: agrid.hh:182
static int getTwistInOutside(const typename Traits::LeafIntersection &intersection)
Definition: agrid.hh:582
int generic2alberta(int codim, int i) const
Definition: agrid.hh:517