3 #ifndef DUNE_ALBERTAGRID_IMP_HH
4 #define DUNE_ALBERTAGRID_IMP_HH
11 #if HAVE_ALBERTA || DOXYGEN
33 #include "albertaheader.hh"
36 #include <dune/grid/utility/grapedataioformattypes.hh>
38 #include <dune/grid/albertagrid/misc.hh>
39 #include <dune/grid/albertagrid/capabilities.hh>
40 #include <dune/grid/albertagrid/backuprestore.hh>
42 #include <dune/grid/albertagrid/coordcache.hh>
44 #include <dune/grid/albertagrid/level.hh>
45 #include <dune/grid/albertagrid/intersection.hh>
47 #include <dune/grid/albertagrid/datahandle.hh>
48 #include <dune/grid/albertagrid/entityseed.hh>
50 #include "indexsets.hh"
51 #include "geometry.hh"
54 #include "hierarchiciterator.hh"
55 #include "treeiterator.hh"
56 #include "leveliterator.hh"
57 #include "leafiterator.hh"
65 template<
class Gr
id >
66 struct DGFGridFactory;
136 template<
int dim,
int dimworld = Alberta::dimWorld >
139 < dim, dimworld, Alberta::Real, AlbertaGridFamily< dim, dimworld > >
143 < dim, dimworld, Alberta::Real, AlbertaGridFamily< dim, dimworld > >
148 template<
class, PartitionIteratorType >
friend class AlbertaLevelGridView;
149 template<
class, PartitionIteratorType >
friend class AlbertaLeafGridView;
152 friend struct DGFGridFactory<
This >;
156 friend class AlbertaGridIntersectionBase< const
This >;
157 friend class AlbertaGridLeafIntersection< const
This >;
160 #if (__GNUC__ < 4) && !(defined __ICC)
165 friend class AlbertaGridIndexSet< dim, dimworld >;
166 friend class AlbertaGridHierarchicIndexSet< dim, dimworld >;
168 template< class, class >
169 friend class Alberta::AdaptRestrictProlongHandler;
175 typedef typename GridFamily::ctype ctype;
177 static const int dimension = GridFamily::dimension;
178 static const int dimensionworld = GridFamily::dimensionworld;
181 typedef typename AlbertaGridFamily< dim, dimworld >::Traits Traits;
201 typedef typename Traits::template
Codim<0>::LeafIterator LeafIterator;
207 struct AdaptationState
209 enum Phase { ComputationPhase, PreAdaptationPhase, PostAdaptationPhase };
218 : phase_( ComputationPhase ),
223 void mark (
int count )
228 refineMarked_ += (2 << count);
231 void unmark (
int count )
236 refineMarked_ -= (2 << count);
239 bool coarsen ()
const
241 return (coarsenMarked_ > 0);
244 int refineMarked ()
const
246 return refineMarked_;
251 if( phase_ != ComputationPhase )
252 error(
"preAdapt may only be called in computation phase." );
253 phase_ = PreAdaptationPhase;
258 if( phase_ != PreAdaptationPhase )
259 error(
"adapt may only be called in preadapdation phase." );
260 phase_ = PostAdaptationPhase;
265 if( phase_ != PostAdaptationPhase )
266 error(
"postAdapt may only be called in postadaptation phase." );
267 phase_ = ComputationPhase;
274 void error (
const std::string &message )
280 template<
class DataHandler >
281 struct AdaptationCallback;
284 static const int MAXL = 64;
286 typedef Alberta::ElementInfo< dimension > ElementInfo;
287 typedef Alberta::MeshPointer< dimension > MeshPointer;
288 typedef Alberta::HierarchyDofNumbering< dimension > DofNumbering;
289 typedef AlbertaGridLevelProvider< dimension > LevelProvider;
293 This &operator= (
const This & );
304 AlbertaGrid (
const Alberta::MacroData< dimension > ¯oData,
308 template<
class Proj,
class Impl >
309 AlbertaGrid (
const Alberta::MacroData< dimension > ¯oData,
310 const Alberta::ProjectionFactoryInterface< Proj, Impl > &projectionFactory );
316 AlbertaGrid (
const std::string ¯oGridFileName );
326 template<
int cd, PartitionIteratorType pitype>
331 template<
int cd, PartitionIteratorType pitype>
333 lend (
int level)
const;
336 template<
int codim >
338 lbegin (
int level )
const;
341 template<
int codim >
343 lend (
int level )
const;
346 template<
int codim, PartitionIteratorType pitype >
352 template<
int codim, PartitionIteratorType pitype >
358 template<
int codim >
363 template<
int codim >
371 int size (
int level,
int codim)
const;
377 int size (
int codim)
const;
385 return numBoundarySegments_;
389 template< PartitionIteratorType pitype >
390 typename Traits::template Partition< pitype >::LevelGridView
393 typedef typename Traits::template Partition< pitype >::LevelGridView View;
394 typedef typename View::GridViewImp ViewImp;
395 return View( ViewImp( *
this, level ) );
399 template< PartitionIteratorType pitype >
400 typename Traits::template Partition< pitype >::LeafGridView
leafGridView ()
const
402 typedef typename Traits::template Partition< pitype >::LeafGridView View;
403 typedef typename View::GridViewImp ViewImp;
404 return View( ViewImp( *
this ) );
408 typename Traits::template Partition< All_Partition >::LevelGridView
411 typedef typename Traits::template Partition< All_Partition >::LevelGridView View;
412 typedef typename View::GridViewImp ViewImp;
413 return View( ViewImp( *
this, level ) );
417 typename Traits::template Partition< All_Partition >::LeafGridView
leafGridView ()
const
419 typedef typename Traits::template Partition< All_Partition >::LeafGridView View;
420 typedef typename View::GridViewImp ViewImp;
421 return View( ViewImp( *
this ) );
440 template<
class DataHandle >
447 template<
class DataHandle >
463 static std::string typeName ()
465 std::ostringstream s;
466 s <<
"AlbertaGrid< " << dim <<
", " << dimworld <<
" >";
478 template<
class EntitySeed >
479 DUNE_DEPRECATED_MSG(
"entityPointer() is deprecated and will be removed after the release of dune-grid 2.4. Use entity() instead to directly obtain an Entity object.")
480 typename Traits::template Codim< EntitySeed::codimension >::EntityPointer
481 entityPointer ( const EntitySeed &seed )
const
483 typedef typename Traits::template Codim< EntitySeed::codimension >::EntityPointerImpl EntityPointerImpl;
484 return EntityPointerImpl( *
this, this->getRealImplementation(seed).elementInfo( meshPointer() ), this->getRealImplementation(seed).subEntity() );
488 template<
class EntitySeed >
489 typename Traits::template Codim< EntitySeed::codimension >::Entity
490 entity (
const EntitySeed &seed )
const
492 typedef typename Traits::template Codim< EntitySeed::codimension >::EntityImpl EntityImpl;
493 return EntityImpl( *
this, this->getRealImplementation(seed).elementInfo( meshPointer() ), this->getRealImplementation(seed).subEntity() );
500 template< GrapeIOFileFormatType ftype >
501 bool writeGrid(
const std::string &filename, ctype time )
const;
504 template< GrapeIOFileFormatType ftype >
505 bool readGrid(
const std::string &filename, ctype &time );
511 const typename Traits :: LevelIndexSet &
levelIndexSet (
int level)
const;
514 const typename Traits :: LeafIndexSet &
leafIndexSet ()
const;
529 ALBERTA MESH* getMesh ()
const
534 const MeshPointer &meshPointer ()
const
539 const DofNumbering &dofNumbering ()
const
541 return dofNumbering_;
544 const LevelProvider &levelProvider ()
const
546 return levelProvider_;
549 int dune2alberta (
int codim,
int i )
const
551 return numberingMap_.dune2alberta( codim, i );
554 int alberta2dune (
int codim,
int i )
const
556 return numberingMap_.alberta2dune( codim, i );
559 int generic2alberta (
int codim,
int i )
const
561 return genericNumberingMap_.dune2alberta( codim, i );
564 int alberta2generic (
int codim,
int i )
const
566 return genericNumberingMap_.alberta2dune( codim, i );
570 bool writeGridXdr (
const std::string &filename, ctype time )
const;
573 bool readGridXdr (
const std::string &filename, ctype &time );
578 typedef std::vector<int> ArrayType;
593 typedef MakeableInterfaceObject< typename Traits::template Codim< 0 >::Entity >
597 friend class AlbertaGridLeafIntersectionIterator< const This >;
599 template<
int codim >
601 getTwist (
const typename Traits::template Codim< codim >::Entity &entity )
603 return getRealImplementation( entity ).twist();
606 template<
int codim >
608 getTwist (
const typename Traits::template Codim< 0 >::Entity &entity,
int subEntity )
610 return getRealImplementation( entity ).template twist< codim >( subEntity );
614 getTwistInInside (
const typename Traits::LeafIntersection &intersection )
616 return getRealImplementation( intersection ).twistInInside();
620 getTwistInOutside (
const typename Traits::LeafIntersection &intersection )
622 return getRealImplementation( intersection ).twistInOutside();
625 const AlbertaGridLeafIntersection< const This > &
626 getRealIntersection (
const typename Traits::LeafIntersection &intersection )
const
628 return getRealImplementation( intersection );
633 const Alberta::GlobalVector &
634 getCoord (
const ElementInfo &elementInfo,
int vertex )
const;
647 size_t numBoundarySegments_;
650 Alberta::NumberingMap< dimension, Alberta::Dune2AlbertaNumbering > numberingMap_;
651 Alberta::NumberingMap< dimension, Alberta::Generic2AlbertaNumbering > genericNumberingMap_;
653 DofNumbering dofNumbering_;
655 LevelProvider levelProvider_;
665 mutable std::vector< typename GridFamily::LevelIndexSetImp * > levelIndexVec_;
669 mutable typename GridFamily::LeafIndexSetImp* leafIndexSet_;
671 SizeCache< This > sizeCache_;
673 typedef AlbertaMarkerVector< dim, dimworld > MarkerVector;
676 mutable MarkerVector leafMarkerVector_;
679 mutable std::vector< MarkerVector > levelMarkerVector_;
681 #if DUNE_ALBERTA_CACHE_COORDINATES
682 Alberta::CoordCache< dimension > coordCache_;
686 AdaptationState adaptationState_;
691 #include "albertagrid.cc"
697 #ifdef _ABS_NOT_DEFINED_
701 #ifdef _MIN_NOT_DEFINED_
705 #ifdef _MAX_NOT_DEFINED_
709 #ifdef obstack_chunk_alloc
710 #undef obstack_chunk_alloc
712 #ifdef obstack_chunk_free
713 #undef obstack_chunk_free
760 #ifdef DEBUG_TEST_EXIT
761 #undef DEBUG_TEST_EXIT
780 #ifdef PRINT_REAL_VEC
781 #undef PRINT_REAL_VEC
800 #ifdef FREE_WORKSPACE
801 #undef FREE_WORKSPACE
interfaces and wrappers needed for the callback adaptation provided by AlbertaGrid and ALUGrid
provides the GridFamily for AlbertaGrid
Implementation of the IntersectionIterator for AlbertaGrid.
Interface class for the Grid's adapt method where the parameter is a AdaptDataHandleInterface.
Definition: adaptcallback.hh:31
EntityPointer implementation for AlbertaGrid.
Definition: entitypointer.hh:19
Definition: hierarchiciterator.hh:29
hierarchic index set of AlbertaGrid
Definition: indexsets.hh:537
[ provides Dune::Grid ]
Definition: agrid.hh:140
Traits::template Partition< All_Partition >::LevelGridView levelGridView(int level) const
View for a grid level for All_Partition.
Definition: agrid.hh:409
Traits ::template Codim< codim >::template Partition< pitype >::LeafIterator leafbegin() const
return LeafIterator which points to first 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: grid.hh:1163
Traits::template Partition< All_Partition >::LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition: agrid.hh:417
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: grid.hh:1175
int maxLevel() const
Definition: albertagrid.cc:481
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
AlbertaGrid()
create an empty grid
Definition: albertagrid.cc:40
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lend(int level) const
one past the end on this level
Definition: albertagrid.cc:224
DUNE_DEPRECATED_MSG("entityPointer() is deprecated and will be removed after the release of dune-grid 2.4. Use entity() instead to directly obtain an Entity object.") typename Traits bool readGrid(const std::string &filename, ctype &time)
obtain EntityPointer from EntitySeed.
bool adapt()
Refine all positive marked leaf entities, coarsen all negative marked entities if possible.
Definition: albertagrid.cc:413
bool readGridXdr(const std::string &filename, ctype &time)
reads ALBERTA mesh file
Definition: albertagrid.cc:629
const LocalIdSet & localIdSet() const
return local IdSet
Definition: agrid.hh:523
void postAdapt()
clean up some markers
Definition: albertagrid.cc:354
const CollectiveCommunication & comm() const
return reference to collective communication, if MPI found this is specialisation for MPI
Definition: agrid.hh:458
AlbertaGridFamily< dim, dimworld > GridFamily
the grid family of AlbertaGrid
Definition: agrid.hh:173
Traits::template Partition< pitype >::LeafGridView leafGridView() const
View for the leaf grid.
Definition: agrid.hh:400
const Traits ::LevelIndexSet & levelIndexSet(int level) const
return level index set for given level
Definition: albertagrid.cc:518
size_t numBoundarySegments() const
number of boundary segments within the macro grid
Definition: agrid.hh:383
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
Traits::HierarchicIndexSet HierarchicIndexSet
type of hierarchic index set
Definition: agrid.hh:189
const Traits ::LeafIndexSet & leafIndexSet() const
return leaf index set
Definition: albertagrid.cc:533
Traits ::template Codim< codim >::template Partition< pitype >::LeafIterator leafend() const
return LeafIterator which points behind last leaf entity
Traits::template Partition< pitype >::LevelGridView levelGridView(int level) const
View for a grid level.
Definition: agrid.hh:391
void globalRefine(int refCount)
uses the interface, mark on entity and refineLocal
Definition: albertagrid.cc:302
~AlbertaGrid()
desctructor
Definition: albertagrid.cc:194
const GlobalIdSet & globalIdSet() const
return global IdSet
Definition: agrid.hh:517
bool preAdapt()
returns true, if a least one element is marked for coarsening
Definition: albertagrid.cc:346
Traits::CollectiveCommunication CollectiveCommunication
type of collective communication
Definition: agrid.hh:197
marker assigning subentities to one element containing them
Definition: treeiterator.hh:30
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
bool mark(int refCount, const typename Traits ::template Codim< 0 >::Entity &e)
Marks an entity to be refined/coarsened in a subsequent adapt.
Definition: grid.hh:1163
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: grid.hh:1305
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: grid.hh:1175
Traits::template Codim< codim >::LevelIterator DUNE_DEPRECATED_MSG("The method lbegin( level ) is superseded by levelGridView( level ).begin.") lbegin(int level) const
Iterator to first entity of given codim on level for PartitionType All_Partition.
Definition: grid.hh:1043
Provide a generic factory class for unstructured grids.
Definition: gridfactory.hh:263
Id Set Interface.
Definition: indexidset.hh:414
Index Set Interface base class.
Definition: indexidset.hh:76
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:306
Implements an utility class that provides collective communication methods for sequential programs.
Wrapper and interface class for a static iterator (EntityPointer)
Different resources needed by all grid implementations.
Provide a generic factory class for unstructured grids.
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Implements a vector constructed from a given type representing a field and a compile-time given size.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
Dune namespace.
Definition: alignment.hh:10
Provides size cache classes to implement the grids size method efficiently.
Standard Dune debug streams.
Static tag representing a codimension.
Definition: dimension.hh:22
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:24
Contains #undefs for all preprocessor macros defined by alberta.