Safeguard reused FGMRES guesses against the current true residual
This commit is contained in:
@@ -743,6 +743,53 @@ TEST_CASE(
|
||||
CHECK(correction(1) == Approx(0.6).margin(1.0e-11));
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"MFEM FGMRES Discards A Supplied Guess That Worsens The Current True Residual",
|
||||
"[solver][linear][fgmres][warm-start][safeguard]"
|
||||
) {
|
||||
using namespace mean_field;
|
||||
using namespace stellar_solver_architecture_test;
|
||||
using Catch::Approx;
|
||||
|
||||
TwoByTwoOperator operation;
|
||||
IdentityInverse inverse;
|
||||
auto backend = solver::linear::prepareLinearBackend(
|
||||
solver::linear::FGMRES({.restartLength = 1, .printLevel = -1}), operation, inverse, MPI_COMM_WORLD
|
||||
);
|
||||
mfem::Vector rhs(2), correction(2);
|
||||
rhs(0) = 1.0;
|
||||
rhs(1) = 2.0;
|
||||
const solver::LinearSolveControl control{
|
||||
.relativeTolerance = 1.0e-12, .absoluteTolerance = 1.0e-14, .maximumIterations = 200
|
||||
};
|
||||
|
||||
correction = 0.0;
|
||||
const auto cold = backend.Solve(rhs, correction, control);
|
||||
REQUIRE(cold.Converged());
|
||||
int rank = 0;
|
||||
REQUIRE(MPI_Comm_rank(MPI_COMM_WORLD, &rank) == MPI_SUCCESS);
|
||||
correction = 0.0;
|
||||
SECTION("A finite adverse guess on one rank falls back collectively") {
|
||||
if (rank == 0) {
|
||||
correction(0) = 100.0;
|
||||
correction(1) = -100.0;
|
||||
}
|
||||
}
|
||||
SECTION("Finite coefficients with an overflowing operator action fall back collectively") {
|
||||
if (rank == 0) {
|
||||
correction = std::numeric_limits<double>::max() / 2.0;
|
||||
}
|
||||
}
|
||||
const auto guarded = backend.Solve(rhs, correction, control);
|
||||
REQUIRE(guarded.Converged());
|
||||
CHECK(guarded.initialResidualNorm == Approx(cold.rightHandSideNorm));
|
||||
CHECK(guarded.iterations == cold.iterations);
|
||||
CHECK(guarded.operatorApplications == cold.operatorApplications + 1);
|
||||
CHECK(correction(0) == Approx(0.1).margin(1.0e-11));
|
||||
CHECK(correction(1) == Approx(0.6).margin(1.0e-11));
|
||||
CHECK(guarded.trueResidualNorm <= control.ConvergenceThreshold(guarded.rightHandSideNorm));
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"A User-Owned Context Certifies Views Only Through Evaluation Reports",
|
||||
"[solver][architecture][ownership][report][view]"
|
||||
|
||||
Reference in New Issue
Block a user