5#ifndef DUNE_ALBERTAGRID_IMP_HH
6#define DUNE_ALBERTAGRID_IMP_HH
13#if HAVE_ALBERTA || DOXYGEN
37#include "albertaheader.hh"
39#include <dune/grid/albertagrid/misc.hh>
40#include <dune/grid/albertagrid/capabilities.hh>
41#include <dune/grid/albertagrid/backuprestore.hh>
43#include <dune/grid/albertagrid/coordcache.hh>
45#include <dune/grid/albertagrid/level.hh>
46#include <dune/grid/albertagrid/intersection.hh>
48#include <dune/grid/albertagrid/datahandle.hh>
49#include <dune/grid/albertagrid/entityseed.hh>
51#include "indexsets.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;
105 template<
int dim,
int dimworld = Alberta::dimWorld >
108 < dim, dimworld, Alberta::Real, AlbertaGridFamily< dim, dimworld > >
112 < dim, dimworld, Alberta::Real, AlbertaGridFamily< dim, dimworld > >
116 template<
class >
friend class AlbertaLevelGridView;
117 template<
class >
friend class AlbertaLeafGridView;
122 friend struct DGFGridFactory<
This >;
124 friend class AlbertaGridIntersectionBase< const
This >;
125 friend class AlbertaGridLeafIntersection< const
This >;
128#if (__GNUC__ < 4) && !(defined __ICC)
133 friend class AlbertaGridIndexSet< dim, dimworld >;
134 friend class AlbertaGridHierarchicIndexSet< dim, dimworld >;
136 template< class, class >
137 friend class Alberta::AdaptRestrictProlongHandler;
143 typedef typename GridFamily::ctype ctype;
145 static const int dimension = GridFamily::dimension;
146 static const int dimensionworld = GridFamily::dimensionworld;
149 typedef typename AlbertaGridFamily< dim, dimworld >::Traits Traits;
169 typedef typename Traits::template
Codim<0>::LeafIterator LeafIterator;
175 struct AdaptationState
177 enum Phase { ComputationPhase, PreAdaptationPhase, PostAdaptationPhase };
186 : phase_( ComputationPhase ),
191 void mark (
int count )
196 refineMarked_ += (2 << count);
199 void unmark (
int count )
204 refineMarked_ -= (2 << count);
207 bool coarsen ()
const
209 return (coarsenMarked_ > 0);
212 int refineMarked ()
const
214 return refineMarked_;
219 if( phase_ != ComputationPhase )
220 error(
"preAdapt may only be called in computation phase." );
221 phase_ = PreAdaptationPhase;
226 if( phase_ != PreAdaptationPhase )
227 error(
"adapt may only be called in preadapdation phase." );
228 phase_ = PostAdaptationPhase;
233 if( phase_ != PostAdaptationPhase )
234 error(
"postAdapt may only be called in postadaptation phase." );
235 phase_ = ComputationPhase;
242 void error (
const std::string &message )
248 template<
class DataHandler >
249 struct AdaptationCallback;
252 static const int MAXL = 64;
254 typedef Alberta::ElementInfo< dimension > ElementInfo;
255 typedef Alberta::MeshPointer< dimension > MeshPointer;
256 typedef Alberta::HierarchyDofNumbering< dimension > DofNumbering;
257 typedef AlbertaGridLevelProvider< dimension > LevelProvider;
261 This &operator= (
const This & ) =
delete;
271 AlbertaGrid (
const Alberta::MacroData< dimension > ¯oData,
275 template<
class Proj,
class Impl >
276 AlbertaGrid (
const Alberta::MacroData< dimension > ¯oData,
277 const Alberta::ProjectionFactoryInterface< Proj, Impl > &projectionFactory );
283 AlbertaGrid (
const std::string ¯oGridFileName );
293 template<
int cd, PartitionIteratorType pitype>
298 template<
int cd, PartitionIteratorType pitype>
303 template<
int codim >
308 template<
int codim >
313 template<
int codim, PartitionIteratorType pitype >
319 template<
int codim, PartitionIteratorType pitype >
325 template<
int codim >
330 template<
int codim >
338 int size (
int level,
int codim)
const;
344 int size (
int codim)
const;
352 return numBoundarySegments_;
359 typedef typename View::GridViewImp ViewImp;
360 return View( ViewImp( *
this, level ) );
367 typedef typename View::GridViewImp ViewImp;
368 return View( ViewImp( *
this ) );
387 template<
class DataHandle >
394 template<
class DataHandle >
410 static std::string typeName ()
412 std::ostringstream s;
413 s <<
"AlbertaGrid< " << dim <<
", " << dimworld <<
" >";
418 template<
class EntitySeed >
419 typename Traits::template Codim< EntitySeed::codimension >::Entity
423 return EntityImpl( *
this, seed.
impl().elementInfo( meshPointer() ), seed.
impl().subEntity() );
430 bool writeGrid(
const std::string &filename, ctype time )
const;
433 bool readGrid(
const std::string &filename, ctype &time );
439 const typename Traits :: LevelIndexSet &
levelIndexSet (
int level)
const;
442 const typename Traits :: LeafIndexSet &
leafIndexSet ()
const;
457 ALBERTA MESH* getMesh ()
const
462 const MeshPointer &meshPointer ()
const
467 const DofNumbering &dofNumbering ()
const
469 return dofNumbering_;
472 const LevelProvider &levelProvider ()
const
474 return levelProvider_;
477 int dune2alberta (
int codim,
int i )
const
479 return numberingMap_.dune2alberta( codim, i );
482 int alberta2dune (
int codim,
int i )
const
484 return numberingMap_.alberta2dune( codim, i );
487 int generic2alberta (
int codim,
int i )
const
489 return genericNumberingMap_.dune2alberta( codim, i );
492 int alberta2generic (
int codim,
int i )
const
494 return genericNumberingMap_.alberta2dune( codim, i );
498 typedef std::vector<int> ArrayType;
513 typedef MakeableInterfaceObject< typename Traits::template Codim< 0 >::Entity >
517 friend class AlbertaGridLeafIntersectionIterator< const This >;
519 template<
int codim >
521 getTwist (
const typename Traits::template Codim< codim >::Entity &
entity )
526 template<
int codim >
528 getTwist (
const typename Traits::template Codim< 0 >::Entity &
entity,
int subEntity )
530 return entity.
impl().template twist< codim >( subEntity );
534 getTwistInInside (
const typename Traits::LeafIntersection &intersection )
536 return intersection.impl().twistInInside();
540 getTwistInOutside (
const typename Traits::LeafIntersection &intersection )
542 return intersection.impl().twistInOutside();
547 const Alberta::GlobalVector &
548 getCoord (
const ElementInfo &elementInfo,
int vertex )
const;
561 size_t numBoundarySegments_;
564 Alberta::NumberingMap< dimension, Alberta::Dune2AlbertaNumbering > numberingMap_;
565 Alberta::NumberingMap< dimension, Alberta::Generic2AlbertaNumbering > genericNumberingMap_;
567 DofNumbering dofNumbering_;
569 LevelProvider levelProvider_;
579 mutable std::vector< typename GridFamily::LevelIndexSetImp * > levelIndexVec_;
583 mutable typename GridFamily::LeafIndexSetImp* leafIndexSet_;
585 SizeCache< This > sizeCache_;
587 typedef AlbertaMarkerVector< dim, dimworld > MarkerVector;
590 mutable MarkerVector leafMarkerVector_;
593 mutable std::vector< MarkerVector > levelMarkerVector_;
595#if DUNE_ALBERTA_CACHE_COORDINATES
596 Alberta::CoordCache< dimension > coordCache_;
600 AdaptationState adaptationState_;
605#include "albertagrid.cc"
611#ifdef _ABS_NOT_DEFINED_
615#ifdef _MIN_NOT_DEFINED_
619#ifdef _MAX_NOT_DEFINED_
623#ifdef obstack_chunk_alloc
624#undef obstack_chunk_alloc
626#ifdef obstack_chunk_free
627#undef obstack_chunk_free
674#ifdef DEBUG_TEST_EXIT
675#undef DEBUG_TEST_EXIT
interfaces and wrappers needed for the callback adaptation provided by AlbertaGrid and dune-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:33
Definition: hierarchiciterator.hh:29
hierarchic index set of AlbertaGrid
Definition: indexsets.hh:518
Definition: treeiterator.hh:189
[ provides Dune::Grid ]
Definition: agrid.hh:109
bool readGrid(const std::string &filename, ctype &time)
read Grid from file filename and store time of mesh in time
Definition: albertagrid.cc:585
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator leafbegin() const
return LeafIterator which points to first leaf entity
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lend(int level) const
one past the end on this level
Traits::Communication Communication
type of communication
Definition: agrid.hh:165
int maxLevel() const
Definition: albertagrid.cc:483
AlbertaGrid()
create an empty grid
Definition: albertagrid.cc:42
Traits::template Codim< codim >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Traits::template Codim< codim >::LevelIterator lend(int level) const
one past the end on this level
Traits::LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition: agrid.hh:364
bool adapt()
Refine all positive marked leaf entities, coarsen all negative marked entities if possible.
Definition: albertagrid.cc:415
void postAdapt()
clean up some markers
Definition: albertagrid.cc:356
Traits::template Codim< codim >::LeafIterator leafbegin() const
return LeafIterator which points to first leaf entity
const LocalIdSet & localIdSet() const
return local IdSet
Definition: agrid.hh:451
std::size_t numBoundarySegments() const
number of boundary segments within the macro grid
Definition: agrid.hh:350
AlbertaGridFamily< dim, dimworld > GridFamily
the grid family of AlbertaGrid
Definition: agrid.hh:141
Traits::template Codim< codim >::LeafIterator leafend() const
return LeafIterator which points behind last leaf entity
const Traits::LevelIndexSet & levelIndexSet(int level) const
return level index set for given level
Definition: albertagrid.cc:520
const Communication & comm() const
return reference to communication, if MPI found this is specialisation for MPI
Definition: agrid.hh:405
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:490
Traits::HierarchicIndexSet HierarchicIndexSet
type of hierarchic index set
Definition: agrid.hh:157
const Traits::LeafIndexSet & leafIndexSet() const
return leaf index set
Definition: albertagrid.cc:535
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator leafend() const
return LeafIterator which points behind last leaf entity
bool writeGrid(const std::string &filename, ctype time) const
write Grid to file in Xdr
Definition: albertagrid.cc:575
Traits::LevelGridView levelGridView(int level) const
View for a grid level for All_Partition.
Definition: agrid.hh:356
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
const GlobalIdSet & globalIdSet() const
return global IdSet
Definition: agrid.hh:445
void globalRefine(int refCount)
uses the interface, mark on entity and refineLocal
Definition: albertagrid.cc:304
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
returns adaptation mark for given entity
Definition: albertagrid.cc:408
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
obtain Entity from EntitySeed.
Definition: agrid.hh:420
~AlbertaGrid()
destructor
Definition: albertagrid.cc:196
bool preAdapt()
returns true, if a least one element is marked for coarsening
Definition: albertagrid.cc:348
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:385
marker assigning subentities to one element containing them
Definition: treeiterator.hh:35
Store a reference to an entity with a minimal memory footprint.
Definition: entityseed.hh:26
Implementation & impl()
access to the underlying implementation
Definition: entityseed.hh:59
Implementation & impl()
access to the underlying implementation
Definition: entity.hh:80
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
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:929
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:941
Provide a generic factory class for unstructured grids.
Definition: gridfactory.hh:275
Grid view abstract base class.
Definition: gridview.hh:66
Id Set Interface.
Definition: indexidset.hh:447
Index Set Interface base class.
Definition: indexidset.hh:78
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:281
Different resources needed by all grid implementations.
Provide a generic factory class for unstructured grids.
Implements an utility class that provides collective communication methods for sequential programs.
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:218
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:492
Dune namespace.
Definition: alignedallocator.hh:13
Provides size cache classes to implement the grids size method efficiently.
Standard Dune debug streams.
Static tag representing a codimension.
Definition: dimension.hh:24
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:33
Contains #undefs for all preprocessor macros defined by alberta.