Snapshot optimized solver and audit diagnostics before numerical experiments
This commit is contained in:
@@ -1552,3 +1552,48 @@ TEST_CASE(
|
||||
CHECK(report.lastAcceptedCheckpointView().valid());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Skipping Geometry Preflight Retains Trial Acceptance And Fold Rejection",
|
||||
"[solver][newton][geometry][preflight][backtracking][wiring]") {
|
||||
using namespace mean_field;
|
||||
using namespace stellar_solver_architecture_test;
|
||||
for (bool folding : {false, true}) {
|
||||
CAPTURE(folding);
|
||||
auto finiteElements = makeFiniteElements();
|
||||
auto discretization = equilibrium::makeStellarDiscretization(
|
||||
std::move(finiteElements),
|
||||
normalization::PhysicalRieszDiagonal{dimensions::LengthValue{utils::RADIUS}, utils::G});
|
||||
auto context = solver::makeContext(
|
||||
makeModel(), std::move(discretization), preconditioning::makePreconditioner(),
|
||||
ScriptedBackend{nullptr, folding ? -10.0 : 0.0, false, true});
|
||||
auto metricState = std::make_shared<MetricSequenceState>();
|
||||
metricState->evaluations = {{.residualNorm = 2.0, .merit = 2.0}, {.residualNorm = 1.0, .merit = 0.5}};
|
||||
bool observed = false;
|
||||
auto observer = solver::nonlinear::makeObserver(
|
||||
[](const solver::nonlinear::BeforeIteration &) {},
|
||||
[&](const solver::nonlinear::AfterIteration &event) {
|
||||
observed = true;
|
||||
CHECK_FALSE(event.geometryPreflight.has_value());
|
||||
CHECK(event.geometryPreflightSeconds == 0.0);
|
||||
CHECK(event.lineSearchTrials == 1);
|
||||
CHECK(event.stepAccepted == !folding);
|
||||
});
|
||||
auto newton = solver::nonlinear::Newton(
|
||||
solver::nonlinear::NewtonOptions{
|
||||
.relativeTolerance = 0.0, .absoluteTolerance = 0.0, .maximumIterations = 1,
|
||||
.linearSolve = {.relativeTolerance = 0.0, .absoluteTolerance = std::numeric_limits<double>::max(),
|
||||
.maximumIterations = 1},
|
||||
.backtracking = {.maximumTrials = 1, .geometryPreflight = false}},
|
||||
SequencedMetric{metricState});
|
||||
auto solverInstance = solver::make(context, std::move(newton), std::move(observer));
|
||||
const auto report = solverInstance.evaluate();
|
||||
CHECK(observed);
|
||||
CHECK_FALSE(report.diagnostics().lastGeometryPreflight.has_value());
|
||||
CHECK(report.diagnostics().totalGeometryPreflightSeconds == 0.0);
|
||||
CHECK(report.diagnostics().geometryLimitedIterations == 0);
|
||||
CHECK(report.diagnostics().totalLineSearchTrials == 1);
|
||||
CHECK(report.diagnostics().acceptedNonlinearIterations == (folding ? 0 : 1));
|
||||
CHECK(report.diagnostics().inadmissibleLineSearchTrials == (folding ? 1 : 0));
|
||||
CHECK(report.lastAcceptedCheckpointView().valid());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user