Commit 2d68f4dc authored by Marcel Koch's avatar Marcel Koch
Browse files

change to seq ILU due to instabilities

parent 7e1ed979
......@@ -91,7 +91,7 @@ struct SolverSettings
{
ss << " - ginkgo executor: " << gkoExecutor << "\n";
}
if ( useAgglomeration)
if ( useAgglomeration )
{
ss << " - use agglomeration on coarse grid\n";
}
......@@ -551,9 +551,10 @@ void tokamak( TokamakDomain tokamakDomain,
}
else
{
auto coarse_storage = storage;
auto coarse_storage = storage;
auto agglomerationWrapper = std::shared_ptr< AgglomerationWrapper< LaplaceOperator_T, LaplaceForm_T > >();
if (solverSettings.useAgglomeration){
if ( solverSettings.useAgglomeration )
{
agglomerationWrapper =
std::make_shared< AgglomerationWrapper< LaplaceOperator_T, LaplaceForm_T > >( storage, minLevel, true, form );
agglomerationWrapper->setStrategyContinuousProcesses( 0, 0 );
......@@ -591,7 +592,7 @@ void tokamak( TokamakDomain tokamakDomain,
}
else if ( solverSettings.coarseGridSolverType == COARSE_GRID_CG_GINKGO )
{
//const auto relativeResidualToleranceCoarseGrid = 1e-30;
const auto relativeResidualToleranceCoarseGrid = 1e-30;
const auto absoluteResidualToleranceCoarseGrid = 1e-12;
const auto maxIterationsCoarseGrid = solverSettings.maxCoarseGridSolverIterations;
auto exec = get_executor( solverSettings.gkoExecutor );
......@@ -599,8 +600,14 @@ void tokamak( TokamakDomain tokamakDomain,
{
WALBERLA_ABORT( "Invalid Ginkgo executor type." );
}
auto actualCoarseGridSolver = std::make_shared< GinkgoCGSolver< LaplaceOperator_T > >(
coarse_storage, minLevel, constraints::zero_row, absoluteResidualToleranceCoarseGrid, maxIterationsCoarseGrid, exec );
auto actualCoarseGridSolver =
std::make_shared< GinkgoCGSolver< LaplaceOperator_T > >( coarse_storage,
minLevel,
constraints::zero_row,
relativeResidualToleranceCoarseGrid,
absoluteResidualToleranceCoarseGrid,
maxIterationsCoarseGrid,
exec );
if ( solverSettings.cgHytegVerbose )
{
actualCoarseGridSolver->setPrintInfo( true );
......@@ -612,12 +619,12 @@ void tokamak( TokamakDomain tokamakDomain,
WALBERLA_ABORT( "Invalid coarse grid solver type." );
}
if( solverSettings.useAgglomeration){
agglomerationWrapper->setSolver(coarseGridSolver);
if ( solverSettings.useAgglomeration )
{
agglomerationWrapper->setSolver( coarseGridSolver );
coarseGridSolver = agglomerationWrapper;
}
if ( solverSettings.solverType == GMG_WJAC )
{
auto restriction = std::make_shared< Restriction_T >();
......@@ -859,7 +866,7 @@ void run( int argc, char** argv )
solverSettings.postSmooth = mainConf.getParameter< uint_t >( "postSmooth" );
solverSettings.cgHytegVerbose = mainConf.getParameter< bool >( "cgHytegVerbose" );
solverSettings.gkoExecutor = mainConf.getParameter< std::string >( "gkoExecutor" );
solverSettings.useAgglomeration = mainConf.getParameter< bool >( "useAgglomeration" );
solverSettings.useAgglomeration = mainConf.getParameter< bool >( "useAgglomeration" );
// use numeric_limits<int> here to prevent overflow when casting to PetscINt
solverSettings.maxCoarseGridSolverIterations =
mainConf.getParameter< uint_t >( "maxCoarseGridSolverIterations", std::numeric_limits< int >::max() );
......
......@@ -199,7 +199,8 @@ class GinkgoCGSolver : public Solver< OperatorType >
GinkgoCGSolver( const std::shared_ptr< PrimitiveStorage >& storage,
const uint_t& level,
const constraints constraints_type,
const valueType tolerance = 1e-12,
const valueType relTolerance = 1e-12,
const valueType absTolerance = 1e-30,
const int maxIterations = 1000,
std::shared_ptr< gko::Executor > solver_exec = gko::ReferenceExecutor::create() )
: storage_( storage )
......@@ -209,15 +210,17 @@ class GinkgoCGSolver : public Solver< OperatorType >
, solver_exec_( std::move(solver_exec) )
, num_( "numerator", storage, level, level )
{
auto rel_mode = constraints_type == constraints::penalty ? gko::stop::mode::initial_resnorm : gko::stop::mode::rhs_norm;
auto log = gko::share( gko::log::Convergence< valueType >::create( solver_exec_ ) );
auto criteria = gko::stop::Combined::build()
.with_criteria( gko::stop::ResidualNorm< valueType >::build()
.with_baseline( gko::stop::mode::initial_resnorm )
.with_reduction_factor( tolerance )
.with_baseline( rel_mode )
.with_reduction_factor( relTolerance )
.on( solver_exec_ ),
gko::stop::ResidualNorm< valueType >::build()
.with_baseline( gko::stop::mode::absolute )
.with_reduction_factor( 1e-30 )
.with_reduction_factor( absTolerance )
.on( solver_exec_ ),
gko::stop::Iteration::build().with_max_iters( maxIterations ).on( solver_exec_ ) )
.on( solver_exec_ );
......@@ -295,7 +298,7 @@ class GinkgoCGSolver : public Solver< OperatorType >
matrix_ = mtx::create( solver_exec_ );
host_matrix->move_to( gko::lend( matrix_ ) );
auto par_ilu = gko::factorization::ParIlu< valueType, int32_t >::build().on( solver_exec_ )->generate( matrix_ );
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_->set_preconditioner( gko::share( ilu ) );
......
......@@ -95,7 +95,7 @@ void ginkgoSolveTest( const uint_t& level,
WALBERLA_LOG_INFO( "localDoFs1: " << localDoFs1 << " globalDoFs1: " << globalDoFs1 );
// WALBERLA_LOG_INFO( "localDoFs2: " << localDoFs2 << " globalDoFs2: " << globalDoFs2 );
GinkgoCGSolver< hyteg::P1ConstantLaplaceOperator > solver_1{ storage, level, constraints::zero_row, 1e-12, 1000, exec };
GinkgoCGSolver< hyteg::P1ConstantLaplaceOperator > solver_1{ storage, level, constraints::zero_row, 1e-30, 1e-12, 1000, exec };
walberla::WcTimer timer;
solver_1.solve( A, x, b, 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