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;
170 [[deprecated("Use Communication instead!")]]
175 typedef typename Traits::template
Codim<0>::LeafIterator LeafIterator;
181 struct AdaptationState
183 enum Phase { ComputationPhase, PreAdaptationPhase, PostAdaptationPhase };
192 : phase_( ComputationPhase ),
197 void mark (
int count )
202 refineMarked_ += (2 << count);
205 void unmark (
int count )
210 refineMarked_ -= (2 << count);
213 bool coarsen ()
const
215 return (coarsenMarked_ > 0);
218 int refineMarked ()
const
220 return refineMarked_;
225 if( phase_ != ComputationPhase )
226 error(
"preAdapt may only be called in computation phase." );
227 phase_ = PreAdaptationPhase;
232 if( phase_ != PreAdaptationPhase )
233 error(
"adapt may only be called in preadapdation phase." );
234 phase_ = PostAdaptationPhase;
239 if( phase_ != PostAdaptationPhase )
240 error(
"postAdapt may only be called in postadaptation phase." );
241 phase_ = ComputationPhase;
248 void error (
const std::string &message )
254 template<
class DataHandler >
255 struct AdaptationCallback;
258 static const int MAXL = 64;
260 typedef Alberta::ElementInfo< dimension > ElementInfo;
261 typedef Alberta::MeshPointer< dimension > MeshPointer;
262 typedef Alberta::HierarchyDofNumbering< dimension > DofNumbering;
263 typedef AlbertaGridLevelProvider< dimension > LevelProvider;
267 This &operator= (
const This & ) =
delete;
277 AlbertaGrid (
const Alberta::MacroData< dimension > ¯oData,
281 template<
class Proj,
class Impl >
282 AlbertaGrid (
const Alberta::MacroData< dimension > ¯oData,
283 const Alberta::ProjectionFactoryInterface< Proj, Impl > &projectionFactory );
289 AlbertaGrid (
const std::string ¯oGridFileName );
299 template<
int cd, PartitionIteratorType pitype>
304 template<
int cd, PartitionIteratorType pitype>
309 template<
int codim >
314 template<
int codim >
319 template<
int codim, PartitionIteratorType pitype >
325 template<
int codim, PartitionIteratorType pitype >
331 template<
int codim >
336 template<
int codim >
344 int size (
int level,
int codim)
const;
350 int size (
int codim)
const;
358 return numBoundarySegments_;
365 typedef typename View::GridViewImp ViewImp;
366 return View( ViewImp( *
this, level ) );
373 typedef typename View::GridViewImp ViewImp;
374 return View( ViewImp( *
this ) );
393 template<
class DataHandle >
400 template<
class DataHandle >
416 static std::string typeName ()
418 std::ostringstream s;
419 s <<
"AlbertaGrid< " << dim <<
", " << dimworld <<
" >";
424 template<
class EntitySeed >
425 typename Traits::template Codim< EntitySeed::codimension >::Entity
429 return EntityImpl( *
this, seed.
impl().elementInfo( meshPointer() ), seed.
impl().subEntity() );
436 bool writeGrid(
const std::string &filename, ctype time )
const;
439 bool readGrid(
const std::string &filename, ctype &time );
445 const typename Traits :: LevelIndexSet &
levelIndexSet (
int level)
const;
448 const typename Traits :: LeafIndexSet &
leafIndexSet ()
const;
463 ALBERTA MESH* getMesh ()
const
468 const MeshPointer &meshPointer ()
const
473 const DofNumbering &dofNumbering ()
const
475 return dofNumbering_;
478 const LevelProvider &levelProvider ()
const
480 return levelProvider_;
483 int dune2alberta (
int codim,
int i )
const
485 return numberingMap_.dune2alberta( codim, i );
488 int alberta2dune (
int codim,
int i )
const
490 return numberingMap_.alberta2dune( codim, i );
493 int generic2alberta (
int codim,
int i )
const
495 return genericNumberingMap_.dune2alberta( codim, i );
498 int alberta2generic (
int codim,
int i )
const
500 return genericNumberingMap_.alberta2dune( codim, i );
504 typedef std::vector<int> ArrayType;
519 typedef MakeableInterfaceObject< typename Traits::template Codim< 0 >::Entity >
523 friend class AlbertaGridLeafIntersectionIterator< const This >;
525 template<
int codim >
527 getTwist (
const typename Traits::template Codim< codim >::Entity &
entity )
532 template<
int codim >
534 getTwist (
const typename Traits::template Codim< 0 >::Entity &
entity,
int subEntity )
536 return entity.
impl().template twist< codim >( subEntity );
540 getTwistInInside (
const typename Traits::LeafIntersection &intersection )
542 return intersection.impl().twistInInside();
546 getTwistInOutside (
const typename Traits::LeafIntersection &intersection )
548 return intersection.impl().twistInOutside();
553 const Alberta::GlobalVector &
554 getCoord (
const ElementInfo &elementInfo,
int vertex )
const;
567 size_t numBoundarySegments_;
570 Alberta::NumberingMap< dimension, Alberta::Dune2AlbertaNumbering > numberingMap_;
571 Alberta::NumberingMap< dimension, Alberta::Generic2AlbertaNumbering > genericNumberingMap_;
573 DofNumbering dofNumbering_;
575 LevelProvider levelProvider_;
585 mutable std::vector< typename GridFamily::LevelIndexSetImp * > levelIndexVec_;
589 mutable typename GridFamily::LeafIndexSetImp* leafIndexSet_;
591 SizeCache< This > sizeCache_;
593 typedef AlbertaMarkerVector< dim, dimworld > MarkerVector;
596 mutable MarkerVector leafMarkerVector_;
599 mutable std::vector< MarkerVector > levelMarkerVector_;
601#if DUNE_ALBERTA_CACHE_COORDINATES
602 Alberta::CoordCache< dimension > coordCache_;
606 AdaptationState adaptationState_;
611#include "albertagrid.cc"
617#ifdef _ABS_NOT_DEFINED_
621#ifdef _MIN_NOT_DEFINED_
625#ifdef _MAX_NOT_DEFINED_
629#ifdef obstack_chunk_alloc
630#undef obstack_chunk_alloc
632#ifdef obstack_chunk_free
633#undef obstack_chunk_free
680#ifdef DEBUG_TEST_EXIT
681#undef DEBUG_TEST_EXIT
interfaces and wrappers needed for the callback adaptation provided by AlbertaGrid and dune-ALUGrid
provides the GridFamily 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:534
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:370
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:457
std::size_t numBoundarySegments() const
number of boundary segments within the macro grid
Definition: agrid.hh:356
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:411
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:362
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:451
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:426
~AlbertaGrid()
desctructor
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:125
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:915
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:927
Provide a generic factory class for unstructured grids.
Definition: gridfactory.hh:314
Grid view abstract base class.
Definition: gridview.hh:66
Id Set Interface.
Definition: indexidset.hh:452
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
Implements an utility class that provides collective communication methods for sequential programs.
Implementation of the IntersectionIterator for AlbertaGrid.
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:218
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:506
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.