Commit 429321c4 authored by Marcel Koch's avatar Marcel Koch
Browse files

revert ginkgo cg debug output

parent 67c75637
......@@ -38,10 +38,13 @@ class DirichletHandlerBase
using vec = gko::distributed::Vector< real_t >;
using mtx = gko::distributed::Matrix< real_t, int32_t >;
DirichletHandlerBase( std::vector< int32_t > bcIndices, const vec* dir_vals, std::shared_ptr<mtx> matrix, bool doUpdate = true )
DirichletHandlerBase( std::vector< int32_t > bcIndices,
const vec* dir_vals,
std::shared_ptr< mtx > matrix,
bool doUpdate = true )
: bcIndices_( std::move( bcIndices ) )
, dir_vals_( dir_vals )
, matrix_( std::move(matrix) )
, matrix_( std::move( matrix ) )
, doUpdate_( doUpdate )
{}
......@@ -57,8 +60,8 @@ class DirichletHandlerBase
std::vector< int32_t > bcIndices_;
const vec* dir_vals_;
std::shared_ptr<mtx> matrix_;
bool doUpdate_;
std::shared_ptr< mtx > matrix_;
bool doUpdate_;
};
template < typename T >
......@@ -255,8 +258,7 @@ enum class constraints
zero_row
};
std::pair< int, int > local_range( const uint_t local_size, std::shared_ptr<gko::mpi::communicator> comm )
std::pair< int, int > local_range( const uint_t local_size, std::shared_ptr< gko::mpi::communicator > comm )
{
uint_t start = 0;
uint_t end = 0;
......@@ -316,14 +318,15 @@ class GinkgoCGSolver : public Solver< OperatorType >
auto rank = walberla::mpi::MPIManager::instance()->rank();
WALBERLA_LOG_INFO( "Rank " << rank << " -> "
<< "start solve" );
auto comm = gko::share( gko::mpi::communicator::create( walberla::mpi::MPIManager::instance()->comm() ) );
auto [start, end] = local_range( num_local_dofs, comm);
auto part = gko::share(gko::distributed::Partition<>::build_from_local_range(host_exec_, start, end, comm));
auto comm = gko::share( gko::mpi::communicator::create( walberla::mpi::MPIManager::instance()->comm() ) );
auto [start, end] = local_range( num_local_dofs, comm );
auto part = gko::share( gko::distributed::Partition<>::build_from_local_range( host_exec_, start, end, comm ) );
WALBERLA_LOG_INFO( "Rank " << rank << " -> " << "local range " << start << "-" << end );
if ( printInfo_ )
{
WALBERLA_LOG_INFO( "[Ginkgo CG] Rank " << rank << " -> local size: " << num_local_dofs << " local range: " << start
<< "-" << end );
}
if ( num_local_dofs )
{
......@@ -339,8 +342,6 @@ class GinkgoCGSolver : public Solver< OperatorType >
hyteg::petsc::applyDirichletBC( num_, bcIndices, level );
std::sort( std::begin( bcIndices ), std::end( bcIndices ) );
WALBERLA_LOG_INFO( "Rank " << rank << " -> "
<< "start vector assembly" );
hyteg::petsc::createVectorFromFunction(
x,
num_,
......@@ -355,32 +356,19 @@ class GinkgoCGSolver : public Solver< OperatorType >
level,
All );
WALBERLA_LOG_INFO( "Rank " << rank << " -> "
<< "end vector assembly" );
// Todo: add check if assembly is neccessary
const bool doAssemble = !matrix_ || reassembleMatrix_;
if ( doAssemble )
{
WALBERLA_LOG_INFO( "Rank " << rank << " -> "
<< "start matrix assembly" );
x.getStorage()->getTimingTree()->start( "Ginkgo System Matrix Assembly" );
matrix_ = gko::share( mtx::create( host_exec_, comm ) );
auto matrix_proxy =
std::make_shared< GinkgoSparseMatrixProxy< mtx > >( matrix_.get(),
gko::dim< 2 >{ num_global_dofs, num_global_dofs },
part);
matrix_ = gko::share( mtx::create( host_exec_, comm ) );
auto matrix_proxy = std::make_shared< GinkgoSparseMatrixProxy< mtx > >(
matrix_.get(), gko::dim< 2 >{ num_global_dofs, num_global_dofs }, part );
hyteg::petsc::createMatrix< OperatorType >( A, num_, num_, matrix_proxy, level, All );
matrix_proxy->finalize();
x.getStorage()->getTimingTree()->stop( "Ginkgo System Matrix Assembly" );
WALBERLA_LOG_INFO( "Rank " << rank << " -> "
<< "end matrix assembly" );
}
WALBERLA_LOG_INFO( "Rank " << rank << " -> "
<< "start dirichlet handling" );
std::unique_ptr< DirichletHandlerBase > dir_handler;
if ( constraints_type_ == constraints::penalty )
{
......@@ -398,13 +386,9 @@ class GinkgoCGSolver : public Solver< OperatorType >
dir_handler->update_matrix();
auto rhs = dir_handler->get_rhs( b_vec.get(), x_vec.get() );
auto x0 = dir_handler->get_initial_guess( x_vec.get() );
WALBERLA_LOG_INFO( "Rank " << rank << " -> "
<< "end dirichlet handling" );
if ( !solver_ || doAssemble )
{
WALBERLA_LOG_INFO( "Rank " << rank << " -> "
<< "start solver setup" );
x.getStorage()->getTimingTree()->start( "Ginkgo CG Solver Set-Up" );
auto host_matrix = matrix_;
matrix_ = mtx::create( solver_exec_ );
......@@ -412,20 +396,13 @@ class GinkgoCGSolver : public Solver< OperatorType >
//auto par_ilu = gko::factorization::Ilu< valueType, int32_t >::build().on( solver_exec_ )->generate( matrix_ );
//auto ilu = gko::preconditioner::Ilu<>::build().on( solver_exec_ )->generate( gko::share( par_ilu ) );
solver_ = solver_factory_->generate( matrix_ );
solver_ = solver_factory_->generate( matrix_ );
//solver_->set_preconditioner( gko::share( ilu ) );
x.getStorage()->getTimingTree()->stop( "Ginkgo CG Solver Set-Up" );
WALBERLA_LOG_INFO( "Rank " << rank << " -> "
<< "end solver setup" );
}
WALBERLA_LOG_INFO( "Rank " << rank << " -> "
<< "start solver apply" );
x.getStorage()->getTimingTree()->start( "Ginkgo CG Solver Apply" );
solver_->apply( gko::lend( rhs ), gko::lend( x0 ) );
x.getStorage()->getTimingTree()->stop( "Ginkgo CG Solver Apply" );
WALBERLA_LOG_INFO( "Rank " << rank << " -> "
<< "end solver apply" );
dir_handler->update_solution( x0 );
......@@ -438,16 +415,13 @@ class GinkgoCGSolver : public Solver< OperatorType >
{
auto log = gko::as< gko::log::Convergence< valueType > >( solver_->get_stop_criterion_factory()->get_loggers()[0] );
WALBERLA_LOG_INFO_ON_ROOT( "[Ginkgo CG]"
<< ( !log->has_converged() ? " NOT " : " " ) << "converged after "
<< log->get_num_iterations() << " iterations, residual norm: "
<< solver_exec_->copy_val_to_host(
gko::as <
gko::matrix::Dense< valueType >>( log->get_residual_norm() )->get_const_values() ) );
WALBERLA_LOG_INFO_ON_ROOT( "[Ginkgo CG]" << ( !log->has_converged() ? " NOT " : " " ) << "converged after "
<< log->get_num_iterations() << " iterations, residual norm: "
<< solver_exec_->copy_val_to_host(
gko::as< gko::matrix::Dense< valueType > >( log->get_residual_norm() )
->get_const_values() ) );
}
}
WALBERLA_LOG_INFO( "Rank " << rank << " -> "
<< "end solve" );
}
void setPrintInfo( bool printInfo ) { printInfo_ = printInfo; }
......
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