3 #ifndef DUNE_ALBERTAGRID_IMP_HH
4 #define DUNE_ALBERTAGRID_IMP_HH
11 #if HAVE_ALBERTA || DOXYGEN
36 #include "albertaheader.hh"
38 #include <dune/grid/albertagrid/misc.hh>
39 #include <dune/grid/albertagrid/capabilities.hh>
40 #include <dune/grid/albertagrid/backuprestore.hh>
42 #include <dune/grid/albertagrid/coordcache.hh>
44 #include <dune/grid/albertagrid/level.hh>
45 #include <dune/grid/albertagrid/intersection.hh>
47 #include <dune/grid/albertagrid/datahandle.hh>
48 #include <dune/grid/albertagrid/entityseed.hh>
50 #include "indexsets.hh"
51 #include "geometry.hh"
53 #include "hierarchiciterator.hh"
54 #include "treeiterator.hh"
55 #include "leveliterator.hh"
56 #include "leafiterator.hh"
64 template<
class Gr
id >
65 struct DGFGridFactory;
135 template<
int dim,
int dimworld = Alberta::dimWorld >
138 < dim, dimworld, Alberta::Real, AlbertaGridFamily< dim, dimworld > >
142 < dim, dimworld, Alberta::Real, AlbertaGridFamily< dim, dimworld > >
146 template<
class >
friend class AlbertaLevelGridView;
147 template<
class >
friend class AlbertaLeafGridView;
152 friend struct DGFGridFactory<
This >;
154 friend class AlbertaGridIntersectionBase< const
This >;
155 friend class AlbertaGridLeafIntersection< const
This >;
158 #if (__GNUC__ < 4) && !(defined __ICC)
163 friend class AlbertaGridIndexSet< dim, dimworld >;
164 friend class AlbertaGridHierarchicIndexSet< dim, dimworld >;
166 template< class, class >
167 friend class Alberta::AdaptRestrictProlongHandler;
173 typedef typename GridFamily::ctype ctype;
175 static const int dimension = GridFamily::dimension;
176 static const int dimensionworld = GridFamily::dimensionworld;
179 typedef typename AlbertaGridFamily< dim, dimworld >::Traits Traits;
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 )
278 template<
class DataHandler >
279 struct AdaptationCallback;
282 static const int MAXL = 64;
284 typedef Alberta::ElementInfo< dimension > ElementInfo;
285 typedef Alberta::MeshPointer< dimension > MeshPointer;
286 typedef Alberta::HierarchyDofNumbering< dimension > DofNumbering;
287 typedef AlbertaGridLevelProvider< dimension > LevelProvider;
291 This &operator= (
const This & ) =
delete;
301 AlbertaGrid (
const Alberta::MacroData< dimension > ¯oData,
305 template<
class Proj,
class Impl >
306 AlbertaGrid (
const Alberta::MacroData< dimension > ¯oData,
307 const Alberta::ProjectionFactoryInterface< Proj, Impl > &projectionFactory );
313 AlbertaGrid (
const std::string ¯oGridFileName );
323 template<
int cd, PartitionIteratorType pitype>
328 template<
int cd, PartitionIteratorType pitype>
330 lend (
int level)
const;
333 template<
int codim >
335 lbegin (
int level )
const;
338 template<
int codim >
340 lend (
int level )
const;
343 template<
int codim, PartitionIteratorType pitype >
349 template<
int codim, PartitionIteratorType pitype >
355 template<
int codim >
360 template<
int codim >
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 ) );
417 template<
class DataHandle >
424 template<
class DataHandle >
440 static std::string typeName ()
442 std::ostringstream s;
443 s <<
"AlbertaGrid< " << dim <<
", " << dimworld <<
" >";
448 template<
class EntitySeed >
449 typename Traits::template Codim< EntitySeed::codimension >::Entity
453 return EntityImpl( *
this, this->getRealImplementation(seed).elementInfo( meshPointer() ), this->getRealImplementation(seed).subEntity() );
460 bool writeGrid(
const std::string &filename, ctype time )
const;
463 bool readGrid(
const std::string &filename, ctype &time );
469 const typename Traits :: LevelIndexSet &
levelIndexSet (
int level)
const;
472 const typename Traits :: LeafIndexSet &
leafIndexSet ()
const;
487 ALBERTA MESH* getMesh ()
const
492 const MeshPointer &meshPointer ()
const
497 const DofNumbering &dofNumbering ()
const
499 return dofNumbering_;
502 const LevelProvider &levelProvider ()
const
504 return levelProvider_;
507 int dune2alberta (
int codim,
int i )
const
509 return numberingMap_.dune2alberta( codim, i );
512 int alberta2dune (
int codim,
int i )
const
514 return numberingMap_.alberta2dune( codim, i );
517 int generic2alberta (
int codim,
int i )
const
519 return genericNumberingMap_.dune2alberta( codim, i );
522 int alberta2generic (
int codim,
int i )
const
524 return genericNumberingMap_.alberta2dune( codim, i );
530 writeGridXdr ( const std::
string &filename, ctype time ) const;
535 readGridXdr ( const std::
string &filename, ctype &time );
538 using Base::getRealImplementation;
540 typedef std::vector<
int> ArrayType;
555 typedef MakeableInterfaceObject< typename Traits::template Codim< 0 >::Entity >
559 friend class AlbertaGridLeafIntersectionIterator< const This >;
561 template<
int codim >
563 getTwist ( const typename Traits::template Codim< codim >::Entity &
entity )
565 return getRealImplementation(
entity ).twist();
568 template<
int codim >
570 getTwist (
const typename Traits::template Codim< 0 >::Entity &
entity,
int subEntity )
572 return getRealImplementation(
entity ).template twist< codim >( subEntity );
576 getTwistInInside (
const typename Traits::LeafIntersection &intersection )
578 return getRealImplementation( intersection ).twistInInside();
582 getTwistInOutside (
const typename Traits::LeafIntersection &intersection )
584 return getRealImplementation( intersection ).twistInOutside();
587 const AlbertaGridLeafIntersection< const This > &
588 getRealIntersection (
const typename Traits::LeafIntersection &intersection )
const
590 return getRealImplementation( intersection );
595 const Alberta::GlobalVector &
596 getCoord (
const ElementInfo &elementInfo,
int vertex )
const;
609 size_t numBoundarySegments_;
612 Alberta::NumberingMap< dimension, Alberta::Dune2AlbertaNumbering > numberingMap_;
613 Alberta::NumberingMap< dimension, Alberta::Generic2AlbertaNumbering > genericNumberingMap_;
615 DofNumbering dofNumbering_;
617 LevelProvider levelProvider_;
627 mutable std::vector< typename GridFamily::LevelIndexSetImp * > levelIndexVec_;
631 mutable typename GridFamily::LeafIndexSetImp* leafIndexSet_;
633 SizeCache< This > sizeCache_;
635 typedef AlbertaMarkerVector< dim, dimworld > MarkerVector;
638 mutable MarkerVector leafMarkerVector_;
641 mutable std::vector< MarkerVector > levelMarkerVector_;
643 #if DUNE_ALBERTA_CACHE_COORDINATES
644 Alberta::CoordCache< dimension > coordCache_;
648 AdaptationState adaptationState_;
653 #include "albertagrid.cc"
659 #ifdef _ABS_NOT_DEFINED_
663 #ifdef _MIN_NOT_DEFINED_
667 #ifdef _MAX_NOT_DEFINED_
671 #ifdef obstack_chunk_alloc
672 #undef obstack_chunk_alloc
674 #ifdef obstack_chunk_free
675 #undef obstack_chunk_free
722 #ifdef DEBUG_TEST_EXIT
723 #undef DEBUG_TEST_EXIT
742 #ifdef PRINT_REAL_VEC
743 #undef PRINT_REAL_VEC
762 #ifdef FREE_WORKSPACE
763 #undef FREE_WORKSPACE
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:184
[ 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
Traits ::template Codim< codim >::template Partition< pitype >::LeafIterator leafbegin() const
return LeafIterator which points to first leaf entity
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:908
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:920
bool writeGridXdr(const std::string &filename, ctype time) const
Definition: albertagrid.cc:573
int maxLevel() const
Definition: albertagrid.cc:481
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: albertagrid.cc:204
AlbertaGrid()
create an empty grid
Definition: albertagrid.cc:40
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lend(int level) const
one past the end on this level
Definition: albertagrid.cc:224
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
void postAdapt()
clean up some markers
Definition: albertagrid.cc:354
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
AlbertaGridFamily< dim, dimworld > GridFamily
the grid family of AlbertaGrid
Definition: agrid.hh:171
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: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
void globalRefine(int refCount)
uses the interface, mark on entity and refineLocal
Definition: albertagrid.cc:302
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
Traits::CollectiveCommunication CollectiveCommunication
type of collective communication
Definition: agrid.hh:195
marker assigning subentities to one element containing them
Definition: treeiterator.hh:32
Collective communication interface and sequential default implementation.
Definition: collectivecommunication.hh:80
Store a reference to an entity with a minimal memory footprint.
Definition: entityseed.hh:24
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:277
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:908
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:920
Provide a generic factory class for unstructured grids.
Definition: gridfactory.hh:263
Grid view abstract base class.
Definition: gridview.hh:60
Id Set Interface.
Definition: indexidset.hh:441
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
Implements an utility class that provides collective communication methods for sequential programs.
Different resources needed by all grid implementations.
Provide a generic factory class for unstructured grids.
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
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_DEPRECATED_MSG(text)
Mark some entity as deprecated.
Definition: deprecated.hh:169
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:727
Dune namespace.
Definition: alignedallocator.hh:10
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:24
Contains #undefs for all preprocessor macros defined by alberta.