Commit 72da656f authored by Benjamin Mann's avatar Benjamin Mann
Browse files

restrict RG-refinement to rank=0

parent 243b0b08
Pipeline #36018 failed with stages
in 105 minutes and 55 seconds
...@@ -36,12 +36,14 @@ template < class K_Simplex > ...@@ -36,12 +36,14 @@ template < class K_Simplex >
K_Mesh< K_Simplex >::K_Mesh( const MeshInfo& meshInfo ) K_Mesh< K_Simplex >::K_Mesh( const MeshInfo& meshInfo )
: _setupStorage( meshInfo, uint_c( walberla::mpi::MPIManager::instance()->numProcesses() ) ) : _setupStorage( meshInfo, uint_c( walberla::mpi::MPIManager::instance()->numProcesses() ) )
{ {
if ( walberla::mpi::MPIManager::instance()->rank() == 0 )
{
// extract vertices // extract vertices
const uint_t n_vtxs = meshInfo.getVertices().size(); _n_vertices = meshInfo.getVertices().size();
_vertices.resize( n_vtxs ); _vertices.resize( _n_vertices );
// [0,1,...,n-1] // [0,1,...,n-1]
std::vector< uint_t > vtxIndices( n_vtxs ); std::vector< uint_t > vtxIndices( _n_vertices );
// convert MeshInfo::vertexID to Mesh::vertexID // convert MeshInfo::vertexID to Mesh::vertexID
std::map< MeshInfo::IDType, uint_t > conversion; std::map< MeshInfo::IDType, uint_t > conversion;
...@@ -84,6 +86,10 @@ K_Mesh< K_Simplex >::K_Mesh( const MeshInfo& meshInfo ) ...@@ -84,6 +86,10 @@ K_Mesh< K_Simplex >::K_Mesh( const MeshInfo& meshInfo )
} }
init_elements( fac.faces(), cells ); init_elements( fac.faces(), cells );
_n_elements = _T.size();
}
// todo communication (_n_vertices, _n_elements)
} }
template <> template <>
...@@ -116,6 +122,10 @@ void K_Mesh< Simplex3 >::init_elements( const std::map< Idx< 3 >, std::shared_pt ...@@ -116,6 +122,10 @@ void K_Mesh< Simplex3 >::init_elements( const std::map< Idx< 3 >, std::shared_pt
template < class K_Simplex > template < class K_Simplex >
void K_Mesh< K_Simplex >::refineRG( const std::vector< PrimitiveID >& elements_to_refine ) void K_Mesh< K_Simplex >::refineRG( const std::vector< PrimitiveID >& elements_to_refine )
{ {
auto meshInfo = hyteg::MeshInfo::emptyMeshInfo();
if ( walberla::mpi::MPIManager::instance()->rank() == 0 )
{
auto R = init_R( elements_to_refine ); auto R = init_R( elements_to_refine );
// remove green edges // remove green edges
remove_green_edges( R ); remove_green_edges( R );
...@@ -139,9 +149,15 @@ void K_Mesh< K_Simplex >::refineRG( const std::vector< PrimitiveID >& elements_t ...@@ -139,9 +149,15 @@ void K_Mesh< K_Simplex >::refineRG( const std::vector< PrimitiveID >& elements_t
// update current configuration // update current configuration
_T = U; _T = U;
_T.merge( refined ); _T.merge( refined );
_n_vertices = _vertices.size();
_n_elements = _T.size();
// update setupStorage // update setupStorage
auto meshInfo = export_meshInfo(); meshInfo = export_meshInfo();
}
// todo communication (meshInfo, _n_vertices, _n_elements)
_setupStorage = SetupPrimitiveStorage( meshInfo, uint_c( walberla::mpi::MPIManager::instance()->numProcesses() ) ); _setupStorage = SetupPrimitiveStorage( meshInfo, uint_c( walberla::mpi::MPIManager::instance()->numProcesses() ) );
} }
...@@ -468,6 +484,8 @@ std::pair< real_t, real_t > K_Mesh< K_Simplex >::min_max_angle() const ...@@ -468,6 +484,8 @@ std::pair< real_t, real_t > K_Mesh< K_Simplex >::min_max_angle() const
{ {
std::pair< real_t, real_t > mm{ 10, 0 }; std::pair< real_t, real_t > mm{ 10, 0 };
if ( walberla::mpi::MPIManager::instance()->rank() == 0 )
{
for ( auto& el : _T ) for ( auto& el : _T )
{ {
auto mm_el = el->min_max_angle( _vertices ); auto mm_el = el->min_max_angle( _vertices );
...@@ -475,6 +493,9 @@ std::pair< real_t, real_t > K_Mesh< K_Simplex >::min_max_angle() const ...@@ -475,6 +493,9 @@ std::pair< real_t, real_t > K_Mesh< K_Simplex >::min_max_angle() const
mm.first = std::min( mm.first, mm_el.first ); mm.first = std::min( mm.first, mm_el.first );
mm.second = std::max( mm.second, mm_el.second ); mm.second = std::max( mm.second, mm_el.second );
} }
}
// todo communication (mm)
return mm; return mm;
} }
...@@ -484,10 +505,15 @@ real_t K_Mesh< K_Simplex >::volume() const ...@@ -484,10 +505,15 @@ real_t K_Mesh< K_Simplex >::volume() const
{ {
real_t v_tot = 0; real_t v_tot = 0;
if ( walberla::mpi::MPIManager::instance()->rank() == 0 )
{
for ( auto& el : _T ) for ( auto& el : _T )
{ {
v_tot += el->volume( _vertices ); v_tot += el->volume( _vertices );
} }
}
// todo communication (v_tot)
return v_tot; return v_tot;
} }
......
...@@ -53,10 +53,8 @@ class K_Mesh ...@@ -53,10 +53,8 @@ class K_Mesh
// get SetupPrimitiveStorage corresponding to current refinement // get SetupPrimitiveStorage corresponding to current refinement
inline SetupPrimitiveStorage& setupStorage() { return _setupStorage; }; inline SetupPrimitiveStorage& setupStorage() { return _setupStorage; };
inline const std::vector< Point3D >& vertices() const { return _vertices; } inline uint_t n_elements() const { return _n_elements; }
inline const std::set< std::shared_ptr< K_Simplex > >& elements() const { return _T; } inline uint_t n_vtx() const { return _n_vertices; }
inline uint_t n_elements() const { return _T.size(); }
inline uint_t n_vtx() const { return _vertices.size(); }
private: private:
/* remove green edges from _T and replace the corresponding faces in R with their parents /* remove green edges from _T and replace the corresponding faces in R with their parents
...@@ -111,6 +109,8 @@ class K_Mesh ...@@ -111,6 +109,8 @@ class K_Mesh
/* generate MeshInfo corresponding to current refinement */ /* generate MeshInfo corresponding to current refinement */
hyteg::MeshInfo export_meshInfo() const; hyteg::MeshInfo export_meshInfo() const;
uint_t _n_vertices;
uint_t _n_elements;
std::vector< Point3D > _vertices; std::vector< Point3D > _vertices;
std::set< std::shared_ptr< K_Simplex > > _T; // set of elements of current refinement level std::set< std::shared_ptr< K_Simplex > > _T; // set of elements of current refinement level
SetupPrimitiveStorage _setupStorage; // primitive storage of current refinement level SetupPrimitiveStorage _setupStorage; // primitive storage of current refinement level
......
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