Commit f435737e authored by Benjamin Mann's avatar Benjamin Mann
Browse files

cleanup

parent 6aaee979
Pipeline #38813 passed with stages
in 121 minutes and 21 seconds
......@@ -210,10 +210,7 @@ adaptiveRefinement::ErrorVector solve( std::shared_ptr< PrimitiveStorage > stora
u.interpolate( pde.u_D, l_max + 1, hyteg::DirichletBoundary );
// solver
tmp.interpolate( []( const hyteg::Point3D& ) { return 1.0; }, l_min, hyteg::Inner );
// cg_iter >= n coarse grid DoFs -> "exact" solve
auto cg_iter = std::max( max_iter, uint_t( tmp.dotGlobal( tmp, l_min ) ) );
auto cg = std::make_shared< CGSolver< A_t > >( storage, l_min, l_max, cg_iter, tol / 10 );
auto cg = std::make_shared< CGSolver< A_t > >( storage, l_min, l_max, std::max( max_iter, n_dof ), tol * 1e-1 );
auto smoother = std::make_shared< GaussSeidelSmoother< A_t > >();
GeometricMultigridSolver< A_t > gmg( storage, smoother, cg, R, P, l_min, l_max, 3, 3 );
......
......@@ -63,8 +63,7 @@ void loadbalancing( std::vector< VertexData >& vtxs,
}
}
void loadbalancing( const std::vector< Point3D >& coordinates,
std::vector< VertexData >& vtxs,
void loadbalancing( std::vector< VertexData >& vtxs,
std::vector< EdgeData >& edges,
std::vector< FaceData >& faces,
std::vector< CellData >& cells,
......@@ -158,7 +157,6 @@ void loadbalancing( const std::vector< Point3D >& coordinates,
// max number of primitives on one rank for each primitive type
std::array< uint_t, ALL > n_max;
// todo: check if this is still required
// distributed id range for each primitive type
std::array< uint_t, ALL > begin, end;
for ( auto pt : VEFC )
......@@ -193,31 +191,6 @@ void loadbalancing( const std::vector< Point3D >& coordinates,
}
}
}
// todo: check if this is still required
// compute barycenter, radius and volume of all primitives
std::vector< Point3D > barycenter( n_prim[ALL] );
std::vector< real_t > radius( n_prim[ALL] );
std::vector< real_t > volume( n_prim[ALL] );
for ( auto& p : vtxs )
{
barycenter[p.getPrimitiveID().getID()] = coordinates[p.getPrimitiveID().getID()];
}
for ( auto& p : edges )
{
barycenter[p.getPrimitiveID().getID()] = Simplex1::barycenter( p.get_coordinates( coordinates ) );
}
for ( auto& p : faces )
{
barycenter[p.getPrimitiveID().getID()] = Simplex2::barycenter( p.get_coordinates( coordinates ) );
radius[p.getPrimitiveID().getID()] = Simplex2::radius( p.get_coordinates( coordinates ) );
volume[p.getPrimitiveID().getID()] = Simplex2::volume( p.get_coordinates( coordinates ) );
}
for ( auto& p : cells )
{
barycenter[p.getPrimitiveID().getID()] = Simplex3::barycenter( p.get_coordinates( coordinates ) );
radius[p.getPrimitiveID().getID()] = Simplex3::radius( p.get_coordinates( coordinates ) );
volume[p.getPrimitiveID().getID()] = Simplex3::volume( p.get_coordinates( coordinates ) );
}
// which primitives are currently assigned to a cluster
std::vector< bool > isAssigned( n_prim[ALL] + 1, false );
......@@ -385,7 +358,7 @@ void loadbalancing( const std::vector< Point3D >& coordinates,
std::vector< uint_t > initID( n_processes );
// select initial elements at random
std::iota( initID.begin(), initID.end(), id0[VOL] );
std::fill( std::next( isAssigned.begin(), id0[VOL] ), std::next( isAssigned.begin(), id0[VOL] + n_processes ), true );
std::fill( isAssigned.begin() + int64_t( id0[VOL] ), isAssigned.begin() + int64_t( id0[VOL] + n_processes ), true );
// loop over all clusters k and choose initial element maximizing potential cluster size
for ( uint_t k = 0; k < n_processes; ++k )
{
......
......@@ -276,8 +276,6 @@ real_t K_Mesh< K_Simplex >::refineRG( const ErrorVector& errors_local, real_t ra
template < class K_Simplex >
std::shared_ptr< PrimitiveStorage > K_Mesh< K_Simplex >::make_storage( const Loadbalancing& lb )
{
auto rank = uint_t( walberla::mpi::MPIManager::instance()->rank() );
// extract connectivity, geometry and boundary data and add PrimitiveIDs
std::vector< VertexData > vtxs;
std::vector< EdgeData > edges;
......@@ -286,9 +284,6 @@ std::shared_ptr< PrimitiveStorage > K_Mesh< K_Simplex >::make_storage( const Loa
std::vector< Neighborhood > nbrHood;
extract_data( vtxs, edges, faces, cells, nbrHood );
// broadcast vertices to all processes
walberla::mpi::broadcastObject( _vertices );
// apply loadbalancing
if ( lb == ROUND_ROBIN )
{
......@@ -296,26 +291,18 @@ std::shared_ptr< PrimitiveStorage > K_Mesh< K_Simplex >::make_storage( const Loa
}
if ( lb == CLUSTERING )
{
loadbalancing( _vertices, vtxs, edges, faces, cells, nbrHood, _n_processes, rank );
loadbalancing( vtxs, edges, faces, cells, nbrHood, _n_processes, uint_t( walberla::mpi::MPIManager::instance()->rank() ) );
}
// create storage
auto storage = make_localPrimitives( vtxs, edges, faces, cells );
// coordinates only required on rank 0
if ( rank != 0 )
{
_vertices.clear();
}
return storage;
return make_localPrimitives( vtxs, edges, faces, cells );
}
template < class K_Simplex >
std::shared_ptr< PrimitiveStorage > K_Mesh< K_Simplex >::make_localPrimitives( std::vector< VertexData >& vtxs,
std::vector< EdgeData >& edges,
std::vector< FaceData >& faces,
std::vector< CellData >& cells ) const
std::vector< CellData >& cells )
{
auto rank = uint_t( walberla::mpi::MPIManager::instance()->rank() );
......@@ -475,6 +462,9 @@ std::shared_ptr< PrimitiveStorage > K_Mesh< K_Simplex >::make_localPrimitives( s
// ****** create primitives ******
// broadcast vertices to all processes
walberla::mpi::broadcastObject( _vertices );
// create new vertex and add it to map
auto add_vertex = [&]( PrimitiveStorage::VertexMap& map, const VertexData& vtx ) {
// add new vertex
......@@ -689,6 +679,12 @@ std::shared_ptr< PrimitiveStorage > K_Mesh< K_Simplex >::make_localPrimitives( s
}
}
// coordinates only required on rank 0
if ( rank != 0 )
{
_vertices.clear();
}
// ****** add neighborhood information to primitives ******
// add neighbor edges to vertices
......@@ -1257,24 +1253,23 @@ std::pair< real_t, real_t > K_Mesh< K_Simplex >::mean_min_max_angle() const
{
auto mm_el = el->min_max_angle( _vertices );
mm.first += mm_el.first;
mm.second += mm_el.second;
mm.first += mm_el.first;
mm.second += mm_el.second;
}
}
mm.first /= real_t(n_elements());
mm.second /= real_t(n_elements());
mm.first /= real_t( n_elements() );
mm.second /= real_t( n_elements() );
walberla::mpi::broadcastObject( mm );
return mm;
}
template < class K_Simplex >
std::pair< real_t, real_t > K_Mesh< K_Simplex >::min_max_volume() const
{
std::pair< real_t, real_t > mm{ std::numeric_limits<real_t>::max(), 0 };
std::pair< real_t, real_t > mm{ std::numeric_limits< real_t >::max(), 0 };
if ( walberla::mpi::MPIManager::instance()->rank() == 0 )
{
......
......@@ -173,7 +173,7 @@ class K_Mesh
std::shared_ptr< PrimitiveStorage > make_localPrimitives( std::vector< VertexData >& vtxs,
std::vector< EdgeData >& edges,
std::vector< FaceData >& faces,
std::vector< CellData >& cells ) const;
std::vector< CellData >& cells );
uint_t _n_vertices;
uint_t _n_elements;
......
......@@ -137,8 +137,7 @@ void loadbalancing( std::vector< VertexData >& vtxs,
const uint_t& n_processes );
/* apply neighborhood aware loadbalancing directly on our datastructures */
void loadbalancing( const std::vector< Point3D >& coordinates,
std::vector< VertexData >& vtxs,
void loadbalancing( std::vector< VertexData >& vtxs,
std::vector< EdgeData >& edges,
std::vector< FaceData >& faces,
std::vector< CellData >& cells,
......
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