Commit c9b98f55 authored by Marcel Koch's avatar Marcel Koch
Browse files

update for multigrid app

parent a2d156f7
......@@ -15,6 +15,7 @@
#include <ginkgo/core/solver/multigrid.hpp>
#include <ginkgo/core/stop/iteration.hpp>
#include <ginkgo/core/stop/residual_norm.hpp>
#include <hyteg/composites/petsc/P1StokesPetsc.hpp>
#include <hyteg/composites/petsc/P2P1TaylorHoodPetsc.hpp>
#include "hyteg/ginkgo/GinkgoCommunication.hpp"
......@@ -67,6 +68,35 @@ void gatherIndices( std::vector< int32_t >& velocityIndices,
}
}
void gatherIndices( std::vector< int32_t >& velocityIndices,
std::vector< int32_t >& pressureIndices,
const PrimitiveStorage& storage,
uint_t level,
const P1StokesFunction< int32_t >& numerator )
{
for ( auto dof : FunctionIterator< vertexdof::VertexDoFFunction< int32_t > >( numerator.uvw[0], level ) )
{
velocityIndices.push_back( dof.value() );
}
for ( auto dof : FunctionIterator< vertexdof::VertexDoFFunction< int32_t > >( numerator.uvw[1], level ) )
{
velocityIndices.push_back( dof.value() );
}
if ( storage.hasGlobalCells() )
{
for ( auto dof : FunctionIterator< vertexdof::VertexDoFFunction< int32_t > >( numerator.uvw[2], level ) )
{
velocityIndices.push_back( dof.value() );
}
}
for ( auto dof : FunctionIterator< vertexdof::VertexDoFFunction< int32_t > >( numerator.p, level ) )
{
pressureIndices.push_back( dof.value() );
}
}
template < typename OperatorType >
class GinkgoBlockSolver : public Solver< OperatorType >
{
......@@ -85,11 +115,15 @@ class GinkgoBlockSolver : public Solver< OperatorType >
explicit GinkgoBlockSolver( const std::shared_ptr< PrimitiveStorage >& storage,
const uint_t& level,
std::shared_ptr< const gko::Executor > exec,
const uint_t& velocityPreconditionerType = 1,
const uint_t& pressurePreconditionerType = 1 )
const valueType absTolerance = 1e-12,
const gko::size_type maxIterations = std::numeric_limits< gko::size_type >::max(),
const uint_t& velocityPreconditionerType = 0,
const uint_t& pressurePreconditionerType = 1 )
: storage_( storage )
, solver_exec_( exec )
, host_exec_( exec->get_master() )
, absTolerance_( absTolerance )
, maxIterations_( maxIterations )
, comm_( gko::mpi::communicator::create( storage->getSplitCommunicatorByPrimitiveDistribution() ) )
, blockPreconditioner_( storage, level, level )
, num_( "numerator", storage, level, level )
......@@ -399,19 +433,20 @@ class GinkgoBlockSolver : public Solver< OperatorType >
if ( monolithic_matrix_->get_size() )
{
solver_ = gko::solver::Gmres< valueType >::build()
.with_criteria( gko::share( gko::stop::ResidualNorm<>::build()
.with_baseline( gko::stop::mode::initial_resnorm )
.with_reduction_factor( 1e-30 )
.on( solver_exec_ ) ),
gko::share( gko::stop::ResidualNorm<>::build()
.with_baseline( gko::stop::mode::absolute )
.with_reduction_factor( 1e-12 )
.on( solver_exec_ ) ),
gko::share( gko::stop::Iteration::build().with_max_iters( 15000 ).on( solver_exec_ ) ) )
.with_generated_preconditioner( block_preconditioner_ )
.on( solver_exec_ )
->generate( monolithic_matrix_ );
solver_ =
gko::solver::Gmres< valueType >::build()
.with_criteria( gko::share( gko::stop::ResidualNorm<>::build()
.with_baseline( gko::stop::mode::initial_resnorm )
.with_reduction_factor( 1e-30 )
.on( solver_exec_ ) ),
gko::share( gko::stop::ResidualNorm<>::build()
.with_baseline( gko::stop::mode::absolute )
.with_reduction_factor( absTolerance_ )
.on( solver_exec_ ) ),
gko::share( gko::stop::Iteration::build().with_max_iters( maxIterations_ ).on( solver_exec_ ) ) )
.with_generated_preconditioner( block_preconditioner_ )
.on( solver_exec_ )
->generate( monolithic_matrix_ );
}
}
......@@ -420,6 +455,9 @@ class GinkgoBlockSolver : public Solver< OperatorType >
std::shared_ptr< const gko::Executor > host_exec_;
std::shared_ptr< const gko::Executor > solver_exec_;
valueType absTolerance_;
gko::size_type maxIterations_;
std::shared_ptr< gko::mpi::communicator > comm_;
std::shared_ptr< gko::distributed::Partition< int32_t > > part_;
......
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