5#ifndef DUNE_ALBERTAGRID_IMP_HH
6#define DUNE_ALBERTAGRID_IMP_HH
13#if HAVE_ALBERTA || DOXYGEN
25#include <dune/common/fvector.hh>
26#include <dune/common/fmatrix.hh>
27#include <dune/common/stdstreams.hh>
28#include <dune/common/parallel/communication.hh>
65 template<
class Gr
id >
105 template<
int dim,
int dimworld = Alberta::dimWorld >
108 < dim, dimworld, Alberta::Real, AlbertaGridFamily< dim, dimworld > >
128#if (__GNUC__ < 4) && !(defined __ICC)
136 template< class, class >
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 )
250 DUNE_THROW( InvalidStateException, message );
254 template<
class DataHandler >
255 struct AdaptationCallback;
258 static const int MAXL = 64;
281 template<
class Proj,
class Impl >
289 AlbertaGrid (
const std::string ¯oGridFileName );
299 template<
int cd, PartitionIteratorType pitype>
300 typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
304 template<
int cd, PartitionIteratorType pitype>
305 typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
309 template<
int codim >
310 typename Traits::template Codim< codim >::LevelIterator
314 template<
int codim >
315 typename Traits::template Codim< codim >::LevelIterator
319 template<
int codim, PartitionIteratorType pitype >
321 ::template Codim< codim >::template Partition< pitype >::LeafIterator
325 template<
int codim, PartitionIteratorType pitype >
327 ::template Codim< codim >::template Partition< pitype >::LeafIterator
331 template<
int codim >
332 typename Traits::template Codim< codim >::LeafIterator
336 template<
int codim >
337 typename Traits::template Codim< codim >::LeafIterator
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 ) );
385 int getMark (
const typename Traits::template Codim< 0 >::Entity &e )
const;
388 bool mark (
int refCount,
const typename Traits::template Codim< 0 >::Entity &e );
393 template<
class DataHandle >
400 template<
class DataHandle >
418 std::ostringstream s;
419 s <<
"AlbertaGrid< " << dim <<
", " << dimworld <<
" >";
424 template<
class EntitySeed >
425 typename Traits::template Codim< EntitySeed::codimension >::Entity
428 typedef typename Traits::template Codim< EntitySeed::codimension >::EntityImpl EntityImpl;
429 return EntityImpl( *
this, seed.
impl().elementInfo(
meshPointer() ), seed.
impl().subEntity() );
475 return dofNumbering_;
480 return levelProvider_;
495 return genericNumberingMap_.dune2alberta( codim, i );
500 return genericNumberingMap_.alberta2dune( codim, i );
504 typedef std::vector<int> ArrayType;
525 template<
int codim >
532 template<
int codim >
534 getTwist (
const typename Traits::template Codim< 0 >::Entity &
entity,
int subEntity )
536 return entity.
impl().template twist< codim >( subEntity );
542 return intersection.
impl().twistInInside();
548 return intersection.
impl().twistInOutside();
567 size_t numBoundarySegments_;
573 DofNumbering dofNumbering_;
575 LevelProvider levelProvider_;
585 mutable std::vector< typename GridFamily::LevelIndexSetImp * > levelIndexVec_;
596 mutable MarkerVector leafMarkerVector_;
599 mutable std::vector< MarkerVector > levelMarkerVector_;
601#if DUNE_ALBERTA_CACHE_COORDINATES
606 AdaptationState adaptationState_;
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
Provides size cache classes to implement the grids size method efficiently.
interfaces and wrappers needed for the callback adaptation provided by AlbertaGrid and dune-ALUGrid
Contains #undefs for all preprocessor macros defined by alberta.
#define ALBERTA
Definition: albertaheader.hh:29
Include standard header files.
Definition: agrid.hh:60
ALBERTA REAL Real
Definition: misc.hh:48
ALBERTA REAL_D GlobalVector
Definition: misc.hh:50
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
@ vertex
Definition: common.hh:133
Definition: dgfgridfactory.hh:38
[ 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
const DofNumbering & dofNumbering() const
Definition: agrid.hh:473
int generic2alberta(int codim, int i) const
Definition: agrid.hh:493
static std::string typeName()
Definition: agrid.hh:416
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator leafbegin() const
return LeafIterator which points to first leaf entity
const HierarchicIndexSet & hierarchicIndexSet() const
Definition: agrid.hh:442
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lend(int level) const
one past the end on this level
static const int dimension
Definition: agrid.hh:145
int dune2alberta(int codim, int i) const
Definition: agrid.hh:483
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.
const LevelProvider & levelProvider() const
Definition: agrid.hh:478
static int getTwistInOutside(const typename Traits::LeafIntersection &intersection)
Definition: agrid.hh:546
const Alberta::GlobalVector & getCoord(const ElementInfo &elementInfo, int vertex) const
Definition: albertagrid.cc:471
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
static const int dimensionworld
Definition: agrid.hh:146
static int getTwistInInside(const typename Traits::LeafIntersection &intersection)
Definition: agrid.hh:540
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
GridFamily::ctype ctype
Definition: agrid.hh:143
AlbertaGrid(const This &)=delete
Communication CollectiveCommunication
Definition: agrid.hh:171
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
int alberta2generic(int codim, int i) const
Definition: agrid.hh:498
static int getTwist(const typename Traits::template Codim< codim >::Entity &entity)
Definition: agrid.hh:527
const Communication & comm() const
return reference to communication, if MPI found this is specialisation for MPI
Definition: agrid.hh:411
ALBERTA MESH * getMesh() const
Definition: agrid.hh:463
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
int alberta2dune(int codim, int i) const
Definition: agrid.hh:488
This & operator=(const This &)=delete
AlbertaGridFamily< dim, dimworld >::Traits Traits
Definition: agrid.hh:149
static int getTwist(const typename Traits::template Codim< 0 >::Entity &entity, int subEntity)
Definition: agrid.hh:534
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
const MeshPointer & meshPointer() const
Definition: agrid.hh:468
Definition: coordcache.hh:25
Definition: albertagrid/datahandle.hh:27
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: common/intersection.hh:164
Implementation & impl()
access to the underlying implementation
Definition: common/intersection.hh:178
Definition: treeiterator.hh:189
Definition: hierarchiciterator.hh:29
Definition: albertagrid/intersection.hh:105
Definition: albertagrid/intersectioniterator.hh:27
Definition: albertagrid/entity.hh:46
Definition: albertagrid/indexsets.hh:42
hierarchic index set of AlbertaGrid
Definition: albertagrid/indexsets.hh:534
Definition: albertagrid/indexsets.hh:335
Definition: albertagrid/gridfamily.hh:83
static const int dimension
Definition: albertagrid/gridfamily.hh:88
static const int dimensionworld
Definition: albertagrid/gridfamily.hh:89
AlbertaGridIndexSet< dim, dimworld > LeafIndexSetImp
Definition: albertagrid/gridfamily.hh:92
Alberta::Real ctype
Definition: albertagrid/gridfamily.hh:86
Definition: albertagrid/gridfamily.hh:98
IndexSet< GridImp, LeafIndexSetImp, int, std::array< GeometryType, 1 > > LeafIndexSet
Definition: albertagrid/gridfamily.hh:143
IndexSet< GridImp, LevelIndexSetImp, int, std::array< GeometryType, 1 > > LevelIndexSet
Definition: albertagrid/gridfamily.hh:142
Dune::Communication< No_Comm > Communication
Definition: albertagrid/gridfamily.hh:148
Definition: albertagrid/gridview.hh:80
Definition: albertagrid/gridview.hh:299
Definition: albertagrid/intersection.hh:32
int alberta2dune(int codim, int i) const
Definition: misc.hh:397
int dune2alberta(int codim, int i) const
Definition: misc.hh:390
Definition: albertagrid/projection.hh:80
marker assigning subentities to one element containing them
Definition: treeiterator.hh:35
Interface class for the Grid's adapt method where the parameter is a AdaptDataHandleInterface.
Definition: adaptcallback.hh:33
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:33
Implementation & impl()
access to the underlying implementation
Definition: common/entity.hh:80
Store a reference to an entity with a minimal memory footprint.
Definition: common/entityseed.hh:26
Implementation & impl()
access to the underlying implementation
Definition: common/entityseed.hh:59
Definition: common/grid.hh:862
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: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: common/grid.hh:927
Index Set Interface base class.
Definition: indexidset.hh:78
Id Set Interface.
Definition: indexidset.hh:452
Definition: common/grid.hh:1107
Provide a generic factory class for unstructured grids.
Definition: common/gridfactory.hh:314
Grid view abstract base class.
Definition: common/gridview.hh:66
organizes the caching of sizes for one grid and one GeometryType
Definition: sizecache.hh:33
Provide a generic factory class for unstructured grids.
provides the GridFamily for AlbertaGrid
Implementation of the IntersectionIterator for AlbertaGrid.
Different resources needed by all grid implementations.