#include #include #include #include #include import mean_field; import test_helpers; namespace field_registry_test_utils { namespace field = mean_field::field; namespace domain = mean_field::utils::domain; namespace quadrature = mean_field::quadrature; template struct TypeListSize; template struct TypeListSize> : std::integral_constant { }; template inline constexpr std::size_t typeListSize = TypeListSize::value; struct MissingSupportField { static constexpr std::string_view name = "missing_support"; using Quantities = field::TypeList; using Constraints = field::TypeList<>; using FormList = field::TypeList<>; }; struct InvalidSupportField { static constexpr std::string_view name = "invalid_support"; struct InvalidSupport { }; using Support = InvalidSupport; using Quantities = field::TypeList; using Constraints = field::TypeList<>; using FormList = field::TypeList<>; }; struct InvalidQuantityListField { static constexpr std::string_view name = "invalid_quantity_list"; using Support = field::NonSpatialSupport; using Quantities = field::TypeList; using Constraints = field::TypeList<>; using FormList = field::TypeList<>; }; struct InvalidFormListField { static constexpr std::string_view name = "invalid_form_list"; using Support = field::NonSpatialSupport; using Quantities = field::TypeList; using Constraints = field::TypeList<>; using FormList = field::TypeList; }; } // namespace field_registry_test_utils TEST_CASE( "Field Registry Recognizes Every Production Field And Rejects Incomplete Definitions", tags::unit &tags::field ) { namespace field = mean_field::field; STATIC_REQUIRE(field::FieldTag); STATIC_REQUIRE(field::FieldTag); STATIC_REQUIRE(field::FieldTag); STATIC_REQUIRE(field::FieldTag); STATIC_REQUIRE(field::FieldTag); STATIC_REQUIRE(field::FieldTag); STATIC_REQUIRE_FALSE(field::FieldTag); STATIC_REQUIRE_FALSE(field::FieldTag); STATIC_REQUIRE_FALSE(field::FieldTag); STATIC_REQUIRE_FALSE(field::FieldTag); CHECK(true); } TEST_CASE( "Field Registry Assigns The Intended Semantic Support To Every Production Field", tags::unit &tags::field ) { namespace field = mean_field::field; namespace domain = mean_field::utils::domain; STATIC_REQUIRE(field::DomainSupportedField); STATIC_REQUIRE(field::DomainSupportedField); STATIC_REQUIRE(field::DomainSupportedField); STATIC_REQUIRE(field::DomainSupportedField); STATIC_REQUIRE(field::NonSpatialField); STATIC_REQUIRE(field::NonSpatialField); STATIC_REQUIRE(std::same_as, domain::Stellar>); STATIC_REQUIRE(std::same_as, domain::Stellar>); STATIC_REQUIRE(std::same_as, domain::All>); STATIC_REQUIRE(std::same_as, domain::All>); STATIC_REQUIRE(std::same_as, field::NonSpatialSupport>); STATIC_REQUIRE(std::same_as, field::NonSpatialSupport>); CHECK(true); } TEST_CASE( "Density Registry Definition Is Complete And Self Consistent", tags::unit &tags::field ) { namespace field = mean_field::field; namespace quadrature = mean_field::quadrature; CHECK(field::Density::name == std::string_view{"density"}); CHECK(field::Density::Scalar::symbol == std::string_view{"ρ"}); STATIC_REQUIRE(field::Density::scalarOrder == 2); STATIC_REQUIRE(field::Density::Scalar::rankValue == 0); STATIC_REQUIRE(field::Density::Scalar::familyOrder == field::Density::scalarOrder); STATIC_REQUIRE(std::same_as); STATIC_REQUIRE(std::same_as); STATIC_REQUIRE(field_registry_test_utils::typeListSize == 1); STATIC_REQUIRE(field_registry_test_utils::typeListSize == 0); STATIC_REQUIRE(field_registry_test_utils::typeListSize == 8); STATIC_REQUIRE(field::Density::constraintsAreValid); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::Density::Form::ProjectionMass::policyKey == quadrature::Term::density_projection); STATIC_REQUIRE(field::Density::Form::ProjectionMass::dynamicOrderCount == 0); STATIC_REQUIRE( std::same_as< typename field::Density::Form::ProjectionMass::Operands, field::TypeList, field::Operand>> ); STATIC_REQUIRE(field::Density::Form::ProjectionSource::dynamicOrderCount == 1); STATIC_REQUIRE(field::Density::Form::EosClosureMass::policyKey == quadrature::Term::eos_closure); STATIC_REQUIRE(field::Density::Form::MassConservation::policyKey == quadrature::Term::mass_conservation); STATIC_REQUIRE(field::Density::Form::MassNormalization::policyKey == quadrature::Term::mass_normalization); STATIC_REQUIRE(field::Density::Form::CenterOfMass::dynamicOrderCount == 1); STATIC_REQUIRE(field::Density::Form::Quadrupole::dynamicOrderCount == 1); CHECK(true); } TEST_CASE( "Gravity Registry Defines A Stable Mixed RT L2 Pair And All Registered Forms", tags::unit &tags::field ) { namespace field = mean_field::field; namespace quadrature = mean_field::quadrature; CHECK(field::Gravity::name == std::string_view{"gravity"}); CHECK(field::Gravity::Potential::symbol == std::string_view{"φ"}); CHECK(field::Gravity::Flux::symbol == std::string_view{"∇φ"}); STATIC_REQUIRE(field::Gravity::potentialOrder == 2); STATIC_REQUIRE(field::Gravity::fluxOrder == 2); STATIC_REQUIRE(std::same_as); STATIC_REQUIRE(std::same_as); STATIC_REQUIRE(field::Gravity::Potential::rankValue == 0); STATIC_REQUIRE(field::Gravity::Flux::rankValue == 1); STATIC_REQUIRE(field::DerivedQuantity); STATIC_REQUIRE(std::same_as, field::Gravity::Potential>); STATIC_REQUIRE(field_registry_test_utils::typeListSize == 2); STATIC_REQUIRE(field_registry_test_utils::typeListSize == 1); STATIC_REQUIRE(field_registry_test_utils::typeListSize == 7); STATIC_REQUIRE(field::Gravity::constraintsAreValid); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::Gravity::Form::HDivMass::policyKey == quadrature::Term::gravity_hdiv_mass); STATIC_REQUIRE( std::same_as< typename field::Gravity::Form::HDivMass::Operands, field::TypeList, field::Operand>> ); STATIC_REQUIRE( std::same_as< typename field::Gravity::Form::DivergenceCoupling::Operands, field::TypeList< field::Operand, field::Operand>> ); STATIC_REQUIRE( std::same_as< typename field::Gravity::Form::Boundary::Operands, field::TypeList< field::Operand, field::Operand>> ); STATIC_REQUIRE( std::same_as< typename field::Gravity::Form::SourceLinear::Operands, field::TypeList, field::Operand>> ); CHECK(true); } TEST_CASE( "Displacement Registry Preserves Vector H1 Geometry And Force Forms", tags::unit &tags::field ) { namespace field = mean_field::field; namespace quadrature = mean_field::quadrature; CHECK(field::Displacement::name == std::string_view{"displacement"}); CHECK(field::Displacement::Vector::symbol == std::string_view{"d"}); STATIC_REQUIRE(field::Displacement::vectorOrder == 3); STATIC_REQUIRE(field::Displacement::Vector::rankValue == 1); STATIC_REQUIRE(std::same_as); STATIC_REQUIRE(field_registry_test_utils::typeListSize == 4); STATIC_REQUIRE(field::Displacement::constraintsAreValid); STATIC_REQUIRE(field::Displacement::Form::MeshExtension::policyKey == quadrature::Term::mesh_extension); STATIC_REQUIRE( std::same_as< typename field::Displacement::Form::MeshExtension::Operands, field::TypeList< field::Operand, field::Operand>> ); STATIC_REQUIRE( std::same_as< typename field::Displacement::Form::GravityForce::Operands, field::TypeList< field::Operand, field::Operand, field::Operand, field::Operand>> ); STATIC_REQUIRE(field::Displacement::Form::CentrifugalForce::dynamicOrderCount == 1); STATIC_REQUIRE(field::Displacement::Form::CentrifugalForce::policyKey == quadrature::Term::centrifugal); CHECK(true); } TEST_CASE( "Enthalpy Registry Preserves Continuous Stellar Field And Coupled Forms", tags::unit &tags::field ) { namespace field = mean_field::field; namespace quadrature = mean_field::quadrature; CHECK(field::Enthalpy::name == std::string_view{"specific_enthalpy"}); CHECK(field::Enthalpy::Scalar::symbol == std::string_view{"h"}); STATIC_REQUIRE(field::Enthalpy::scalarOrder == 3); STATIC_REQUIRE(field::Enthalpy::Scalar::rankValue == 0); STATIC_REQUIRE(std::same_as); STATIC_REQUIRE(field_registry_test_utils::typeListSize == 9); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::typeListContains); STATIC_REQUIRE(field::Enthalpy::Form::EosClosureSource::dynamicOrderCount == 1); STATIC_REQUIRE( std::same_as< typename field::Enthalpy::Form::EosClosureSource::Operands, field::TypeList, field::Operand>> ); STATIC_REQUIRE( std::same_as< typename field::Enthalpy::Form::EquilibriumGravity::Operands, field::TypeList, field::Operand>> ); STATIC_REQUIRE( std::same_as< typename field::Enthalpy::Form::EquilibriumConstant::Operands, field::TypeList, field::Operand>> ); STATIC_REQUIRE(field::Enthalpy::Form::IsobaricSurface::policyKey == quadrature::Term::isobaric_surface); STATIC_REQUIRE(field::Enthalpy::Form::PressureIntegral::policyKey == quadrature::Term::pressure_integral); STATIC_REQUIRE(field::Enthalpy::Form::PressureForce::policyKey == quadrature::Term::pressure_force); STATIC_REQUIRE( std::same_as< typename field::Enthalpy::Form::PressureForce::Operands, field::TypeList< field::Operand, field::Operand>> ); CHECK(true); } TEST_CASE( "Barotropic Constant Registry Is A Non Spatial Unit Sized Scalar", tags::unit &tags::field ) { namespace field = mean_field::field; CHECK(field::BarotropicConstant::name == std::string_view{"barotropic_constant"}); CHECK(field::BarotropicConstant::Scalar::symbol == std::string_view{"C"}); STATIC_REQUIRE(field::GlobalScalarQuantity); STATIC_REQUIRE(field::BarotropicConstant::Scalar::staticBlockSize == 1); STATIC_REQUIRE(field_registry_test_utils::typeListSize == 1); STATIC_REQUIRE(field_registry_test_utils::typeListSize == 0); STATIC_REQUIRE(field_registry_test_utils::typeListSize == 0); STATIC_REQUIRE(field::BarotropicConstant::constraintsAreValid); CHECK(true); }