Skip to content

Commit

Permalink
apply_uses_initial_guess return the local solvers' value
Browse files Browse the repository at this point in the history
  • Loading branch information
yhmtsai committed Oct 9, 2024
1 parent 62df88b commit ff56be7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/distributed/preconditioner/schwarz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ Schwarz<ValueType, LocalIndexType, GlobalIndexType>::parse(
return params;
}

template <typename ValueType, typename LocalIndexType, typename GlobalIndexType>
bool Schwarz<ValueType, LocalIndexType,
GlobalIndexType>::apply_uses_initial_guess() const
{
return this->local_solver_->apply_uses_initial_guess();
}


template <typename ValueType, typename LocalIndexType, typename GlobalIndexType>
void Schwarz<ValueType, LocalIndexType, GlobalIndexType>::apply_impl(
Expand Down
25 changes: 25 additions & 0 deletions core/test/mpi/distributed/preconditioner/schwarz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <ginkgo/core/distributed/preconditioner/schwarz.hpp>
#include <ginkgo/core/matrix/csr.hpp>
#include <ginkgo/core/preconditioner/jacobi.hpp>
#include <ginkgo/core/solver/cg.hpp>
#include <ginkgo/core/stop/iteration.hpp>

#include "core/test/utils.hpp"

Expand Down Expand Up @@ -143,4 +145,27 @@ TYPED_TEST(SchwarzFactory, PassExplicitFactory)
}


TYPED_TEST(SchwarzFactory, ApplyUsesInitialGuessAsLocalSolver)
{
using value_type = typename TestFixture::value_type;
using Cg = typename gko::solver::Cg<value_type>;
using Jacobi = typename TestFixture::Jacobi;
using Schwarz = typename TestFixture::Schwarz;

auto schwarz_with_jacobi = Schwarz::build()
.with_local_solver(Jacobi::build())
.on(this->exec)
->generate(this->mtx);
auto schwarz_with_cg =
Schwarz::build()
.with_local_solver(Cg::build().with_criteria(
gko::stop::Iteration::build().with_max_iters(1u)))
.on(this->exec)
->generate(this->mtx);

ASSERT_EQ(schwarz_with_jacobi->apply_uses_initial_guess(), false);
ASSERT_EQ(schwarz_with_cg->apply_uses_initial_guess(), true);
}


} // namespace
10 changes: 10 additions & 0 deletions include/ginkgo/core/distributed/preconditioner/schwarz.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ class Schwarz
using local_index_type = LocalIndexType;
using global_index_type = GlobalIndexType;

/**
* Return whether the local solvers use the data in x as an initial guess.
*
* @return true when the local solvers use the data in x as an initial
* guess. otherwise, false.
*
* @note TODO: after adding refining step, need to revisit this.
*/
bool apply_uses_initial_guess() const override;

GKO_CREATE_FACTORY_PARAMETERS(parameters, Factory)
{
/**
Expand Down

0 comments on commit ff56be7

Please sign in to comment.