3#ifndef DUNE_ALBERTAGRID_IMP_HH
4#define DUNE_ALBERTAGRID_IMP_HH
11#if HAVE_ALBERTA || DOXYGEN
35#include "albertaheader.hh"
37#include <dune/grid/albertagrid/misc.hh>
38#include <dune/grid/albertagrid/capabilities.hh>
39#include <dune/grid/albertagrid/backuprestore.hh>
41#include <dune/grid/albertagrid/coordcache.hh>
43#include <dune/grid/albertagrid/level.hh>
44#include <dune/grid/albertagrid/intersection.hh>
46#include <dune/grid/albertagrid/datahandle.hh>
47#include <dune/grid/albertagrid/entityseed.hh>
49#include "indexsets.hh"
52#include "hierarchiciterator.hh"
53#include "treeiterator.hh"
54#include "leveliterator.hh"
55#include "leafiterator.hh"
63 template<
class Gr
id >
64 struct DGFGridFactory;
103 template<
int dim,
int dimworld = Alberta::dimWorld >
106 < dim, dimworld, Alberta::Real, AlbertaGridFamily< dim, dimworld > >
110 < dim, dimworld, Alberta::Real, AlbertaGridFamily< dim, dimworld > >
114 template<
class >
friend class AlbertaLevelGridView;
115 template<
class >
friend class AlbertaLeafGridView;
120 friend struct DGFGridFactory<
This >;
122 friend class AlbertaGridIntersectionBase< const
This >;
123 friend class AlbertaGridLeafIntersection< const
This >;
126#if (__GNUC__ < 4) && !(defined __ICC)
131 friend class AlbertaGridIndexSet< dim, dimworld >;
132 friend class AlbertaGridHierarchicIndexSet< dim, dimworld >;
134 template< class, class >
135 friend class Alberta::AdaptRestrictProlongHandler;
141 typedef typename GridFamily::ctype ctype;
143 static const int dimension = GridFamily::dimension;
144 static const int dimensionworld = GridFamily::dimensionworld;
147 typedef typename AlbertaGridFamily< dim, dimworld >::Traits Traits;
167 typedef typename Traits::template
Codim<0>::LeafIterator LeafIterator;
173 struct AdaptationState
175 enum Phase { ComputationPhase, PreAdaptationPhase, PostAdaptationPhase };
184 : phase_( ComputationPhase ),
189 void mark (
int count )
194 refineMarked_ += (2 << count);
197 void unmark (
int count )
202 refineMarked_ -= (2 << count);
205 bool coarsen ()
const
207 return (coarsenMarked_ > 0);
210 int refineMarked ()
const
212 return refineMarked_;
217 if( phase_ != ComputationPhase )
218 error(
"preAdapt may only be called in computation phase." );
219 phase_ = PreAdaptationPhase;
224 if( phase_ != PreAdaptationPhase )
225 error(
"adapt may only be called in preadapdation phase." );
226 phase_ = PostAdaptationPhase;
231 if( phase_ != PostAdaptationPhase )
232 error(
"postAdapt may only be called in postadaptation phase." );
233 phase_ = ComputationPhase;
240 void error (
const std::string &message )
246 template<
class DataHandler >
247 struct AdaptationCallback;
250 static const int MAXL = 64;
252 typedef Alberta::ElementInfo< dimension > ElementInfo;
253 typedef Alberta::MeshPointer< dimension > MeshPointer;
254 typedef Alberta::HierarchyDofNumbering< dimension > DofNumbering;
255 typedef AlbertaGridLevelProvider< dimension > LevelProvider;
259 This &operator= (
const This & ) =
delete;
269 AlbertaGrid (
const Alberta::MacroData< dimension > ¯oData,
273 template<
class Proj,
class Impl >
274 AlbertaGrid (
const Alberta::MacroData< dimension > ¯oData,
275 const Alberta::ProjectionFactoryInterface< Proj, Impl > &projectionFactory );
281 AlbertaGrid (
const std::string ¯oGridFileName );
291 template<
int cd, PartitionIteratorType pitype>
296 template<
int cd, PartitionIteratorType pitype>
301 template<
int codim >
306 template<
int codim >
311 template<
int codim, PartitionIteratorType pitype >
317 template<
int codim, PartitionIteratorType pitype >
323 template<
int codim >
328 template<
int codim >
336 int size (
int level,
int codim)
const;
342 int size (
int codim)
const;
350 return numBoundarySegments_;
357 typedef typename View::GridViewImp ViewImp;
358 return View( ViewImp( *
this, level ) );
365 typedef typename View::GridViewImp ViewImp;
366 return View( ViewImp( *
this ) );
385 template<
class DataHandle >
392 template<
class DataHandle >
408 static std::string typeName ()
410 std::ostringstream s;
411 s <<
"AlbertaGrid< " << dim <<
", " << dimworld <<
" >";
416 template<
class EntitySeed >
417 typename Traits::template Codim< EntitySeed::codimension >::Entity
421 return EntityImpl( *
this, seed.
impl().elementInfo( meshPointer() ), seed.
impl().subEntity() );
428 bool writeGrid(
const std::string &filename, ctype time )
const;
431 bool readGrid(
const std::string &filename, ctype &time );
437 const typename Traits :: LevelIndexSet &
levelIndexSet (
int level)
const;
440 const typename Traits :: LeafIndexSet &
leafIndexSet ()
const;
455 ALBERTA MESH* getMesh ()
const
460 const MeshPointer &meshPointer ()
const
465 const DofNumbering &dofNumbering ()
const
467 return dofNumbering_;
470 const LevelProvider &levelProvider ()
const
472 return levelProvider_;
475 int dune2alberta (
int codim,
int i )
const
477 return numberingMap_.dune2alberta( codim, i );
480 int alberta2dune (
int codim,
int i )
const
482 return numberingMap_.alberta2dune( codim, i );
485 int generic2alberta (
int codim,
int i )
const
487 return genericNumberingMap_.dune2alberta( codim, i );
490 int alberta2generic (
int codim,
int i )
const
492 return genericNumberingMap_.alberta2dune( codim, i );
496 typedef std::vector<int> ArrayType;
511 typedef MakeableInterfaceObject< typename Traits::template Codim< 0 >::Entity >
515 friend class AlbertaGridLeafIntersectionIterator< const This >;
517 template<
int codim >
519 getTwist (
const typename Traits::template Codim< codim >::Entity &
entity )
524 template<
int codim >
526 getTwist (
const typename Traits::template Codim< 0 >::Entity &
entity,
int subEntity )
528 return entity.
impl().template twist< codim >( subEntity );
532 getTwistInInside (
const typename Traits::LeafIntersection &intersection )
534 return intersection.impl().twistInInside();
538 getTwistInOutside (
const typename Traits::LeafIntersection &intersection )
540 return intersection.impl().twistInOutside();
545 const Alberta::GlobalVector &
546 getCoord (
const ElementInfo &elementInfo,
int vertex )
const;
559 size_t numBoundarySegments_;
562 Alberta::NumberingMap< dimension, Alberta::Dune2AlbertaNumbering > numberingMap_;
563 Alberta::NumberingMap< dimension, Alberta::Generic2AlbertaNumbering > genericNumberingMap_;
565 DofNumbering dofNumbering_;
567 LevelProvider levelProvider_;
577 mutable std::vector< typename GridFamily::LevelIndexSetImp * > levelIndexVec_;
581 mutable typename GridFamily::LeafIndexSetImp* leafIndexSet_;
583 SizeCache< This > sizeCache_;
585 typedef AlbertaMarkerVector< dim, dimworld > MarkerVector;
588 mutable MarkerVector leafMarkerVector_;
591 mutable std::vector< MarkerVector > levelMarkerVector_;
593#if DUNE_ALBERTA_CACHE_COORDINATES
594 Alberta::CoordCache< dimension > coordCache_;
598 AdaptationState adaptationState_;
603#include "albertagrid.cc"
609#ifdef _ABS_NOT_DEFINED_
613#ifdef _MIN_NOT_DEFINED_
617#ifdef _MAX_NOT_DEFINED_
621#ifdef obstack_chunk_alloc
622#undef obstack_chunk_alloc
624#ifdef obstack_chunk_free
625#undef obstack_chunk_free
672#ifdef DEBUG_TEST_EXIT
673#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:31
Definition: hierarchiciterator.hh:27
hierarchic index set of AlbertaGrid
Definition: indexsets.hh:532
Definition: treeiterator.hh:187
[ provides Dune::Grid ]
Definition: agrid.hh:107
bool readGrid(const std::string &filename, ctype &time)
read Grid from file filename and store time of mesh in time
Definition: albertagrid.cc:583
const CollectiveCommunication & comm() const
return reference to collective communication, if MPI found this is specialisation for MPI
Definition: agrid.hh:403
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
int maxLevel() const
Definition: albertagrid.cc:481
AlbertaGrid()
create an empty grid
Definition: albertagrid.cc:40
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:362
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
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:449
std::size_t numBoundarySegments() const
number of boundary segments within the macro grid
Definition: agrid.hh:348
AlbertaGridFamily< dim, dimworld > GridFamily
the grid family of AlbertaGrid
Definition: agrid.hh:139
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:518
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:155
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
bool writeGrid(const std::string &filename, ctype time) const
write Grid to file in Xdr
Definition: albertagrid.cc:573
Traits::LevelGridView levelGridView(int level) const
View for a grid level for All_Partition.
Definition: agrid.hh:354
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:443
void globalRefine(int refCount)
uses the interface, mark on entity and refineLocal
Definition: albertagrid.cc:302
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
returns adaptation mark for given entity
Definition: albertagrid.cc:406
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
obtain Entity from EntitySeed.
Definition: agrid.hh:418
~AlbertaGrid()
desctructor
Definition: albertagrid.cc:194
bool preAdapt()
returns true, if a least one element is marked for coarsening
Definition: albertagrid.cc:346
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
Traits::CollectiveCommunication CollectiveCommunication
type of collective communication
Definition: agrid.hh:163
marker assigning subentities to one element containing them
Definition: treeiterator.hh:33
Store a reference to an entity with a minimal memory footprint.
Definition: entityseed.hh:24
Implementation & impl()
access to the underlying implementation
Definition: entityseed.hh:57
Implementation & impl()
access to the underlying implementation
Definition: entity.hh:78
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:123
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:904
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:916
Provide a generic factory class for unstructured grids.
Definition: gridfactory.hh:312
Grid view abstract base class.
Definition: gridview.hh:63
Id Set Interface.
Definition: indexidset.hh:450
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:279
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:216
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:504
Dune namespace.
Definition: alignedallocator.hh:11
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:31
Contains #undefs for all preprocessor macros defined by alberta.