Commit 8b520a8e authored by Robert K's avatar Robert K

[bugfix][MacroGridBuilder] adjust iterator appropriately when removing

item from map.
parent 08472516
Pipeline #17645 passed with stage
in 15 minutes and 38 seconds
......@@ -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);
......
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