Clear unavailable gravity measurements before each attempt
This commit is contained in:
@@ -140,6 +140,17 @@ namespace mean_field::solver::detail {
|
||||
}
|
||||
|
||||
protected:
|
||||
void BeginGravityAttempt() noexcept {
|
||||
trialSolveSucceeded = true;
|
||||
// These measurements belong to this attempt. An early preparation
|
||||
// or inner-solve failure must not publish the preceding trial's
|
||||
// successful assessment. The last completed solve and cumulative
|
||||
// counters deliberately retain their separate lifetime.
|
||||
lastCorrectionNorm = lastPreparedDefect = lastAffineDisagreement =
|
||||
lastArithmeticAllowance = lastPreparedTargetThreshold =
|
||||
std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
|
||||
void Refresh(State &state) {
|
||||
// Preparing a trial invalidates both normalized and physical
|
||||
// inverses. Refreshing only the restricted wrapper would hide this.
|
||||
@@ -157,8 +168,6 @@ namespace mean_field::solver::detail {
|
||||
}
|
||||
|
||||
auto ApplyCorrection(State &state) {
|
||||
lastPreparedDefect = lastAffineDisagreement = lastArithmeticAllowance =
|
||||
lastPreparedTargetThreshold = std::numeric_limits<double>::quiet_NaN();
|
||||
const auto &partition = subsystem.GetPartition();
|
||||
partition.InjectGravityValues(gravityCorrection, fullCorrection);
|
||||
subsystem.GetOperator().Mult(gravityCorrection, gravityAction);
|
||||
@@ -249,7 +258,7 @@ namespace mean_field::solver::detail {
|
||||
return true;
|
||||
}
|
||||
auto PrepareTrial(State &state, const double alpha) {
|
||||
this->trialSolveSucceeded = true;
|
||||
this->BeginGravityAttempt();
|
||||
auto preparation = state.PrepareTrial();
|
||||
if (!preparation) { return preparation; }
|
||||
this->Refresh(state);
|
||||
@@ -281,6 +290,7 @@ namespace mean_field::solver::detail {
|
||||
m_rhs(m_operator.Height()), m_correction(m_operator.Width()) { }
|
||||
|
||||
bool Initialize(State &state, nonlinear::NumericalStrategyDiagnostics &diagnostics) {
|
||||
this->BeginGravityAttempt();
|
||||
const auto &partition = this->subsystem.GetPartition();
|
||||
partition.GatherGravityResiduals(state.acceptedNormalizedResidual, this->gravityResidual);
|
||||
diagnostics.initialGravityResidual = StrategyNorm(this->gravityResidual, this->subsystem.GetCommunicator());
|
||||
@@ -343,11 +353,14 @@ namespace mean_field::solver::detail {
|
||||
this->subsystem.GetPartition().GatherRetainedValues(state.normalizedCorrection, m_correction);
|
||||
this->lastSolve = m_operator.TryLiftCorrection(m_correction, state.linearRightHandSide,
|
||||
state.normalizedCorrection);
|
||||
// Keep the report space attached to the outer Solve result; this
|
||||
// later auxiliary failure is reported through DirectionSolveFailed
|
||||
// and the gravity counters/last completed inner defect.
|
||||
return this->lastSolve.Converged();
|
||||
}
|
||||
|
||||
auto PrepareTrial(State &state, double) {
|
||||
this->trialSolveSucceeded = true;
|
||||
this->BeginGravityAttempt();
|
||||
auto preparation = state.PrepareTrial();
|
||||
if (!preparation) { return preparation; }
|
||||
this->Refresh(state);
|
||||
|
||||
Reference in New Issue
Block a user