3 #ifndef DUNE_ALBERTAGRID_IMP_HH
4 #define DUNE_ALBERTAGRID_IMP_HH
11 #if HAVE_ALBERTA || DOXYGEN
21 #include <dune/common/fvector.hh>
22 #include <dune/common/fmatrix.hh>
23 #include <dune/common/stdstreams.hh>
24 #include <dune/common/parallel/collectivecommunication.hh>
65 template<
class Gr
id >
136 template<
int dim,
int dimworld = Alberta::dimWorld >
139 < dim, dimworld, Alberta::Real, AlbertaGridFamily< dim, dimworld > >
160 #if (__GNUC__ < 4) && !(defined __ICC)
168 template< class, class >
201 typedef typename Traits::template
Codim<0>::LeafIterator LeafIterator;
207 struct AdaptationState
209 enum Phase { ComputationPhase, PreAdaptationPhase, PostAdaptationPhase };
218 : phase_( ComputationPhase ),
223 void mark (
int count )
228 refineMarked_ += (2 << count);
231 void unmark (
int count )
236 refineMarked_ -= (2 << count);
239 bool coarsen ()
const
241 return (coarsenMarked_ > 0);
244 int refineMarked ()
const
246 return refineMarked_;
251 if( phase_ != ComputationPhase )
252 error(
"preAdapt may only be called in computation phase." );
253 phase_ = PreAdaptationPhase;
258 if( phase_ != PreAdaptationPhase )
259 error(
"adapt may only be called in preadapdation phase." );
260 phase_ = PostAdaptationPhase;
265 if( phase_ != PostAdaptationPhase )
266 error(
"postAdapt may only be called in postadaptation phase." );
267 phase_ = ComputationPhase;
274 void error (
const std::string &message )
276 DUNE_THROW( InvalidStateException, message );
280 template<
class DataHandler >
281 struct AdaptationCallback;
284 static const int MAXL = 64;
293 This &operator= (
const This & );
308 template<
class Proj,
class Impl >
316 AlbertaGrid (
const std::string ¯oGridFileName );
326 template<
int cd, PartitionIteratorType pitype>
327 typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
331 template<
int cd, PartitionIteratorType pitype>
332 typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
333 lend (
int level)
const;
336 template<
int codim >
337 typename Traits::template Codim< codim >::LevelIterator
338 lbegin (
int level )
const;
341 template<
int codim >
342 typename Traits::template Codim< codim >::LevelIterator
343 lend (
int level )
const;
346 template<
int codim, PartitionIteratorType pitype >
348 ::template Codim< codim >::template Partition< pitype >::LeafIterator
352 template<
int codim, PartitionIteratorType pitype >
354 ::template Codim< codim >::template Partition< pitype >::LeafIterator
358 template<
int codim >
359 typename Traits::template Codim< codim >::LeafIterator
363 template<
int codim >
364 typename Traits::template Codim< codim >::LeafIterator
371 int size (
int level,
int codim)
const;
377 int size (
int codim)
const;
385 return numBoundarySegments_;
389 template< PartitionIteratorType pitype >
390 typename Traits::template Partition< pitype >::LevelGridView
394 typedef typename View::GridViewImp ViewImp;
395 return View( ViewImp( *
this, level ) );
399 template< PartitionIteratorType pitype >
403 typedef typename View::GridViewImp ViewImp;
404 return View( ViewImp( *
this ) );
408 typename Traits::template Partition< All_Partition >::LevelGridView
412 typedef typename View::GridViewImp ViewImp;
413 return View( ViewImp( *
this, level ) );
420 typedef typename View::GridViewImp ViewImp;
421 return View( ViewImp( *
this ) );
432 int getMark (
const typename Traits::template Codim< 0 >::Entity &e )
const;
435 bool mark (
int refCount,
const typename Traits::template Codim< 0 >::Entity &e );
440 template<
class DataHandle >
447 template<
class DataHandle >
465 std::ostringstream s;
466 s <<
"AlbertaGrid< " << dim <<
", " << dimworld <<
" >";
478 template<
class EntitySeed >
479 DUNE_DEPRECATED_MSG(
"entityPointer() is deprecated and will be removed after the release of dune-grid 2.4. Use entity() instead to directly obtain an Entity object.")
488 template<
class EntitySeed >
489 typename Traits::template Codim< EntitySeed::codimension >::Entity
500 template< GrapeIOFileFormatType ftype >
504 template< GrapeIOFileFormatType ftype >
541 return dofNumbering_;
546 return levelProvider_;
578 typedef std::vector<int> ArrayType;
599 template<
int codim >
606 template<
int codim >
647 size_t numBoundarySegments_;
653 DofNumbering dofNumbering_;
655 LevelProvider levelProvider_;
665 mutable std::vector< typename GridFamily::LevelIndexSetImp * > levelIndexVec_;
676 mutable MarkerVector leafMarkerVector_;
679 mutable std::vector< MarkerVector > levelMarkerVector_;
681 #if DUNE_ALBERTA_CACHE_COORDINATES
686 AdaptationState adaptationState_;
697 #ifdef _ABS_NOT_DEFINED_
701 #ifdef _MIN_NOT_DEFINED_
705 #ifdef _MAX_NOT_DEFINED_
709 #ifdef obstack_chunk_alloc
710 #undef obstack_chunk_alloc
712 #ifdef obstack_chunk_free
713 #undef obstack_chunk_free
732 #endif // #ifdef ERROR
737 #endif // #ifdef ERROR_EXIT
742 #endif // #ifdef WARNING
747 #endif // #ifdef TEST
752 #endif // #ifdef TEST_EXIT
757 #endif // #ifdef DEBUG_TEST
760 #ifdef DEBUG_TEST_EXIT
761 #undef DEBUG_TEST_EXIT
762 #endif // #ifdef DEBUG_TEST_EXIT
767 #endif // #ifdef INFO
772 #endif // #ifdef PRINT_INFO
777 #endif // #ifdef PRINT_INT_VEC
780 #ifdef PRINT_REAL_VEC
781 #undef PRINT_REAL_VEC
782 #endif // #ifdef PRINT_REAL_VEC
787 #endif // #ifdef WAIT
792 #endif // #ifdef WAIT_REALLY
797 #endif // #ifdef GET_WORKSPACE
800 #ifdef FREE_WORKSPACE
801 #undef FREE_WORKSPACE
802 #endif // #ifdef FREE_WORKSPACE
807 #endif // #ifdef MAT_ALLOC
812 #endif // #ifdef MAT_FREE
817 #endif // #ifdef NAME
822 #endif // #ifdef GET_STRUCT
827 #endif // #ifdef ADD_PARAMETER
832 #endif // #ifdef GET_PARAMETER
836 #endif // HAVE_ALBERTA || DOXYGEN
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: albertagrid/dgfparser.hh:26
const MeshPointer & meshPointer() const
Definition: agrid.hh:534
Index Set Interface base class.
Definition: common/grid.hh:361
Definition: albertagrid/gridfamily.hh:81
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator leafend() const
return LeafIterator which points behind last leaf entity
Definition: albertagrid/datahandle.hh:24
Store a reference to an entity with a minimal memory footprint.
Definition: common/entityseed.hh:23
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:23
const LocalIdSet & localIdSet() const
return local IdSet
Definition: agrid.hh:523
Definition: albertagrid/entity.hh:27
Definition: albertagrid/projection.hh:77
GridFamily::ctype ctype
Definition: agrid.hh:175
Different resources needed by all grid implementations.
IndexSet< GridImp, LeafIndexSetImp, int, std::array< GeometryType, 1 > > LeafIndexSet
Definition: albertagrid/gridfamily.hh:148
size_t numBoundarySegments() const
number of boundary segments within the macro grid
Definition: agrid.hh:383
Definition: albertagrid/intersection.hh:29
void globalRefine(int refCount)
uses the interface, mark on entity and refineLocal
Definition: albertagrid.cc:302
Traits::template Partition< pitype >::LevelGridView levelGridView(int level) const
View for a grid level.
Definition: agrid.hh:391
Definition: albertagrid/gridfamily.hh:96
Types for GridView.
Definition: common/grid.hh:420
int alberta2dune(int codim, int i) const
Definition: misc.hh:394
void postAdapt()
clean up some markers
Definition: albertagrid.cc:354
int alberta2generic(int codim, int i) const
Definition: agrid.hh:564
const HierarchicIndexSet & hierarchicIndexSet() const
Definition: agrid.hh:508
Definition: objectfactory.hh:23
Provides size cache classes to implement the grids size method efficiently.
int dune2alberta(int codim, int i) const
Definition: agrid.hh:549
Wrapper class for pointers to entities.
Definition: common/entitypointer.hh:112
static const int dimensionworld
Definition: agrid.hh:178
Provide a generic factory class for unstructured grids.
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:1163
bool writeGrid(const std::string &filename, ctype time) const
write Grid to file in specified GrapeIOFileFormatType
Definition: albertagrid.cc:574
Definition: albertagrid/gridview.hh:20
EntityPointer implementation for AlbertaGrid.
Definition: albertagrid/entity.hh:21
ALBERTA MESH * getMesh() const
Definition: agrid.hh:529
interfaces and wrappers needed for the callback adaptation provided by AlbertaGrid and ALUGrid ...
int generic2alberta(int codim, int i) const
Definition: agrid.hh:559
Definition: albertagrid/gridview.hh:23
bool adapt()
Refine all positive marked leaf entities, coarsen all negative marked entities if possible...
Definition: albertagrid.cc:413
static int getTwistInOutside(const typename Traits::LeafIntersection &intersection)
Definition: agrid.hh:620
~AlbertaGrid()
desctructor
Definition: albertagrid.cc:194
AlbertaGrid()
create an empty grid
Definition: albertagrid.cc:40
static std::string typeName()
Definition: agrid.hh:463
ALBERTA REAL Real
Definition: misc.hh:45
const DofNumbering & dofNumbering() const
Definition: agrid.hh:539
ALBERTA REAL_D GlobalVector
Definition: misc.hh:47
const CollectiveCommunication & comm() const
return reference to collective communication, if MPI found this is specialisation for MPI ...
Definition: agrid.hh:458
Definition: common/geometry.hh:24
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Definition: albertagrid/gridfamily.hh:51
[ provides Dune::Grid ]
Definition: agrid.hh:137
Contains #undefs for all preprocessor macros defined by alberta.
#define ALBERTA
Definition: albertaheader.hh:27
Implementation of the IntersectionIterator for AlbertaGrid.
static const int dimension
Definition: albertagrid/gridfamily.hh:87
int dune2alberta(int codim, int i) const
Definition: misc.hh:387
Traits::template Partition< All_Partition >::LeafGridView leafGridView() const
View for the leaf grid for All_Partition.
Definition: agrid.hh:417
Traits::HierarchicIndexSet HierarchicIndexSet
type of hierarchic index set
Definition: agrid.hh:189
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
const LevelProvider & levelProvider() const
Definition: agrid.hh:544
Definition: albertagrid/gridfamily.hh:66
Traits::template Codim< EntitySeed::codimension >::Entity entity(const EntitySeed &seed) const
obtain Entity from EntitySeed.
Definition: agrid.hh:490
const Alberta::GlobalVector & getCoord(const ElementInfo &elementInfo, int vertex) const
Definition: albertagrid.cc:469
Definition: albertagrid/entity.hh:33
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lend(int level) const
one past the end on this level
Definition: topology.hh:13
AlbertaGridIndexSet< dim, dimworld > LeafIndexSetImp
Definition: albertagrid/gridfamily.hh:91
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator leafbegin() const
return LeafIterator which points to first leaf entity
Definition: common.hh:179
Traits::template Partition< All_Partition >::LevelGridView levelGridView(int level) const
View for a grid level for All_Partition.
Definition: agrid.hh:409
static const int dimension
Definition: agrid.hh:177
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:1305
Provide a generic factory class for unstructured grids.
Definition: common/gridfactory.hh:263
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
const AlbertaGridLeafIntersection< const This > & getRealIntersection(const typename Traits::LeafIntersection &intersection) const
Definition: agrid.hh:626
Traits::CollectiveCommunication CollectiveCommunication
type of collective communication
Definition: agrid.hh:197
bool readGridXdr(const std::string &filename, ctype &time)
reads ALBERTA mesh file
Definition: albertagrid.cc:629
organizes the caching of sizes for one grid and one GeometryType
Definition: sizecache.hh:29
bool writeGridXdr(const std::string &filename, ctype time) const
Definition: albertagrid.cc:619
marker assigning subentities to one element containing them
Definition: treeiterator.hh:29
static int getTwist(const typename Traits::template Codim< codim >::Entity &entity)
Definition: agrid.hh:601
static int getTwist(const typename Traits::template Codim< 0 >::Entity &entity, int subEntity)
Definition: agrid.hh:608
IndexSet< GridImp, LevelIndexSetImp, int, std::array< GeometryType, 1 > > LevelIndexSet
Definition: albertagrid/gridfamily.hh:147
bool readGrid(const std::string &filename, ctype &time)
read Grid from file filename and store time of mesh in time
Definition: albertagrid.cc:598
Definition: albertagrid/entity.hh:30
const GlobalIdSet & globalIdSet() const
return global IdSet
Definition: agrid.hh:517
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:1175
Dune::CollectiveCommunication< No_Comm > CollectiveCommunication
Definition: albertagrid/gridfamily.hh:153
bool preAdapt()
returns true, if a least one element is marked for coarsening
Definition: albertagrid.cc:346
Definition: coordcache.hh:22
hierarchic index set of AlbertaGrid
Definition: albertagrid/gridfamily.hh:63
const Traits::LeafIndexSet & leafIndexSet() const
return leaf index set
Definition: albertagrid.cc:533
Definition: albertagrid/entity.hh:45
static int getTwistInInside(const typename Traits::LeafIntersection &intersection)
Definition: agrid.hh:614
int maxLevel() const
Definition: albertagrid.cc:481
A Traits struct that collects all associated types of one implementation.
Definition: common/grid.hh:437
static const int dimensionworld
Definition: albertagrid/gridfamily.hh:88
int alberta2dune(int codim, int i) const
Definition: agrid.hh:554
int size(int level, int codim) const
Number of grid entities per level and codim because lbegin and lend are none const, and we need this methods counting the entities on each level, you know.
Definition: albertagrid.cc:488
AlbertaGridFamily< dim, dimworld >::Traits Traits
Definition: agrid.hh:181
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
returns adaptation mark for given entity
Definition: albertagrid.cc:406
provides the GridFamily for AlbertaGrid
Traits::template Codim< EntitySeed::codimension >::EntityPointer entityPointer(const EntitySeed &seed) const
obtain EntityPointer from EntitySeed.
Definition: agrid.hh:481
Alberta::Real ctype
Definition: albertagrid/gridfamily.hh:85
const Traits::LevelIndexSet & levelIndexSet(int level) const
return level index set for given level
Definition: albertagrid.cc:518
Traits::template Partition< pitype >::LeafGridView leafGridView() const
View for the leaf grid.
Definition: agrid.hh:400
Id Set Interface.
Definition: common/grid.hh:362
Interface class for the Grid's adapt method where the parameter is a AdaptDataHandleInterface.
Definition: adaptcallback.hh:30