feat(newton): first newton solver implementation
This commit is contained in:
@@ -1505,6 +1505,69 @@ TEST_CASE(
|
||||
CHECK(targetReport.assembledResidual);
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"Prepared Stellar Trial Preparation Reports Folded Geometry Without Unwinding",
|
||||
tags::reduced_stellar_geometry &tags::prepared &tags::geometry &tags::unit
|
||||
) {
|
||||
mean_field::utils::Args args = test_utils::setup_args();
|
||||
mean_field::fem::FEM f = mean_field::fem::setup_fem(args.mesh_file, args, 0);
|
||||
REQUIRE(f.okay());
|
||||
|
||||
const mean_field::eos::Polytrope barotrope(3.0, 0.25);
|
||||
const auto stellarModel = stellar_equilibrium_test_utils::make_stellar_model(barotrope, 1.15);
|
||||
const auto parameterGeometry = stellarModel.compileDomainDeformation(f);
|
||||
const auto &surface = parameterGeometry.surfaceDeformationPrescription();
|
||||
|
||||
mean_field::operators::PreparedStellarEquilibriumOperator stellarOperator(
|
||||
f, *f.domainMapperStateless, stellarModel
|
||||
);
|
||||
const auto &layout = stellarOperator.GetLayout();
|
||||
mfem::Vector state = stellar_equilibrium_test_utils::make_state(f, layout);
|
||||
auto dependencies = stellar_equilibrium_test_utils::make_dependencies();
|
||||
const auto rotation = stellar_equilibrium_test_utils::make_zero_rotation();
|
||||
|
||||
const double finiteStateValue = state(0);
|
||||
state(0) = std::numeric_limits<double>::quiet_NaN();
|
||||
const auto nonFiniteState = stellarOperator.TryPrepare(state, dependencies, rotation);
|
||||
REQUIRE_FALSE(nonFiniteState.has_value());
|
||||
CHECK(
|
||||
nonFiniteState.error().reason ==
|
||||
mean_field::operators::StellarEquilibriumPreparationRejectionReason::non_finite_physics
|
||||
);
|
||||
CHECK_FALSE(stellarOperator.IsPrepared());
|
||||
CHECK_THROWS_AS(stellarOperator.Prepare(state, dependencies, rotation), std::domain_error);
|
||||
state(0) = finiteStateValue;
|
||||
|
||||
mfem::Vector foldingParameters(surface.parameterCount());
|
||||
for (int parameter = 0; parameter < foldingParameters.Size(); ++parameter) {
|
||||
foldingParameters(parameter) = -1.5 * surface.referenceRadius(parameter);
|
||||
}
|
||||
stellar_equilibrium_test_utils::assign_value_block(
|
||||
state, layout, stellar_equilibrium_test_utils::displacementValue, foldingParameters
|
||||
);
|
||||
|
||||
const auto rejected = stellarOperator.TryPrepare(state, dependencies, rotation);
|
||||
REQUIRE_FALSE(rejected.has_value());
|
||||
CHECK(
|
||||
rejected.error().reason ==
|
||||
mean_field::operators::StellarEquilibriumPreparationRejectionReason::inverted_geometry
|
||||
);
|
||||
CHECK(rejected.error().stage == mean_field::operators::StellarEquilibriumPreparationStage::generated_geometry);
|
||||
CHECK(std::isfinite(rejected.error().minimumJacobianDeterminant));
|
||||
CHECK(rejected.error().minimumJacobianDeterminant <= 0.0);
|
||||
CHECK_FALSE(stellarOperator.IsPrepared());
|
||||
CHECK_THROWS_AS(stellarOperator.Prepare(state, dependencies, rotation), std::domain_error);
|
||||
|
||||
foldingParameters = 0.0;
|
||||
stellar_equilibrium_test_utils::assign_value_block(
|
||||
state, layout, stellar_equilibrium_test_utils::displacementValue, foldingParameters
|
||||
);
|
||||
const auto accepted = stellarOperator.TryPrepare(state, dependencies, rotation);
|
||||
REQUIRE(accepted.has_value());
|
||||
CHECK(accepted->generatedGeometry.isOrientationPreserving());
|
||||
CHECK(stellarOperator.IsPrepared());
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"Accepted Reduced Geometries Remain Valid Across Prepared Stellar Physics Quadrature Rules",
|
||||
tags::reduced_stellar_geometry &tags::prepared &tags::geometry &tags::self_consistency
|
||||
|
||||
Reference in New Issue
Block a user