3 #ifndef DUNE_ALBERTAGRID_IMP_HH
4 #define DUNE_ALBERTAGRID_IMP_HH
11 #if HAVE_ALBERTA || DOXYGEN
23 #include <dune/common/deprecated.hh>
24 #include <dune/common/fvector.hh>
25 #include <dune/common/fmatrix.hh>
26 #include <dune/common/stdstreams.hh>
27 #include <dune/common/parallel/communication.hh>
64 template<
class Gr
id >
135 template<
int dim,
int dimworld = Alberta::dimWorld >
138 < dim, dimworld, Alberta::Real, AlbertaGridFamily< dim, dimworld > >
158 #if (__GNUC__ < 4) && !(defined __ICC)
166 template< class, class >
199 typedef typename Traits::template Codim<0>::LeafIterator LeafIterator;
205 struct AdaptationState
207 enum Phase { ComputationPhase, PreAdaptationPhase, PostAdaptationPhase };
216 : phase_( ComputationPhase ),
221 void mark (
int count )
226 refineMarked_ += (2 << count);
229 void unmark (
int count )
234 refineMarked_ -= (2 << count);
237 bool coarsen ()
const
239 return (coarsenMarked_ > 0);
242 int refineMarked ()
const
244 return refineMarked_;
249 if( phase_ != ComputationPhase )
250 error(
"preAdapt may only be called in computation phase." );
251 phase_ = PreAdaptationPhase;
256 if( phase_ != PreAdaptationPhase )
257 error(
"adapt may only be called in preadapdation phase." );
258 phase_ = PostAdaptationPhase;
263 if( phase_ != PostAdaptationPhase )
264 error(
"postAdapt may only be called in postadaptation phase." );
265 phase_ = ComputationPhase;
272 void error (
const std::string &message )
274 DUNE_THROW( InvalidStateException, message );
278 template<
class DataHandler >
279 struct AdaptationCallback;
282 static const int MAXL = 64;
305 template<
class Proj,
class Impl >
313 AlbertaGrid (
const std::string ¯oGridFileName );
323 template<
int cd, PartitionIteratorType pitype>
324 typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
328 template<
int cd, PartitionIteratorType pitype>
329 typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
333 template<
int codim >
334 typename Traits::template Codim< codim >::LevelIterator
338 template<
int codim >
339 typename Traits::template Codim< codim >::LevelIterator
343 template<
int codim, PartitionIteratorType pitype >
345 ::template Codim< codim >::template Partition< pitype >::LeafIterator
349 template<
int codim, PartitionIteratorType pitype >
351 ::template Codim< codim >::template Partition< pitype >::LeafIterator
355 template<
int codim >
356 typename Traits::template Codim< codim >::LeafIterator
360 template<
int codim >
361 typename Traits::template Codim< codim >::LeafIterator
368 int size (
int level,
int codim)
const;
374 int size (
int codim)
const;
382 return numBoundarySegments_;
389 typedef typename View::GridViewImp ViewImp;
390 return View( ViewImp( *
this, level ) );
397 typedef typename View::GridViewImp ViewImp;
398 return View( ViewImp( *
this ) );
409 int getMark (
const typename Traits::template Codim< 0 >::Entity &e )
const;
412 bool mark (
int refCount,
const typename Traits::template Codim< 0 >::Entity &e );
417 template<
class DataHandle >
424 template<
class DataHandle >
442 std::ostringstream s;
443 s <<
"AlbertaGrid< " << dim <<
", " << dimworld <<
" >";
448 template<
class EntitySeed >
449 typename Traits::template Codim< EntitySeed::codimension >::Entity
452 typedef typename Traits::template Codim< EntitySeed::codimension >::EntityImpl EntityImpl;
453 return EntityImpl( *
this, seed.
impl().elementInfo(
meshPointer() ), seed.
impl().subEntity() );
499 return dofNumbering_;
504 return levelProvider_;
519 return genericNumberingMap_.dune2alberta( codim, i );
524 return genericNumberingMap_.alberta2dune( codim, i );
529 DUNE_DEPRECATED_MSG(
"Deprecated in Dune 3.0, use writeGrid instead.")
534 DUNE_DEPRECATED_MSG("Deprecated in
Dune 3.0, use
readGrid instead.")
540 typedef std::vector<
int> ArrayType;
561 template<
int codim >
568 template<
int codim >
570 getTwist (
const typename Traits::template Codim< 0 >::Entity &
entity,
int subEntity )
572 return entity.
impl().template twist< codim >( subEntity );
578 return intersection.
impl().twistInInside();
584 return intersection.
impl().twistInOutside();
587 DUNE_DEPRECATED_MSG(
"use intersection.impl() instead")
591 return intersection.impl();
610 size_t numBoundarySegments_;
616 DofNumbering dofNumbering_;
618 LevelProvider levelProvider_;
628 mutable std::vector< typename GridFamily::LevelIndexSetImp * > levelIndexVec_;
639 mutable MarkerVector leafMarkerVector_;
642 mutable std::vector< MarkerVector > levelMarkerVector_;
644 #if DUNE_ALBERTA_CACHE_COORDINATES
649 AdaptationState adaptationState_;
660 #ifdef _ABS_NOT_DEFINED_
664 #ifdef _MIN_NOT_DEFINED_
668 #ifdef _MAX_NOT_DEFINED_
672 #ifdef obstack_chunk_alloc
673 #undef obstack_chunk_alloc
675 #ifdef obstack_chunk_free
676 #undef obstack_chunk_free
723 #ifdef DEBUG_TEST_EXIT
724 #undef DEBUG_TEST_EXIT
743 #ifdef PRINT_REAL_VEC
744 #undef PRINT_REAL_VEC
763 #ifdef FREE_WORKSPACE
764 #undef FREE_WORKSPACE
interfaces and wrappers needed for the callback adaptation provided by AlbertaGrid and dune-ALUGrid
Provides size cache classes to implement the grids size method efficiently.
#define ALBERTA
Definition: albertaheader.hh:27
Contains #undefs for all preprocessor macros defined by alberta.
Include standard header files.
Definition: agrid.hh:59
ALBERTA REAL Real
Definition: misc.hh:46
ALBERTA REAL_D GlobalVector
Definition: misc.hh:48
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:180
@ vertex
Definition: common.hh:181
Definition: dgfgridfactory.hh:36
[ provides Dune::Grid ]
Definition: agrid.hh:139
bool readGrid(const std::string &filename, ctype &time)
read Grid from file filename and store time of mesh in time
Definition: albertagrid.cc:599
int generic2alberta(int codim, int i) const
Definition: agrid.hh:517
static std::string typeName()
Definition: agrid.hh:440
const DofNumbering & dofNumbering() const
Definition: agrid.hh:497
Traits ::template Codim< codim >::template Partition< pitype >::LeafIterator leafbegin() const
return LeafIterator which points to first leaf entity
static const int dimension
Definition: agrid.hh:175
AlbertaGridFamily< dim, dimworld >::Traits Traits
Definition: agrid.hh:179
int dune2alberta(int codim, int i) const
Definition: agrid.hh:507
const HierarchicIndexSet & hierarchicIndexSet() const
Definition: agrid.hh:466
bool writeGridXdr(const std::string &filename, ctype time) const
Definition: albertagrid.cc:573
const AlbertaGridLeafIntersection< const This > & getRealIntersection(const typename Traits::LeafIntersection &intersection) const
Definition: agrid.hh:589
int maxLevel() const
Definition: albertagrid.cc:481
const LevelProvider & levelProvider() const
Definition: agrid.hh:502
const MeshPointer & meshPointer() const
Definition: agrid.hh:492
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.
static int getTwistInOutside(const typename Traits::LeafIntersection &intersection)
Definition: agrid.hh:582
ALBERTA MESH * getMesh() const
Definition: agrid.hh:487
const Alberta::GlobalVector & getCoord(const ElementInfo &elementInfo, int vertex) const
Definition: albertagrid.cc:469
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:394
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:581
const LocalIdSet & localIdSet() const
return local IdSet
Definition: agrid.hh:481
static const int dimensionworld
Definition: agrid.hh:176
static int getTwistInInside(const typename Traits::LeafIntersection &intersection)
Definition: agrid.hh:576
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
This & operator=(const This &)=delete
std::size_t numBoundarySegments() const
number of boundary segments within the macro grid
Definition: agrid.hh:380
const CollectiveCommunication & comm() const
return reference to collective communication, if MPI found this is specialisation for MPI
Definition: agrid.hh:435
GridFamily::ctype ctype
Definition: agrid.hh:173
AlbertaGrid(const This &)=delete
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 alberta2generic(int codim, int i) const
Definition: agrid.hh:522
static int getTwist(const typename Traits::template Codim< codim >::Entity &entity)
Definition: agrid.hh:563
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:187
const Traits ::LeafIndexSet & leafIndexSet() const
return leaf index set
Definition: albertagrid.cc:533
bool writeGrid(const std::string &filename, ctype time) const
write Grid to file in Xdr
Definition: albertagrid.cc:589
Traits::LevelGridView levelGridView(int level) const
View for a grid level for All_Partition.
Definition: agrid.hh:386
Traits ::template Codim< codim >::template Partition< pitype >::LeafIterator leafend() const
return LeafIterator which points behind last leaf entity
int alberta2dune(int codim, int i) const
Definition: agrid.hh:512
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lend(int level) const
one past the end on this level
static int getTwist(const typename Traits::template Codim< 0 >::Entity &entity, int subEntity)
Definition: agrid.hh:570
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:450
~AlbertaGrid()
desctructor
Definition: albertagrid.cc:194
const GlobalIdSet & globalIdSet() const
return global IdSet
Definition: agrid.hh:475
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:195
Definition: coordcache.hh:23
Definition: albertagrid/datahandle.hh:25
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: common/intersection.hh:162
Implementation & impl()
access to the underlying implementation
Definition: common/intersection.hh:176
Definition: treeiterator.hh:184
Definition: hierarchiciterator.hh:27
Definition: albertagrid/intersection.hh:103
Definition: albertagrid/intersectioniterator.hh:25
Definition: albertagrid/entity.hh:44
Definition: albertagrid/indexsets.hh:42
hierarchic index set of AlbertaGrid
Definition: albertagrid/indexsets.hh:532
Definition: albertagrid/indexsets.hh:333
Definition: albertagrid/gridfamily.hh:81
static const int dimension
Definition: albertagrid/gridfamily.hh:86
static const int dimensionworld
Definition: albertagrid/gridfamily.hh:87
AlbertaGridIndexSet< dim, dimworld > LeafIndexSetImp
Definition: albertagrid/gridfamily.hh:90
Alberta::Real ctype
Definition: albertagrid/gridfamily.hh:84
Definition: albertagrid/gridfamily.hh:96
IndexSet< GridImp, LeafIndexSetImp, int, std::array< GeometryType, 1 > > LeafIndexSet
Definition: albertagrid/gridfamily.hh:141
IndexSet< GridImp, LevelIndexSetImp, int, std::array< GeometryType, 1 > > LevelIndexSet
Definition: albertagrid/gridfamily.hh:140
Dune::CollectiveCommunication< No_Comm > CollectiveCommunication
Definition: albertagrid/gridfamily.hh:146
Definition: albertagrid/gridview.hh:74
Definition: albertagrid/gridview.hh:282
Definition: albertagrid/intersection.hh:30
int alberta2dune(int codim, int i) const
Definition: misc.hh:395
int dune2alberta(int codim, int i) const
Definition: misc.hh:388
Definition: albertagrid/projection.hh:78
marker assigning subentities to one element containing them
Definition: treeiterator.hh:32
Interface class for the Grid's adapt method where the parameter is a AdaptDataHandleInterface.
Definition: adaptcallback.hh:31
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:31
Wrapper class for entities.
Definition: common/entity.hh:64
Implementation & impl()
access to the underlying implementation
Definition: common/entity.hh:78
Store a reference to an entity with a minimal memory footprint.
Definition: common/entityseed.hh:24
Implementation & impl()
access to the underlying implementation
Definition: common/entityseed.hh:57
Definition: common/grid.hh:855
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:908
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: common/grid.hh:1027
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:920
Index Set Interface base class.
Definition: indexidset.hh:76
Id Set Interface.
Definition: indexidset.hh:441
GridFamily::Traits::LeafIntersection LeafIntersection
A type that is a model of Dune::Intersection, an intersections of two codimension 1 of two codimensio...
Definition: common/grid.hh:460
Definition: common/grid.hh:1173
Provide a generic factory class for unstructured grids.
Definition: common/gridfactory.hh:269
Grid view abstract base class.
Definition: common/gridview.hh:60
organizes the caching of sizes for one grid and one GeometryType
Definition: sizecache.hh:31
Different resources needed by all grid implementations.
Provide a generic factory class for unstructured grids.
provides the GridFamily for AlbertaGrid
Implementation of the IntersectionIterator for AlbertaGrid.