diff --git a/dune/alugrid/src/serial/gitter_mgb.cc b/dune/alugrid/src/serial/gitter_mgb.cc index ea3ba46d716a91eb5262b3058dacfbfbb58bae1e..8c41722e4c2bf3c7d7c25ef9316da85562480227 100644 --- a/dune/alugrid/src/serial/gitter_mgb.cc +++ b/dune/alugrid/src/serial/gitter_mgb.cc @@ -2,194 +2,196 @@ // modifications for Dune Interface // (c) Robert Kloefkorn 2004 - 2005 +#include <sstream> + #include "gitter_sti.h" #include "gitter_mgb.h" -pair < Gitter :: Geometric :: VertexGeo *, bool > MacroGridBuilder :: +std::pair< Gitter::Geometric::VertexGeo *, bool > MacroGridBuilder:: InsertUniqueVertex (double x, double y, double z, int i) { - vertexMap_t :: const_iterator hit = _vertexMap.find (i) ; + vertexMap_t::const_iterator hit = _vertexMap.find (i); if (hit == _vertexMap.end ()) { - VertexGeo * v = myBuilder ().insert_vertex (x,y,z,i) ; - _vertexMap [i] = v ; - return pair < VertexGeo *, bool > (v,true) ; + VertexGeo * v = myBuilder ().insert_vertex (x,y,z,i); + _vertexMap [i] = v; + return std::pair< VertexGeo *, bool > (v,true); } else { - return pair < VertexGeo *, bool > ((*hit).second, false) ; + return std::pair< VertexGeo *, bool > ((*hit).second, false); } } -pair < Gitter :: Geometric :: hedge1_GEO *, bool > MacroGridBuilder :: +std::pair< Gitter::Geometric::hedge1_GEO *, bool > MacroGridBuilder:: InsertUniqueHedge (int l, int r) { if (l > r) { - int i = l ; l = r ; r = i ; + int i = l; l = r; r = i; } - edgeKey_t key (l,r) ; - edgeMap_t :: const_iterator hit = _edgeMap.find (key) ; + edgeKey_t key (l,r); + edgeMap_t::const_iterator hit = _edgeMap.find (key); if (hit == _edgeMap.end ()) { - vertexMap_t :: const_iterator a = _vertexMap.find (l), b = _vertexMap.find (r); + vertexMap_t::const_iterator a = _vertexMap.find (l), b = _vertexMap.find (r); assert( a != _vertexMap.end() ); assert( b != _vertexMap.end() ); - hedge1_GEO * h = myBuilder ().insert_hedge1 ((*a).second,(*b).second) ; - _edgeMap [key] = h ; - return pair < hedge1_GEO *, bool > (h,true) ; + hedge1_GEO * h = myBuilder ().insert_hedge1 ((*a).second,(*b).second); + _edgeMap [key] = h; + return std::pair< hedge1_GEO *, bool > (h,true); } else { - return pair < hedge1_GEO *, bool > ((*hit).second,false) ; + return std::pair< hedge1_GEO *, bool > ((*hit).second,false); } } -pair < Gitter :: Geometric :: hface3_GEO *, bool > MacroGridBuilder :: +std::pair< Gitter::Geometric::hface3_GEO *, bool > MacroGridBuilder:: InsertUniqueHface (int (&v)[3]) { - cyclicReorder (v,v+3) ; - faceKey_t key (v[0],v[1],v[2]) ; - faceMap_t :: const_iterator hit = _face3Map.find (key) ; + cyclicReorder (v,v+3); + faceKey_t key (v[0],v[1],v[2]); + faceMap_t::const_iterator hit = _face3Map.find (key); if (hit == _face3Map.end ()) { - hedge1_GEO * edge [3] ; - int dire [3] = { 0, 0, 1 } ; - edge [0] = InsertUniqueHedge (v[0],v[1]).first ; - edge [1] = InsertUniqueHedge (v[1],v[2]).first ; - edge [2] = InsertUniqueHedge (v[2],v[0]).first ; - hface3_GEO * f3 = myBuilder ().insert_hface3 (edge,dire) ; - _face3Map [key] = f3 ; - return pair < hface3_GEO *, bool > (f3,true) ; + hedge1_GEO * edge [3]; + int dire [3] = { 0, 0, 1 }; + edge [0] = InsertUniqueHedge (v[0],v[1]).first; + edge [1] = InsertUniqueHedge (v[1],v[2]).first; + edge [2] = InsertUniqueHedge (v[2],v[0]).first; + hface3_GEO * f3 = myBuilder ().insert_hface3 (edge,dire); + _face3Map [key] = f3; + return std::pair< hface3_GEO *, bool > (f3,true); } else { - return pair < hface3_GEO *, bool > ((hface3_GEO *)(*hit).second,false) ; + return std::pair< hface3_GEO *, bool > ((hface3_GEO *)(*hit).second,false); } } -pair < Gitter :: Geometric :: hface4_GEO *, bool > MacroGridBuilder :: InsertUniqueHface (int (&v)[4]) { - cyclicReorder (v,v+4) ; - faceKey_t key (v[0],v[1],v[2]) ; - faceMap_t :: const_iterator hit = _face4Map.find (key) ; +std::pair< Gitter::Geometric::hface4_GEO *, bool > MacroGridBuilder::InsertUniqueHface (int (&v)[4]) { + cyclicReorder (v,v+4); + faceKey_t key (v[0],v[1],v[2]); + faceMap_t::const_iterator hit = _face4Map.find (key); if (hit == _face4Map.end ()) { - hedge1_GEO * edge [4] ; + hedge1_GEO * edge [4]; int dire [4]; - edge [0] = InsertUniqueHedge (v[0],v[1]).first ; - edge [1] = InsertUniqueHedge (v[1],v[2]).first ; - edge [2] = InsertUniqueHedge (v[2],v[3]).first ; - edge [3] = InsertUniqueHedge (v[3],v[0]).first ; - dire [0] = v[0] < v[1] ? 0 : 1 ; - dire [1] = v[1] < v[2] ? 0 : 1 ; - dire [2] = v[2] < v[3] ? 0 : 1 ; - dire [3] = v[3] < v[0] ? 0 : 1 ; - hface4_GEO * f4 = myBuilder ().insert_hface4 (edge,dire) ; - _face4Map [key] = f4 ; - return pair < hface4_GEO *, bool > (f4,true) ; + edge [0] = InsertUniqueHedge (v[0],v[1]).first; + edge [1] = InsertUniqueHedge (v[1],v[2]).first; + edge [2] = InsertUniqueHedge (v[2],v[3]).first; + edge [3] = InsertUniqueHedge (v[3],v[0]).first; + dire [0] = v[0] < v[1] ? 0 : 1; + dire [1] = v[1] < v[2] ? 0 : 1; + dire [2] = v[2] < v[3] ? 0 : 1; + dire [3] = v[3] < v[0] ? 0 : 1; + hface4_GEO * f4 = myBuilder ().insert_hface4 (edge,dire); + _face4Map [key] = f4; + return std::pair< hface4_GEO *, bool > (f4,true); } else { - return pair < hface4_GEO *, bool > ((hface4_GEO *)(*hit).second,false) ; + return std::pair< hface4_GEO *, bool > ((hface4_GEO *)(*hit).second,false); } } -pair < Gitter :: Geometric :: tetra_GEO *, bool > MacroGridBuilder :: +std::pair< Gitter::Geometric::tetra_GEO *, bool > MacroGridBuilder:: InsertUniqueTetra (int (&v)[4], int orientation) { - elementKey_t key (v [0], v [1], v [2], v [3]) ; - elementMap_t :: const_iterator hit = _tetraMap.find (key) ; + elementKey_t key (v [0], v [1], v [2], v [3]); + elementMap_t::const_iterator hit = _tetraMap.find (key); if (hit == _tetraMap.end ()) { - hface3_GEO * face [4] ; - int twst [4] ; - for (int fce = 0 ; fce < 4 ; ++fce ) + hface3_GEO * face [4]; + int twst [4]; + for (int fce = 0; fce < 4; ++fce ) { - int x [3] ; - x [0] = v [Tetra :: prototype [fce][0]] ; - x [1] = v [Tetra :: prototype [fce][1]] ; - x [2] = v [Tetra :: prototype [fce][2]] ; - twst [fce] = cyclicReorder (x,x+3) ; - face [fce] = InsertUniqueHface (x).first ; + int x [3]; + x [0] = v [Tetra::prototype [fce][0]]; + x [1] = v [Tetra::prototype [fce][1]]; + x [2] = v [Tetra::prototype [fce][2]]; + twst [fce] = cyclicReorder (x,x+3); + face [fce] = InsertUniqueHface (x).first; } - tetra_GEO * t = myBuilder ().insert_tetra (face,twst,orientation) ; - assert (t) ; - _tetraMap [key] = t ; - return pair < tetra_GEO *, bool > (t,true) ; + tetra_GEO * t = myBuilder ().insert_tetra (face,twst,orientation); + assert (t); + _tetraMap [key] = t; + return std::pair< tetra_GEO *, bool > (t,true); } else { - return pair < tetra_GEO *, bool > ((tetra_GEO *)(*hit).second,false) ; + return std::pair< tetra_GEO *, bool > ((tetra_GEO *)(*hit).second,false); } } -pair < Gitter :: Geometric :: hexa_GEO *, bool > MacroGridBuilder :: InsertUniqueHexa (int (&v)[8]) +std::pair< Gitter::Geometric::hexa_GEO *, bool > MacroGridBuilder::InsertUniqueHexa (int (&v)[8]) { - elementKey_t key (v [0], v [1], v [3], v[4]) ; - elementMap_t :: const_iterator hit = _hexaMap.find (key) ; + elementKey_t key (v [0], v [1], v [3], v[4]); + elementMap_t::const_iterator hit = _hexaMap.find (key); if (hit == _hexaMap.end ()) { - hface4_GEO * face [6] ; - int twst [6] ; - for (int fce = 0 ; fce < 6 ; ++fce) + hface4_GEO * face [6]; + int twst [6]; + for (int fce = 0; fce < 6; ++fce) { - int x [4] ; - x [0] = v [Hexa :: prototype [fce][0]] ; - x [1] = v [Hexa :: prototype [fce][1]] ; - x [2] = v [Hexa :: prototype [fce][2]] ; - x [3] = v [Hexa :: prototype [fce][3]] ; - twst [fce] = cyclicReorder (x,x+4) ; - face [fce] = InsertUniqueHface (x).first ; + int x [4]; + x [0] = v [Hexa::prototype [fce][0]]; + x [1] = v [Hexa::prototype [fce][1]]; + x [2] = v [Hexa::prototype [fce][2]]; + x [3] = v [Hexa::prototype [fce][3]]; + twst [fce] = cyclicReorder (x,x+4); + face [fce] = InsertUniqueHface (x).first; } - hexa_GEO * hx = myBuilder ().insert_hexa (face,twst) ; - _hexaMap [key] = hx ; - return pair < hexa_GEO *, bool > (hx,true) ; + hexa_GEO * hx = myBuilder ().insert_hexa (face,twst); + _hexaMap [key] = hx; + return std::pair< hexa_GEO *, bool > (hx,true); } else { - return pair < hexa_GEO *, bool > ((hexa_GEO *)(*hit).second,false) ; + return std::pair< hexa_GEO *, bool > ((hexa_GEO *)(*hit).second,false); } } -bool MacroGridBuilder :: -InsertUniqueHbnd3 (int (&v)[3],Gitter :: hbndseg_STI ::bnd_t bt, int ldbVertexIndex ) +bool MacroGridBuilder:: +InsertUniqueHbnd3 (int (&v)[3],Gitter::hbndseg_STI ::bnd_t bt, int ldbVertexIndex ) { - int twst = cyclicReorder (v,v+3) ; - faceKey_t key (v [0], v [1], v [2]) ; - if (bt == Gitter :: hbndseg_STI :: closure) + int twst = cyclicReorder (v,v+3); + faceKey_t key (v [0], v [1], v [2]); + if (bt == Gitter::hbndseg_STI::closure) { if (_hbnd3Int.find (key) == _hbnd3Int.end ()) { - hface3_GEO * face = InsertUniqueHface (v).first ; - _hbnd3Int [key] = new Hbnd3IntStorage (face, twst, ldbVertexIndex) ; - return true ; + hface3_GEO * face = InsertUniqueHface (v).first; + _hbnd3Int [key] = new Hbnd3IntStorage (face, twst, ldbVertexIndex); + return true; } } else { if (_hbnd3Map.find (key) == _hbnd3Map.end ()) { - hface3_GEO * face = InsertUniqueHface (v).first ; - hbndseg3_GEO * hb3 = myBuilder ().insert_hbnd3 (face,twst,bt) ; + hface3_GEO * face = InsertUniqueHface (v).first; + hbndseg3_GEO * hb3 = myBuilder ().insert_hbnd3 (face,twst,bt); hb3->setLoadBalanceVertexIndex( ldbVertexIndex ); - _hbnd3Map [key] = hb3 ; - return true ; + _hbnd3Map [key] = hb3; + return true; } } - return false ; + return false; } -bool MacroGridBuilder :: -InsertUniqueHbnd4 (int (&v)[4], Gitter :: hbndseg_STI ::bnd_t bt, int ldbVertexIndex ) +bool MacroGridBuilder:: +InsertUniqueHbnd4 (int (&v)[4], Gitter::hbndseg_STI ::bnd_t bt, int ldbVertexIndex ) { - int twst = cyclicReorder (v,v+4) ; - faceKey_t key (v [0], v [1], v [2]) ; - if (bt == Gitter :: hbndseg_STI :: closure) + int twst = cyclicReorder (v,v+4); + faceKey_t key (v [0], v [1], v [2]); + if (bt == Gitter::hbndseg_STI::closure) { if (_hbnd4Int.find (key) == _hbnd4Int.end ()) { - hface4_GEO * face = InsertUniqueHface (v).first ; - _hbnd4Int [key] = new Hbnd4IntStorage (face, twst, ldbVertexIndex ) ; - return true ; + hface4_GEO * face = InsertUniqueHface (v).first; + _hbnd4Int [key] = new Hbnd4IntStorage (face, twst, ldbVertexIndex ); + return true; } } else { if (_hbnd4Map.find (key) == _hbnd4Map.end ()) { - hface4_GEO * face = InsertUniqueHface (v).first ; - hbndseg4_GEO * hb4 = myBuilder ().insert_hbnd4 (face,twst,bt) ; + hface4_GEO * face = InsertUniqueHface (v).first; + hbndseg4_GEO * hb4 = myBuilder ().insert_hbnd4 (face,twst,bt); hb4->setLoadBalanceVertexIndex( ldbVertexIndex ); - _hbnd4Map [key] = hb4 ; - return true ; + _hbnd4Map [key] = hb4; + return true; } } - return false ; + return false; } -pair < Gitter :: Geometric :: periodic3_GEO *, bool > MacroGridBuilder :: -InsertUniquePeriodic (int (&v)[6], const Gitter :: hbndseg_STI ::bnd_t (&bt)[2] ) +std::pair< Gitter::Geometric::periodic3_GEO *, bool > MacroGridBuilder:: +InsertUniquePeriodic (int (&v)[6], const Gitter::hbndseg_STI ::bnd_t (&bt)[2] ) { // Vorsicht: Der Schl"ussel f"ur das periodische Randelement wird @@ -197,31 +199,31 @@ InsertUniquePeriodic (int (&v)[6], const Gitter :: hbndseg_STI ::bnd_t (&bt)[2] // der letzte Knoten negativ (mit umgekehrtem Vorzeichen) in die // Schl"ussel eingef"ugt wird. - elementKey_t key (v [0], v [1], v [2], -(v [3])-1) ; - elementMap_t :: const_iterator hit = _periodic3Map.find (key) ; + elementKey_t key (v [0], v [1], v [2], -(v [3])-1); + elementMap_t::const_iterator hit = _periodic3Map.find (key); if (hit == _periodic3Map.end ()) { - hface3_GEO * face [2] ; - int twst [2] ; - for (int fce = 0 ; fce < 2 ; ++fce ) + hface3_GEO * face [2]; + int twst [2]; + for (int fce = 0; fce < 2; ++fce ) { - int x [3] ; - x [0] = v [Periodic3 :: prototype [fce][0]] ; - x [1] = v [Periodic3 :: prototype [fce][1]] ; - x [2] = v [Periodic3 :: prototype [fce][2]] ; - twst [fce] = cyclicReorder (x,x+3) ; - face [fce] = InsertUniqueHface (x).first ; + int x [3]; + x [0] = v [Periodic3::prototype [fce][0]]; + x [1] = v [Periodic3::prototype [fce][1]]; + x [2] = v [Periodic3::prototype [fce][2]]; + twst [fce] = cyclicReorder (x,x+3); + face [fce] = InsertUniqueHface (x).first; } - periodic3_GEO * t = myBuilder ().insert_periodic3 (face,twst,bt) ; - assert (t) ; - _periodic3Map [key] = t ; - return pair < periodic3_GEO *, bool > (t,true) ; + periodic3_GEO * t = myBuilder ().insert_periodic3 (face,twst,bt); + assert (t); + _periodic3Map [key] = t; + return std::pair< periodic3_GEO *, bool > (t,true); } else { - return pair < periodic3_GEO *, bool > ((periodic3_GEO *)(*hit).second,false) ; + return std::pair< periodic3_GEO *, bool > ((periodic3_GEO *)(*hit).second,false); } } -pair < Gitter :: Geometric :: periodic4_GEO *, bool > MacroGridBuilder :: -InsertUniquePeriodic (int (&v)[8], const Gitter :: hbndseg_STI ::bnd_t (&bt)[2] ) +std::pair< Gitter::Geometric::periodic4_GEO *, bool > MacroGridBuilder:: +InsertUniquePeriodic (int (&v)[8], const Gitter::hbndseg_STI ::bnd_t (&bt)[2] ) { // Vorsicht: Der Schl"ussel f"ur das periodische Randelement wird @@ -229,62 +231,62 @@ InsertUniquePeriodic (int (&v)[8], const Gitter :: hbndseg_STI ::bnd_t (&bt)[2] // der letzte Knoten negativ (mit umgekehrtem Vorzeichen) in die // Schl"ussel eingef"ugt wird. - elementKey_t key (v [0], v [1], v [3], -(v [4])-1) ; - elementMap_t :: const_iterator hit = _periodic4Map.find (key) ; + elementKey_t key (v [0], v [1], v [3], -(v [4])-1); + elementMap_t::const_iterator hit = _periodic4Map.find (key); if (hit == _periodic4Map.end ()) { - hface4_GEO * face [2] ; - int twst [2] ; - for (int fce = 0 ; fce < 2 ; ++fce ) + hface4_GEO * face [2]; + int twst [2]; + for (int fce = 0; fce < 2; ++fce ) { - int x [4] ; - x [0] = v [Periodic4 :: prototype [fce][0]] ; - x [1] = v [Periodic4 :: prototype [fce][1]] ; - x [2] = v [Periodic4 :: prototype [fce][2]] ; - x [3] = v [Periodic4 :: prototype [fce][3]] ; - twst [fce] = cyclicReorder (x,x+4) ; - face [fce] = InsertUniqueHface (x).first ; + int x [4]; + x [0] = v [Periodic4::prototype [fce][0]]; + x [1] = v [Periodic4::prototype [fce][1]]; + x [2] = v [Periodic4::prototype [fce][2]]; + x [3] = v [Periodic4::prototype [fce][3]]; + twst [fce] = cyclicReorder (x,x+4); + face [fce] = InsertUniqueHface (x).first; } - periodic4_GEO * t = myBuilder ().insert_periodic4 (face,twst,bt) ; - assert (t) ; - _periodic4Map [key] = t ; - return pair < periodic4_GEO *, bool > (t,true) ; + periodic4_GEO * t = myBuilder ().insert_periodic4 (face,twst,bt); + assert (t); + _periodic4Map [key] = t; + return std::pair< periodic4_GEO *, bool > (t,true); } else { - return pair < periodic4_GEO *, bool > ((periodic4_GEO *)(*hit).second,false) ; + return std::pair< periodic4_GEO *, bool > ((periodic4_GEO *)(*hit).second,false); } } // Ende - Neu am 23.5.02 (BS) -void MacroGridBuilder :: removeElement (const elementKey_t & k, const bool realElement ) +void MacroGridBuilder::removeElement (const elementKey_t & k, const bool realElement ) { // Der Schl"ussel sollte nur in genau einer Map vorliegen. 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) ; + + (_periodic4Map.find (k) == _periodic4Map.end () ? 0 : 1) == 1); if( realElement ) { - elementMap_t :: iterator hit = _tetraMap.find (k) ; + elementMap_t::iterator hit = _tetraMap.find (k); if (hit != _tetraMap.end ()) { - tetra_GEO * tr = (tetra_GEO *)(*hit).second ; - int ldbVertexIndex = tr->ldbVertexIndex() ; + tetra_GEO * tr = (tetra_GEO *)(*hit).second; + int ldbVertexIndex = tr->ldbVertexIndex(); - typedef typename hbnd3intMap_t :: iterator iterator ; - const iterator end = _hbnd3Int.end() ; - for (int i = 0 ; i < 4 ; ++i) + typedef typename hbnd3intMap_t::iterator iterator; + const iterator end = _hbnd3Int.end(); + for (int i = 0; i < 4; ++i) { // for periodic neighbours we do not create internal storages if( tr->myneighbour( i ).first->isperiodic() ) - continue ; + continue; - hface3_GEO* face = tr->myhface3 (i) ; + hface3_GEO* face = tr->myhface3 (i); faceKey_t key (face->myvertex (0)->ident (), face->myvertex (1)->ident (), - face->myvertex (2)->ident ()) ; + face->myvertex (2)->ident ()); // if the face does not exist in the map of internal boundaries // we need to insert this @@ -292,43 +294,41 @@ void MacroGridBuilder :: removeElement (const elementKey_t & k, const bool realE if( hbndit == end ) { Hbnd3IntStorage* hbnd = - new Hbnd3IntStorage (face, tr->twist (i), ldbVertexIndex, tr , i ) ; - _hbnd3Int.insert( make_pair( key, hbnd ) ); + new Hbnd3IntStorage (face, tr->twist (i), ldbVertexIndex, tr , i ); + _hbnd3Int.insert( std::make_pair( key, hbnd ) ); } // if the face already exists this means we can delete it, // since both adjacent element will disappear else { - Hbnd3IntStorage* hbnd = (*hbndit).second ; + Hbnd3IntStorage* hbnd = (*hbndit).second; _hbnd3Int.erase( hbndit ); - delete hbnd ; + delete hbnd; } } - delete tr ; - _tetraMap.erase (hit) ; - - return ; + delete tr; + _tetraMap.erase (hit); } - hit = _hexaMap.find (k) ; + hit = _hexaMap.find (k); if (hit != _hexaMap.end ()) { - hexa_GEO * hx = (hexa_GEO *)(*hit).second ; + hexa_GEO * hx = (hexa_GEO *)(*hit).second; int ldbVertexIndex = hx->ldbVertexIndex(); - typedef typename hbnd4intMap_t :: iterator iterator ; - const iterator end = _hbnd4Int.end() ; - for (int i = 0 ; i < 6 ; ++i) + typedef typename hbnd4intMap_t::iterator iterator; + const iterator end = _hbnd4Int.end(); + for (int i = 0; i < 6; ++i) { // for periodic neighbours we do not create internal storages if( hx->myneighbour( i ).first->isperiodic() ) - continue ; + continue; hface4_GEO* face = hx->myhface4 (i); faceKey_t key (face->myvertex (0)->ident (), face->myvertex (1)->ident (), - face->myvertex (2)->ident ()) ; + face->myvertex (2)->ident ()); iterator hbndit = _hbnd4Int.find( key ); // if the face does not exist in the map of internal boundaries @@ -338,54 +338,55 @@ void MacroGridBuilder :: removeElement (const elementKey_t & k, const bool realE Hbnd4IntStorage* hbnd = new Hbnd4IntStorage ( face, hx->twist (i), ldbVertexIndex, hx, i ); - _hbnd4Int.insert( make_pair( key, hbnd ) ); + _hbnd4Int.insert( std::make_pair( key, hbnd ) ); } // if the face already exists this means we can delete it, // since both adjacent element will disappear else { - Hbnd4IntStorage* hbnd = (*hbndit).second ; + Hbnd4IntStorage* hbnd = (*hbndit).second; _hbnd4Int.erase( hbndit ); - delete hbnd ; + delete hbnd; } } - delete hx ; - _hexaMap.erase (hit) ; + delete hx; + _hexaMap.erase (hit); - return ; + return; } } else { - elementMap_t :: iterator hit = _periodic3Map.find (k) ; + elementMap_t::iterator hit = _periodic3Map.find (k); if (hit != _periodic3Map.end ()) { - periodic3_GEO * p3 = (periodic3_GEO *)(*hit).second ; + periodic3_GEO * p3 = (periodic3_GEO *)(*hit).second; - delete p3 ; - _periodic3Map.erase (hit) ; + delete p3; + _periodic3Map.erase (hit); - return ; + return; } - hit = _periodic4Map.find (k) ; + hit = _periodic4Map.find (k); if (hit != _periodic4Map.end ()) { - periodic4_GEO * p4 = (periodic4_GEO *)(*hit).second ; + periodic4_GEO * p4 = (periodic4_GEO *)(*hit).second; - delete p4 ; - _periodic4Map.erase (hit) ; + delete p4; + _periodic4Map.erase (hit); - return ; + return; } } - abort () ; - return ; + abort (); + return; } -void MacroGridBuilder :: cubeHexaGrid (int n, ostream & out) { +void MacroGridBuilder::cubeHexaGrid ( int n, std::ostream &out ) +{ // cubeHexaGrid () ist eine statische Methode, die einen ASCII Strom // mit einem gleichm"assigen Hexaedernetz auf dem Einheitsw"urfel @@ -395,104 +396,104 @@ void MacroGridBuilder :: cubeHexaGrid (int n, ostream & out) { // programme n"otig und deshalb in der MacrogridBuilder Klasse // beheimatet. - const int bndtype = -1 ; - out.setf(ios::fixed, ios::floatfield) ; - out.precision ( ALUGridExternalParameters :: precision() ) ; - n = n < 0 ? 0 : n ; - int npe = n + 1 ; - out << (npe * npe * npe) << endl ; - double delta = 1.0 / (double)(n) ; + const int bndtype = -1; + out.setf( std::ios::fixed, std::ios::floatfield ); + out.precision ( ALUGridExternalParameters::precision() ); + n = n < 0 ? 0 : n; + int npe = n + 1; + out << (npe * npe * npe) << std::endl; + double delta = 1.0 / (double)(n); { - for(int i = 0 ; i < npe ; i ++) { - for(int j = 0 ; j < npe ; j ++) { - for(int k = 0 ; k < npe ; k ++) { - out << double(k * delta) << " " << double(j * delta) << " " << double(i * delta) << "\n" ; + for(int i = 0; i < npe; i ++) { + for(int j = 0; j < npe; j ++) { + for(int k = 0; k < npe; k ++) { + out << double(k * delta) << " " << double(j * delta) << " " << double(i * delta) << "\n"; } } } } - out << n * n * n << "\n" ; + out << n * n * n << "\n"; { - for(int i = 0 ; i < n ; i ++) { - int ipea = (i + 1) * npe * npe, ia = i * npe * npe ; - for(int j = 0 ; j < n ; j ++) { - int jpea = (j + 1) * npe, ja = j * npe ; - for(int k = 0 ; k < n ; k ++) { - int kpe = k + 1 ; + for(int i = 0; i < n; i ++) { + int ipea = (i + 1) * npe * npe, ia = i * npe * npe; + for(int j = 0; j < n; j ++) { + int jpea = (j + 1) * npe, ja = j * npe; + for(int k = 0; k < n; k ++) { + int kpe = k + 1; out << k + ia + ja << " " << kpe + ia + ja << " " << kpe + ia + jpea << " " << k + ia + jpea << " " - << k + ja + ipea << " " << kpe + ja + ipea << " " << kpe + ipea + jpea << " " << k + ipea + jpea << "\n" ; + << k + ja + ipea << " " << kpe + ja + ipea << " " << kpe + ipea + jpea << " " << k + ipea + jpea << "\n"; } } } - out << endl ; + out << std::endl; } - out << 6 * n * n << endl ; + out << 6 * n * n << std::endl; { // unten und oben - int l = n * npe * npe ; - for(int j = 0 ; j < n ; j ++) { - int jpea = (j + 1) * npe, ja = j * npe ; - for(int k = 0 ; k < n ; k ++) { - int kpe = k + 1 ; + int l = n * npe * npe; + for(int j = 0; j < n; j ++) { + int jpea = (j + 1) * npe, ja = j * npe; + for(int k = 0; k < n; k ++) { + int kpe = k + 1; out << bndtype << " " << 4 << " " << (kpe + ja) << " " << (kpe + jpea) << " " << (k + jpea) << " " << (k + ja) << "\n" << bndtype << " " << 4 << " " - << (k + jpea + l) << " " << (kpe + jpea + l) << " " << (kpe + ja + l) << " " << (k + ja + l) << "\n" ; + << (k + jpea + l) << " " << (kpe + jpea + l) << " " << (kpe + ja + l) << " " << (k + ja + l) << "\n"; } } - out << endl ; + out << std::endl; } { // links und rechts - int l = n * npe ; - for(int j = 0 ; j < n ; j ++) { - int jpea = (j + 1) * npe * npe, ja = j * npe * npe ; - for(int ka = 0 ; ka < n ; ka ++) { - int kpea = (ka + 1) ; + int l = n * npe; + for(int j = 0; j < n; j ++) { + int jpea = (j + 1) * npe * npe, ja = j * npe * npe; + for(int ka = 0; ka < n; ka ++) { + int kpea = (ka + 1); out << bndtype << " " << 4 << " " << ka + jpea << " " << kpea + jpea << " " << kpea + ja << " " << ka + ja << "\n" << bndtype << " " << 4 << " " - << kpea + ja + l << " " << kpea + jpea + l << " " << ka + jpea + l << " " << ka + ja + l << "\n" ; + << kpea + ja + l << " " << kpea + jpea + l << " " << ka + jpea + l << " " << ka + ja + l << "\n"; } } - out << endl ; + out << std::endl; } { // hinten und vorne - int l = n ; - for(int j = 0 ; j < n ; j ++) { - int jpea = (j + 1) * npe * npe, ja = j * npe * npe ; - for(int k = 0 ; k < n ; k ++) { - int kpea = (k + 1) * npe, ka = k * npe ; + int l = n; + for(int j = 0; j < n; j ++) { + int jpea = (j + 1) * npe * npe, ja = j * npe * npe; + for(int k = 0; k < n; k ++) { + int kpea = (k + 1) * npe, ka = k * npe; out << bndtype << " " << 4 << " " << kpea + ja << " " << kpea + jpea << " " << ka + jpea << " " << ka + ja << "\n" << bndtype << " " << 4 << " " - << ka + jpea + l << " " << kpea + jpea + l << " " << kpea + ja + l << " " << ka + ja + l << "\n" ; + << ka + jpea + l << " " << kpea + jpea + l << " " << kpea + ja + l << " " << ka + ja + l << "\n"; } } - out << endl ; + out << std::endl; } - return ; + return; } -void MacroGridBuilder :: generateRawHexaImage (istream& in, ostream & os) +void MacroGridBuilder::generateRawHexaImage ( std::istream& in, std::ostream &os ) { generateRawImage( in, os, HEXA_RAW, PERIODIC4_RAW ); } -void MacroGridBuilder :: generateRawHexaImage (ObjectStream& in, ostream & os) +void MacroGridBuilder::generateRawHexaImage ( ObjectStream& in, std::ostream &os ) { generateRawImage( in, os, HEXA_RAW, PERIODIC4_RAW ); } -void MacroGridBuilder :: generateRawTetraImage (istream& in, ostream & os) +void MacroGridBuilder::generateRawTetraImage ( std::istream &in, std::ostream &os ) { generateRawImage( in, os, TETRA_RAW, PERIODIC3_RAW ); } -void MacroGridBuilder :: generateRawTetraImage (ObjectStream& in, ostream & os) +void MacroGridBuilder::generateRawTetraImage ( ObjectStream &in, std::ostream &os ) { generateRawImage( in, os, TETRA_RAW, PERIODIC3_RAW ); } -template <class istream_t> -void MacroGridBuilder :: -generateRawImage (istream_t & in, ostream & os, - const ElementRawID elementId, const ElementRawID periodicId) +template< class istream_t > +void MacroGridBuilder + ::generateRawImage ( istream_t &in, std::ostream &os, + const ElementRawID elementId, const ElementRawID periodicId ) { // generateRawHexaImage () ist im nur ein Adapter, der aus den // bisherigen Hexaederdateiformaten ein entsprechendes 'rohes' @@ -516,48 +517,48 @@ generateRawImage (istream_t & in, ostream & os, // <Identifier f"ur den letzten Knoten : int> /* einem Gitter optional, sonst muss // /* jeder Vertex eine eigene Nummer haben - const int start = clock () ; - int nv = 0, ne = 0, nb = 0, nper = 0 ; - int (* vnum)[8] = 0, (* bvec)[5] = 0, (* pervec)[9] = 0, * pident = 0 ; - double (* coord)[3] = 0 ; + const int start = clock (); + int nv = 0, ne = 0, nb = 0, nper = 0; + int (* vnum)[8] = 0, (* bvec)[5] = 0, (* pervec)[9] = 0, * pident = 0; + double (* coord)[3] = 0; - const int elementVertices = elementId ; + const int elementVertices = elementId; const int faceVertices = (elementId == TETRA_RAW) ? 3 : 4; const int periodicVertices = (elementId == TETRA_RAW) ? 6 : 8; assert( faceVertices == 4 ? elementId == HEXA_RAW : true ); assert( periodicVertices == 8 ? elementId == HEXA_RAW : true ); { - in >> nv ; - coord = new double [nv][3] ; - assert (coord) ; - for (int i = 0 ; i < nv ; ++i) in >> coord [i][0] >> coord [i][1] >> coord [i][2] ; + in >> nv; + coord = new double [nv][3]; + assert (coord); + for (int i = 0; i < nv; ++i) in >> coord [i][0] >> coord [i][1] >> coord [i][2]; } { - in >> ne ; - vnum = new int [ne][8] ; - assert (vnum) ; - for (int i = 0 ; i < ne ; ++i) + in >> ne; + vnum = new int [ne][8]; + assert (vnum); + for (int i = 0; i < ne; ++i) { for( int vx = 0; vx < elementVertices; ++ vx ) { - in >> vnum [i][vx] ; + in >> vnum [i][vx]; } } } { int temp_nb; - in >> temp_nb ; - bvec = new int [temp_nb][5] ; - pervec = new int [temp_nb][9] ; + in >> temp_nb; + bvec = new int [temp_nb][5]; + pervec = new int [temp_nb][9]; assert (bvec); assert (pervec); - for (int i = 0 ; i < temp_nb ; ++i) + for (int i = 0; i < temp_nb; ++i) { - int n ; - int identification ; + int n; + int identification; in >> identification >> n; // hexa or tetra element boundary if ( n == faceVertices ) @@ -567,7 +568,7 @@ generateRawImage (istream_t & in, ostream & os, in >> bvec [nb][vx]; } // use last component for storage of identification - bvec [nb][n] = identification ; + bvec [nb][n] = identification; nb++; } // periodic boundary @@ -580,58 +581,58 @@ generateRawImage (istream_t & in, ostream & os, // keep boundary information // use last component for storage of identification - pervec [nper][n] = identification ; + pervec [nper][n] = identification; nper++; } - else { - cerr << "**FEHLER (FATAL): " << __FILE__ << " " << __LINE__ << " ... Exiting." << endl ; + else + { + std::cerr << "ERROR (fatal): " << __FILE__ << " " << __LINE__ << " ... Exiting." << std::endl; abort(); } } } - if (! in.good ()) { - cerr << "**FEHLER (FATAL): Dateiende zu fr\"uh erreicht (inkonsistente Datei). " ; - cerr << __FILE__ << " " << __LINE__ << " ... Exiting." << endl ; - exit (1) ; + if ( !in.good() ) + { + std::cerr << "ERROR (fatal): Unexpected end of file." << std::endl; + abort(); } - pident = new int [nv] ; + pident = new int [nv]; { - int dummy ; - for (int i = 0 ; i < nv ; ++ i ) in >> pident [i] >> dummy ; + int dummy; + for (int i = 0; i < nv; ++ i ) in >> pident [i] >> dummy; } - if (! in.good() ) + if( !in.good() ) { - cerr << "**WARNUNG (IGNORIERT) MacroGridBuilder :: generateRawImage () " ; - cerr << "Identifierliste unvollst\"andig oder nicht vorhanden. Daher keine parallele " ; - cerr << "Identifikation falls aus mehreren Gittern geladen wurde." << endl ; - for (int i = 0 ; i < nv ; ++ i ) pident [i] = i ; + std::cerr << "WARNING (ignored) No parallel identification applied due to incomplete (or non-existent) identifier list." << std::endl; + for( int i = 0; i < nv; ++ i ) + pident[ i ] = i; } - // get last endl character (from backup to make stream consistent) - if( ! in.eof() ) + // get last std::endl character (from backup to make stream consistent) + if( !in.eof() ) in.get(); // write vertices - os << nv << endl ; - for (int i = 0 ; i < nv ; ++i ) - os << pident [i] << " " << coord [i][0] << " " << coord [i][1] << " " << coord [i][2] << endl ; + os << nv << std::endl; + for (int i = 0; i < nv; ++i ) + os << pident [i] << " " << coord [i][0] << " " << coord [i][1] << " " << coord [i][2] << std::endl; // write elements - os << (ne + nper) << endl ; - for (int i = 0 ; i < ne ; ++i) + os << (ne + nper) << std::endl; + for (int i = 0; i < ne; ++i) { os << elementId << " "; for( int vx = 0; vx < elementVertices; ++ vx ) { os << pident[ vnum [i][vx] ] << " "; } - os << endl; + os << std::endl; } // write periodic elements - for (int i = 0 ; i < nper ; ++i) + for (int i = 0; i < nper; ++i) { os << periodicId << " "; for( int vx = 0; vx < periodicVertices; ++vx ) @@ -639,12 +640,12 @@ generateRawImage (istream_t & in, ostream & os, os << pident[ pervec[i][vx] ] << " "; } // write the identification - os << pervec [i][ periodicVertices ] << endl; + os << pervec [i][ periodicVertices ] << std::endl; } // write boundaries - os << nb << endl ; - for (int i = 0 ; i < nb ; ++i) + os << nb << std::endl; + for (int i = 0; i < nb; ++i) { os << faceVertices << " "; for( int vx = 0; vx < faceVertices; ++vx ) @@ -652,23 +653,21 @@ generateRawImage (istream_t & in, ostream & os, os << pident[ bvec[i][vx] ] << " "; } // write the identification - os << bvec[i][ faceVertices ] << endl; + os << bvec[i][ faceVertices ] << std::endl; } // delete temporary memory - delete [] vnum ; - delete [] coord ; - delete [] pervec ; - delete [] bvec ; - delete [] pident ; - if (debugOption (4)) - cout << "**INFO MacroGridBuilder :: generateRawHexaImage () used: " - << (float)(clock () - start)/(float)(CLOCKS_PER_SEC) << " sec." << endl ; - return ; + delete [] vnum; + delete [] coord; + delete [] pervec; + delete [] bvec; + delete [] pident; + if( debugOption( 4 ) ) + std::cout << "INFO: MacroGridBuilder::generateRawHexaImage() used: " << (float)(clock () - start)/(float)(CLOCKS_PER_SEC) << " s." << std::endl; } // default of init == true -MacroGridBuilder :: MacroGridBuilder (BuilderIF & b, const bool init) +MacroGridBuilder::MacroGridBuilder (BuilderIF & b, const bool init) : _initialized(false) , _finalized(false) , _mgb (b) @@ -677,7 +676,7 @@ MacroGridBuilder :: MacroGridBuilder (BuilderIF & b, const bool init) } // deprecated constructor, project vertex has been removed -MacroGridBuilder :: MacroGridBuilder (BuilderIF & b, ProjectVertex* ) +MacroGridBuilder::MacroGridBuilder (BuilderIF & b, ProjectVertex* ) : _initialized(false) , _finalized(false) , _mgb (b) @@ -685,140 +684,140 @@ MacroGridBuilder :: MacroGridBuilder (BuilderIF & b, ProjectVertex* ) initialize(); } -void MacroGridBuilder :: initialize () +void MacroGridBuilder::initialize () { { - typedef BuilderIF :: vertexlist_t :: iterator iterator ; + typedef BuilderIF::vertexlist_t::iterator iterator; const iterator vertexListEnd = myBuilder ()._vertexList.end (); - for ( iterator i = myBuilder ()._vertexList.begin () ; i != vertexListEnd ; myBuilder ()._vertexList.erase (i ++)) - _vertexMap [(*i)->ident ()] = (*i) ; + for ( iterator i = myBuilder ()._vertexList.begin (); i != vertexListEnd; myBuilder ()._vertexList.erase (i ++)) + _vertexMap [(*i)->ident ()] = (*i); } { - typedef BuilderIF :: hedge1list_t :: iterator iterator ; - const iterator hedge1ListEnd = myBuilder ()._hedge1List.end () ; - for ( iterator i = myBuilder ()._hedge1List.begin () ; i != hedge1ListEnd ; myBuilder ()._hedge1List.erase (i ++)) + typedef BuilderIF::hedge1list_t::iterator iterator; + const iterator hedge1ListEnd = myBuilder ()._hedge1List.end (); + for ( iterator i = myBuilder ()._hedge1List.begin (); i != hedge1ListEnd; myBuilder ()._hedge1List.erase (i ++)) { - long k = (*i)->myvertex (0)->ident (), l = (*i)->myvertex (1)->ident () ; - _edgeMap [edgeKey_t (k < l ? k : l, k < l ? l : k)] = (*i) ; + long k = (*i)->myvertex (0)->ident (), l = (*i)->myvertex (1)->ident (); + _edgeMap [edgeKey_t (k < l ? k : l, k < l ? l : k)] = (*i); } } { - typedef BuilderIF :: hface3list_t :: iterator iterator ; - const iterator hface3ListEnd = myBuilder ()._hface3List.end () ; - for ( iterator i = myBuilder ()._hface3List.begin () ; i != hface3ListEnd ; myBuilder ()._hface3List.erase (i ++)) + typedef BuilderIF::hface3list_t::iterator iterator; + const iterator hface3ListEnd = myBuilder ()._hface3List.end (); + for ( iterator i = myBuilder ()._hface3List.begin (); i != hface3ListEnd; myBuilder ()._hface3List.erase (i ++)) { - _face3Map [faceKey_t ((*i)->myvertex (0)->ident (),(*i)->myvertex (1)->ident (), (*i)->myvertex (2)->ident ())] = (*i) ; + _face3Map [faceKey_t ((*i)->myvertex (0)->ident (),(*i)->myvertex (1)->ident (), (*i)->myvertex (2)->ident ())] = (*i); } } { - typedef BuilderIF :: hface4list_t :: iterator iterator ; - const iterator hface4ListEnd = myBuilder ()._hface4List.end () ; - for ( iterator i = myBuilder ()._hface4List.begin () ; i != hface4ListEnd ; myBuilder ()._hface4List.erase (i ++)) - _face4Map [faceKey_t ((*i)->myvertex (0)->ident (),(*i)->myvertex (1)->ident (), (*i)->myvertex (2)->ident ())] = (*i) ; + typedef BuilderIF::hface4list_t::iterator iterator; + const iterator hface4ListEnd = myBuilder ()._hface4List.end (); + for ( iterator i = myBuilder ()._hface4List.begin (); i != hface4ListEnd; myBuilder ()._hface4List.erase (i ++)) + _face4Map [faceKey_t ((*i)->myvertex (0)->ident (),(*i)->myvertex (1)->ident (), (*i)->myvertex (2)->ident ())] = (*i); } { - typedef BuilderIF :: hbndseg4list_t :: iterator iterator; - const iterator hbndseg4ListEnd = myBuilder ()._hbndseg4List.end () ; - for ( iterator i = myBuilder ()._hbndseg4List.begin () ; i != hbndseg4ListEnd ; myBuilder ()._hbndseg4List.erase (i++)) + typedef BuilderIF::hbndseg4list_t::iterator iterator; + const iterator hbndseg4ListEnd = myBuilder ()._hbndseg4List.end (); + for ( iterator i = myBuilder ()._hbndseg4List.begin (); i != hbndseg4ListEnd; myBuilder ()._hbndseg4List.erase (i++)) { - faceKey_t key ((*i)->myhface4 (0)->myvertex (0)->ident (), (*i)->myhface4 (0)->myvertex (1)->ident (), (*i)->myhface4 (0)->myvertex (2)->ident ()) ; - if ((*i)->bndtype () == Gitter :: hbndseg_STI :: closure) { - _hbnd4Int [key] = new Hbnd4IntStorage ((*i)->myhface4 (0),(*i)->twist (0),(*i)->ldbVertexIndex()) ; - delete (*i) ; + faceKey_t key ((*i)->myhface4 (0)->myvertex (0)->ident (), (*i)->myhface4 (0)->myvertex (1)->ident (), (*i)->myhface4 (0)->myvertex (2)->ident ()); + if ((*i)->bndtype () == Gitter::hbndseg_STI::closure) { + _hbnd4Int [key] = new Hbnd4IntStorage ((*i)->myhface4 (0),(*i)->twist (0),(*i)->ldbVertexIndex()); + delete (*i); } else { - _hbnd4Map [key] = (*i) ; + _hbnd4Map [key] = (*i); } } } { - typedef BuilderIF :: hbndseg3list_t :: iterator iterator; - const iterator hbndseg3ListEnd = myBuilder ()._hbndseg3List.end () ; - for ( iterator i = myBuilder ()._hbndseg3List.begin () ; i != hbndseg3ListEnd ; myBuilder ()._hbndseg3List.erase (i++)) + typedef BuilderIF::hbndseg3list_t::iterator iterator; + const iterator hbndseg3ListEnd = myBuilder ()._hbndseg3List.end (); + for ( iterator i = myBuilder ()._hbndseg3List.begin (); i != hbndseg3ListEnd; myBuilder ()._hbndseg3List.erase (i++)) { - faceKey_t key ((*i)->myhface3 (0)->myvertex (0)->ident (), (*i)->myhface3 (0)->myvertex (1)->ident (), (*i)->myhface3 (0)->myvertex (2)->ident ()) ; - if ((*i)->bndtype () == Gitter :: hbndseg_STI :: closure) + faceKey_t key ((*i)->myhface3 (0)->myvertex (0)->ident (), (*i)->myhface3 (0)->myvertex (1)->ident (), (*i)->myhface3 (0)->myvertex (2)->ident ()); + if ((*i)->bndtype () == Gitter::hbndseg_STI::closure) { - _hbnd3Int [key] = new Hbnd3IntStorage ((*i)->myhface3 (0), (*i)->twist (0),(*i)->ldbVertexIndex()) ; - delete (*i) ; + _hbnd3Int [key] = new Hbnd3IntStorage ((*i)->myhface3 (0), (*i)->twist (0),(*i)->ldbVertexIndex()); + delete (*i); } else { - _hbnd3Map [key] = (*i) ; + _hbnd3Map [key] = (*i); } } } { - typedef BuilderIF :: tetralist_t :: iterator iterator ; - const iterator tetraListEnd = myBuilder ()._tetraList.end () ; - for ( iterator i = myBuilder ()._tetraList.begin () ; i != tetraListEnd ; myBuilder ()._tetraList.erase (i++)) + typedef BuilderIF::tetralist_t::iterator iterator; + const iterator tetraListEnd = myBuilder ()._tetraList.end (); + for ( iterator i = myBuilder ()._tetraList.begin (); i != tetraListEnd; myBuilder ()._tetraList.erase (i++)) { _tetraMap [elementKey_t ( (*i)->myvertex (0)->ident (), (*i)->myvertex (1)->ident (), - (*i)->myvertex (2)->ident (), (*i)->myvertex (3)->ident ())] = (*i) ; + (*i)->myvertex (2)->ident (), (*i)->myvertex (3)->ident ())] = (*i); } } { - typedef BuilderIF :: periodic3list_t :: iterator iterator ; - const iterator periodic3ListEnd = myBuilder ()._periodic3List.end () ; - for ( iterator i = myBuilder ()._periodic3List.begin () ; i != periodic3ListEnd ; myBuilder ()._periodic3List.erase (i++)) + typedef BuilderIF::periodic3list_t::iterator iterator; + const iterator periodic3ListEnd = myBuilder ()._periodic3List.end (); + for ( iterator i = myBuilder ()._periodic3List.begin (); i != periodic3ListEnd; myBuilder ()._periodic3List.erase (i++)) { _periodic3Map [elementKey_t ( (*i)->myvertex (0)->ident (), (*i)->myvertex (1)->ident (), - (*i)->myvertex (2)->ident (), -((*i)->myvertex (3)->ident ())-1)] = (*i) ; + (*i)->myvertex (2)->ident (), -((*i)->myvertex (3)->ident ())-1)] = (*i); } } { - typedef BuilderIF :: periodic4list_t :: iterator iterator; - const iterator periodic4ListEnd = myBuilder ()._periodic4List.end () ; - for ( iterator i = myBuilder ()._periodic4List.begin () ; i != periodic4ListEnd ; myBuilder ()._periodic4List.erase (i++)) + typedef BuilderIF::periodic4list_t::iterator iterator; + const iterator periodic4ListEnd = myBuilder ()._periodic4List.end (); + for ( iterator i = myBuilder ()._periodic4List.begin (); i != periodic4ListEnd; myBuilder ()._periodic4List.erase (i++)) { _periodic4Map [elementKey_t ( (*i)->myvertex (0)->ident (), (*i)->myvertex (1)->ident (), - (*i)->myvertex (3)->ident (), -((*i)->myvertex (4)->ident ())-1)] = (*i) ; + (*i)->myvertex (3)->ident (), -((*i)->myvertex (4)->ident ())-1)] = (*i); } } { - typedef BuilderIF :: hexalist_t :: iterator iterator; - const iterator hexaListEnd = myBuilder ()._hexaList.end () ; - for ( iterator i = myBuilder ()._hexaList.begin () ; i != hexaListEnd ; myBuilder ()._hexaList.erase (i++)) + typedef BuilderIF::hexalist_t::iterator iterator; + const iterator hexaListEnd = myBuilder ()._hexaList.end (); + for ( iterator i = myBuilder ()._hexaList.begin (); i != hexaListEnd; myBuilder ()._hexaList.erase (i++)) _hexaMap [elementKey_t ( (*i)->myvertex (0)->ident (), (*i)->myvertex (1)->ident (), - (*i)->myvertex (3)->ident (), (*i)->myvertex (4)->ident ())] = (*i) ; + (*i)->myvertex (3)->ident (), (*i)->myvertex (4)->ident ())] = (*i); } _initialized = true; - return ; + return; } -MacroGridBuilder :: ~MacroGridBuilder () +MacroGridBuilder::~MacroGridBuilder () { // _finalized is true if the method was called in inherited classes if(!_finalized) finalize(); } -void MacroGridBuilder :: -tetraMapToList( elementMap_t& elementMap, list< tetra_GEO* >& elemList, const bool setIndex ) +void MacroGridBuilder:: +tetraMapToList( elementMap_t& elementMap, std::list< tetra_GEO* >& elemList, const bool setIndex ) { elementMapToList( elementMap, elemList, setIndex ); } -void MacroGridBuilder :: -hexaMapToList( elementMap_t& elementMap, list< hexa_GEO* >& elemList, const bool setIndex ) +void MacroGridBuilder:: +hexaMapToList( elementMap_t& elementMap, std::list< hexa_GEO* >& elemList, const bool setIndex ) { elementMapToList( elementMap, elemList, setIndex ); } -template <class elem_GEO> -void MacroGridBuilder :: -elementMapToList( elementMap_t& elementMap, list< elem_GEO* >& elemList, const bool setIndex ) +template<class elem_GEO> +void MacroGridBuilder:: +elementMapToList( elementMap_t& elementMap, std::list< elem_GEO* >& elemList, const bool setIndex ) { { // sort by element numbering which is unique for macro elements - typedef std::map< int, elem_GEO* > elemmap_t ; + typedef std::map< int, elem_GEO* > elemmap_t; elemmap_t elemMap; { - typedef typename elementMap_t :: iterator iterator ; + typedef typename elementMap_t::iterator iterator; const iterator elementMapEnd = elementMap.end(); - for (iterator i = elementMap.begin () ; - i != elementMapEnd ; elementMap.erase (i++) ) + for (iterator i = elementMap.begin (); + i != elementMapEnd; elementMap.erase (i++) ) { elem_GEO* elem = (elem_GEO *)(*i).second; // if ldbVertexIndex still needs to be set (in case of initial read) @@ -832,9 +831,9 @@ elementMapToList( elementMap_t& elementMap, list< elem_GEO* >& elemList, const b } { int elemCount = 0; - typedef typename elemmap_t :: iterator iterator ; + typedef typename elemmap_t::iterator iterator; const iterator iend = elemMap.end(); - for ( iterator i = elemMap.begin () ; i != iend; ++ i, ++elemCount ) + for ( iterator i = elemMap.begin (); i != iend; ++ i, ++elemCount ) { elem_GEO* elem = (elem_GEO *)(*i).second; // make sure that the insertion order @@ -848,7 +847,7 @@ elementMapToList( elementMap_t& elementMap, list< elem_GEO* >& elemList, const b } // clean the map tables -void MacroGridBuilder :: finalize () +void MacroGridBuilder::finalize () { assert(_initialized); @@ -859,62 +858,62 @@ void MacroGridBuilder :: finalize () tetraMapToList( _tetraMap, myBuilder()._tetraList, true ); { - typedef elementMap_t :: iterator iterator ; - const iterator periodic3MapEnd = _periodic3Map.end () ; - for (elementMap_t :: iterator i = _periodic3Map.begin () ; i != periodic3MapEnd ; _periodic3Map.erase (i++)) - myBuilder ()._periodic3List.push_back ((periodic3_GEO *)(*i).second) ; + typedef elementMap_t::iterator iterator; + const iterator periodic3MapEnd = _periodic3Map.end (); + for (elementMap_t::iterator i = _periodic3Map.begin (); i != periodic3MapEnd; _periodic3Map.erase (i++)) + myBuilder ()._periodic3List.push_back ((periodic3_GEO *)(*i).second); } { - typedef elementMap_t :: iterator iterator ; - const iterator periodic4MapEnd = _periodic4Map.end () ; - for (elementMap_t :: iterator i = _periodic4Map.begin () ; i != periodic4MapEnd ; _periodic4Map.erase (i++)) - myBuilder ()._periodic4List.push_back ((periodic4_GEO *)(*i).second) ; + typedef elementMap_t::iterator iterator; + const iterator periodic4MapEnd = _periodic4Map.end (); + for (elementMap_t::iterator i = _periodic4Map.begin (); i != periodic4MapEnd; _periodic4Map.erase (i++)) + myBuilder ()._periodic4List.push_back ((periodic4_GEO *)(*i).second); } { - typedef faceMap_t :: iterator iterator ; - const iterator hbnd4MapEnd = _hbnd4Map.end () ; - for (faceMap_t :: iterator i = _hbnd4Map.begin () ; i != hbnd4MapEnd ; ) + typedef faceMap_t::iterator iterator; + const iterator hbnd4MapEnd = _hbnd4Map.end (); + for (faceMap_t::iterator i = _hbnd4Map.begin (); i != hbnd4MapEnd; ) { if (((hbndseg4_GEO *)(*i).second)->myhface4 (0)->ref == 1) { - delete (hbndseg4_GEO *)(*i).second ; - _hbnd4Map.erase (i++) ; + delete (hbndseg4_GEO *)(*i).second; + _hbnd4Map.erase (i++); } else { - myBuilder ()._hbndseg4List.push_back ((hbndseg4_GEO *)(*i ++).second) ; + myBuilder ()._hbndseg4List.push_back ((hbndseg4_GEO *)(*i ++).second); } } } { - typedef faceMap_t :: iterator iterator; - const iterator hbnd3MapEnd = _hbnd3Map.end () ; - for (faceMap_t :: iterator i = _hbnd3Map.begin () ; i != hbnd3MapEnd ; ) + typedef faceMap_t::iterator iterator; + const iterator hbnd3MapEnd = _hbnd3Map.end (); + for (faceMap_t::iterator i = _hbnd3Map.begin (); i != hbnd3MapEnd; ) { if (((hbndseg3_GEO *)(*i).second)->myhface3 (0)->ref == 1) { - delete (hbndseg3_GEO *)(*i).second ; - _hbnd3Map.erase (i++) ; + delete (hbndseg3_GEO *)(*i).second; + _hbnd3Map.erase (i++); } else { - myBuilder ()._hbndseg3List.push_back ((hbndseg3_GEO *)(*i ++).second) ; + myBuilder ()._hbndseg3List.push_back ((hbndseg3_GEO *)(*i ++).second); } } } { - typedef hbnd4intMap_t :: iterator iterator; - const iterator hbnd4IntEnd = _hbnd4Int.end () ; - for (hbnd4intMap_t :: iterator i = _hbnd4Int.begin () ; i != hbnd4IntEnd ; ++i) + typedef hbnd4intMap_t::iterator iterator; + const iterator hbnd4IntEnd = _hbnd4Int.end (); + for (hbnd4intMap_t::iterator i = _hbnd4Int.begin (); i != hbnd4IntEnd; ++i) { const Hbnd4IntStorage & p = * ((*i).second); if (p.first()->ref == 1) { hbndseg4_GEO * hb4 = myBuilder ().insert_hbnd4 (p.first(), p.second(), - Gitter :: hbndseg_STI :: closure) ; - myBuilder ()._hbndseg4List.push_back (hb4) ; + Gitter::hbndseg_STI::closure); + myBuilder ()._hbndseg4List.push_back (hb4); } delete (*i).second; } @@ -922,232 +921,230 @@ void MacroGridBuilder :: finalize () // here the internal boundary elements are created { - typedef hbnd3intMap_t :: iterator iterator ; - const iterator hbnd3IntEnd = _hbnd3Int.end () ; - for (hbnd3intMap_t :: iterator i = _hbnd3Int.begin () ; i != hbnd3IntEnd ; ++i) + typedef hbnd3intMap_t::iterator iterator; + const iterator hbnd3IntEnd = _hbnd3Int.end (); + for (hbnd3intMap_t::iterator i = _hbnd3Int.begin (); i != hbnd3IntEnd; ++i) { const Hbnd3IntStorage & p = * ((*i).second); if (p.first()->ref == 1) { hbndseg3_GEO * hb3 = - myBuilder ().insert_hbnd3 (p.first(),p.second(), Gitter :: hbndseg_STI :: closure) ; - myBuilder ()._hbndseg3List.push_back (hb3) ; + myBuilder ().insert_hbnd3 (p.first(),p.second(), Gitter::hbndseg_STI::closure); + myBuilder ()._hbndseg3List.push_back (hb3); } delete (*i).second; } } { - typedef faceMap_t :: iterator iterator; - const iterator face4MapEnd = _face4Map.end () ; - for (faceMap_t :: iterator i = _face4Map.begin () ; i != face4MapEnd ; ) + typedef faceMap_t::iterator iterator; + const iterator face4MapEnd = _face4Map.end (); + for (faceMap_t::iterator i = _face4Map.begin (); i != face4MapEnd; ) if (!((hface4_GEO *)(*i).second)->ref) { - delete (hface4_GEO *)(*i).second ; - _face4Map.erase (i++) ; + delete (hface4_GEO *)(*i).second; + _face4Map.erase (i++); } else { - assert (((hface4_GEO *)(*i).second)->ref == 2) ; - myBuilder ()._hface4List.push_back ((hface4_GEO *)(*i ++).second ) ; + assert (((hface4_GEO *)(*i).second)->ref == 2); + myBuilder ()._hface4List.push_back ((hface4_GEO *)(*i ++).second ); } } { - typedef faceMap_t :: iterator iterator ; - const iterator face3MapEnd = _face3Map.end () ; - for (faceMap_t :: iterator i = _face3Map.begin () ; i != face3MapEnd ; ) + typedef faceMap_t::iterator iterator; + const iterator face3MapEnd = _face3Map.end (); + for (faceMap_t::iterator i = _face3Map.begin (); i != face3MapEnd; ) { if (!((hface3_GEO *)(*i).second)->ref) { - delete (hface3_GEO *)(*i).second ; - _face3Map.erase (i++) ; + delete (hface3_GEO *)(*i).second; + _face3Map.erase (i++); } else { - assert (((hface3_GEO *)(*i).second)->ref == 2) ; - myBuilder ()._hface3List.push_back ((hface3_GEO *)(*i ++).second ) ; + assert (((hface3_GEO *)(*i).second)->ref == 2); + myBuilder ()._hface3List.push_back ((hface3_GEO *)(*i ++).second ); } } } { - typedef edgeMap_t :: iterator iterator; - const iterator edgeMapEnd = _edgeMap.end () ; - for (edgeMap_t :: iterator i = _edgeMap.begin () ; i != edgeMapEnd ; ) + typedef edgeMap_t::iterator iterator; + const iterator edgeMapEnd = _edgeMap.end (); + for (edgeMap_t::iterator i = _edgeMap.begin (); i != edgeMapEnd; ) { if (!(*i).second->ref) { - delete (*i).second ; - _edgeMap.erase (i++) ; + delete (*i).second; + _edgeMap.erase (i++); } else { - assert ((*i).second->ref >= 1) ; - myBuilder ()._hedge1List.push_back ((*i ++).second) ; + assert ((*i).second->ref >= 1); + myBuilder ()._hedge1List.push_back ((*i ++).second); } } } { - typedef vertexMap_t :: iterator iterator; - const iterator vertexMapEnd = _vertexMap.end () ; - for (vertexMap_t :: iterator i = _vertexMap.begin () ; i != vertexMapEnd ; ) + typedef vertexMap_t::iterator iterator; + const iterator vertexMapEnd = _vertexMap.end (); + for (vertexMap_t::iterator i = _vertexMap.begin (); i != vertexMapEnd; ) { if (!(*i).second->ref) { - delete (*i).second ; - _vertexMap.erase (i++) ; + delete (*i).second; + _vertexMap.erase (i++); } else { - assert ((*i).second->ref >= 2) ; - myBuilder ()._vertexList.push_back ((*i ++).second) ; + assert ((*i).second->ref >= 2); + myBuilder ()._vertexList.push_back ((*i ++).second); } } } _finalized = true; - return ; + return; } -void MacroGridBuilder :: inflateMacroGrid (istream & rawInput) { - const int start = clock () ; +void MacroGridBuilder::inflateMacroGrid ( std::istream &rawInput ) +{ + const int start = clock (); { - int nv = 0 ; - rawInput >> nv ; - for (int i = 0 ; i < nv ; i ++ ) { - int id ; - double x, y, z ; - rawInput >> id >> x >> y >> z ; - InsertUniqueVertex (x,y,z,id) ; + int nv = 0; + rawInput >> nv; + for (int i = 0; i < nv; i ++ ) { + int id; + double x, y, z; + rawInput >> id >> x >> y >> z; + InsertUniqueVertex (x,y,z,id); } } { - int ne = 0 ; - rawInput >> ne ; - for (int i = 0 ; i < ne ; i ++ ) + int ne = 0; + rawInput >> ne; + for (int i = 0; i < ne; i ++ ) { - int elementType ; - rawInput >> elementType ; + int elementType; + rawInput >> elementType; switch (elementType) { case HEXA_RAW : { - int v [8] ; - rawInput >> v [0] >> v [1] >> v [2] >> v [3] >> v [4] >> v [5] >> v [6] >> v [7] ; - InsertUniqueHexa (v) ; + int v [8]; + rawInput >> v [0] >> v [1] >> v [2] >> v [3] >> v [4] >> v [5] >> v [6] >> v [7]; + InsertUniqueHexa (v); } - break ; + break; case TETRA_RAW : { - int v [4] ; - rawInput >> v [0] >> v [1] >> v [2] >> v [3] ; - int orientation = i%2 ; - InsertUniqueTetra (v, orientation ) ; + int v [4]; + rawInput >> v [0] >> v [1] >> v [2] >> v [3]; + int orientation = i%2; + InsertUniqueTetra (v, orientation ); } - break ; + break; case PERIODIC3_RAW : { - int v [6] ; - int bt ; - rawInput >> v [0] >> v [1] >> v [2] >> v [3] >> v [4] >> v [5] >> bt ; - if( ! ( Gitter :: hbndseg_STI :: bndRangeCheck(bt) ) ) + int v [6]; + int bt; + rawInput >> v [0] >> v [1] >> v [2] >> v [3] >> v [4] >> v [5] >> bt; + if( !Gitter::hbndseg_STI::bndRangeCheck( bt ) ) { - cerr << "**ERROR (FATAL): boundary id = " << bt << " out of range! Valid are: " << Gitter :: hbndseg_STI :: validRanges() << endl ; - exit(1); + std::cerr << "ERROR (fatal): Boundary id = " << bt << " out of range (valid are " << Gitter::hbndseg_STI::validRanges() << ")." << std::endl; + abort(); } - Gitter :: hbndseg :: bnd_t btAbs = (Gitter :: hbndseg :: bnd_t)(std::abs(bt)); - Gitter :: hbndseg :: bnd_t bndId[ 2 ] = { btAbs, btAbs }; - InsertUniquePeriodic (v, bndId ) ; + Gitter::hbndseg::bnd_t btAbs = (Gitter::hbndseg::bnd_t)(std::abs(bt)); + Gitter::hbndseg::bnd_t bndId[ 2 ] = { btAbs, btAbs }; + InsertUniquePeriodic (v, bndId ); } - break ; - case PERIODIC4_RAW : + break; + + case PERIODIC4_RAW: { - int v [8] ; - int bt ; - rawInput >> v [0] >> v [1] >> v [2] >> v [3] >> v [4] >> v [5] >> v [6] >> v [7] >> bt ; - if( ! ( Gitter :: hbndseg_STI :: bndRangeCheck(bt) ) ) + int v [8]; + int bt; + rawInput >> v [0] >> v [1] >> v [2] >> v [3] >> v [4] >> v [5] >> v [6] >> v [7] >> bt; + if( !Gitter::hbndseg_STI::bndRangeCheck( bt ) ) { - cerr << "**ERROR (FATAL): boundary id = " << bt << " out of range! Valid are: " << Gitter :: hbndseg_STI :: validRanges() << endl ; - exit(1); + std::cerr << "ERROR (fatal): Boundary id = " << bt << " out of range (valid are " << Gitter::hbndseg_STI::validRanges() << ")." << std::endl; + abort(); } - Gitter :: hbndseg :: bnd_t btAbs = (Gitter :: hbndseg :: bnd_t)(std::abs(bt)); - Gitter :: hbndseg :: bnd_t bndId[ 2 ] = { btAbs, btAbs }; - InsertUniquePeriodic (v, bndId ) ; + Gitter::hbndseg::bnd_t btAbs = (Gitter::hbndseg::bnd_t)(std::abs(bt)); + Gitter::hbndseg::bnd_t bndId[ 2 ] = { btAbs, btAbs }; + InsertUniquePeriodic (v, bndId ); } - break ; - default : - cerr << "**ERROR (FATAL): unknown ElementID in Rawformat File [" - << elementType << "] in " << __FILE__ << " " << __LINE__ << " ... Exiting. " << endl ; - exit (1) ; - break ; + break; + + default: + std::cerr << "ERROR (fatal): Unknown ElementID in Rawformat File [" << elementType << "]." << std::endl; + abort(); + break; } } } { - int nb = 0 ; - rawInput >> nb ; - for (int i = 0 ; i < nb ; i ++) + int nb = 0; + rawInput >> nb; + for (int i = 0; i < nb; i ++) { - int polygonLen ; - rawInput >> polygonLen ; + int polygonLen; + rawInput >> polygonLen; if (polygonLen == 4) { - int bt, v [4] ; - rawInput >> v [0] >> v [1] >> v [2] >> v [3] >> bt ; - if( ! ( Gitter :: hbndseg_STI :: bndRangeCheck(bt) ) ) + int bt, v [4]; + rawInput >> v [0] >> v [1] >> v [2] >> v [3] >> bt; + if( ! ( Gitter::hbndseg_STI::bndRangeCheck(bt) ) ) { - cerr << "**ERROR (FATAL): boundary id = " << bt << " out of range! Valid are: " << Gitter :: hbndseg_STI :: validRanges() << endl ; - exit(1); + std::cerr << "ERROR (fatal): Boundary id = " << bt << " out of range (valid are " << Gitter::hbndseg_STI::validRanges() << ")." << std::endl; + abort(); } - InsertUniqueHbnd4 (v,(Gitter :: hbndseg :: bnd_t)(std::abs(bt))) ; + InsertUniqueHbnd4 (v,(Gitter::hbndseg::bnd_t)(std::abs(bt))); } else if (polygonLen == 3) { - int bt, v [3] ; - rawInput >> v [0] >> v [1] >> v [2] >> bt ; - if( ! ( Gitter :: hbndseg_STI :: bndRangeCheck(bt) ) ) + int bt, v [3]; + rawInput >> v [0] >> v [1] >> v [2] >> bt; + if( ! ( Gitter::hbndseg_STI::bndRangeCheck(bt) ) ) { - cerr << "**ERROR (FATAL): boundary id = " << bt << " out of range! Valid are: " << Gitter :: hbndseg_STI :: validRanges() << endl ; - exit(1); + std::cerr << "ERROR (fatal): Boundary id = " << bt << " out of range (valid are " << Gitter::hbndseg_STI::validRanges() << ")." << std::endl; + abort(); } - InsertUniqueHbnd3 (v,(Gitter :: hbndseg :: bnd_t)(std::abs(bt))) ; + InsertUniqueHbnd3 (v,(Gitter::hbndseg::bnd_t)(std::abs(bt))); } else { - cerr << " MacroGridBuilder :: inflateMacroGrid (istream &) ERROR (fatal): cannot" ; - cerr << " create BoundarySegments with polygon length " << polygonLen << "!" << endl ; - abort () ; + std::cerr << "ERROR (fatal): Cannot create boundary segments with polygon length " << polygonLen << "." << std::endl; + abort(); } } } - if (debugOption (3)) { - cout << "**INFO MacroGridBuilder :: inflateMacroGrid () used: " ; - cout << (float)(clock () - start)/(float)(CLOCKS_PER_SEC) << " sec." << endl ; - } - return ; + if( debugOption( 3 ) ) + std::cout << "INFO: MacroGridBuilder::inflateMacroGrid() used " << (float)(clock () - start)/(float)(CLOCKS_PER_SEC) << " s." << std::endl; } -void Gitter :: Geometric :: BuilderIF :: macrogridBuilder (istream & in) +void Gitter::Geometric::BuilderIF::macrogridBuilder ( std::istream &in ) { macrogridBuilderImpl( in ); } -void Gitter :: Geometric :: BuilderIF :: macrogridBuilder (ObjectStream & in) +void Gitter::Geometric::BuilderIF::macrogridBuilder (ObjectStream & in) { // macrogridBuilderImpl( in ); - cerr << "BuilderIF :: macrogridBuilder not implemented for ObjectStream: " << __FILE__ << " " << __LINE__ << endl ; + std::cerr << "ERROR (fatal): BuilderIF::macrogridBuilder not implemented for ObjectStream." << std::endl; abort(); } -template <class istream_t> -void Gitter :: Geometric :: BuilderIF :: macrogridBuilderImpl (istream_t & in) +template<class istream_t> +void Gitter::Geometric::BuilderIF::macrogridBuilderImpl (istream_t & in) { - strstream_t raw ; + std::stringstream raw; // set scientific mode and high precision - raw << scientific ; - raw.precision( ALUGridExternalParameters :: precision() ); + raw << std::scientific; + raw.precision( ALUGridExternalParameters::precision() ); - MacroGridBuilder mm (*this) ; + MacroGridBuilder mm (*this); - string firstline ; - getline( in, firstline ); + std::string firstline; + std::getline( in, firstline ); // check first character if ( firstline[ 0 ] == char('!')) @@ -1155,35 +1152,26 @@ void Gitter :: Geometric :: BuilderIF :: macrogridBuilderImpl (istream_t & in) // Das erste Wort nach dem Kommentar steht jetzt in str. // Alle weiteren k"onnen noch aus is gelesen werden, das // array str ist so lang, wie die gesamte Zeile in 'buf'. - if ( firstline.find( "Tetrahedra" ) != string :: npos || - firstline.find( "Tetraeder" ) != string :: npos ) + if( (firstline.find( "Tetrahedra" ) != std::string::npos) || (firstline.find( "Tetraeder" ) != std::string::npos) ) { // Versuchen wir's mal mit Tetraedern - MacroGridBuilder :: generateRawTetraImage (in,raw) ; + MacroGridBuilder::generateRawTetraImage (in,raw); } - else if - ( firstline.find( "Hexahedra" ) != string :: npos || - firstline.find( "Hexaeder" ) != string :: npos ) + else if( (firstline.find( "Hexahedra" ) != std::string::npos) || (firstline.find( "Hexaeder" ) != std::string::npos) ) { // oder andernfalls mit Hexaedern. - MacroGridBuilder :: generateRawHexaImage (in,raw) ; + MacroGridBuilder::generateRawHexaImage (in,raw); } else { - cerr << "**WARNING (IGNORED) Unknown comment to file format: " << firstline ; - cerr << " In : " << __FILE__ << " " << __LINE__ << endl ; - return ; + std::cerr << "WARNING (ignored): Unknown comment to file format (" << firstline << ")." << std::endl; + return; } - } - else + } + else { - cerr << "**WARNING (IGNORED) No identifier for file format found!\n" ; - cerr << " -> Try to read as hexa mesh." << endl ; - MacroGridBuilder :: generateRawHexaImage (in,raw) ; + std::cerr << "WARNING (ignored) No identifier for file format found. Trying to read as hexahedral grid." << std::endl; + MacroGridBuilder::generateRawHexaImage( in,raw ); } - mm.inflateMacroGrid (raw) ; - return ; + mm.inflateMacroGrid( raw ); } - - - diff --git a/dune/alugrid/src/serial/gitter_mgb.h b/dune/alugrid/src/serial/gitter_mgb.h index 38197f6be137e55cfb4c54b31dd204cfa75d834e..30af6cecc4ca5d12f4e332533964cde91c50a6d0 100644 --- a/dune/alugrid/src/serial/gitter_mgb.h +++ b/dune/alugrid/src/serial/gitter_mgb.h @@ -5,22 +5,31 @@ #ifndef GITTER_MGB_H_INCLUDED #define GITTER_MGB_H_INCLUDED +#include <list> +#include <map> +#include <utility> + #include "key.h" #include "gitter_sti.h" #include "ghost_info.h" -template < class RandomAccessIterator > inline int cyclicReorder (RandomAccessIterator begin, RandomAccessIterator end) { - RandomAccessIterator middle = min_element (begin,end) ; - int pos = middle == begin ? 0 : (rotate (begin,middle,end), (end - middle)) ; - if (*(begin + 1) < *(end - 1)) return pos ; - else { - reverse (begin,end) ; - rotate (begin,end - 1,end) ; - return - pos - 1 ; +template< class RandomAccessIterator > inline int cyclicReorder (RandomAccessIterator begin, RandomAccessIterator end) +{ + RandomAccessIterator middle = std::min_element( begin,end ); + int pos = (middle == begin ? 0 : (std::rotate( begin, middle, end ), end - middle)); + if( *(begin + 1) < *(end - 1) ) + return pos; + else + { + std::reverse( begin, end ); + std::rotate( begin, end - 1, end ); + return -pos - 1; } } -class MacroGridBuilder : protected Gitter :: Geometric { +class MacroGridBuilder +: protected Gitter::Geometric +{ protected: // stores a hface3 and the other point needed to build a tetra @@ -108,23 +117,23 @@ class MacroGridBuilder : protected Gitter :: Geometric { }; protected : - enum ElementRawID {TETRA_RAW=4, HEXA_RAW=8, PERIODIC3_RAW=33, PERIODIC4_RAW=44} ; + enum ElementRawID {TETRA_RAW=4, HEXA_RAW=8, PERIODIC3_RAW=33, PERIODIC4_RAW=44}; protected : - typedef long vertexKey_t ; - typedef pair < int, int > edgeKey_t ; - typedef Key3 < int > faceKey_t ; - typedef Key4 < int > elementKey_t ; - - typedef map < vertexKey_t , VertexGeo *, less < vertexKey_t > > vertexMap_t ; - typedef map < edgeKey_t, hedge1_GEO *, less < edgeKey_t > > edgeMap_t ; - typedef map < faceKey_t, void *, less < faceKey_t > > faceMap_t ; - typedef map < elementKey_t, void *, less < elementKey_t > > elementMap_t ; + typedef long vertexKey_t; + typedef std::pair< int, int > edgeKey_t; + typedef Key3 < int > faceKey_t; + typedef Key4 < int > elementKey_t; + + typedef std::map< vertexKey_t, VertexGeo * > vertexMap_t; + typedef std::map< edgeKey_t, hedge1_GEO * > edgeMap_t; + typedef std::map< faceKey_t, void * > faceMap_t; + typedef std::map< elementKey_t, void * > elementMap_t; - typedef map < faceKey_t, Hbnd3IntStorage* , less < faceKey_t > > hbnd3intMap_t ; - typedef map < faceKey_t, Hbnd4IntStorage* , less < faceKey_t > > hbnd4intMap_t ; + typedef std::map< faceKey_t, Hbnd3IntStorage* > hbnd3intMap_t; + typedef std::map< faceKey_t, Hbnd4IntStorage* > hbnd4intMap_t; - vertexMap_t _vertexMap ; - edgeMap_t _edgeMap ; + vertexMap_t _vertexMap; + edgeMap_t _edgeMap; faceMap_t _face4Map, _face3Map, _hbnd3Map, _hbnd4Map; @@ -132,77 +141,77 @@ class MacroGridBuilder : protected Gitter :: Geometric { hbnd3intMap_t _hbnd3Int; hbnd4intMap_t _hbnd4Int; - elementMap_t _hexaMap, _tetraMap, _periodic3Map, _periodic4Map ; + elementMap_t _hexaMap, _tetraMap, _periodic3Map, _periodic4Map; - inline BuilderIF & myBuilder () ; - inline const BuilderIF & myBuilder () const ; - void removeElement (const elementKey_t &, const bool ) ; + inline BuilderIF & myBuilder (); + inline const BuilderIF & myBuilder () const; + void removeElement (const elementKey_t &, const bool ); public : - virtual pair < VertexGeo *, bool > InsertUniqueVertex (double, double, double, int) ; - virtual pair < hedge1_GEO *, bool > InsertUniqueHedge (int,int) ; - virtual pair < hedge1_GEO *, bool > InsertUniqueHedge1 (int a, int b) { return InsertUniqueHedge( a, b); } - virtual pair < hface3_GEO *, bool > InsertUniqueHface3 (int (&v)[3]) { return InsertUniqueHface( v ); } - virtual pair < hface4_GEO *, bool > InsertUniqueHface4 (int (&v)[4]) { return InsertUniqueHface( v ); } - virtual pair < hface3_GEO *, bool > InsertUniqueHface (int (&)[3]) ; - virtual pair < hface4_GEO *, bool > InsertUniqueHface (int (&)[4]) ; - - virtual pair < tetra_GEO *, bool > InsertUniqueTetra (int (&v)[4] ) { return InsertUniqueTetra( v, 0 ); } - virtual pair < tetra_GEO *, bool > InsertUniqueTetra (int (&)[4], int) ; - virtual pair < hexa_GEO *, bool > InsertUniqueHexa (int (&)[8]) ; - - virtual pair < periodic3_GEO *, bool > InsertUniquePeriodic (int (&)[6], const Gitter :: hbndseg :: bnd_t (&)[2]) ; - virtual pair < periodic4_GEO *, bool > InsertUniquePeriodic (int (&)[8], const Gitter :: hbndseg :: bnd_t (&)[2]) ; - virtual pair < periodic3_GEO *, bool > - InsertUniquePeriodic3 (int (&v)[6], const Gitter :: hbndseg :: bnd_t (&bnd)[2]) { return InsertUniquePeriodic( v, bnd ); } - virtual pair < periodic4_GEO *, bool > - InsertUniquePeriodic4 (int (&v)[8], const Gitter :: hbndseg :: bnd_t (&bnd)[2]) { return InsertUniquePeriodic( v, bnd ); } + virtual std::pair< VertexGeo *, bool > InsertUniqueVertex (double, double, double, int); + virtual std::pair< hedge1_GEO *, bool > InsertUniqueHedge (int,int); + virtual std::pair< hedge1_GEO *, bool > InsertUniqueHedge1 (int a, int b) { return InsertUniqueHedge( a, b); } + virtual std::pair< hface3_GEO *, bool > InsertUniqueHface3 (int (&v)[3]) { return InsertUniqueHface( v ); } + virtual std::pair< hface4_GEO *, bool > InsertUniqueHface4 (int (&v)[4]) { return InsertUniqueHface( v ); } + virtual std::pair< hface3_GEO *, bool > InsertUniqueHface (int (&)[3]); + virtual std::pair< hface4_GEO *, bool > InsertUniqueHface (int (&)[4]); + + virtual std::pair< tetra_GEO *, bool > InsertUniqueTetra (int (&v)[4] ) { return InsertUniqueTetra( v, 0 ); } + virtual std::pair< tetra_GEO *, bool > InsertUniqueTetra (int (&)[4], int); + virtual std::pair< hexa_GEO *, bool > InsertUniqueHexa (int (&)[8]); + + virtual std::pair< periodic3_GEO *, bool > InsertUniquePeriodic (int (&)[6], const Gitter::hbndseg::bnd_t (&)[2]); + virtual std::pair< periodic4_GEO *, bool > InsertUniquePeriodic (int (&)[8], const Gitter::hbndseg::bnd_t (&)[2]); + virtual std::pair< periodic3_GEO *, bool > + InsertUniquePeriodic3 (int (&v)[6], const Gitter::hbndseg::bnd_t (&bnd)[2]) { return InsertUniquePeriodic( v, bnd ); } + virtual std::pair< periodic4_GEO *, bool > + InsertUniquePeriodic4 (int (&v)[8], const Gitter::hbndseg::bnd_t (&bnd)[2]) { return InsertUniquePeriodic( v, bnd ); } // old version setting default boundary ids - pair < periodic3_GEO *, bool > InsertUniquePeriodic3 (int (&v)[6] ) + std::pair< periodic3_GEO *, bool > InsertUniquePeriodic3 (int (&v)[6] ) { - Gitter :: hbndseg :: bnd_t bnd[ 2 ] = - { Gitter :: hbndseg :: periodic, Gitter :: hbndseg :: periodic }; + Gitter::hbndseg::bnd_t bnd[ 2 ] = + { Gitter::hbndseg::periodic, Gitter::hbndseg::periodic }; return InsertUniquePeriodic( v, bnd ); } // old version setting default boundary ids - pair < periodic4_GEO *, bool > InsertUniquePeriodic4 (int (&v)[8] ) + std::pair< periodic4_GEO *, bool > InsertUniquePeriodic4 (int (&v)[8] ) { - Gitter :: hbndseg :: bnd_t bnd[ 2 ] = - { Gitter :: hbndseg :: periodic, Gitter :: hbndseg :: periodic }; + Gitter::hbndseg::bnd_t bnd[ 2 ] = + { Gitter::hbndseg::periodic, Gitter::hbndseg::periodic }; return InsertUniquePeriodic( v, bnd ); } - virtual bool InsertUniqueHbnd3 (int (&)[3], Gitter :: hbndseg :: bnd_t, int) ; - virtual bool InsertUniqueHbnd4 (int (&)[4], Gitter :: hbndseg :: bnd_t, int) ; + virtual bool InsertUniqueHbnd3 (int (&)[3], Gitter::hbndseg::bnd_t, int); + virtual bool InsertUniqueHbnd4 (int (&)[4], Gitter::hbndseg::bnd_t, int); - virtual bool InsertUniqueHbnd3 (int (&v)[3], Gitter :: hbndseg :: bnd_t bt ) + virtual bool InsertUniqueHbnd3 (int (&v)[3], Gitter::hbndseg::bnd_t bt ) { // ldbVertexIndex = -1 return InsertUniqueHbnd3( v, bt, int(-1) ); } - virtual bool InsertUniqueHbnd4 (int (&v)[4], Gitter :: hbndseg :: bnd_t bt) + virtual bool InsertUniqueHbnd4 (int (&v)[4], Gitter::hbndseg::bnd_t bt) { // ldbVertexIndex = -1 return InsertUniqueHbnd4( v, bt, int(-1) ); } public : - static bool debugOption (int) ; + static bool debugOption (int); - static void generateRawHexaImage (istream &, ostream &) ; - static void generateRawHexaImage (ObjectStream&, ostream &) ; + static void generateRawHexaImage ( std::istream &, std::ostream & ); + static void generateRawHexaImage ( ObjectStream&, std::ostream & ); - static void generateRawTetraImage (istream &, ostream &) ; - static void generateRawTetraImage (ObjectStream&, ostream &) ; + static void generateRawTetraImage ( std::istream &, std::ostream & ); + static void generateRawTetraImage ( ObjectStream &, std::ostream & ); - static void cubeHexaGrid (int, ostream &) ; - MacroGridBuilder (BuilderIF &, const bool init = true) ; + static void cubeHexaGrid ( int, std::ostream & ); + MacroGridBuilder (BuilderIF &, const bool init = true); // deprecated - MacroGridBuilder (BuilderIF &, ProjectVertex* ) ; - virtual ~MacroGridBuilder () ; - void inflateMacroGrid (istream &) ; - void backupMacroGrid (ostream &) ; + MacroGridBuilder (BuilderIF &, ProjectVertex* ); + virtual ~MacroGridBuilder (); + void inflateMacroGrid ( std::istream & ); + void backupMacroGrid ( std::ostream & ); // former constructor void initialize (); @@ -213,23 +222,22 @@ class MacroGridBuilder : protected Gitter :: Geometric { bool _finalized; // generate raw image of macro grid - template <class istream_t> - static void generateRawImage (istream_t &, ostream &, - const ElementRawID, const ElementRawID ) ; + template<class istream_t> + static void generateRawImage ( istream_t &, std::ostream &, const ElementRawID, const ElementRawID ); // insert all tetra from elemMap into tetraList - void tetraMapToList( elementMap_t& elemMap, list< tetra_GEO* >& elemList, const bool setIndex ); + void tetraMapToList( elementMap_t& elemMap, std::list< tetra_GEO* >& elemList, const bool setIndex ); // insert all hexa from elemMap into hexaList - void hexaMapToList( elementMap_t& elemMap, list< hexa_GEO* >& elemList, const bool setIndex ); + void hexaMapToList( elementMap_t& elemMap, std::list< hexa_GEO* >& elemList, const bool setIndex ); private : // insert all element from elemMap into elemList - template <class elem_GEO> - void elementMapToList( elementMap_t& elemMap, list< elem_GEO* >& elemList, const bool setIndex ); + template<class elem_GEO> + void elementMapToList( elementMap_t& elemMap, std::list< elem_GEO* >& elemList, const bool setIndex ); private: - BuilderIF & _mgb ; -} ; + BuilderIF & _mgb; +}; // @@ -240,20 +248,20 @@ class MacroGridBuilder : protected Gitter :: Geometric { // # # ## # # # ## # // # # # ###### # # # ###### // -inline Gitter :: Geometric :: BuilderIF & MacroGridBuilder :: myBuilder () { - return _mgb ; +inline Gitter::Geometric::BuilderIF & MacroGridBuilder::myBuilder () { + return _mgb; } -inline const Gitter :: Geometric :: BuilderIF & MacroGridBuilder :: myBuilder () const { - return _mgb ; +inline const Gitter::Geometric::BuilderIF & MacroGridBuilder::myBuilder () const { + return _mgb; } -inline bool MacroGridBuilder :: debugOption (int level) { - return (getenv ("VERBOSE_MGB") ? ( atoi (getenv ("VERBOSE_MGB")) > level ? true : (level == 0)) : false) ; +inline bool MacroGridBuilder::debugOption (int level) { + return (getenv ("VERBOSE_MGB") ? ( atoi (getenv ("VERBOSE_MGB")) > level ? true : (level == 0)) : false); } //- Hbnd3IntStorage -inline MacroGridBuilder :: Hbnd3IntStorage :: +inline MacroGridBuilder::Hbnd3IntStorage:: Hbnd3IntStorage( hface3_GEO * f, int tw, int ldbVertexIndex, const tetra_GEO * tetra, int fce) : _ptr(new MacroGhostInfoTetra(tetra,fce)) , _first(f) , _second(tw), _ldbVertexIndex( ldbVertexIndex ) @@ -261,7 +269,7 @@ Hbnd3IntStorage( hface3_GEO * f, int tw, int ldbVertexIndex, const tetra_GEO * t assert( _ldbVertexIndex >= 0 ); } -inline MacroGridBuilder :: Hbnd3IntStorage :: +inline MacroGridBuilder::Hbnd3IntStorage:: Hbnd3IntStorage( hface3_GEO * f, int tw, int ldbVertexIndex, MacroGhostInfoTetra *p) : _ptr(p) , _first(f) , _second(tw), _ldbVertexIndex( ldbVertexIndex ) { @@ -269,7 +277,7 @@ Hbnd3IntStorage( hface3_GEO * f, int tw, int ldbVertexIndex, MacroGhostInfoTetra assert( _ptr ); } -inline MacroGridBuilder :: Hbnd3IntStorage :: +inline MacroGridBuilder::Hbnd3IntStorage:: Hbnd3IntStorage( hface3_GEO * f, int tw, int ldbVertexIndex ) : _ptr(0), _first(f) , _second(tw), _ldbVertexIndex( ldbVertexIndex ) { @@ -278,7 +286,7 @@ Hbnd3IntStorage( hface3_GEO * f, int tw, int ldbVertexIndex ) // assert( _ldbVertexIndex >= 0 ); } -inline MacroGridBuilder :: Hbnd3IntStorage :: ~Hbnd3IntStorage () +inline MacroGridBuilder::Hbnd3IntStorage::~Hbnd3IntStorage () { if( _ptr ) { @@ -287,12 +295,12 @@ inline MacroGridBuilder :: Hbnd3IntStorage :: ~Hbnd3IntStorage () } } -inline MacroGhostInfoTetra* MacroGridBuilder :: Hbnd3IntStorage :: ghInfo () +inline MacroGhostInfoTetra* MacroGridBuilder::Hbnd3IntStorage::ghInfo () { return _ptr; } -inline MacroGhostInfoTetra* MacroGridBuilder :: Hbnd3IntStorage :: release () +inline MacroGhostInfoTetra* MacroGridBuilder::Hbnd3IntStorage::release () { MacroGhostInfoTetra* p = _ptr; _ptr = 0; @@ -300,7 +308,7 @@ inline MacroGhostInfoTetra* MacroGridBuilder :: Hbnd3IntStorage :: release () } //- Hbnd4IntStorage -inline MacroGridBuilder :: Hbnd4IntStorage :: +inline MacroGridBuilder::Hbnd4IntStorage:: Hbnd4IntStorage( hface4_GEO * f, int tw, int ldbVertexIndex, const hexa_GEO * hexa, int fce) : _ptr( new MacroGhostInfoHexa(hexa,fce) ), _first(f) , _second(tw), _ldbVertexIndex( ldbVertexIndex ) { @@ -308,7 +316,7 @@ Hbnd4IntStorage( hface4_GEO * f, int tw, int ldbVertexIndex, const hexa_GEO * he } // hface4 storage -inline MacroGridBuilder :: Hbnd4IntStorage :: +inline MacroGridBuilder::Hbnd4IntStorage:: Hbnd4IntStorage( hface4_GEO * f, int tw, int ldbVertexIndex, MacroGhostInfoHexa* p) : _ptr(p) , _first(f) , _second(tw), _ldbVertexIndex( ldbVertexIndex ) { @@ -316,7 +324,7 @@ Hbnd4IntStorage( hface4_GEO * f, int tw, int ldbVertexIndex, MacroGhostInfoHexa* assert( _ptr ); } -inline MacroGridBuilder :: Hbnd4IntStorage :: +inline MacroGridBuilder::Hbnd4IntStorage:: Hbnd4IntStorage( hface4_GEO * f, int tw, int ldbVertexIndex ) : _ptr(0) , _first(f) , _second(tw), _ldbVertexIndex( ldbVertexIndex ) { @@ -325,7 +333,7 @@ Hbnd4IntStorage( hface4_GEO * f, int tw, int ldbVertexIndex ) // assert( _ldbVertexIndex >= 0 ); } -inline MacroGridBuilder :: Hbnd4IntStorage :: ~Hbnd4IntStorage () +inline MacroGridBuilder::Hbnd4IntStorage::~Hbnd4IntStorage () { if( _ptr ) { @@ -334,12 +342,12 @@ inline MacroGridBuilder :: Hbnd4IntStorage :: ~Hbnd4IntStorage () } } -inline MacroGhostInfoHexa* MacroGridBuilder :: Hbnd4IntStorage :: ghInfo() +inline MacroGhostInfoHexa* MacroGridBuilder::Hbnd4IntStorage::ghInfo() { - return _ptr ; + return _ptr; } -inline MacroGhostInfoHexa* MacroGridBuilder :: Hbnd4IntStorage :: release() +inline MacroGhostInfoHexa* MacroGridBuilder::Hbnd4IntStorage::release() { MacroGhostInfoHexa* p = _ptr; _ptr = 0; diff --git a/lib/Makefile.am b/lib/Makefile.am index f31766442a3987d8b9f0bcecea72a9b16f19c119..cce7beaf2b564fb99f20146064067a96fe7e6c7c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -3,6 +3,7 @@ lib_LTLIBRARIES = libalugrid_serial.la libdunealugrid.la libalugrid_serial_la_SOURCES = \ $(top_srcdir)/dune/alugrid/src/serial/gitter_geo.cc \ $(top_srcdir)/dune/alugrid/src/serial/gitter_hexa_top.cc \ + $(top_srcdir)/dune/alugrid/src/serial/gitter_mgb.cc \ $(top_srcdir)/dune/alugrid/src/serial/gitter_sti.cc \ $(top_srcdir)/dune/alugrid/src/serial/gitter_tetra_top.cc \ $(top_srcdir)/dune/alugrid/src/serial/myalloc.cc