feat(newton): first newton solver implementation
This commit is contained in:
@@ -122,7 +122,7 @@ namespace unsupported_physical_preconditioner_test {
|
||||
mean_field::dimensions::SpecificEnthalpyValue target;
|
||||
};
|
||||
|
||||
using TargetValue = mean_field::dimensions::SpecificEnthalpyValue;
|
||||
using TargetValue = mean_field::dimensions::SpecificEnthalpyValue;
|
||||
using ScalarDescription = mean_field::stellar::ScalarConstraint<
|
||||
mean_field::dimensions::quantity::SpecificEnthalpy,
|
||||
mean_field::dimensions::quantity::Dimensionless,
|
||||
@@ -134,18 +134,13 @@ namespace unsupported_physical_preconditioner_test {
|
||||
using ModelDefinition = mean_field::constraint::ScalarPhaseCondition<
|
||||
Constraint,
|
||||
"UnsupportedPhysicalPreconditionerEdge",
|
||||
mean_field::stellar::Reads<
|
||||
mean_field::stellar::state::SpecificEnthalpy,
|
||||
mean_field::stellar::state::OwnGeneratedCoordinate>,
|
||||
mean_field::stellar::Changes<
|
||||
mean_field::stellar::equation::PoissonEquation>,
|
||||
mean_field::stellar::
|
||||
Reads<mean_field::stellar::state::SpecificEnthalpy, mean_field::stellar::state::OwnGeneratedCoordinate>,
|
||||
mean_field::stellar::Changes<mean_field::stellar::equation::PoissonEquation>,
|
||||
ScalarDescription>;
|
||||
using EquilibriumPhysics =
|
||||
mean_field::operators::LocalSpecificationEquilibriumPhysics<
|
||||
PreparedConstraint>;
|
||||
using EquilibriumPhysics = mean_field::operators::LocalSpecificationEquilibriumPhysics<PreparedConstraint>;
|
||||
|
||||
explicit constexpr Constraint(const Parameters parameters) noexcept
|
||||
: m_target(parameters.target) {
|
||||
explicit constexpr Constraint(const Parameters parameters) noexcept : m_target(parameters.target) {
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr TargetValue target() const noexcept {
|
||||
@@ -167,8 +162,7 @@ namespace unsupported_physical_preconditioner_test {
|
||||
explicit PreparedConstraint(const Constraint &) noexcept {
|
||||
}
|
||||
|
||||
template <typename StateView>
|
||||
[[nodiscard]] Report PrepareAfterPhysical(const StateView &) noexcept {
|
||||
template <typename StateView> [[nodiscard]] Report PrepareAfterPhysical(const StateView &) noexcept {
|
||||
m_isPrepared = true;
|
||||
return {};
|
||||
}
|
||||
@@ -189,7 +183,9 @@ namespace unsupported_physical_preconditioner_test {
|
||||
return mean_field::stellar::structuralZero;
|
||||
}
|
||||
|
||||
template <typename Direction, typename Row>
|
||||
template <
|
||||
typename Direction,
|
||||
typename Row>
|
||||
[[nodiscard]] mean_field::stellar::StructuralZero AddJacobianAction(
|
||||
mean_field::stellar::Derivative<
|
||||
mean_field::stellar::equation::OwnConstraint,
|
||||
@@ -200,7 +196,9 @@ namespace unsupported_physical_preconditioner_test {
|
||||
return mean_field::stellar::zeroDerivative;
|
||||
}
|
||||
|
||||
template <typename Direction, typename Row>
|
||||
template <
|
||||
typename Direction,
|
||||
typename Row>
|
||||
[[nodiscard]] mean_field::stellar::StructuralZero AddJacobianAction(
|
||||
mean_field::stellar::Derivative<
|
||||
mean_field::stellar::equation::OwnConstraint,
|
||||
@@ -211,7 +209,9 @@ namespace unsupported_physical_preconditioner_test {
|
||||
return mean_field::stellar::zeroDerivative;
|
||||
}
|
||||
|
||||
template <typename Direction, typename Row>
|
||||
template <
|
||||
typename Direction,
|
||||
typename Row>
|
||||
[[nodiscard]] mean_field::stellar::StructuralZero AddJacobianAction(
|
||||
mean_field::stellar::Derivative<
|
||||
mean_field::stellar::equation::PoissonEquation,
|
||||
@@ -222,7 +222,9 @@ namespace unsupported_physical_preconditioner_test {
|
||||
return mean_field::stellar::zeroDerivative;
|
||||
}
|
||||
|
||||
template <typename Direction, typename Row>
|
||||
template <
|
||||
typename Direction,
|
||||
typename Row>
|
||||
[[nodiscard]] mean_field::stellar::StructuralZero AddJacobianAction(
|
||||
mean_field::stellar::Derivative<
|
||||
mean_field::stellar::equation::PoissonEquation,
|
||||
@@ -277,42 +279,40 @@ template <> struct mean_field::preconditioning::StellarEquilibriumProblemTraits<
|
||||
};
|
||||
|
||||
namespace {
|
||||
namespace blocks = mean_field::utils::blocks;
|
||||
namespace preconditioning = mean_field::preconditioning;
|
||||
namespace blocks = mean_field::utils::blocks;
|
||||
namespace preconditioning = mean_field::preconditioning;
|
||||
|
||||
using ModelWithoutPhase = mean_field::model::StellarModel<mean_field::models::SpecificationSet<
|
||||
using ModelWithoutPhase = mean_field::model::StellarModel<mean_field::models::SpecificationSet<
|
||||
mean_field::eos::Polytrope,
|
||||
mean_field::surface::Isobaric,
|
||||
mean_field::models::FixedTotalMass>>;
|
||||
using CentralDensityModel = mean_field::model::StellarModel<mean_field::models::SpecificationSet<
|
||||
using CentralDensityModel = mean_field::model::StellarModel<mean_field::models::SpecificationSet<
|
||||
mean_field::eos::Polytrope,
|
||||
mean_field::surface::Isobaric,
|
||||
mean_field::models::FixedTotalMass,
|
||||
mean_field::models::FixedCentralDensity>>;
|
||||
using AngularMomentumModel = mean_field::model::StellarModel<mean_field::models::SpecificationSet<
|
||||
using AngularMomentumModel = mean_field::model::StellarModel<mean_field::models::SpecificationSet<
|
||||
mean_field::eos::Polytrope,
|
||||
mean_field::surface::Isobaric,
|
||||
mean_field::models::FixedTotalMass,
|
||||
mean_field::models::FixedAngularMomentum>>;
|
||||
using ProvenZeroPhysicalEdgeModel = mean_field::model::StellarModel<
|
||||
mean_field::models::SpecificationSet<
|
||||
mean_field::eos::Polytrope,
|
||||
mean_field::surface::Isobaric,
|
||||
mean_field::models::FixedTotalMass,
|
||||
unsupported_physical_preconditioner_test::Constraint>>;
|
||||
using ProvenZeroPhysicalEdgeModel = mean_field::model::StellarModel<mean_field::models::SpecificationSet<
|
||||
mean_field::eos::Polytrope,
|
||||
mean_field::surface::Isobaric,
|
||||
mean_field::models::FixedTotalMass,
|
||||
unsupported_physical_preconditioner_test::Constraint>>;
|
||||
|
||||
using ProblemWithoutPhase = mean_field::equilibrium::StellarEquilibriumProblem<ModelWithoutPhase>;
|
||||
using CentralDensityProblem = mean_field::equilibrium::StellarEquilibriumProblem<CentralDensityModel>;
|
||||
using AngularMomentumProblem = mean_field::equilibrium::StellarEquilibriumProblem<AngularMomentumModel>;
|
||||
using ProblemWithoutPhase = mean_field::equilibrium::StellarEquilibriumProblem<ModelWithoutPhase>;
|
||||
using CentralDensityProblem = mean_field::equilibrium::StellarEquilibriumProblem<CentralDensityModel>;
|
||||
using AngularMomentumProblem = mean_field::equilibrium::StellarEquilibriumProblem<AngularMomentumModel>;
|
||||
using ProvenZeroPhysicalEdgeProblem =
|
||||
mean_field::equilibrium::StellarEquilibriumProblem<ProvenZeroPhysicalEdgeModel>;
|
||||
using PlanWithoutPhase = preconditioning::IdentityPreconditionerPlanFor<ProblemWithoutPhase>;
|
||||
using CentralDensityPlan = preconditioning::IdentityPreconditionerPlanFor<CentralDensityProblem>;
|
||||
using PlanWithoutPhase = preconditioning::IdentityPreconditionerPlanFor<ProblemWithoutPhase>;
|
||||
using CentralDensityPlan = preconditioning::IdentityPreconditionerPlanFor<CentralDensityProblem>;
|
||||
|
||||
template <typename Problem>
|
||||
concept CanMakeDefaultStellarStructureBlock = requires(const Problem &problem) {
|
||||
preconditioning::stellarStructureBlock(problem);
|
||||
};
|
||||
concept CanMakeDefaultStellarStructureBlock =
|
||||
requires(const Problem &problem) { preconditioning::stellarStructureBlock(problem); };
|
||||
|
||||
using RefreshingDensityIdentity = preconditioning::ComponentDeclaration<
|
||||
blocks::type_list<blocks::density::mass::value>,
|
||||
@@ -367,67 +367,51 @@ TEST_CASE(
|
||||
"Default Stellar Structure Availability Distinguishes Proven Zeros From Unhandled Physical Edges",
|
||||
"[preconditioning][stellar_structure][type_contract][compiler]"
|
||||
) {
|
||||
using BaseCompilation =
|
||||
mean_field::operators::CompiledStellarEquilibriumSystem<ModelWithoutPhase>;
|
||||
using BaseSupport =
|
||||
preconditioning::DefaultStellarStructurePhysicalTopologySupport<
|
||||
ModelWithoutPhase>;
|
||||
using BaseCompilation = mean_field::operators::CompiledStellarEquilibriumSystem<ModelWithoutPhase>;
|
||||
using BaseSupport = preconditioning::DefaultStellarStructurePhysicalTopologySupport<ModelWithoutPhase>;
|
||||
using ProvenZeroSupport =
|
||||
preconditioning::DefaultStellarStructurePhysicalTopologySupport<
|
||||
ProvenZeroPhysicalEdgeModel>;
|
||||
using TrustedFixedMassEdge =
|
||||
mean_field::operators::StellarEquilibriumJacobianCoupling<
|
||||
blocks::enthalpy::specific::residual,
|
||||
blocks::density::mass::value>;
|
||||
using ProvenZeroPoissonEnthalpyEdge =
|
||||
mean_field::operators::StellarEquilibriumJacobianCoupling<
|
||||
blocks::gravity::poisson::residual,
|
||||
blocks::enthalpy::specific::value>;
|
||||
preconditioning::DefaultStellarStructurePhysicalTopologySupport<ProvenZeroPhysicalEdgeModel>;
|
||||
using TrustedFixedMassEdge = mean_field::operators::StellarEquilibriumJacobianCoupling<
|
||||
blocks::enthalpy::specific::residual, blocks::density::mass::value>;
|
||||
using ProvenZeroPoissonEnthalpyEdge = mean_field::operators::StellarEquilibriumJacobianCoupling<
|
||||
blocks::gravity::poisson::residual, blocks::enthalpy::specific::value>;
|
||||
|
||||
// FixedTotalMass contributes h <- rho outside the generic five-field base
|
||||
// graph. It remains supported because that specification is explicitly
|
||||
// embedded in the trusted numerical core, not because of a model-pack
|
||||
// special case.
|
||||
STATIC_CHECK_FALSE(mean_field::utils::blocks::contains_type_v<
|
||||
TrustedFixedMassEdge,
|
||||
typename BaseCompilation::BaseJacobianCouplings>);
|
||||
STATIC_CHECK(mean_field::utils::blocks::contains_type_v<
|
||||
TrustedFixedMassEdge,
|
||||
typename BaseCompilation::ContributionJacobianCouplings>);
|
||||
STATIC_CHECK_FALSE(
|
||||
mean_field::utils::blocks::contains_type_v<
|
||||
TrustedFixedMassEdge, typename BaseCompilation::BaseJacobianCouplings>
|
||||
);
|
||||
STATIC_CHECK(
|
||||
mean_field::utils::blocks::contains_type_v<
|
||||
TrustedFixedMassEdge, typename BaseCompilation::ContributionJacobianCouplings>
|
||||
);
|
||||
STATIC_CHECK(BaseSupport::UnsupportedCouplings::size == 0);
|
||||
STATIC_CHECK(preconditioning::DefaultStellarStructurePhysicalTopologySupportedFor<
|
||||
ModelWithoutPhase>);
|
||||
STATIC_CHECK(preconditioning::DefaultStellarStructurePhysicalTopologySupportedFor<
|
||||
CentralDensityModel>);
|
||||
STATIC_CHECK(preconditioning::DefaultStellarStructurePhysicalTopologySupportedFor<
|
||||
AngularMomentumModel>);
|
||||
STATIC_CHECK(preconditioning::StellarStructurePreconditionerProblem<
|
||||
ProblemWithoutPhase>);
|
||||
STATIC_CHECK(preconditioning::DefaultStellarStructurePhysicalTopologySupportedFor<ModelWithoutPhase>);
|
||||
STATIC_CHECK(preconditioning::DefaultStellarStructurePhysicalTopologySupportedFor<CentralDensityModel>);
|
||||
STATIC_CHECK(preconditioning::DefaultStellarStructurePhysicalTopologySupportedFor<AngularMomentumModel>);
|
||||
STATIC_CHECK(preconditioning::StellarStructurePreconditionerProblem<ProblemWithoutPhase>);
|
||||
STATIC_CHECK(CanMakeDefaultStellarStructureBlock<ProblemWithoutPhase>);
|
||||
STATIC_CHECK(preconditioning::DefaultStellarPreconditionerAvailableFor<
|
||||
ProblemWithoutPhase>);
|
||||
STATIC_CHECK(preconditioning::DefaultStellarPreconditionerAvailableFor<ProblemWithoutPhase>);
|
||||
|
||||
// The mock's novel Poisson <- enthalpy edge is absent from the structure
|
||||
// backend, but its exact nested provider returns StructuralZero. That is
|
||||
// a compile-time proof that no preconditioner term is missing; generated-
|
||||
// coordinate edges are handled independently by the inferred border.
|
||||
STATIC_CHECK(mean_field::equilibrium::StellarEquilibriumModel<
|
||||
ProvenZeroPhysicalEdgeModel>);
|
||||
STATIC_CHECK(mean_field::equilibrium::DiscretizedStellarEquilibriumProblem<
|
||||
ProvenZeroPhysicalEdgeProblem>);
|
||||
STATIC_CHECK(mean_field::equilibrium::StellarEquilibriumModel<ProvenZeroPhysicalEdgeModel>);
|
||||
STATIC_CHECK(mean_field::equilibrium::DiscretizedStellarEquilibriumProblem<ProvenZeroPhysicalEdgeProblem>);
|
||||
STATIC_CHECK(ProvenZeroSupport::UnsupportedCouplings::size == 0);
|
||||
STATIC_CHECK(mean_field::utils::blocks::contains_type_v<
|
||||
ProvenZeroPoissonEnthalpyEdge,
|
||||
typename mean_field::operators::CompiledStellarEquilibriumSystem<
|
||||
ProvenZeroPhysicalEdgeModel>::ContributionJacobianCouplings>);
|
||||
STATIC_CHECK(preconditioning::DefaultStellarStructurePhysicalTopologySupportedFor<
|
||||
ProvenZeroPhysicalEdgeModel>);
|
||||
STATIC_CHECK(preconditioning::StellarStructurePreconditionerProblem<
|
||||
ProvenZeroPhysicalEdgeProblem>);
|
||||
STATIC_CHECK(CanMakeDefaultStellarStructureBlock<
|
||||
ProvenZeroPhysicalEdgeProblem>);
|
||||
STATIC_CHECK(preconditioning::DefaultStellarPreconditionerAvailableFor<
|
||||
ProvenZeroPhysicalEdgeProblem>);
|
||||
STATIC_CHECK(
|
||||
mean_field::utils::blocks::contains_type_v<
|
||||
ProvenZeroPoissonEnthalpyEdge, typename mean_field::operators::CompiledStellarEquilibriumSystem<
|
||||
ProvenZeroPhysicalEdgeModel>::ContributionJacobianCouplings>
|
||||
);
|
||||
STATIC_CHECK(preconditioning::DefaultStellarStructurePhysicalTopologySupportedFor<ProvenZeroPhysicalEdgeModel>);
|
||||
STATIC_CHECK(preconditioning::StellarStructurePreconditionerProblem<ProvenZeroPhysicalEdgeProblem>);
|
||||
STATIC_CHECK(CanMakeDefaultStellarStructureBlock<ProvenZeroPhysicalEdgeProblem>);
|
||||
STATIC_CHECK(preconditioning::DefaultStellarPreconditionerAvailableFor<ProvenZeroPhysicalEdgeProblem>);
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
|
||||
Reference in New Issue
Block a user