Commit 632b3fd9 authored by Robert K's avatar Robert K

[!68] [bugfix][GonformingGrids] conforming closure and disabling ghost cells.

Merge branch 'bugfix/ghost-cells-and-restore' into 'master'

ref:extensions/dune-alugrid conforming closure and disabling ghost cells has
to be done before ghost cells are rebuild during restore. This MR fixes this.

See merge request [!68]

  [!68]: gitlab.dune-project.org/extensions/dune-alugrid/merge_requests/68
parents d2f643c1 8b520a8e
Pipeline #17646 passed with stage
in 14 minutes and 28 seconds
......@@ -113,32 +113,12 @@ namespace Dune
};
// ALU3dGridCommunications
// -----------------------
struct ALU3dGridCommunicationsBase
{
template < class GitterImpl >
void checkForConformingRefinement( GitterImpl* grid,
const bool conformingRefinement )
{
if( grid && conformingRefinement )
{
grid->enableConformingClosure();
grid->disableGhostCells();
}
}
};
template< int dim, int dimworld, ALU3dGridElementType elType, class Comm >
struct ALU3dGridCommunications;
template< int dim, int dimworld, ALU3dGridElementType elType >
struct ALU3dGridCommunications< dim, dimworld, elType, ALUGridNoComm > : public ALU3dGridCommunicationsBase
struct ALU3dGridCommunications< dim, dimworld, elType, ALUGridNoComm >
{
using ALU3dGridCommunicationsBase :: checkForConformingRefinement ;
typedef ALU3dGridLocalIdSet< dim, dimworld, elType, ALUGridNoComm > GlobalIdSet;
typedef int GlobalId;
......@@ -154,19 +134,14 @@ namespace Dune
const bool conformingRefinement )
{
GitterImplType* grid = ( macroName.empty() ) ?
new GitterImplType( dim ) : new GitterImplType ( dim, macroName.c_str(), projections );
// check whether conforming refinement should be enabled
checkForConformingRefinement( grid, conformingRefinement );
new GitterImplType( dim, conformingRefinement ) : new GitterImplType ( dim, conformingRefinement, macroName.c_str(), projections );
return grid ;
}
GitterImplType *createALUGrid ( std::istream& stream, const ALU3DSPACE ProjectVertexPtrPair& projection,
const bool conformingRefinement )
{
GitterImplType* grid = new GitterImplType ( dim, stream, projection );
// check whether conforming refinement should be enabled
checkForConformingRefinement( grid, conformingRefinement );
return grid ;
return new GitterImplType ( dim, conformingRefinement, stream, projection );
}
static ALUGridNoComm defaultComm () { return ALUGridNoComm(); }
......@@ -192,10 +167,8 @@ namespace Dune
#if ALU3DGRID_PARALLEL
template< int dim, int dimworld, ALU3dGridElementType elType >
struct ALU3dGridCommunications< dim, dimworld, elType, ALUGridMPIComm > : public ALU3dGridCommunicationsBase
struct ALU3dGridCommunications< dim, dimworld, elType, ALUGridMPIComm >
{
using ALU3dGridCommunicationsBase :: checkForConformingRefinement ;
typedef ALU3dGridGlobalIdSet< dim, dimworld, elType, ALUGridMPIComm > GlobalIdSet;
typedef ALUGridId< ALUMacroKey > GlobalId;
......@@ -212,19 +185,13 @@ namespace Dune
GitterImplType *createALUGrid ( const std::string &macroName, const ALU3DSPACE ProjectVertexPtrPair& projections,
const bool conformingRefinement )
{
GitterImplType* grid = new GitterImplType( dim, macroName.c_str(), mpAccess_, projections );
// check whether conforming refinement should be enabled
checkForConformingRefinement( grid, conformingRefinement );
return grid;
return new GitterImplType( dim, conformingRefinement, macroName.c_str(), mpAccess_, projections );
}
GitterImplType *createALUGrid ( std::istream& stream, const ALU3DSPACE ProjectVertexPtrPair& projections,
const bool conformingRefinement )
{
GitterImplType* grid = new GitterImplType ( dim, stream, mpAccess_, projections );
// check whether conforming refinement should be enabled
checkForConformingRefinement( grid, conformingRefinement );
return grid ;
return new GitterImplType ( dim, conformingRefinement, stream, mpAccess_, projections );
}
static MPI_Comm defaultComm () { return MPI_COMM_WORLD; }
......
......@@ -86,6 +86,15 @@ namespace ALUGrid
// read status of grid istream
virtual void restore ( std::istream &in ) { restoreImpl(in, true ); }
protected:
void checkForConformingRefinement( const bool conformingRefinement )
{
if( conformingRefinement )
{
this->enableConformingClosure();
this->disableGhostCells();
}
}
void restoreImpl( std::istream &in, const bool restoreBndFaces );
};
......@@ -96,22 +105,30 @@ namespace ALUGrid
virtual IteratorSTI < Gitter::helement_STI > * leafIterator (const IteratorSTI < Gitter::helement_STI > *);
friend class PureElementLeafIterator < Gitter::helement_STI >;
using GitterDuneBasis :: checkForConformingRefinement;
public:
//! constructor creating grid from std::istream
GitterDuneImpl ( const int dim, std::istream &in, const ProjectVertexPtrPair& ppv = ProjectVertexPtrPair() )
GitterDuneImpl ( const int dim, const bool conformingRefinement, std::istream &in, const ProjectVertexPtrPair& ppv = ProjectVertexPtrPair() )
: GitterBasisImpl ( dim, in, ppv )
{}
{
checkForConformingRefinement( conformingRefinement );
}
//! constructor creating grid from macro grid file
inline GitterDuneImpl (const int dim, const char *filename, const ProjectVertexPtrPair& ppv = ProjectVertexPtrPair() )
inline GitterDuneImpl (const int dim, const bool conformingRefinement, const char *filename, const ProjectVertexPtrPair& ppv = ProjectVertexPtrPair() )
: GitterBasisImpl ( dim, filename, ppv )
{}
{
checkForConformingRefinement( conformingRefinement );
}
//! constructor creating empty grid
explicit GitterDuneImpl ( const int dim )
explicit GitterDuneImpl ( const int dim, const bool conformingRefinement )
: GitterBasisImpl ( dim )
{}
{
checkForConformingRefinement( conformingRefinement );
}
// compress memory of given grid and return new object (holding equivalent information)
static GitterDuneImpl* compress( GitterDuneImpl* grd )
......@@ -127,7 +144,7 @@ namespace ALUGrid
// free allocated memory (only works if all grids are deleted at this point)
MyAlloc::clearFreeMemory ();
// restore saved grid
grd = new GitterDuneImpl( grd->dimension(), backup );
grd = new GitterDuneImpl( grd->dimension(), grd->conformingClosureNeeded(), backup );
alugrid_assert ( grd );
grd->restore( backup );
}
......
......@@ -24,6 +24,8 @@ namespace ALUGrid
leafIterator (const IteratorSTI < Gitter::helement_STI > *);
friend class PackUnpackInteriorGhostData ;
using GitterDuneBasis :: checkForConformingRefinement;
protected:
bool balanceGrid_;
......@@ -46,28 +48,34 @@ namespace ALUGrid
typedef GitterBasisPll::ObjectsPll Objects;
// constructor taking filename containing the macro grid
GitterDunePll ( const int dim, const char * filename, MpAccessLocal &mp, const ProjectVertexPtrPair &ppv = ProjectVertexPtrPair() )
GitterDunePll ( const int dim, const bool conformingRefinement, const char * filename, MpAccessLocal &mp, const ProjectVertexPtrPair &ppv = ProjectVertexPtrPair() )
: GitterBasisPll( dim, filename, mp, ppv ),
balanceGrid_ ( false )
{
// check and set conforming refinement if true
checkForConformingRefinement( conformingRefinement );
// build ghost cells after the macro grid has been assembled
rebuildGhostCells();
}
// constructor taking std::istream containing the macro grid
GitterDunePll ( const int dim, std::istream &in, MpAccessLocal &mp, const ProjectVertexPtrPair &ppv = ProjectVertexPtrPair() )
GitterDunePll ( const int dim, const bool conformingRefinement, std::istream &in, MpAccessLocal &mp, const ProjectVertexPtrPair &ppv = ProjectVertexPtrPair() )
: GitterBasisPll( dim, in, mp, ppv ),
balanceGrid_( false )
{
// check and set conforming refinement if true
checkForConformingRefinement( conformingRefinement );
// build ghost cells after the macro grid has been assembled
rebuildGhostCells();
}
// constructor creating empty grid
GitterDunePll (const int dim, MpAccessLocal &mp)
GitterDunePll (const int dim, const bool conformingRefinement, MpAccessLocal &mp)
: GitterBasisPll (dim, "", mp, ProjectVertexPtrPair() )
, balanceGrid_ (false)
{
// check and set conforming refinement if true
checkForConformingRefinement( conformingRefinement );
// build ghost cells after the macro grid has been assembled
rebuildGhostCells();
}
......@@ -151,7 +159,7 @@ namespace ALUGrid
// free allocated memory (only works if all grids are deleted at this point)
MyAlloc::clearFreeMemory ();
// restore saved grid
grd = new GitterDunePll( grd->dimension(), backup, mpa );
grd = new GitterDunePll( grd->dimension(), grd->conformingClosureNeeded(), backup, mpa );
alugrid_assert ( grd );
grd->restore( backup );
......
......@@ -269,20 +269,23 @@ namespace ALUGrid
const elementMap_t::iterator _periodic3Mapend = _periodic3Map.end ();
for (elementMap_t::iterator i = _periodic3Map.begin (); i != _periodic3Mapend; ++i)
{
if ( ((periodic3_GEO *)(*i).second)->erasable () )
periodic3_GEO * p3 = (periodic3_GEO *)(*i).second;
if( p3->erasable () )
{
// false means periodic element
removeElement ((*i).first, false );
delete p3;
i = _periodic3Map.erase( i );
}
}
const elementMap_t::iterator _periodic4Mapend = _periodic4Map.end ();
for (elementMap_t::iterator i = _periodic4Map.begin (); i != _periodic4Mapend; ++i)
size_t pI = 0;
for ( elementMap_t::iterator i = _periodic4Map.begin (); i != _periodic4Mapend; ++i, ++pI )
{
if ( ((periodic4_GEO *)(*i).second)->erasable ())
periodic4_GEO * p4 = (periodic4_GEO *)(*i).second;
if( p4->erasable () )
{
// false means periodic element
removeElement ((*i).first, false );
delete p4;
i = _periodic4Map.erase( i );
}
}
}
......@@ -292,8 +295,8 @@ namespace ALUGrid
const std::vector< elementKey_t >::iterator toDeleteend = toDelete.end ();
for (std::vector< elementKey_t >::iterator i = toDelete.begin (); i != toDeleteend; ++i )
{
// true means we have a real element
removeElement (*i, true);
// removes given element from _tetraMap or _hexaMap
removeElement ( *i );
}
}
......
......@@ -251,16 +251,14 @@ namespace ALUGrid
}
// Ende - Neu am 23.5.02 (BS)
void MacroGridBuilder::removeElement (const elementKey_t & k, const bool realElement )
void MacroGridBuilder::removeElement (const elementKey_t & k )
{
// Der Schl"ussel sollte nur in genau einer Map vorliegen.
// the key should only exist in exactly one map
alugrid_assert ((_hexaMap.find (k) == _hexaMap.end () ? 0 : 1)
+ (_tetraMap.find(k) == _tetraMap.end () ? 0 : 1)
+ (_periodic3Map.find (k) == _periodic3Map.end () ? 0 : 1)
+ (_periodic4Map.find (k) == _periodic4Map.end () ? 0 : 1) == 1);
alugrid_assert ((_hexaMap.find (k) == _hexaMap.end () ? 0 : 1)
+ (_tetraMap.find(k) == _tetraMap.end () ? 0 : 1) );
if( realElement )
if( ! _tetraMap.empty() )
{
elementMap_t::iterator hit = _tetraMap.find (k);
if (hit != _tetraMap.end ())
......@@ -306,8 +304,11 @@ namespace ALUGrid
return;
}
}
hit = _hexaMap.find (k);
if( ! _hexaMap.empty() )
{
elementMap_t::iterator hit = _hexaMap.find (k);
if (hit != _hexaMap.end ())
{
hexa_GEO * hx = (hexa_GEO *)(*hit).second;
......@@ -353,32 +354,8 @@ namespace ALUGrid
return;
}
}
else
{
elementMap_t::iterator hit = _periodic3Map.find (k);
if (hit != _periodic3Map.end ())
{
periodic3_GEO * p3 = (periodic3_GEO *)(*hit).second;
delete p3;
_periodic3Map.erase (hit);
return;
}
hit = _periodic4Map.find (k);
if (hit != _periodic4Map.end ())
{
periodic4_GEO * p4 = (periodic4_GEO *)(*hit).second;
delete p4;
_periodic4Map.erase (hit);
return;
}
}
abort ();
std::abort ();
return;
}
......
......@@ -185,7 +185,7 @@ namespace ALUGrid
inline BuilderIF & myBuilder ();
inline const BuilderIF & myBuilder () const;
void removeElement (const elementKey_t &, const bool );
void removeElement (const elementKey_t & );
public :
virtual std::pair< VertexGeo *, bool > InsertUniqueVertex (double, double, double, int);
virtual std::pair< hedge1_GEO *, bool > InsertUniqueHedge (int,int);
......
......@@ -548,10 +548,8 @@ namespace ALUGrid
typedef typename Gitter::GhostChildrenInfo GhostChildrenInfo;
GhostChildrenInfo ghostInfo;
// ghostInfo is filled by splitGhost, see gitter_tetra_top_pll.h
if( this->myhface(0)-> myvertex( 0 )->myGrid()->ghostCellsEnabled() )
{
this->splitGhost( ghostInfo );
}
this->splitGhost( ghostInfo );
//int gFace = this->getGhost().second ;
innerbndseg_t * b0 = new innerbndseg_t (l, subface (0,0), twist (0), this , _bt, ghostInfo.child(0), ghostInfo.face(0) ) ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment