Snapshot optimized solver and audit diagnostics before numerical experiments
This commit is contained in:
@@ -312,6 +312,10 @@ TEST_CASE(
|
||||
operation.ApplyCompleteJacobianAction(
|
||||
reducedDensityDirection, reducedDisplacementDirection, angularVelocityDirection, completeAction
|
||||
);
|
||||
mfem::Vector preparedReference;
|
||||
operation.ApplyCompleteJacobianActionReference(
|
||||
reducedDensityDirection, reducedDisplacementDirection, angularVelocityDirection, preparedReference);
|
||||
CHECK(angular_momentum_test_utils::relativeError(completeAction(0), preparedReference(0)) < 2.0e-11);
|
||||
CHECK(
|
||||
angular_momentum_test_utils::relativeError(
|
||||
completeAction(0), densityAction(0) + geometryAction(0) + angularVelocityAction(0)
|
||||
@@ -409,10 +413,26 @@ TEST_CASE(
|
||||
operation.Prepare(0.52, dependencies);
|
||||
const auto preparationCount = operation.GetPreparationCount();
|
||||
const double moment = operation.GetMomentOfInertia();
|
||||
CHECK(operation.GetJacobianRowPreparationCount() == 0);
|
||||
const auto rhoDirection = gravityContext.GetDensityMap().gather(
|
||||
angular_momentum_test_utils::projectDensityDirection(finiteElements, 0.67));
|
||||
const auto uDirection = gravityContext.GetDisplacementMap().gather(
|
||||
angular_momentum_test_utils::projectDisplacementDirection(finiteElements, -0.53));
|
||||
auto checkRows = [&](std::uint64_t expectedBuilds) {
|
||||
REQUIRE(operation.PrepareJacobianRows());
|
||||
CHECK(operation.GetJacobianRowPreparationCount() == expectedBuilds);
|
||||
mfem::Vector actual, reference;
|
||||
operation.ApplyCompleteJacobianAction(rhoDirection, uDirection, -0.19, actual);
|
||||
operation.ApplyCompleteJacobianActionReference(rhoDirection, uDirection, -0.19, reference);
|
||||
CHECK(angular_momentum_test_utils::relativeError(actual(0), reference(0)) < 2.0e-11);
|
||||
CHECK(operation.GetJacobianRowPreparationCount() == expectedBuilds);
|
||||
};
|
||||
checkRows(1);
|
||||
|
||||
const auto repeated = operation.Prepare(0.52, dependencies);
|
||||
CHECK_FALSE(repeated.DidAnyWork());
|
||||
CHECK(operation.GetPreparationCount() == preparationCount);
|
||||
checkRows(1);
|
||||
|
||||
++gravityPotentialRevision;
|
||||
angular_momentum_test_utils::prepareGravityContext(
|
||||
@@ -420,6 +440,7 @@ TEST_CASE(
|
||||
);
|
||||
const auto unrelatedPotential = operation.Prepare(0.52, dependencies);
|
||||
CHECK_FALSE(unrelatedPotential.DidAnyWork());
|
||||
checkRows(1);
|
||||
|
||||
const double residualBeforeRotation = angular_momentum_test_utils::residual(operation);
|
||||
++dependencies.rotation.revision;
|
||||
@@ -429,6 +450,7 @@ TEST_CASE(
|
||||
CHECK_FALSE(rotationOnly.refreshedDensity);
|
||||
CHECK_FALSE(rotationOnly.refreshedGeometry);
|
||||
CHECK(operation.GetMomentOfInertia() == moment);
|
||||
checkRows(1);
|
||||
CHECK(
|
||||
angular_momentum_test_utils::residual(operation) - residualBeforeRotation ==
|
||||
Catch::Approx((0.81 - 0.52) * moment).epsilon(3.0e-15)
|
||||
@@ -443,6 +465,8 @@ TEST_CASE(
|
||||
CHECK(densityOnly.refreshedDensity);
|
||||
CHECK_FALSE(densityOnly.refreshedGeometry);
|
||||
CHECK_FALSE(densityOnly.updatedAngularVelocity);
|
||||
CHECK(operation.GetJacobianRowPreparationCount() == 1);
|
||||
checkRows(2);
|
||||
|
||||
displacement = angular_momentum_test_utils::projectDisplacementDirection(finiteElements, 0.87);
|
||||
++dependencies.displacement.revision;
|
||||
@@ -453,6 +477,8 @@ TEST_CASE(
|
||||
CHECK(geometryOnly.refreshedGeometry);
|
||||
CHECK_FALSE(geometryOnly.refreshedDensity);
|
||||
CHECK_FALSE(geometryOnly.updatedAngularVelocity);
|
||||
CHECK(operation.GetJacobianRowPreparationCount() == 2);
|
||||
checkRows(3);
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
@@ -488,6 +514,8 @@ TEST_CASE(
|
||||
const auto initial = operation.TryPrepare(angularVelocity, dependencies);
|
||||
REQUIRE(initial.has_value());
|
||||
const std::uint64_t initialPreparationCount = operation.GetPreparationCount();
|
||||
REQUIRE(operation.PrepareJacobianRows());
|
||||
CHECK(operation.GetJacobianRowPreparationCount() == 1);
|
||||
|
||||
const std::uint64_t successfulPreparations = initialPreparationCount;
|
||||
|
||||
@@ -513,6 +541,8 @@ TEST_CASE(
|
||||
const auto recovered = operation.TryPrepare(angularVelocity, dependencies);
|
||||
REQUIRE(recovered.has_value());
|
||||
CHECK(operation.IsPrepared());
|
||||
REQUIRE(operation.PrepareJacobianRows());
|
||||
CHECK(operation.GetJacobianRowPreparationCount() == 2);
|
||||
|
||||
++dependencies.rotation.revision;
|
||||
const auto nonFiniteAngularVelocity = operation.TryPrepare(std::numeric_limits<double>::quiet_NaN(), dependencies);
|
||||
@@ -527,4 +557,6 @@ TEST_CASE(
|
||||
++dependencies.rotation.revision;
|
||||
REQUIRE(operation.TryPrepare(angularVelocity, dependencies).has_value());
|
||||
CHECK(operation.IsPrepared());
|
||||
REQUIRE(operation.PrepareJacobianRows());
|
||||
CHECK(operation.GetJacobianRowPreparationCount() == 3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user