feat(newton): first newton solver implementation
This commit is contained in:
@@ -57,33 +57,26 @@ namespace {
|
||||
blocks::type_list<>,
|
||||
preconditioning::IdentityOperatorCharacteristics,
|
||||
preconditioning::backend::Identity>;
|
||||
using LifetimeModel = mean_field::model::StellarModel<mean_field::models::SpecificationSet<
|
||||
using LifetimeModel = 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 LifetimeProblem = mean_field::equilibrium::StellarEquilibriumProblem<LifetimeModel>;
|
||||
using LifetimeBlock = decltype(preconditioning::makePreconditioner(
|
||||
std::declval<const LifetimeProblem &>()
|
||||
));
|
||||
using LifetimePrepared = preconditioning::PreparedStellarPreconditioner<
|
||||
LifetimeProblem,
|
||||
LifetimeBlock>;
|
||||
using LifetimeProblem = mean_field::equilibrium::StellarEquilibriumProblem<LifetimeModel>;
|
||||
using LifetimeBlock = decltype(preconditioning::makePreconditioner(std::declval<const LifetimeProblem &>()));
|
||||
using LifetimePrepared = preconditioning::PreparedStellarPreconditioner<LifetimeProblem, LifetimeBlock>;
|
||||
|
||||
template <typename Problem, typename Block>
|
||||
concept CanPrepareStellarPreconditioner = requires(const Problem &problem, Block block) {
|
||||
preconditioning::prepare(problem, std::move(block));
|
||||
};
|
||||
concept CanPrepareStellarPreconditioner =
|
||||
requires(const Problem &problem, Block block) { preconditioning::prepare(problem, std::move(block)); };
|
||||
|
||||
template <typename Problem, typename Block>
|
||||
concept CanPrepareStellarPreconditionerFromTemporary = requires(Block block) {
|
||||
preconditioning::prepare(std::declval<Problem &&>(), std::move(block));
|
||||
};
|
||||
concept CanPrepareStellarPreconditionerFromTemporary =
|
||||
requires(Block block) { preconditioning::prepare(std::declval<Problem &&>(), std::move(block)); };
|
||||
|
||||
template <typename Problem, typename Block>
|
||||
concept CanPrepareStellarPreconditionerFromConstTemporary = requires(Block block) {
|
||||
preconditioning::prepare(std::declval<const Problem &&>(), std::move(block));
|
||||
};
|
||||
concept CanPrepareStellarPreconditionerFromConstTemporary =
|
||||
requires(Block block) { preconditioning::prepare(std::declval<const Problem &&>(), std::move(block)); };
|
||||
|
||||
[[nodiscard]] blocks::form_layout<Form> makeUnevenLayout() {
|
||||
return {
|
||||
@@ -221,7 +214,7 @@ TEST_CASE(
|
||||
integral::FixedTotalMass({.Mtotal = dimensions::MassValue{mass}}),
|
||||
constraint::FixedCentralDensity({.RhoC = dimensions::DensityValue{centralDensity}})
|
||||
);
|
||||
auto problem = equilibrium::discretize(model, finiteElements);
|
||||
auto problem = equilibrium::discretize(model, std::move(finiteElements));
|
||||
auto projected = seed::makeProjectedEquilibriumState(problem, seed::LaneEmden({.radialSampleCount = 512}));
|
||||
problem.Prepare(projected.values, makeDependencies(), zeroRotation());
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <numbers>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include <catch2/catch_approx.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
@@ -18,12 +19,12 @@ namespace material_surface_runtime_contract_test {
|
||||
struct RegisteredAlternateEquationOfState final {
|
||||
struct Parameters final { };
|
||||
|
||||
using ModelDefinition = mean_field::models::ConstitutiveLaw<
|
||||
RegisteredAlternateEquationOfState,
|
||||
"RegisteredAlternateMaterialSurfaceEquationOfState">;
|
||||
using ModelDefinition = mean_field::models::
|
||||
ConstitutiveLaw<RegisteredAlternateEquationOfState, "RegisteredAlternateMaterialSurfaceEquationOfState">;
|
||||
using Relations = mean_field::eos::RelationCatalog<mean_field::eos::SpecificEnthalpyFromPressure>;
|
||||
|
||||
explicit RegisteredAlternateEquationOfState(Parameters) noexcept { }
|
||||
explicit RegisteredAlternateEquationOfState(Parameters) noexcept {
|
||||
}
|
||||
|
||||
[[nodiscard]] mean_field::dimensions::SpecificEnthalpyValue evaluate(
|
||||
mean_field::eos::SpecificEnthalpyFromPressure,
|
||||
@@ -40,7 +41,10 @@ namespace material_surface_runtime_contract_test {
|
||||
|
||||
using mfem::Operator::Operator;
|
||||
|
||||
void Mult(const mfem::Vector &, mfem::Vector &) const override;
|
||||
void Mult(
|
||||
const mfem::Vector &,
|
||||
mfem::Vector &
|
||||
) const override;
|
||||
|
||||
[[nodiscard]] const mean_field::operators::StellarEquilibriumLayout &GetLayout() const noexcept;
|
||||
[[nodiscard]] mean_field::operators::PreparedStellarEquilibriumReport Prepare(
|
||||
@@ -58,8 +62,7 @@ namespace material_surface_runtime_contract_test {
|
||||
GetSurfaceConstraintOperator() const;
|
||||
};
|
||||
|
||||
template <mean_field::model::StellarModelType Model>
|
||||
class AlternateEquationOfStateRuntime final {
|
||||
template <mean_field::model::StellarModelType Model> class AlternateEquationOfStateRuntime final {
|
||||
public:
|
||||
using Report = mean_field::operators::EmptySpecificationPreparationReport;
|
||||
|
||||
@@ -68,10 +71,17 @@ namespace material_surface_runtime_contract_test {
|
||||
const mean_field::mapping::DomainMapper &,
|
||||
AlternatePhysicalCore &,
|
||||
const Model &
|
||||
) noexcept { }
|
||||
) noexcept {
|
||||
}
|
||||
|
||||
template <typename StateView, typename Controls>
|
||||
void ReadPhysicalControls(const StateView &, Controls &) noexcept { }
|
||||
template <
|
||||
typename StateView,
|
||||
typename Controls>
|
||||
void ReadPhysicalControls(
|
||||
const StateView &,
|
||||
Controls &
|
||||
) noexcept {
|
||||
}
|
||||
|
||||
template <typename StateView>
|
||||
[[nodiscard]] Report PrepareAfterPhysical(
|
||||
@@ -82,15 +92,18 @@ namespace material_surface_runtime_contract_test {
|
||||
return {};
|
||||
}
|
||||
|
||||
template <typename ResidualView>
|
||||
void AddResidual(const ResidualView &) const noexcept { }
|
||||
template <typename ResidualView> void AddResidual(const ResidualView &) const noexcept {
|
||||
}
|
||||
|
||||
template <typename DirectionView, typename ActionView>
|
||||
template <
|
||||
typename DirectionView,
|
||||
typename ActionView>
|
||||
void AddJacobianAction(
|
||||
const DirectionView &,
|
||||
const ActionView &,
|
||||
const AlternatePhysicalCore &
|
||||
) const noexcept { }
|
||||
) const noexcept {
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool IsPrepared() const noexcept {
|
||||
return true;
|
||||
@@ -100,10 +113,9 @@ namespace material_surface_runtime_contract_test {
|
||||
|
||||
namespace mean_field::operators {
|
||||
template <>
|
||||
struct StellarEquilibriumCoreRuntime<
|
||||
material_surface_runtime_contract_test::RegisteredAlternateEquationOfState> {
|
||||
struct StellarEquilibriumCoreRuntime<material_surface_runtime_contract_test::RegisteredAlternateEquationOfState> {
|
||||
static constexpr bool registered = true;
|
||||
using CoreType = material_surface_runtime_contract_test::AlternatePhysicalCore;
|
||||
using CoreType = material_surface_runtime_contract_test::AlternatePhysicalCore;
|
||||
|
||||
[[nodiscard]] static std::unique_ptr<CoreType> Make(
|
||||
fem::FEM &,
|
||||
@@ -134,7 +146,7 @@ namespace mean_field::preconditioning {
|
||||
struct MaterialSurfaceEquationOfStateBackend<
|
||||
material_surface_runtime_contract_test::RegisteredAlternateEquationOfState> {
|
||||
static constexpr bool registered = true;
|
||||
using CoreType = material_surface_runtime_contract_test::AlternatePhysicalCore;
|
||||
using CoreType = material_surface_runtime_contract_test::AlternatePhysicalCore;
|
||||
};
|
||||
} // namespace mean_field::preconditioning
|
||||
|
||||
@@ -150,12 +162,12 @@ namespace {
|
||||
mean_field::constraint::FixedCentralDensity>>;
|
||||
using PolytropicProblem = mean_field::equilibrium::StellarEquilibriumProblem<PolytropicModel>;
|
||||
using PolytropicMaterialSurfaceDescriptor = preconditioning::MaterialSurfaceDescriptorFor<PolytropicProblem>;
|
||||
using RegisteredAlternateModel = mean_field::model::StellarModel<mean_field::models::SpecificationSet<
|
||||
using RegisteredAlternateModel = mean_field::model::StellarModel<mean_field::models::SpecificationSet<
|
||||
material_surface_runtime_contract_test::RegisteredAlternateEquationOfState,
|
||||
mean_field::surface::Isobaric,
|
||||
mean_field::integral::FixedTotalMass>>;
|
||||
using RegisteredAlternateProblem = mean_field::equilibrium::StellarEquilibriumProblem<RegisteredAlternateModel>;
|
||||
using MaterialSurfaceDiagonal = preconditioning::MaterialSurfaceBlock<
|
||||
using MaterialSurfaceDiagonal = preconditioning::MaterialSurfaceBlock<
|
||||
PolytropicMaterialSurfaceDescriptor,
|
||||
backend::Diagonal,
|
||||
backend::Diagonal,
|
||||
@@ -174,10 +186,8 @@ namespace {
|
||||
PolytropicMaterialSurfaceDescriptor,
|
||||
preconditioning::ApproximateMaterialSurfaceLDU,
|
||||
backend::FixedCycles>;
|
||||
using RegisteredAlternateGravityComponent = preconditioning::GravityFieldBlock<
|
||||
backend::Diagonal,
|
||||
FixedCycleAMG,
|
||||
preconditioning::GravityApproximateLDU>;
|
||||
using RegisteredAlternateGravityComponent =
|
||||
preconditioning::GravityFieldBlock<backend::Diagonal, FixedCycleAMG, preconditioning::GravityApproximateLDU>;
|
||||
|
||||
using RegisteredAlternateMaterialSurfaceDescriptor =
|
||||
preconditioning::MaterialSurfaceDescriptorFor<RegisteredAlternateProblem>;
|
||||
@@ -185,9 +195,8 @@ namespace {
|
||||
struct DistinctPhysicalCore final { };
|
||||
|
||||
template <typename Problem>
|
||||
concept CanMakeDefaultMaterialSurface = requires(const Problem &problem) {
|
||||
preconditioning::materialSurfaceBlock(problem);
|
||||
};
|
||||
concept CanMakeDefaultMaterialSurface =
|
||||
requires(const Problem &problem) { preconditioning::materialSurfaceBlock(problem); };
|
||||
|
||||
template <typename Problem>
|
||||
concept CanPrepareDefaultMaterialSurface = requires(const Problem &problem) {
|
||||
@@ -195,9 +204,8 @@ namespace {
|
||||
};
|
||||
|
||||
template <typename Problem>
|
||||
concept CanMakeDefaultStellarStructure = requires(const Problem &problem) {
|
||||
preconditioning::stellarStructureBlock(problem);
|
||||
};
|
||||
concept CanMakeDefaultStellarStructure =
|
||||
requires(const Problem &problem) { preconditioning::stellarStructureBlock(problem); };
|
||||
|
||||
class KnownCouplings final {
|
||||
public:
|
||||
@@ -315,41 +323,46 @@ TEST_CASE(
|
||||
STATIC_CHECK(preconditioning::PreconditionerComponent<MaterialSurfaceDiagonal>);
|
||||
STATIC_CHECK(preconditioning::PreconditionerComponent<MaterialSurfaceH1>);
|
||||
STATIC_CHECK(preconditioning::MaterialSurfaceDescriptor<PolytropicMaterialSurfaceDescriptor>);
|
||||
STATIC_CHECK(preconditioning::ImplementedMaterialSurfaceEquationOfState<
|
||||
mean_field::eos::Polytrope>);
|
||||
STATIC_CHECK(preconditioning::ImplementedMaterialSurfaceEquationOfState<mean_field::eos::Polytrope>);
|
||||
STATIC_CHECK_FALSE(preconditioning::ImplementedMaterialSurfaceEquationOfState<int>);
|
||||
STATIC_CHECK(preconditioning::ImplementedMaterialSurfaceDescriptor<PolytropicMaterialSurfaceDescriptor>);
|
||||
STATIC_CHECK(
|
||||
preconditioning::ExecutableMaterialSurfaceRuntimeFor<
|
||||
mean_field::eos::Polytrope, mean_field::operators::PreparedStellarEquilibriumOperator>
|
||||
);
|
||||
STATIC_CHECK(
|
||||
std::same_as<
|
||||
typename preconditioning::MaterialSurfaceEquationOfStateBackend<mean_field::eos::Polytrope>::CoreType,
|
||||
mean_field::operators::PreparedStellarEquilibriumOperator>
|
||||
);
|
||||
STATIC_CHECK(
|
||||
preconditioning::MaterialSurfaceRuntimeFor<
|
||||
PolytropicMaterialSurfaceDescriptor, mean_field::operators::PreparedStellarEquilibriumOperator>
|
||||
);
|
||||
STATIC_CHECK_FALSE(
|
||||
preconditioning::ImplementedMaterialSurfaceEquationOfState<int>);
|
||||
STATIC_CHECK(preconditioning::ImplementedMaterialSurfaceDescriptor<
|
||||
PolytropicMaterialSurfaceDescriptor>);
|
||||
STATIC_CHECK(preconditioning::ExecutableMaterialSurfaceRuntimeFor<
|
||||
mean_field::eos::Polytrope,
|
||||
mean_field::operators::PreparedStellarEquilibriumOperator>);
|
||||
STATIC_CHECK(std::same_as<
|
||||
typename preconditioning::MaterialSurfaceEquationOfStateBackend<
|
||||
mean_field::eos::Polytrope>::CoreType,
|
||||
mean_field::operators::PreparedStellarEquilibriumOperator>);
|
||||
STATIC_CHECK(preconditioning::MaterialSurfaceRuntimeFor<
|
||||
PolytropicMaterialSurfaceDescriptor,
|
||||
mean_field::operators::PreparedStellarEquilibriumOperator>);
|
||||
STATIC_CHECK_FALSE(preconditioning::MaterialSurfaceRuntimeFor<
|
||||
PolytropicMaterialSurfaceDescriptor,
|
||||
DistinctPhysicalCore>);
|
||||
STATIC_CHECK(preconditioning::MaterialSurfaceDescriptor<
|
||||
RegisteredAlternateMaterialSurfaceDescriptor>);
|
||||
preconditioning::MaterialSurfaceRuntimeFor<PolytropicMaterialSurfaceDescriptor, DistinctPhysicalCore>
|
||||
);
|
||||
STATIC_CHECK(preconditioning::MaterialSurfaceDescriptor<RegisteredAlternateMaterialSurfaceDescriptor>);
|
||||
STATIC_CHECK(mean_field::equilibrium::StellarEquilibriumModel<RegisteredAlternateModel>);
|
||||
STATIC_CHECK(std::same_as<
|
||||
typename RegisteredAlternateProblem::PhysicalCoreType,
|
||||
material_surface_runtime_contract_test::AlternatePhysicalCore>);
|
||||
STATIC_CHECK(preconditioning::ImplementedMaterialSurfaceEquationOfState<
|
||||
material_surface_runtime_contract_test::RegisteredAlternateEquationOfState>);
|
||||
STATIC_CHECK(preconditioning::ImplementedMaterialSurfaceDescriptor<
|
||||
RegisteredAlternateMaterialSurfaceDescriptor>);
|
||||
STATIC_CHECK_FALSE(preconditioning::ExecutableMaterialSurfaceRuntimeFor<
|
||||
material_surface_runtime_contract_test::RegisteredAlternateEquationOfState,
|
||||
material_surface_runtime_contract_test::AlternatePhysicalCore>);
|
||||
STATIC_CHECK_FALSE(preconditioning::MaterialSurfaceRuntimeFor<
|
||||
RegisteredAlternateMaterialSurfaceDescriptor,
|
||||
material_surface_runtime_contract_test::AlternatePhysicalCore>);
|
||||
STATIC_CHECK(
|
||||
std::same_as<
|
||||
typename RegisteredAlternateProblem::PhysicalCoreType,
|
||||
material_surface_runtime_contract_test::AlternatePhysicalCore>
|
||||
);
|
||||
STATIC_CHECK(
|
||||
preconditioning::ImplementedMaterialSurfaceEquationOfState<
|
||||
material_surface_runtime_contract_test::RegisteredAlternateEquationOfState>
|
||||
);
|
||||
STATIC_CHECK(preconditioning::ImplementedMaterialSurfaceDescriptor<RegisteredAlternateMaterialSurfaceDescriptor>);
|
||||
STATIC_CHECK_FALSE(
|
||||
preconditioning::ExecutableMaterialSurfaceRuntimeFor<
|
||||
material_surface_runtime_contract_test::RegisteredAlternateEquationOfState,
|
||||
material_surface_runtime_contract_test::AlternatePhysicalCore>
|
||||
);
|
||||
STATIC_CHECK_FALSE(
|
||||
preconditioning::MaterialSurfaceRuntimeFor<
|
||||
RegisteredAlternateMaterialSurfaceDescriptor, material_surface_runtime_contract_test::AlternatePhysicalCore>
|
||||
);
|
||||
STATIC_CHECK(preconditioning::MaterialSurfacePreconditionerProblem<PolytropicProblem>);
|
||||
STATIC_CHECK_FALSE(preconditioning::MaterialSurfacePreconditionerProblem<RegisteredAlternateProblem>);
|
||||
STATIC_CHECK(CanMakeDefaultMaterialSurface<PolytropicProblem>);
|
||||
@@ -357,10 +370,10 @@ TEST_CASE(
|
||||
STATIC_CHECK(CanPrepareDefaultMaterialSurface<PolytropicProblem>);
|
||||
STATIC_CHECK_FALSE(CanPrepareDefaultMaterialSurface<RegisteredAlternateProblem>);
|
||||
STATIC_CHECK_FALSE(preconditioning::StellarStructurePreconditionerProblem<RegisteredAlternateProblem>);
|
||||
STATIC_CHECK_FALSE(preconditioning::StellarStructurePreparableFor<
|
||||
RegisteredAlternateProblem,
|
||||
MaterialSurfaceDiagonal,
|
||||
RegisteredAlternateGravityComponent>);
|
||||
STATIC_CHECK_FALSE(
|
||||
preconditioning::StellarStructurePreparableFor<
|
||||
RegisteredAlternateProblem, MaterialSurfaceDiagonal, RegisteredAlternateGravityComponent>
|
||||
);
|
||||
STATIC_CHECK_FALSE(CanMakeDefaultStellarStructure<RegisteredAlternateProblem>);
|
||||
STATIC_CHECK(
|
||||
mean_field::material::CompiledThermodynamicEquations<typename PolytropicProblem::ThermodynamicEquationsType>
|
||||
@@ -572,9 +585,10 @@ TEST_CASE(
|
||||
const utils::Args arguments = test_utils::setup_args();
|
||||
fem::FEM finiteElements = fem::setup_fem(arguments.mesh_file, arguments, 0);
|
||||
REQUIRE(finiteElements.okay());
|
||||
const mfem::ParFiniteElementSpace *surfaceDeformationSpace = finiteElements.surfaceDeformationFes.get();
|
||||
|
||||
constexpr double radius = utils::RADIUS;
|
||||
constexpr double mass = utils::MASS;
|
||||
constexpr double radius = utils::RADIUS;
|
||||
constexpr double mass = utils::MASS;
|
||||
const double polytropicConstant = 2.0 * utils::G * radius * radius / std::numbers::pi_v<double>;
|
||||
const double centralDensity = std::numbers::pi_v<double> * mass / (4.0 * radius * radius * radius);
|
||||
const auto stellarModel = model::StellarModel(
|
||||
@@ -583,7 +597,7 @@ TEST_CASE(
|
||||
integral::FixedTotalMass({.Mtotal = dimensions::MassValue{mass}}),
|
||||
constraint::FixedCentralDensity({.RhoC = dimensions::DensityValue{centralDensity}})
|
||||
);
|
||||
auto problem = equilibrium::discretize(stellarModel, finiteElements);
|
||||
auto problem = equilibrium::discretize(stellarModel, std::move(finiteElements));
|
||||
auto projected = seed::makeProjectedEquilibriumState(problem, seed::LaneEmden({.radialSampleCount = 512}));
|
||||
const auto rotation = zeroRotation();
|
||||
problem.Prepare(projected.values, makeDependencies(), rotation);
|
||||
@@ -711,7 +725,7 @@ TEST_CASE(
|
||||
CHECK(surfaceFit.relativeGramDeterminant > 1.0e-12);
|
||||
CHECK(surfaceFit.normalEquations.targetTarget > 0.0);
|
||||
CHECK(frequencyAware.GetSurfaceInverse().Height() == physical.GetDomainDeformation().parameterCount());
|
||||
CHECK(frequencyAware.GetSurfaceSurrogateMatrix().Height() == finiteElements.surfaceDeformationFes->GetTrueVSize());
|
||||
CHECK(frequencyAware.GetSurfaceSurrogateMatrix().Height() == surfaceDeformationSpace->GetTrueVSize());
|
||||
CHECK(frequencyAware.GetSurfaceBackend().GetStatistics().setups == 1);
|
||||
CHECK(frequencyAware.GetStatistics().surfaceJacobianProbes == 4);
|
||||
CHECK(frequencyAware.GetStatistics().surfaceH1Assemblies == 3);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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(
|
||||
|
||||
@@ -108,12 +108,12 @@ namespace {
|
||||
return action;
|
||||
}
|
||||
|
||||
using PolytropicModel = mean_field::model::StellarModel<mean_field::models::SpecificationSet<
|
||||
using PolytropicModel = mean_field::model::StellarModel<mean_field::models::SpecificationSet<
|
||||
mean_field::eos::Polytrope,
|
||||
mean_field::surface::Isobaric,
|
||||
mean_field::integral::FixedTotalMass,
|
||||
mean_field::constraint::FixedCentralDensity>>;
|
||||
using PolytropicProblem = mean_field::equilibrium::StellarEquilibriumProblem<PolytropicModel>;
|
||||
using PolytropicProblem = mean_field::equilibrium::StellarEquilibriumProblem<PolytropicModel>;
|
||||
using PolytropicMaterialSurfaceDescriptor = preconditioning::MaterialSurfaceDescriptorFor<PolytropicProblem>;
|
||||
using MaterialComponent =
|
||||
decltype(preconditioning::materialSurfaceBlock(std::declval<const PolytropicProblem &>()));
|
||||
@@ -181,20 +181,21 @@ TEST_CASE(
|
||||
preconditioning::Coupling<blocks::enthalpy::specific::residual, blocks::gravity::poisson::value>>;
|
||||
|
||||
STATIC_CHECK(preconditioning::PreconditionerComponent<PolytropicStructure>);
|
||||
STATIC_CHECK(preconditioning::ExecutableStellarStructureRuntimeFor<
|
||||
mean_field::operators::PreparedStellarEquilibriumOperator>);
|
||||
STATIC_CHECK(
|
||||
preconditioning::ExecutableStellarStructureRuntimeFor<mean_field::operators::PreparedStellarEquilibriumOperator>
|
||||
);
|
||||
STATIC_CHECK_FALSE(preconditioning::ExecutableStellarStructureRuntimeFor<DistinctPhysicalCore>);
|
||||
STATIC_CHECK(preconditioning::StellarStructureRuntimeFor<
|
||||
PolytropicMaterialSurfaceDescriptor,
|
||||
mean_field::operators::PreparedStellarEquilibriumOperator>);
|
||||
STATIC_CHECK_FALSE(preconditioning::StellarStructureRuntimeFor<
|
||||
PolytropicMaterialSurfaceDescriptor,
|
||||
DistinctPhysicalCore>);
|
||||
STATIC_CHECK(
|
||||
preconditioning::StellarStructureRuntimeFor<
|
||||
PolytropicMaterialSurfaceDescriptor, mean_field::operators::PreparedStellarEquilibriumOperator>
|
||||
);
|
||||
STATIC_CHECK_FALSE(
|
||||
preconditioning::StellarStructureRuntimeFor<PolytropicMaterialSurfaceDescriptor, DistinctPhysicalCore>
|
||||
);
|
||||
STATIC_CHECK(preconditioning::StellarStructurePreconditionerProblem<PolytropicProblem>);
|
||||
STATIC_CHECK(preconditioning::StellarStructurePreparableFor<
|
||||
PolytropicProblem,
|
||||
MaterialComponent,
|
||||
GravityComponent>);
|
||||
STATIC_CHECK(
|
||||
preconditioning::StellarStructurePreparableFor<PolytropicProblem, MaterialComponent, GravityComponent>
|
||||
);
|
||||
STATIC_CHECK(CanPrepareDefaultStellarStructure<PolytropicProblem>);
|
||||
STATIC_CHECK(std::same_as<typename PolytropicStructure::MaterialToGravityCouplings, ExpectedMaterialToGravity>);
|
||||
STATIC_CHECK(std::same_as<typename PolytropicStructure::GravityToMaterialCouplings, ExpectedGravityToMaterial>);
|
||||
@@ -268,7 +269,7 @@ TEST_CASE(
|
||||
integral::FixedTotalMass({.Mtotal = dimensions::MassValue{mass}}),
|
||||
constraint::FixedCentralDensity({.RhoC = dimensions::DensityValue{centralDensity}})
|
||||
);
|
||||
auto problem = equilibrium::discretize(stellarModel, finiteElements);
|
||||
auto problem = equilibrium::discretize(stellarModel, std::move(finiteElements));
|
||||
auto projected = seed::makeProjectedEquilibriumState(problem, seed::LaneEmden({.radialSampleCount = 512}));
|
||||
problem.Prepare(projected.values, makeDependencies(), zeroRotation());
|
||||
const auto &physical = problem.GetPreparedOperator().GetPhysicalOperator();
|
||||
|
||||
Reference in New Issue
Block a user