feat(preconditioner): major work on preconditioner system
first preconditioner MVP
This commit is contained in:
@@ -25,12 +25,21 @@ namespace {
|
||||
|
||||
struct EntropyField final {
|
||||
static constexpr std::string_view name = "entropy";
|
||||
using PhysicalQuantity = Entropy;
|
||||
};
|
||||
|
||||
struct ElectronFractionField final {
|
||||
static constexpr std::string_view name = "electron_fraction";
|
||||
using PhysicalQuantity = ElectronFraction;
|
||||
};
|
||||
|
||||
struct EntropyValueBlock final : mean_field::utils::blocks::value_block_base { };
|
||||
struct EntropyResidualBlock final : mean_field::utils::blocks::residual_block_base { };
|
||||
struct ElectronFractionValueBlock final : mean_field::utils::blocks::value_block_base { };
|
||||
struct ElectronFractionResidualBlock final : mean_field::utils::blocks::residual_block_base { };
|
||||
struct GeneralEnthalpyValueBlock final : mean_field::utils::blocks::value_block_base { };
|
||||
struct GeneralEnthalpyResidualBlock final : mean_field::utils::blocks::residual_block_base { };
|
||||
|
||||
using SpecificEnthalpyFromPressureEntropyAndElectronFraction =
|
||||
eos::Relation<eos::quantity::SpecificEnthalpy, eos::quantity::Pressure, Entropy, ElectronFraction>;
|
||||
|
||||
@@ -151,13 +160,46 @@ namespace {
|
||||
}
|
||||
};
|
||||
|
||||
using GeneralSurfaceFormulation = surface::SurfaceConstraintFormulation<
|
||||
eos::quantity::SpecificEnthalpy,
|
||||
field::Enthalpy,
|
||||
surface::SurfaceStateBindings<
|
||||
surface::SurfaceStateBinding<eos::quantity::SpecificEnthalpy, field::Enthalpy>,
|
||||
surface::SurfaceStateBinding<Entropy, EntropyField>,
|
||||
surface::SurfaceStateBinding<ElectronFraction, ElectronFractionField>>>;
|
||||
using GeneralAvailableThermodynamicEquations = mean_field::material::ThermodynamicEquationCatalog<
|
||||
mean_field::material::ThermodynamicEquation<EntropyField, EntropyValueBlock, EntropyResidualBlock>,
|
||||
mean_field::material::
|
||||
ThermodynamicEquation<ElectronFractionField, ElectronFractionValueBlock, ElectronFractionResidualBlock>,
|
||||
mean_field::material::
|
||||
ThermodynamicEquation<field::Enthalpy, GeneralEnthalpyValueBlock, GeneralEnthalpyResidualBlock>>;
|
||||
|
||||
using GeneralMaterialSurfaceForm = mean_field::utils::blocks::block_form<
|
||||
mean_field::utils::blocks::type_list<
|
||||
EntropyValueBlock,
|
||||
ElectronFractionValueBlock,
|
||||
mean_field::utils::blocks::surface_deformation::parameters::value,
|
||||
GeneralEnthalpyValueBlock>,
|
||||
mean_field::utils::blocks::type_list<
|
||||
EntropyResidualBlock,
|
||||
ElectronFractionResidualBlock,
|
||||
mean_field::utils::blocks::surface_deformation::shape_equilibrium::residual,
|
||||
GeneralEnthalpyResidualBlock>>;
|
||||
using GeneralMaterialSurfaceJacobian = mean_field::utils::blocks::type_list<
|
||||
mean_field::utils::blocks::block_row<EntropyResidualBlock, EntropyValueBlock, GeneralEnthalpyValueBlock>,
|
||||
mean_field::utils::blocks::
|
||||
block_row<ElectronFractionResidualBlock, ElectronFractionValueBlock, GeneralEnthalpyValueBlock>,
|
||||
mean_field::utils::blocks::block_row<
|
||||
mean_field::utils::blocks::surface_deformation::shape_equilibrium::residual,
|
||||
EntropyValueBlock,
|
||||
ElectronFractionValueBlock,
|
||||
mean_field::utils::blocks::surface_deformation::parameters::value,
|
||||
GeneralEnthalpyValueBlock>,
|
||||
mean_field::utils::blocks::block_row<
|
||||
GeneralEnthalpyResidualBlock,
|
||||
EntropyValueBlock,
|
||||
ElectronFractionValueBlock,
|
||||
mean_field::utils::blocks::surface_deformation::parameters::value,
|
||||
GeneralEnthalpyValueBlock>>;
|
||||
|
||||
using GeneralThermodynamicEquations = mean_field::material::CompiledThermodynamicEquationsT<
|
||||
GeneralStellarMatterEquationOfState,
|
||||
GeneralMaterialSurfaceForm,
|
||||
GeneralAvailableThermodynamicEquations>;
|
||||
using GeneralSurfaceFormulation = GeneralThermodynamicEquations::PressureSurfaceFormulation;
|
||||
|
||||
struct PolytropicSurfaceState final {
|
||||
double specificEnthalpy;
|
||||
@@ -187,6 +229,9 @@ namespace {
|
||||
|
||||
template <typename Candidate>
|
||||
concept HasTargetEnthalpy = requires(const Candidate &candidate) { candidate.targetEnthalpy; };
|
||||
|
||||
template <typename Candidate>
|
||||
concept SelectsThermodynamicCarrier = requires { typename Candidate::CarrierField; };
|
||||
} // namespace
|
||||
|
||||
TEST_CASE(
|
||||
@@ -198,6 +243,7 @@ TEST_CASE(
|
||||
STATIC_CHECK_FALSE(std::constructible_from<surface::ConstantPressureSurface, eos::SpecificEnthalpyValue>);
|
||||
STATIC_CHECK_FALSE(std::constructible_from<surface::ConstantPressureSurface, double>);
|
||||
STATIC_CHECK(std::same_as<surface::Isobaric, surface::ConstantPressureSurface>);
|
||||
STATIC_CHECK_FALSE(SelectsThermodynamicCarrier<surface::Isobaric>);
|
||||
STATIC_CHECK(std::is_trivially_copyable_v<surface::ConstantPressureSurface>);
|
||||
STATIC_CHECK(std::is_trivially_copyable_v<surface::PressureSurfaceDescriptor>);
|
||||
STATIC_CHECK(std::is_trivially_copyable_v<surface::RuntimeSurfaceConstraintDependencies>);
|
||||
@@ -218,8 +264,12 @@ TEST_CASE(
|
||||
"Polytropic EOS Resolves Constant Surface Pressure Through Its Enthalpy Relation",
|
||||
tags::surface_constraint_compilation
|
||||
) {
|
||||
using Formulation = surface::BarotropicSurfaceFormulation;
|
||||
using ThermodynamicEquations = mean_field::material::CompiledThermodynamicEquationsT<
|
||||
eos::Polytrope, mean_field::utils::blocks::surface_deformed_stellar_equilibrium_form,
|
||||
mean_field::material::StellarEquilibriumThermodynamicEquations>;
|
||||
using Formulation = ThermodynamicEquations::PressureSurfaceFormulation;
|
||||
|
||||
STATIC_CHECK(mean_field::material::CompiledThermodynamicEquations<ThermodynamicEquations>);
|
||||
STATIC_CHECK(surface::PressureSurfaceCompilable<Formulation, eos::Polytrope>);
|
||||
STATIC_CHECK_FALSE(surface::PressureSurfaceCompilable<Formulation, DensityOnlyEquationOfState>);
|
||||
|
||||
@@ -255,7 +305,10 @@ TEST_CASE(
|
||||
"General EOS Resolves Constant Surface Pressure With Local Composition",
|
||||
tags::surface_constraint_compilation
|
||||
) {
|
||||
STATIC_CHECK(surface::PressureSurfaceCompilable<GeneralSurfaceFormulation, GeneralStellarMatterEquationOfState>);
|
||||
using Formulation = GeneralThermodynamicEquations::PressureSurfaceFormulation;
|
||||
|
||||
STATIC_CHECK(mean_field::material::CompiledThermodynamicEquations<GeneralThermodynamicEquations>);
|
||||
STATIC_CHECK(surface::PressureSurfaceCompilable<Formulation, GeneralStellarMatterEquationOfState>);
|
||||
STATIC_CHECK_FALSE(
|
||||
surface::PressureSurfaceCompilable<surface::BarotropicSurfaceFormulation, GeneralStellarMatterEquationOfState>
|
||||
);
|
||||
@@ -267,11 +320,10 @@ TEST_CASE(
|
||||
|
||||
const GeneralStellarMatterEquationOfState equationOfState;
|
||||
const surface::ConstantPressureSurface pressureSurface{eos::PressureValue{0.4}};
|
||||
const auto constraint =
|
||||
surface::compilePressureSurfaceConstraint<GeneralSurfaceFormulation>(pressureSurface, equationOfState);
|
||||
const auto constraint = surface::compilePressureSurfaceConstraint<Formulation>(pressureSurface, equationOfState);
|
||||
|
||||
using Constraint = std::remove_cvref_t<decltype(constraint)>;
|
||||
using Dependencies = Constraint::SurfaceDependencies;
|
||||
using Constraint = std::remove_cvref_t<decltype(constraint)>;
|
||||
using Dependencies = Constraint::SurfaceDependencies;
|
||||
|
||||
STATIC_CHECK(std::same_as<Constraint::Relation, SpecificEnthalpyFromPressureEntropyAndElectronFraction>);
|
||||
STATIC_CHECK(
|
||||
@@ -297,6 +349,50 @@ TEST_CASE(
|
||||
CHECK(runtimeDependencies.stateFields[2] == surface::surfaceFieldId<ElectronFractionField>);
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"Compiled Material Surface Descriptors Change With The Material State Basis",
|
||||
tags::surface_constraint_compilation
|
||||
) {
|
||||
using Constraint = surface::CompiledPressureSurfaceConstraintT<
|
||||
GeneralThermodynamicEquations::PressureSurfaceFormulation, GeneralStellarMatterEquationOfState>;
|
||||
using Descriptor = mean_field::preconditioning::CompiledMaterialSurfaceDescriptor<
|
||||
GeneralThermodynamicEquations, Constraint, GeneralMaterialSurfaceForm, GeneralMaterialSurfaceJacobian>;
|
||||
using IncompleteForm = mean_field::utils::blocks::block_form<
|
||||
mean_field::utils::blocks::type_list<
|
||||
EntropyValueBlock, mean_field::utils::blocks::surface_deformation::parameters::value,
|
||||
GeneralEnthalpyValueBlock>,
|
||||
mean_field::utils::blocks::type_list<
|
||||
EntropyResidualBlock, mean_field::utils::blocks::surface_deformation::shape_equilibrium::residual,
|
||||
GeneralEnthalpyResidualBlock>>;
|
||||
using IncompleteJacobian = mean_field::utils::blocks::type_list<
|
||||
mean_field::utils::blocks::block_row<EntropyResidualBlock, EntropyValueBlock, GeneralEnthalpyValueBlock>,
|
||||
mean_field::utils::blocks::block_row<
|
||||
mean_field::utils::blocks::surface_deformation::shape_equilibrium::residual, EntropyValueBlock,
|
||||
mean_field::utils::blocks::surface_deformation::parameters::value, GeneralEnthalpyValueBlock>,
|
||||
mean_field::utils::blocks::block_row<
|
||||
GeneralEnthalpyResidualBlock, EntropyValueBlock,
|
||||
mean_field::utils::blocks::surface_deformation::parameters::value, GeneralEnthalpyValueBlock>>;
|
||||
using IncompleteDescriptor = mean_field::preconditioning::CompiledMaterialSurfaceDescriptor<
|
||||
GeneralThermodynamicEquations, Constraint, IncompleteForm, IncompleteJacobian>;
|
||||
|
||||
STATIC_CHECK(mean_field::preconditioning::MaterialSurfaceDescriptor<Descriptor>);
|
||||
STATIC_CHECK_FALSE(mean_field::preconditioning::MaterialSurfaceDescriptor<IncompleteDescriptor>);
|
||||
STATIC_CHECK(Descriptor::CorrectionBlocks::size == 4);
|
||||
STATIC_CHECK(Descriptor::ResidualBlocks::size == 4);
|
||||
STATIC_CHECK(Descriptor::RequiredCouplings::size == 12);
|
||||
STATIC_CHECK(
|
||||
std::same_as<
|
||||
Descriptor::SurfaceStateFields, field::TypeList<field::Enthalpy, EntropyField, ElectronFractionField>>
|
||||
);
|
||||
STATIC_CHECK(
|
||||
std::same_as<
|
||||
Descriptor::CorrectionBlocks,
|
||||
mean_field::utils::blocks::type_list<
|
||||
EntropyValueBlock, ElectronFractionValueBlock,
|
||||
mean_field::utils::blocks::surface_deformation::parameters::value, GeneralEnthalpyValueBlock>>
|
||||
);
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"General EOS Pressure Surface Jacobian Includes Every Local State Dependency",
|
||||
tags::surface_constraint_jacobian
|
||||
|
||||
Reference in New Issue
Block a user