Skip to content
Snippets Groups Projects
Commit 4b1c0210 authored by Robert K's avatar Robert K
Browse files

merged.

parent 371804a6
No related branches found
No related tags found
No related merge requests found
......@@ -54,7 +54,7 @@ namespace Dune
public:
//! constructor creating empty face info
ALU3dGridFaceInfo( const bool conformingRefinement, const bool ghostCellsEnabled, const bool levelIntersection = false );
ALU3dGridFaceInfo( const bool levelIntersection = false );
void updateFaceInfo(const GEOFaceType& face, int innerLevel, int innerTwist);
//- constructors and destructors
......@@ -137,6 +137,12 @@ namespace Dune
//! return true if conforming refinement is enabled
bool conformingRefinement () const { return conformingRefinement_; }
//! return true if ghost cells are enabled
bool ghostCellsEnabled () const { return ghostCellsEnabled_; }
//! reset flags
void setFlags( const bool conformingRefinement, const bool ghostCellsEnabled );
private:
//! Description of conformance on the face
ConformanceState getConformanceState(const int innerLevel) const;
......@@ -170,8 +176,8 @@ namespace Dune
boundary_t bndType_;
ConformanceState conformanceState_;
const bool conformingRefinement_ ; // true if conforming refinement is enabled
const bool ghostCellsEnabled_ ; // true if ghost cells are present
bool conformingRefinement_ ; // true if conforming refinement is enabled
bool ghostCellsEnabled_ ; // true if ghost cells are present
const bool levelIntersection_ ; // true if called from a levelintersection iterator
};
......
......@@ -7,7 +7,7 @@ namespace Dune
template< int dim, int dimworld, ALU3dGridElementType type, class Comm >
inline ALU3dGridFaceInfo< dim, dimworld, type, Comm >::
ALU3dGridFaceInfo( const bool conformingRefinement, const bool ghostCellsEnabled , const bool levelIntersection ) :
ALU3dGridFaceInfo( const bool levelIntersection ) :
face_(0),
innerElement_(0),
outerElement_(0),
......@@ -19,12 +19,23 @@ namespace Dune
bndId_( -1 ),
bndType_( noBoundary ),
conformanceState_(UNDEFINED),
conformingRefinement_( conformingRefinement ),
ghostCellsEnabled_( ghostCellsEnabled ),
conformingRefinement_( false ),
ghostCellsEnabled_( false ),
levelIntersection_( levelIntersection )
{
}
// points face from inner element away?
template< int dim, int dimworld, ALU3dGridElementType type, class Comm >
inline void
ALU3dGridFaceInfo< dim, dimworld, type, Comm >::
setFlags(const bool conformingRefinement,
const bool ghostCellsEnabled )
{
conformingRefinement_ = conformingRefinement;
ghostCellsEnabled_ = ghostCellsEnabled;
}
// points face from inner element away?
template< int dim, int dimworld, ALU3dGridElementType type, class Comm >
inline void
......
......@@ -12,7 +12,7 @@
#include "alu3dinclude.hh"
#include "topology.hh"
#include "mappings.hh"
#include <dune/alugrid/common/objectfactory.hh>
#include <dune/alugrid/common/memory.hh>
namespace Dune
{
......
......@@ -5,9 +5,6 @@
#include <vector>
//- Dune includes
#if !DUNE_VERSION_NEWER( DUNE_GRID, 3, 0 )
#include <dune/grid/utility/grapedataioformattypes.hh>
#endif // #if !DUNE_VERSION_NEWER( DUNE_GRID, 3, 0 )
#include <dune/grid/common/capabilities.hh>
#include <dune/alugrid/common/interfaces.hh>
#include <dune/common/bigunsignedint.hh>
......@@ -25,7 +22,6 @@
// bnd projection stuff
#include <dune/grid/common/boundaryprojection.hh>
#include <dune/alugrid/common/bndprojection.hh>
#include <dune/alugrid/common/objectfactory.hh>
#include <dune/alugrid/common/backuprestore.hh>
#include <dune/alugrid/common/macrogridview.hh>
#include <dune/alugrid/common/twists.hh>
......@@ -393,13 +389,15 @@ namespace Dune
struct Partition
{
typedef Dune::GridView< ALU3dLevelGridViewTraits< const Grid, pitype > > LevelGridView;
typedef Dune::GridView< ALU3dLeafGridViewTraits< const Grid, pitype > > LeafGridView;
typedef Dune::GridView< ALU3dLeafGridViewTraits< const Grid, pitype > > LeafGridView;
typedef Dune::MacroGridView<const Grid, pitype> MacroGridView;
}; // struct Partition
typedef typename Partition< All_Partition >::LevelGridView LevelGridView;
typedef typename Partition< All_Partition >::LeafGridView LeafGridView;
typedef typename Partition< All_Partition > :: MacroGridView MacroGridView;
typedef typename Partition< All_Partition > :: LeafGridView LeafGridView;
typedef typename Partition< All_Partition > :: LevelGridView LevelGridView;
//! Type of the level index set
typedef DefaultIndexSet< GridImp, typename Codim< 0 > :: LevelIterator > LevelIndexSetImp;
......@@ -585,14 +583,6 @@ namespace Dune
typedef ALULeafCommunication< dim, dimworld, elType, Comm > LeafCommunication;
typedef ALULevelCommunication< dim, dimworld, elType, Comm > LevelCommunication;
public:
typedef MakeableInterfaceObject<typename Traits::template Codim<0>::Entity> EntityObject;
typedef MakeableInterfaceObject<typename Traits::template Codim<1>::Entity> FaceObject;
typedef MakeableInterfaceObject<typename Traits::template Codim<2>::Entity> EdgeObject;
typedef MakeableInterfaceObject<typename Traits::template Codim<3>::Entity> VertexObject;
typedef ALUGridObjectFactory< ThisType > GridObjectFactoryType;
protected:
friend class ALUGridBoundaryProjection< ThisType, alu3d_ctype >;
// type of ALUGrid boundary projection wrapper
......@@ -693,7 +683,7 @@ namespace Dune
typename Traits::LeafIntersectionIterator
ileafbegin( const typename Traits::template Codim< 0 >::Entity& entity ) const
{
return LefInterItWrapperType( factory(),
return LefInterItWrapperType( *this,
getRealImplementation( entity ),
entity.level(), false );
}
......@@ -701,7 +691,7 @@ namespace Dune
typename Traits::LeafIntersectionIterator
ileafend( const typename Traits::template Codim< 0 >::Entity& entity ) const
{
return LefInterItWrapperType( factory(),
return LefInterItWrapperType( *this,
getRealImplementation( entity ),
entity.level(), true );
}
......@@ -709,7 +699,7 @@ namespace Dune
typename Traits::LevelIntersectionIterator
ilevelbegin( const typename Traits::template Codim< 0 >::Entity& entity ) const
{
return LvlInterItWrapperType( factory(),
return LvlInterItWrapperType( *this,
getRealImplementation( entity ),
entity.level(), false );
}
......@@ -717,7 +707,7 @@ namespace Dune
typename Traits::LevelIntersectionIterator
ilevelend( const typename Traits::template Codim< 0 >::Entity& entity ) const
{
return LvlInterItWrapperType( factory(),
return LvlInterItWrapperType( *this,
getRealImplementation( entity ),
entity.level(), true );
}
......@@ -1266,8 +1256,6 @@ namespace Dune
void makeGeometries();
public:
const GridObjectFactoryType &factory () const { return factory_; }
std::pair< LevelIndexSetImp *, bool > getLevelIndexSet ( int level ) const
{
assert( (level >= 0) && (level < int( levelIndexVec_.size() )) );
......@@ -1345,8 +1333,6 @@ namespace Dune
typedef SizeCache<MyType> SizeCacheType;
SizeCacheType * sizeCache_;
GridObjectFactoryType factory_;
// variable to ensure that postAdapt ist called after adapt
bool lockPostAdapt_;
......
......@@ -31,7 +31,6 @@ namespace Dune
, localIdSet_( *this )
, levelIndexVec_(MAXL,0) , leafIndexSet_(0)
, sizeCache_ ( 0 )
, factory_( *this )
, lockPostAdapt_( false )
, bndPrj_ ( bndPrj )
, bndVec_ ( (bndVec) ? (new DuneBoundaryProjectionVector( *bndVec )) : 0 )
......@@ -129,7 +128,7 @@ namespace Dune
if( level > maxlevel_ )
return this->template lend<cd,pitype> (level);
return ALU3dGridLevelIterator< cd, pitype, const ThisType >( factory(), level, true );
return ALU3dGridLevelIterator< cd, pitype, const ThisType >( *this, level, true );
}
......@@ -139,7 +138,7 @@ namespace Dune
ALU3dGrid< dim, dimworld, elType, Comm >::lend ( int level ) const
{
alugrid_assert ( level >= 0 );
return ALU3dGridLevelIterator< cd, pitype, const ThisType >( factory(), level );
return ALU3dGridLevelIterator< cd, pitype, const ThisType >( *this, level );
}
......@@ -174,7 +173,7 @@ namespace Dune
ALU3dGrid< dim, dimworld, elType, Comm >::createLeafIteratorBegin ( int level ) const
{
alugrid_assert ( level >= 0 );
return ALU3dGridLeafIterator< cd, pitype, const ThisType >( factory(), level, true );
return ALU3dGridLeafIterator< cd, pitype, const ThisType >( *this, level, true );
}
......@@ -241,7 +240,7 @@ namespace Dune
ALU3dGrid< dim, dimworld, elType, Comm >::createLeafIteratorEnd ( int level ) const
{
alugrid_assert ( level >= 0 );
return ALU3dGridLeafIterator<cd, pitype, const MyType> ( factory() , level);
return ALU3dGridLeafIterator<cd, pitype, const MyType> ( *this, level);
}
......
......@@ -26,9 +26,9 @@ namespace Dune {
// Constructor for begin iterator
template<int codim, PartitionIteratorType pitype, class GridImp >
alu_inline ALU3dGridLevelIterator<codim,pitype,GridImp> ::
ALU3dGridLevelIterator(const FactoryType& factory, int level, bool )
ALU3dGridLevelIterator(const GridImp& grd, int level, bool )
: ALU3dGridEntityPointer<codim,GridImp> ()
, factory_( &factory )
, grid_( &grd )
, iter_()
, level_(level)
{
......@@ -40,9 +40,9 @@ alu_inline ALU3dGridLevelIterator<codim,pitype,GridImp> ::
// Constructor for end iterator
template<int codim, PartitionIteratorType pitype, class GridImp >
alu_inline ALU3dGridLevelIterator<codim,pitype,GridImp> ::
ALU3dGridLevelIterator(const FactoryType& factory, int level)
ALU3dGridLevelIterator(const GridImp& grid, int level)
: ALU3dGridEntityPointer<codim,GridImp> ()
, factory_( &factory )
, grid_( &grid )
, iter_()
, level_(level)
{
......@@ -53,7 +53,7 @@ template<int codim, PartitionIteratorType pitype, class GridImp >
alu_inline ALU3dGridLevelIterator<codim,pitype,GridImp> ::
ALU3dGridLevelIterator(const ThisType & org )
: ALU3dGridEntityPointer<codim,GridImp> ( org )
, factory_( org.factory_ )
, grid_( org.grid_ )
, iter_()
, level_( org.level_ )
{
......@@ -80,7 +80,7 @@ alu_inline void ALU3dGridLevelIterator<codim, pitype, GridImp> ::
assign(const ThisType & org)
{
alugrid_assert ( !iter_ );
factory_ = org.factory_;
grid_ = org.grid_;
ALU3dGridEntityPointer <codim,GridImp> :: clone (org);
level_ = org.level_;
if( org.iter_ )
......@@ -124,9 +124,9 @@ alu_inline void ALU3dGridLevelIterator<codim,pitype,GridImp> :: increment ()
// constructor for end iterators
template<int cdim, PartitionIteratorType pitype, class GridImp>
alu_inline ALU3dGridLeafIterator<cdim, pitype, GridImp> ::
ALU3dGridLeafIterator( const FactoryType& factory, int level )
ALU3dGridLeafIterator( const GridImp& grid, int level )
: ALU3dGridEntityPointer <cdim,GridImp> ()
, factory_( &factory )
, grid_( &grid )
, iter_()
{
this->done();
......@@ -134,10 +134,10 @@ ALU3dGridLeafIterator( const FactoryType& factory, int level )
template<int cdim, PartitionIteratorType pitype, class GridImp>
alu_inline ALU3dGridLeafIterator<cdim, pitype, GridImp> ::
ALU3dGridLeafIterator(const FactoryType& factory, int level ,
ALU3dGridLeafIterator(const GridImp& grd, int level ,
bool isBegin)
: ALU3dGridEntityPointer <cdim,GridImp> ()
, factory_( &factory )
, grid_( &grd )
, iter_()
{
// create interior iterator
......@@ -151,7 +151,7 @@ template<int cdim, PartitionIteratorType pitype, class GridImp>
alu_inline ALU3dGridLeafIterator<cdim, pitype, GridImp> ::
ALU3dGridLeafIterator(const ThisType & org)
: ALU3dGridEntityPointer <cdim,GridImp> ()
, factory_( org.factory_ )
, grid_( org.grid_ )
, iter_()
{
// assign iterator without cloning entity pointer again
......@@ -188,7 +188,7 @@ alu_inline void ALU3dGridLeafIterator<cdim, pitype, GridImp> ::
assign (const ThisType & org)
{
alugrid_assert( !iter_ );
factory_ = org.factory_;
grid_ = org.grid_;
ALU3dGridEntityPointer <cdim,GridImp> :: clone (org);
if( org.iter_ )
......
......@@ -103,8 +103,6 @@ public:
typedef ALUTwists< (dim == 3 ) ? GridImp::elementType == tetra ? 3 : 4 : 2, dim-1 > Twists;
typedef typename Twists::Twist Twist;
typedef typename GridImp::GridObjectFactoryType FactoryType;
typedef typename GridImp::template Codim<0>::Entity Entity;
typedef typename GridImp::template Codim<1>::Geometry Geometry;
typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
......@@ -118,13 +116,8 @@ public:
typedef ALUMemoryProvider< ThisType > StorageType;
//! The default Constructor , level tells on which level we want
//! neighbours
ALU3dGridIntersectionIterator(const FactoryType& factory,
HElementType *el,
int wLevel,bool end=false, bool levelIntersectionIterator = false);
ALU3dGridIntersectionIterator(const FactoryType& factory, int wLevel, bool levelIntersectionIterator = false);
//! The default Constructor
explicit ALU3dGridIntersectionIterator( const bool levelIntersectionIterator = false );
//! The copy constructor
ALU3dGridIntersectionIterator(const ALU3dGridIntersectionIterator<GridImp> & org);
......@@ -236,7 +229,9 @@ protected:
// reset IntersectionIterator to first neighbour
template <class EntityType>
void first(const EntityType & en, int wLevel);
void first(const EntityType & en, int wLevel,
const bool conformingRefinement,
const bool ghostCellsEnabled );
// set new face
void setNewFace(const GEOFaceType& newFace);
......@@ -337,17 +332,8 @@ protected:
using BaseType :: neighbor ;
public:
typedef typename GridImp::GridObjectFactoryType FactoryType;
typedef ALUMemoryProvider< ThisType > StorageType;
//! The default Constructor , level tells on which level we want
//! neighbours
ALU3dGridLevelIntersectionIterator(const FactoryType& factory,
HElementType *el,
int wLevel,bool end=false);
ALU3dGridLevelIntersectionIterator(const FactoryType& factory, int wLevel);
//! The default Constructor
ALU3dGridLevelIntersectionIterator();
//! The copy constructor
ALU3dGridLevelIntersectionIterator(const ThisType & org);
......@@ -360,7 +346,9 @@ public:
// reset IntersectionIterator to first neighbour
template <class EntityType>
void first(const EntityType & en, int wLevel);
void first(const EntityType & en, int wLevel,
const bool conformingRefinement,
const bool ghostCellsEnabled );
//! return true if across the edge an neighbor on this level exists
bool neighbor () const;
......@@ -570,8 +558,6 @@ class ALU3dGridLevelIterator
typedef ALU3dGridEntityPointer< cd, GridImp > BaseType;
public:
typedef typename GridImp::GridObjectFactoryType FactoryType;
typedef typename GridImp::template Codim<cd>::Entity Entity;
typedef ALU3dGridVertexList< Comm > VertexListType;
......@@ -583,13 +569,13 @@ public:
typedef typename ALU3DSPACE IteratorElType< (GridImp::dimension == 2 && cd == 2) ? 3 : cd, Comm >::val_t val_t;
/** \brief default constructor */
ALU3dGridLevelIterator () : factory_( nullptr ), iter_(), level_( 0 ) {}
ALU3dGridLevelIterator () : grid_( nullptr ), iter_(), level_( 0 ) {}
//! Constructor for begin iterator
ALU3dGridLevelIterator(const FactoryType& factory, int level, bool);
ALU3dGridLevelIterator(const GridImp& grid, int level, bool);
//! Constructor for end iterator
ALU3dGridLevelIterator(const FactoryType& factory, int level);
ALU3dGridLevelIterator(const GridImp& grid, int level);
//! Constructor
ALU3dGridLevelIterator(const ThisType & org);
......@@ -609,10 +595,10 @@ private:
//! do assignment
void assign (const ThisType & org);
const GridImp &grid () const { alugrid_assert( factory_ ); return factory_->grid(); }
const GridImp &grid () const { alugrid_assert( grid_ ); return *grid_; }
// reference to factory class (ie grid)
const FactoryType *factory_;
const GridImp *grid_;
// the internal iterator
std::unique_ptr< IteratorType > iter_ ;
......@@ -652,8 +638,6 @@ class ALU3dGridLeafIterator
typedef ALU3dGridEntityPointer< cdim, GridImp > BaseType;
public:
typedef typename GridImp::GridObjectFactoryType FactoryType;
typedef typename GridImp::template Codim<cdim>::Entity Entity;
typedef typename ALU3DSPACE ALU3dGridLeafIteratorWrapper< (GridImp::dimension == 2 && cdim == 2) ? 3 : cdim, pitype, Comm > IteratorType ;
......@@ -665,13 +649,13 @@ public:
typedef ALU3dGridLeafIterator<cdim, pitype, GridImp> ThisType;
/** \brief default constructor */
ALU3dGridLeafIterator () : factory_( nullptr ), iter_() {}
ALU3dGridLeafIterator () : grid_( nullptr ), iter_() {}
//! Constructor for end iterators
ALU3dGridLeafIterator(const FactoryType& factory, int level);
ALU3dGridLeafIterator(const GridImp& grid, int level);
//! Constructor for begin Iterators
ALU3dGridLeafIterator(const FactoryType& factory, int level , bool isBegin);
ALU3dGridLeafIterator(const GridImp& grid, int level , bool isBegin);
//! copy Constructor
ALU3dGridLeafIterator(const ThisType & org);
......@@ -689,10 +673,10 @@ public:
ThisType & operator = (const ThisType & org);
private:
const GridImp &grid () const { alugrid_assert( factory_ ); return factory_->grid(); }
const GridImp &grid () const { alugrid_assert( grid_ ); return *grid_; }
// reference to factory class (ie grid)
const FactoryType *factory_;
// reference to grid class (ie grid)
const GridImp *grid_;
// the internal iterator
std::unique_ptr< IteratorType > iter_;
......@@ -783,8 +767,6 @@ class ALU3dGridHierarchicIterator
};
public:
typedef typename GridImp::GridObjectFactoryType FactoryType;
typedef typename GridImp::template Codim<0>::Entity Entity;
typedef typename GridImp::ctype ctype;
......
......@@ -25,9 +25,8 @@ namespace Dune {
// --IntersectionIterator
template<class GridImp>
inline ALU3dGridIntersectionIterator<GridImp> ::
ALU3dGridIntersectionIterator(const FactoryType& factory,
int wLevel, bool levelIntersectionIterator) :
connector_( factory.grid().conformingRefinement(), factory.grid().ghostCellsEnabled(), levelIntersectionIterator ),
ALU3dGridIntersectionIterator(const bool levelIntersectionIterator) :
connector_( levelIntersectionIterator ),
geoProvider_(connector_),
item_(0),
ghost_(0),
......@@ -35,28 +34,6 @@ ALU3dGridIntersectionIterator(const FactoryType& factory,
{
}
// --IntersectionIterator
template<class GridImp>
inline ALU3dGridIntersectionIterator<GridImp> ::
ALU3dGridIntersectionIterator(const FactoryType& factory,
HElementType *el,
int wLevel,bool end, bool levelIntersectionIterator) :
connector_( factory.grid().conformingRefinement(), factory.grid().ghostCellsEnabled(), levelIntersectionIterator ),
geoProvider_(connector_),
item_(0),
ghost_(0),
index_(-1)
{
if( ! end )
{
setFirstItem(*el,wLevel);
}
else
{
done();
}
}
template<class GridImp>
inline void
ALU3dGridIntersectionIterator<GridImp> :: done ()
......@@ -108,7 +85,9 @@ setInteriorItem (const HElementType & elem, const BNDFaceType& ghost, int wLevel
template<class GridImp>
template <class EntityType>
inline void ALU3dGridIntersectionIterator<GridImp> ::
first (const EntityType & en, int wLevel)
first (const EntityType & en, int wLevel,
const bool conformingRefinement,
const bool ghostCellsEnabled )
{
if( ! en.isLeaf() && en.level()>0)
{
......@@ -116,6 +95,9 @@ first (const EntityType & en, int wLevel)
return ;
}
// adjust connector flags
connector_.setFlags( conformingRefinement, ghostCellsEnabled );
innerLevel_ = en.level();
index_ = 0;
......@@ -163,13 +145,16 @@ assign(const ALU3dGridIntersectionIterator<GridImp> & org)
{
if(org.item_)
{
// adjust connector flags
connector_.setFlags( org.connector_.conformingRefinement(), org.connector_.ghostCellsEnabled() );
// else it's a end iterator
item_ = org.item_;
ghost_ = org.ghost_;
innerLevel_ = org.innerLevel_;
index_ = org.index_;
connector_.updateFaceInfo(org.connector_.face(),innerLevel_,
item_->twist(ElementTopo::dune2aluFace(index_)));
item_->twist(ElementTopo::dune2aluFace(index_)));
geoProvider_.resetFaceGeom();
}
else {
......@@ -508,21 +493,8 @@ level() const {
// --IntersectionIterator
template<class GridImp>
inline ALU3dGridLevelIntersectionIterator<GridImp> ::
ALU3dGridLevelIntersectionIterator(const FactoryType& factory,
int wLevel)
: ALU3dGridIntersectionIterator<GridImp>(factory,wLevel,true)
, levelNeighbor_(false)
, isLeafItem_(false)
{
}
// --IntersectionIterator
template<class GridImp>
inline ALU3dGridLevelIntersectionIterator<GridImp> ::
ALU3dGridLevelIntersectionIterator(const FactoryType& factory,
HElementType *el,
int wLevel,bool end)
: ALU3dGridIntersectionIterator<GridImp>(factory,el,wLevel,end, true)
ALU3dGridLevelIntersectionIterator()
: ALU3dGridIntersectionIterator<GridImp>( true )
, levelNeighbor_(false)
, isLeafItem_(false)
{
......@@ -531,8 +503,11 @@ ALU3dGridLevelIntersectionIterator(const FactoryType& factory,
template<class GridImp>
template <class EntityType>
inline void ALU3dGridLevelIntersectionIterator<GridImp> ::
first (const EntityType & en, int wLevel)
first (const EntityType & en, int wLevel,
const bool conformingRefinement, const bool ghostCellsEnabled )
{
connector_.setFlags( conformingRefinement, ghostCellsEnabled );
// if given Entity is not leaf, we create an end iterator
index_ = 0;
isLeafItem_ = en.isLeaf();
......@@ -645,7 +620,8 @@ setNewFace(const GEOFaceType& newFace)
connector_.updateFaceInfo(newFace, innerLevel_,
( ImplTraits::isGhost( ghost_ ) ) ?
ghost_->twist(0) :
item_->twist(ElementTopo::dune2aluFace( index_ )));
item_->twist(ElementTopo::dune2aluFace( index_ ))
);
geoProvider_.resetFaceGeom();
// check again level neighbor because outer element might be coarser then
......
......@@ -12,7 +12,6 @@ set(alucommon_HEADERS alugrid_assert.hh
ldbhandleif.hh
macrogridview.hh
memory.hh
objectfactory.hh
persistentcontainer.hh
structuredgridfactory.hh
transformation.hh
......
......@@ -14,11 +14,10 @@ alucommon_HEADERS = alugrid_assert.hh \
ldbhandleif.hh \
macrogridview.hh \
memory.hh \
objectfactory.hh \
persistentcontainer.hh \
structuredgridfactory.hh \
transformation.hh \
typetraits.hh \
typetraits.hh \
twists.hh \
writeparalleldgf.hh
......
......@@ -6,6 +6,8 @@
#include <dune/grid/common/intersectioniterator.hh>
#include <dune/alugrid/common/macrogridview.hh>
#include <dune/alugrid/common/memory.hh>
/** @file
@author Robert Kloefkorn
@brief Provides proxy classes for IntersectionsIterators
......@@ -25,11 +27,8 @@ class IntersectionIteratorWrapper
typedef IntersectionIteratorImpl IntersectionIteratorImp;
typedef typename IntersectionIteratorImp :: StorageType IntersectionIteratorProviderType;
typedef ALUMemoryProvider< IntersectionIteratorImpl > IntersectionIteratorProviderType ;
public:
typedef typename GridImp :: GridObjectFactoryType FactoryType;
//! dimension
enum { dimension = dim };
//! dimensionworld
......@@ -54,66 +53,72 @@ public:
typedef typename IntersectionIteratorImpl::Twists Twists;
typedef typename Twists::Twist Twist;
IntersectionIteratorWrapper () : factory_( nullptr ), it_( nullptr ) {}
IntersectionIteratorWrapper () : it_( nullptr ) {}
//! constructor called from the ibegin and iend method
template <class EntityImp>
IntersectionIteratorWrapper(const FactoryType& factory, const EntityImp & en, int wLevel , bool end)
: factory_( &factory )
, it_( &factory.getIntersection(wLevel, (IntersectionIteratorImpl *) 0) )
IntersectionIteratorWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end)
: it_( provider().getEmptyObject() )
{
if(end)
it().done( en );
else
it().first(en,wLevel);
it().first( en, wLevel, grid.conformingRefinement(), grid.ghostCellsEnabled() );
}
//! The copy constructor
IntersectionIteratorWrapper(const ThisType & org)
: factory_( org.factory_ )
: it_( nullptr )
{
if( factory_ )
{
it_ = &factory().getIntersection( -1, static_cast< IntersectionIteratorImpl * >( nullptr ) );
it_->assign( org.it() );
}
assign( org );
}
//! the assignment operator
ThisType & operator = (const ThisType & org)
void assign(const ThisType & org)
{
if( factory_ )
if( ! org.it_ )
{
if( !org.factory_ )
{
factory_->freeIntersection( *it_ );
factory_ = nullptr;
}
else
it_->assign( *org.it_ );
removeObj();
return;
}
else if( org.factory_ )
if( ! it_ )
{
factory_ = org.factory_;
it_ = &factory().getIntersection( -1, static_cast< IntersectionIteratorImpl * >( nullptr ) );
it_->assign( *org.it_ );
it_ = provider().getEmptyObject();
}
return *this;
// copy intersection
it().assign( org.it() );
}
void removeObj()
{
if( it_ )
{
provider().freeObject( it_ );
it_ = nullptr ;
}
}
//! the assignment operator
ThisType & operator = (const ThisType & org)
{
assign( org );
return *this ;
}
//! The Destructor puts internal object back to stack
~IntersectionIteratorWrapper()
{
if( factory_ )
factory_->freeIntersection( *it_ );
removeObj();
}
operator bool () const { return bool( factory_ ); }
operator bool () const { return bool( it_ ); }
//! the equality method
bool equals ( const ThisType &other ) const
{
return (factory_ == other.factory_) && (!factory_ || it().equals( other.it() ));
return (it_ && other.it_ ) ? it().equals( other.it() ) : false ;
}
//! increment iterator
......@@ -238,9 +243,13 @@ public:
}
private:
const FactoryType &factory () const { assert( factory_ ); return *factory_; }
static IntersectionIteratorProviderType&
provider()
{
static thread_local IntersectionIteratorProviderType provider ;
return provider ;
}
const FactoryType *factory_ ;
IntersectionIteratorImp *it_;
}; // end class IntersectionIteratorWrapper
......@@ -251,13 +260,12 @@ class LeafIntersectionWrapper
typedef LeafIntersectionWrapper<GridImp> ThisType;
typedef IntersectionIteratorWrapper<GridImp,typename GridImp::LeafIntersectionIteratorImp> BaseType;
public:
typedef typename BaseType::FactoryType FactoryType;
LeafIntersectionWrapper () {}
//! constructor called from the ibegin and iend method
template <class EntityImp>
LeafIntersectionWrapper(const FactoryType& factory, const EntityImp & en, int wLevel , bool end )
: BaseType(factory,en,wLevel,end)
LeafIntersectionWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
: BaseType( grid, en, wLevel, end )
{
}
......@@ -278,7 +286,6 @@ class LeafIntersectionIteratorWrapper
typedef LeafIntersectionWrapper<GridImp> IntersectionImp;
public:
typedef typename IntersectionImp::FactoryType FactoryType;
typedef Dune::Intersection< GridImp, IntersectionImp > Intersection;
//! dimension
......@@ -302,12 +309,13 @@ public:
//! type of normal vector
typedef FieldVector<ctype , dimensionworld> NormalType;
//! default constructor
LeafIntersectionIteratorWrapper () {}
//! constructor called from the ibegin and iend method
template <class EntityImp>
LeafIntersectionIteratorWrapper(const FactoryType& factory, const EntityImp & en, int wLevel , bool end )
: intersection_( IntersectionImp(factory,en,wLevel,end) )
LeafIntersectionIteratorWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
: intersection_( IntersectionImp( grid, en, wLevel, end) )
{}
//! The copy constructor
......@@ -355,13 +363,12 @@ class LevelIntersectionWrapper
typedef LevelIntersectionWrapper<GridImp> ThisType;
typedef IntersectionIteratorWrapper<GridImp,typename GridImp::LevelIntersectionIteratorImp> BaseType;
public:
typedef typename BaseType::FactoryType FactoryType;
LevelIntersectionWrapper () {}
//! constructor called from the ibegin and iend method
template <class EntityImp>
LevelIntersectionWrapper(const FactoryType& factory, const EntityImp & en, int wLevel , bool end )
: BaseType(factory,en,wLevel,end)
LevelIntersectionWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
: BaseType( grid, en, wLevel, end )
{
}
......@@ -379,7 +386,6 @@ class LevelIntersectionIteratorWrapper
{
typedef LevelIntersectionIteratorWrapper<GridImp> ThisType;
typedef LevelIntersectionWrapper<GridImp> IntersectionImp;
typedef typename IntersectionImp::FactoryType FactoryType;
public:
typedef Dune::Intersection< GridImp, IntersectionImp > Intersection;
......@@ -408,8 +414,8 @@ public:
//! constructor called from the ibegin and iend method
template <class EntityImp>
LevelIntersectionIteratorWrapper(const FactoryType& factory, const EntityImp & en, int wLevel , bool end )
: intersection_( IntersectionImp(factory,en,wLevel,end) )
LevelIntersectionIteratorWrapper(const GridImp& grid, const EntityImp & en, int wLevel , bool end )
: intersection_( IntersectionImp( grid, en, wLevel, end ) )
{}
//! The copy constructor
......
#ifndef DUNE_ALUGRIDOBJECTFACTORY_HH
#define DUNE_ALUGRIDOBJECTFACTORY_HH
#include <dune/alugrid/common/memory.hh>
namespace Dune
{
template <class InterfaceType>
struct MakeableInterfaceObject ;
template <class GridImp>
class ALUGridObjectFactory
{
template <class OF, int codim>
class ALUGridEntityFactory;
/////////////////////////////////////////////////////
//
// partial specialization of method getNewEntity
//
/////////////////////////////////////////////////////
template <class GridObjectFactory>
class ALUGridEntityFactory<GridObjectFactory,0>
{
public:
enum { codim = 0 };
typedef typename GridImp :: template Codim<codim> :: Entity Entity;
typedef MakeableInterfaceObject<Entity> EntityObject;
typedef typename EntityObject :: ImplementationType EntityImp;
inline static EntityObject *
getNewEntity (const GridObjectFactory& factory, int level)
{
return factory.entityProvider_.getEntityObject( factory, level, (EntityImp *) 0);
}
inline static void freeEntity(const GridObjectFactory& factory, EntityObject * e )
{
factory.entityProvider_.freeObject( e );
}
};
template <class GridObjectFactory>
class ALUGridEntityFactory<GridObjectFactory,1>
{
public:
enum { codim = 1 };
typedef typename GridImp :: template Codim<codim> :: Entity Entity;
typedef MakeableInterfaceObject<Entity> EntityObject;
typedef typename EntityObject :: ImplementationType EntityImp;
inline static EntityObject *
getNewEntity (const GridObjectFactory& factory, int level)
{
return factory.faceProvider_.getEntityObject( factory, level, (EntityImp *) 0);
}
inline static void freeEntity(const GridObjectFactory& factory, EntityObject * e )
{
factory.faceProvider_.freeObject( e );
}
};
template <class GridObjectFactory>
class ALUGridEntityFactory<GridObjectFactory,2>
{
public:
enum { codim = 2 };
typedef typename GridImp :: template Codim<codim> :: Entity Entity;
typedef MakeableInterfaceObject<Entity> EntityObject;
typedef typename EntityObject :: ImplementationType EntityImp;
inline static EntityObject *
getNewEntity (const GridObjectFactory& factory, int level)
{
return factory.edgeProvider_.getEntityObject( factory, level, (EntityImp *) 0);
}
inline static void freeEntity(const GridObjectFactory& factory, EntityObject * e )
{
factory.edgeProvider_.freeObject( e );
}
};
template <class GridObjectFactory>
class ALUGridEntityFactory<GridObjectFactory,3>
{
public:
enum { codim = 3 };
typedef typename GridImp :: template Codim<codim> :: Entity Entity;
typedef MakeableInterfaceObject<Entity> EntityObject;
typedef typename EntityObject :: ImplementationType EntityImp;
inline static EntityObject *
getNewEntity (const GridObjectFactory& factory, int level)
{
return factory.vertexProvider_.getEntityObject( factory, level, (EntityImp *) 0);
}
inline static void freeEntity(const GridObjectFactory& factory, EntityObject * e )
{
factory.vertexProvider_.freeObject( e );
}
}; // end of ALUGridEntityFactory
enum { vxCodim = GridImp :: dimension };
public:
typedef GridImp GridType;
typedef ALUGridObjectFactory FactoryType;
typedef MakeableInterfaceObject<typename GridType :: Traits::template Codim<0>::Entity> EntityObject;
typedef MakeableInterfaceObject<typename GridType :: Traits::template Codim<1>::Entity> FaceObject;
typedef MakeableInterfaceObject<typename GridType :: Traits::template Codim<2>::Entity> EdgeObject;
typedef MakeableInterfaceObject<typename GridType :: Traits::template Codim< vxCodim >::Entity> VertexObject;
typedef typename GridType :: LeafIntersectionIteratorImp LeafIntersectionIteratorImp ;
typedef typename GridType :: LevelIntersectionIteratorImp LevelIntersectionIteratorImp ;
// declare friendship
friend class ALUGridEntityFactory<FactoryType,0>;
friend class ALUGridEntityFactory<FactoryType,1>;
friend class ALUGridEntityFactory<FactoryType,2>;
friend class ALUGridEntityFactory<FactoryType,3>;
protected:
typedef ALUMemoryProvider< EntityObject > EntityProvider;
typedef ALUMemoryProvider< FaceObject > FaceProvider;
typedef ALUMemoryProvider< EdgeObject > EdgeProvider;
typedef ALUMemoryProvider< VertexObject > VertexProvider;
mutable EntityProvider entityProvider_;
mutable FaceProvider faceProvider_;
mutable EdgeProvider edgeProvider_;
mutable VertexProvider vertexProvider_;
typedef ALUMemoryProvider< LeafIntersectionIteratorImp > LeafIntersectionIteratorProviderType;
typedef ALUMemoryProvider< LevelIntersectionIteratorImp > LevelIntersectionIteratorProviderType;
mutable LeafIntersectionIteratorProviderType leafInterItProvider_;
mutable LevelIntersectionIteratorProviderType levelInterItProvider_;
const GridType& grid_ ;
private:
ALUGridObjectFactory( const ALUGridObjectFactory& other );
public:
const GridType& grid() const { return grid_; }
ALUGridObjectFactory( const GridType& grid ) : grid_( grid ) {}
template <int codim>
inline MakeableInterfaceObject<typename GridType :: Traits::template Codim<codim>::Entity> *
getNewEntity ( int level = -1 ) const
{
return ALUGridEntityFactory<FactoryType,codim>::getNewEntity( *this, level);
}
template <int codim>
inline void freeEntity (MakeableInterfaceObject<typename GridType :: Traits::template Codim<codim>::Entity> * en) const
{
ALUGridEntityFactory<FactoryType,codim>::freeEntity(*this, en);
}
LeafIntersectionIteratorImp& getIntersection( const int wLevel, const LeafIntersectionIteratorImp* ) const
{
return * (leafInterItProvider_.getObject( *this, wLevel ));
}
LevelIntersectionIteratorImp& getIntersection(const int wLevel, const LevelIntersectionIteratorImp* ) const
{
return * (levelInterItProvider_.getObject( *this, wLevel ));
}
//! free intersection
void freeIntersection(LeafIntersectionIteratorImp & it) const { leafInterItProvider_.freeObject( &it ); }
void freeIntersection(LevelIntersectionIteratorImp & it) const { levelInterItProvider_.freeObject( &it ); }
}; /// end class ALUGridObjectFactory
} // end namespace Dune
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment