feat(field-support): added field support system, mid migration
currently the barotope and the pressure force operator are migrated to the new support system
This commit is contained in:
@@ -20,8 +20,7 @@ namespace polytropic_barotrope_test_utils {
|
||||
const double position,
|
||||
const double step
|
||||
) {
|
||||
return (function(position + step) - function(position - step)) /
|
||||
(2.0 * step);
|
||||
return (function(position + step) - function(position - step)) / (2.0 * step);
|
||||
}
|
||||
|
||||
template <typename Integrand>
|
||||
@@ -31,10 +30,8 @@ namespace polytropic_barotrope_test_utils {
|
||||
) {
|
||||
double integral = 0.0;
|
||||
|
||||
for (int pointIndex = 0; pointIndex < integrationRule.GetNPoints();
|
||||
++pointIndex) {
|
||||
const mfem::IntegrationPoint &integrationPoint =
|
||||
integrationRule.IntPoint(pointIndex);
|
||||
for (int pointIndex = 0; pointIndex < integrationRule.GetNPoints(); ++pointIndex) {
|
||||
const mfem::IntegrationPoint &integrationPoint = integrationRule.IntPoint(pointIndex);
|
||||
|
||||
integral += integrationPoint.weight * integrand(integrationPoint);
|
||||
}
|
||||
@@ -55,12 +52,9 @@ TEST_CASE(
|
||||
|
||||
for (const double polytropicIndex : polytropicIndices) {
|
||||
DYNAMIC_SECTION("polytropic index n = " << polytropicIndex) {
|
||||
const mean_field::physics::PolytropicBarotrope barotrope(
|
||||
polytropicIndex, polytropicConstant
|
||||
);
|
||||
const mean_field::physics::PolytropicBarotrope barotrope(polytropicIndex, polytropicConstant);
|
||||
|
||||
const double expectedEnthalpyScale =
|
||||
(polytropicIndex + 1.0) * polytropicConstant;
|
||||
const double expectedEnthalpyScale = (polytropicIndex + 1.0) * polytropicConstant;
|
||||
|
||||
CHECK(barotrope.polytropic_index() == polytropicIndex);
|
||||
|
||||
@@ -71,45 +65,25 @@ TEST_CASE(
|
||||
for (const double density : densities) {
|
||||
CAPTURE(polytropicIndex, polytropicConstant, density);
|
||||
|
||||
const double expectedPressure =
|
||||
polytropicConstant *
|
||||
std::pow(density, 1.0 + 1.0 / polytropicIndex);
|
||||
const double expectedPressure = polytropicConstant * std::pow(density, 1.0 + 1.0 / polytropicIndex);
|
||||
|
||||
const double expectedEnthalpy =
|
||||
expectedEnthalpyScale *
|
||||
std::pow(density, 1.0 / polytropicIndex);
|
||||
const double expectedEnthalpy = expectedEnthalpyScale * std::pow(density, 1.0 / polytropicIndex);
|
||||
|
||||
const double pressureFromDensity =
|
||||
barotrope.pressure_from_density(density);
|
||||
const double pressureFromDensity = barotrope.pressure_from_density(density);
|
||||
|
||||
const double enthalpyFromDensity =
|
||||
barotrope.enthalpy_from_density(density);
|
||||
const double enthalpyFromDensity = barotrope.enthalpy_from_density(density);
|
||||
|
||||
const double recoveredDensity =
|
||||
barotrope.density_from_enthalpy(enthalpyFromDensity);
|
||||
const double recoveredDensity = barotrope.density_from_enthalpy(enthalpyFromDensity);
|
||||
|
||||
const double pressureFromEnthalpy =
|
||||
barotrope.pressure_from_enthalpy(enthalpyFromDensity);
|
||||
const double pressureFromEnthalpy = barotrope.pressure_from_enthalpy(enthalpyFromDensity);
|
||||
|
||||
CHECK_THAT(
|
||||
pressureFromDensity,
|
||||
Catch::Matchers::WithinRel(expectedPressure, 2.0e-13)
|
||||
);
|
||||
CHECK_THAT(pressureFromDensity, Catch::Matchers::WithinRel(expectedPressure, 2.0e-13));
|
||||
|
||||
CHECK_THAT(
|
||||
enthalpyFromDensity,
|
||||
Catch::Matchers::WithinRel(expectedEnthalpy, 2.0e-13)
|
||||
);
|
||||
CHECK_THAT(enthalpyFromDensity, Catch::Matchers::WithinRel(expectedEnthalpy, 2.0e-13));
|
||||
|
||||
CHECK_THAT(
|
||||
recoveredDensity,
|
||||
Catch::Matchers::WithinRel(density, 5.0e-13)
|
||||
);
|
||||
CHECK_THAT(recoveredDensity, Catch::Matchers::WithinRel(density, 5.0e-13));
|
||||
|
||||
CHECK_THAT(
|
||||
pressureFromEnthalpy,
|
||||
Catch::Matchers::WithinRel(expectedPressure, 5.0e-13)
|
||||
);
|
||||
CHECK_THAT(pressureFromEnthalpy, Catch::Matchers::WithinRel(expectedPressure, 5.0e-13));
|
||||
|
||||
/*
|
||||
* Polytropic identity:
|
||||
@@ -118,10 +92,7 @@ TEST_CASE(
|
||||
*/
|
||||
CHECK_THAT(
|
||||
pressureFromEnthalpy,
|
||||
Catch::Matchers::WithinRel(
|
||||
density * enthalpyFromDensity / (polytropicIndex + 1.0),
|
||||
5.0e-13
|
||||
)
|
||||
Catch::Matchers::WithinRel(density * enthalpyFromDensity / (polytropicIndex + 1.0), 5.0e-13)
|
||||
);
|
||||
|
||||
/*
|
||||
@@ -133,9 +104,8 @@ TEST_CASE(
|
||||
* value as density_from_enthalpy().
|
||||
*/
|
||||
CHECK(
|
||||
barotrope.pressure_derivative_from_enthalpy(
|
||||
enthalpyFromDensity
|
||||
) == barotrope.density_from_enthalpy(enthalpyFromDensity)
|
||||
barotrope.pressure_derivative_from_enthalpy(enthalpyFromDensity) ==
|
||||
barotrope.density_from_enthalpy(enthalpyFromDensity)
|
||||
);
|
||||
|
||||
/*
|
||||
@@ -149,9 +119,7 @@ TEST_CASE(
|
||||
*/
|
||||
CHECK_THAT(
|
||||
barotrope.pressure_derivative_from_density(density),
|
||||
Catch::Matchers::WithinRel(
|
||||
enthalpyFromDensity / polytropicIndex, 5.0e-13
|
||||
)
|
||||
Catch::Matchers::WithinRel(enthalpyFromDensity / polytropicIndex, 5.0e-13)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -169,63 +137,41 @@ TEST_CASE(
|
||||
constexpr double polytropicConstant = 0.61;
|
||||
|
||||
for (const double polytropicIndex : polytropicIndices) {
|
||||
const mean_field::physics::PolytropicBarotrope barotrope(
|
||||
polytropicIndex, polytropicConstant
|
||||
);
|
||||
const mean_field::physics::PolytropicBarotrope barotrope(polytropicIndex, polytropicConstant);
|
||||
|
||||
DYNAMIC_SECTION("polytropic index n = " << polytropicIndex) {
|
||||
for (const double enthalpy : positiveValues) {
|
||||
const double step = 2.0e-6 * std::max(1.0, std::abs(enthalpy));
|
||||
const double step = 2.0e-6 * std::max(1.0, std::abs(enthalpy));
|
||||
|
||||
const double numericalDerivative =
|
||||
polytropic_barotrope_test_utils::centered_derivative(
|
||||
[&barotrope](const double perturbedEnthalpy) {
|
||||
return barotrope.pressure_from_enthalpy(
|
||||
perturbedEnthalpy
|
||||
);
|
||||
},
|
||||
enthalpy, step
|
||||
);
|
||||
|
||||
const double analyticDerivative =
|
||||
barotrope.pressure_derivative_from_enthalpy(enthalpy);
|
||||
|
||||
CAPTURE(
|
||||
polytropicIndex, enthalpy, step, numericalDerivative,
|
||||
analyticDerivative
|
||||
const double numericalDerivative = polytropic_barotrope_test_utils::centered_derivative(
|
||||
[&barotrope](const double perturbedEnthalpy) {
|
||||
return barotrope.pressure_from_enthalpy(perturbedEnthalpy);
|
||||
},
|
||||
enthalpy, step
|
||||
);
|
||||
|
||||
CHECK_THAT(
|
||||
numericalDerivative,
|
||||
Catch::Matchers::WithinRel(analyticDerivative, 5.0e-8)
|
||||
);
|
||||
const double analyticDerivative = barotrope.pressure_derivative_from_enthalpy(enthalpy);
|
||||
|
||||
CAPTURE(polytropicIndex, enthalpy, step, numericalDerivative, analyticDerivative);
|
||||
|
||||
CHECK_THAT(numericalDerivative, Catch::Matchers::WithinRel(analyticDerivative, 5.0e-8));
|
||||
}
|
||||
|
||||
for (const double density : positiveValues) {
|
||||
const double step = 2.0e-6 * std::max(1.0, std::abs(density));
|
||||
const double step = 2.0e-6 * std::max(1.0, std::abs(density));
|
||||
|
||||
const double numericalDerivative =
|
||||
polytropic_barotrope_test_utils::centered_derivative(
|
||||
[&barotrope](const double perturbedDensity) {
|
||||
return barotrope.pressure_from_density(
|
||||
perturbedDensity
|
||||
);
|
||||
},
|
||||
density, step
|
||||
);
|
||||
|
||||
const double analyticDerivative =
|
||||
barotrope.pressure_derivative_from_density(density);
|
||||
|
||||
CAPTURE(
|
||||
polytropicIndex, density, step, numericalDerivative,
|
||||
analyticDerivative
|
||||
const double numericalDerivative = polytropic_barotrope_test_utils::centered_derivative(
|
||||
[&barotrope](const double perturbedDensity) {
|
||||
return barotrope.pressure_from_density(perturbedDensity);
|
||||
},
|
||||
density, step
|
||||
);
|
||||
|
||||
CHECK_THAT(
|
||||
numericalDerivative,
|
||||
Catch::Matchers::WithinRel(analyticDerivative, 5.0e-8)
|
||||
);
|
||||
const double analyticDerivative = barotrope.pressure_derivative_from_density(density);
|
||||
|
||||
CAPTURE(polytropicIndex, density, step, numericalDerivative, analyticDerivative);
|
||||
|
||||
CHECK_THAT(numericalDerivative, Catch::Matchers::WithinRel(analyticDerivative, 5.0e-8));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,36 +188,24 @@ TEST_CASE(
|
||||
constexpr double polytropicConstant = 0.61;
|
||||
|
||||
for (const double polytropicIndex : polytropicIndices) {
|
||||
const mean_field::physics::PolytropicBarotrope barotrope(
|
||||
polytropicIndex, polytropicConstant
|
||||
);
|
||||
const mean_field::physics::PolytropicBarotrope barotrope(polytropicIndex, polytropicConstant);
|
||||
|
||||
DYNAMIC_SECTION("polytropic index n = " << polytropicIndex) {
|
||||
for (const double enthalpy : enthalpies) {
|
||||
const double step = 2.0e-6 * std::max(1.0, std::abs(enthalpy));
|
||||
const double step = 2.0e-6 * std::max(1.0, std::abs(enthalpy));
|
||||
|
||||
const double numericalDerivative =
|
||||
polytropic_barotrope_test_utils::centered_derivative(
|
||||
[&barotrope](const double perturbedEnthalpy) {
|
||||
return barotrope.density_from_enthalpy(
|
||||
perturbedEnthalpy
|
||||
);
|
||||
},
|
||||
enthalpy, step
|
||||
);
|
||||
|
||||
const double analyticDerivative =
|
||||
barotrope.density_derivative_from_enthalpy(enthalpy);
|
||||
|
||||
CAPTURE(
|
||||
polytropicIndex, enthalpy, step, numericalDerivative,
|
||||
analyticDerivative
|
||||
const double numericalDerivative = polytropic_barotrope_test_utils::centered_derivative(
|
||||
[&barotrope](const double perturbedEnthalpy) {
|
||||
return barotrope.density_from_enthalpy(perturbedEnthalpy);
|
||||
},
|
||||
enthalpy, step
|
||||
);
|
||||
|
||||
CHECK_THAT(
|
||||
numericalDerivative,
|
||||
Catch::Matchers::WithinRel(analyticDerivative, 5.0e-8)
|
||||
);
|
||||
const double analyticDerivative = barotrope.density_derivative_from_enthalpy(enthalpy);
|
||||
|
||||
CAPTURE(polytropicIndex, enthalpy, step, numericalDerivative, analyticDerivative);
|
||||
|
||||
CHECK_THAT(numericalDerivative, Catch::Matchers::WithinRel(analyticDerivative, 5.0e-8));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,9 +221,7 @@ TEST_CASE(
|
||||
constexpr double exteriorEnthalpy = -0.3;
|
||||
|
||||
for (const double polytropicIndex : polytropicIndices) {
|
||||
const mean_field::physics::PolytropicBarotrope barotrope(
|
||||
polytropicIndex, polytropicConstant
|
||||
);
|
||||
const mean_field::physics::PolytropicBarotrope barotrope(polytropicIndex, polytropicConstant);
|
||||
|
||||
DYNAMIC_SECTION("polytropic index n = " << polytropicIndex) {
|
||||
/*
|
||||
@@ -314,15 +246,9 @@ TEST_CASE(
|
||||
|
||||
CHECK(barotrope.pressure_from_enthalpy(exteriorEnthalpy) == 0.0);
|
||||
|
||||
CHECK(
|
||||
barotrope.density_derivative_from_enthalpy(exteriorEnthalpy) ==
|
||||
0.0
|
||||
);
|
||||
CHECK(barotrope.density_derivative_from_enthalpy(exteriorEnthalpy) == 0.0);
|
||||
|
||||
CHECK(
|
||||
barotrope.pressure_derivative_from_enthalpy(exteriorEnthalpy) ==
|
||||
0.0
|
||||
);
|
||||
CHECK(barotrope.pressure_derivative_from_enthalpy(exteriorEnthalpy) == 0.0);
|
||||
|
||||
/*
|
||||
* At h = 0, rho(h) has a nonzero right
|
||||
@@ -331,10 +257,7 @@ TEST_CASE(
|
||||
const double expectedSurfaceDensityDerivative =
|
||||
polytropicIndex == 1.0 ? 1.0 / barotrope.enthalpy_scale() : 0.0;
|
||||
|
||||
CHECK(
|
||||
barotrope.density_derivative_from_enthalpy(0.0) ==
|
||||
expectedSurfaceDensityDerivative
|
||||
);
|
||||
CHECK(barotrope.density_derivative_from_enthalpy(0.0) == expectedSurfaceDensityDerivative);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -343,27 +266,15 @@ TEST_CASE(
|
||||
"Polytropic Barotrope Rejects Invalid Physical Inputs",
|
||||
tags::barotrope &tags::physics &tags::unit &tags::pressure
|
||||
) {
|
||||
CHECK_THROWS_AS(
|
||||
mean_field::physics::PolytropicBarotrope(0.999, 1.0),
|
||||
std::invalid_argument
|
||||
);
|
||||
CHECK_THROWS_AS(mean_field::physics::PolytropicBarotrope(0.999, 1.0), std::invalid_argument);
|
||||
|
||||
CHECK_THROWS_AS(
|
||||
mean_field::physics::PolytropicBarotrope(
|
||||
std::numeric_limits<double>::infinity(), 1.0
|
||||
),
|
||||
std::invalid_argument
|
||||
mean_field::physics::PolytropicBarotrope(std::numeric_limits<double>::infinity(), 1.0), std::invalid_argument
|
||||
);
|
||||
|
||||
CHECK_THROWS_AS(
|
||||
mean_field::physics::PolytropicBarotrope(3.0, 0.0),
|
||||
std::invalid_argument
|
||||
);
|
||||
CHECK_THROWS_AS(mean_field::physics::PolytropicBarotrope(3.0, 0.0), std::invalid_argument);
|
||||
|
||||
CHECK_THROWS_AS(
|
||||
mean_field::physics::PolytropicBarotrope(3.0, -1.0),
|
||||
std::invalid_argument
|
||||
);
|
||||
CHECK_THROWS_AS(mean_field::physics::PolytropicBarotrope(3.0, -1.0), std::invalid_argument);
|
||||
|
||||
const mean_field::physics::PolytropicBarotrope barotrope(3.0, 0.75);
|
||||
|
||||
@@ -371,45 +282,31 @@ TEST_CASE(
|
||||
|
||||
CHECK_THROWS_AS(barotrope.enthalpy_from_density(-0.1), std::domain_error);
|
||||
|
||||
CHECK_THROWS_AS(
|
||||
barotrope.pressure_derivative_from_density(-0.1), std::domain_error
|
||||
);
|
||||
CHECK_THROWS_AS(barotrope.pressure_derivative_from_density(-0.1), std::domain_error);
|
||||
|
||||
constexpr std::array<double, 3> nonfiniteValues{
|
||||
std::numeric_limits<double>::infinity(),
|
||||
-std::numeric_limits<double>::infinity(),
|
||||
std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity(),
|
||||
std::numeric_limits<double>::quiet_NaN()
|
||||
};
|
||||
|
||||
for (const double nonfiniteValue : nonfiniteValues) {
|
||||
CAPTURE(nonfiniteValue);
|
||||
|
||||
CHECK_THROWS_AS(
|
||||
barotrope.density_from_enthalpy(nonfiniteValue), std::domain_error
|
||||
);
|
||||
CHECK_THROWS_AS(barotrope.density_from_enthalpy(nonfiniteValue), std::domain_error);
|
||||
|
||||
CHECK_THROWS_AS(
|
||||
barotrope.pressure_from_enthalpy(nonfiniteValue), std::domain_error
|
||||
);
|
||||
CHECK_THROWS_AS(barotrope.pressure_from_enthalpy(nonfiniteValue), std::domain_error);
|
||||
|
||||
CHECK_THROWS_AS(
|
||||
barotrope.density_derivative_from_enthalpy(nonfiniteValue),
|
||||
std::domain_error
|
||||
);
|
||||
CHECK_THROWS_AS(barotrope.density_derivative_from_enthalpy(nonfiniteValue), std::domain_error);
|
||||
|
||||
CHECK_THROWS_AS(
|
||||
barotrope.pressure_derivative_from_enthalpy(nonfiniteValue),
|
||||
std::domain_error
|
||||
);
|
||||
CHECK_THROWS_AS(barotrope.pressure_derivative_from_enthalpy(nonfiniteValue), std::domain_error);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"Pressure Force And Pressure Integral Have Distinct Registered Forms",
|
||||
tags::barotrope &tags::pressure &tags::pressure_gradient &tags::quadrature
|
||||
&tags::unit
|
||||
tags::barotrope &tags::pressure &tags::pressure_gradient &tags::quadrature &tags::unit
|
||||
) {
|
||||
using EnthalpyField = mean_field::field::Field<mean_field::field::Enthalpy>;
|
||||
using EnthalpyField = mean_field::field::Field<mean_field::field::Enthalpy>;
|
||||
|
||||
/*
|
||||
* For the registered H1 order p = 3 and n = 3:
|
||||
@@ -423,39 +320,29 @@ TEST_CASE(
|
||||
*
|
||||
* beyond the registered enthalpy operand.
|
||||
*/
|
||||
constexpr int enthalpyOrder =
|
||||
mean_field::field::Enthalpy::Scalar::familyOrder;
|
||||
constexpr int enthalpyOrder = mean_field::field::Enthalpy::Scalar::familyOrder;
|
||||
|
||||
constexpr int pressureExtraOrder = 3 * enthalpyOrder;
|
||||
|
||||
constexpr int geometryWeightOrder = 2;
|
||||
|
||||
constexpr mean_field::quadrature::Query pressureIntegralQuery =
|
||||
EnthalpyField::make_query<
|
||||
mean_field::field::Enthalpy::Form::PressureIntegral>(
|
||||
mean_field::quadrature::QuadratureRole::diagnostic,
|
||||
geometryWeightOrder, std::array<int, 1>{pressureExtraOrder},
|
||||
mean_field::utils::DOMAINS::STELLAR,
|
||||
EnthalpyField::make_query<mean_field::field::Enthalpy::Form::PressureIntegral>(
|
||||
mean_field::quadrature::QuadratureRole::diagnostic, geometryWeightOrder,
|
||||
std::array<int, 1>{pressureExtraOrder}, mean_field::utils::DOMAINS::STELLAR,
|
||||
mean_field::quadrature::MappingKind::general
|
||||
);
|
||||
|
||||
constexpr mean_field::quadrature::Query pressureForceQuery =
|
||||
EnthalpyField::make_query<
|
||||
mean_field::field::Enthalpy::Form::PressureForce>(
|
||||
mean_field::quadrature::QuadratureRole::discretization,
|
||||
geometryWeightOrder, std::array<int, 1>{pressureExtraOrder},
|
||||
mean_field::utils::DOMAINS::STELLAR,
|
||||
EnthalpyField::make_query<mean_field::field::Enthalpy::Form::PressureForce>(
|
||||
mean_field::quadrature::QuadratureRole::discretization, geometryWeightOrder,
|
||||
std::array<int, 1>{pressureExtraOrder}, mean_field::utils::DOMAINS::STELLAR,
|
||||
mean_field::quadrature::MappingKind::general
|
||||
);
|
||||
|
||||
STATIC_CHECK(
|
||||
mean_field::field::Enthalpy::Form::PressureIntegral::
|
||||
dynamicOrderCount == 1
|
||||
);
|
||||
STATIC_CHECK(mean_field::field::Enthalpy::Form::PressureIntegral::dynamicOrderCount == 1);
|
||||
|
||||
STATIC_CHECK(
|
||||
mean_field::field::Enthalpy::Form::PressureForce::dynamicOrderCount == 1
|
||||
);
|
||||
STATIC_CHECK(mean_field::field::Enthalpy::Form::PressureForce::dynamicOrderCount == 1);
|
||||
|
||||
STATIC_CHECK(
|
||||
mean_field::field::Enthalpy::Form::PressureIntegral::policyKey !=
|
||||
@@ -487,24 +374,13 @@ TEST_CASE(
|
||||
*/
|
||||
CHECK(*pressureForceQuery.base_order == 16);
|
||||
|
||||
CHECK(
|
||||
pressureIntegralQuery.term ==
|
||||
mean_field::quadrature::Term::pressure_integral
|
||||
);
|
||||
CHECK(pressureIntegralQuery.term == mean_field::quadrature::Term::pressure_integral);
|
||||
|
||||
CHECK(
|
||||
pressureForceQuery.term == mean_field::quadrature::Term::pressure_force
|
||||
);
|
||||
CHECK(pressureForceQuery.term == mean_field::quadrature::Term::pressure_force);
|
||||
|
||||
CHECK(
|
||||
pressureIntegralQuery.role ==
|
||||
mean_field::quadrature::QuadratureRole::diagnostic
|
||||
);
|
||||
CHECK(pressureIntegralQuery.role == mean_field::quadrature::QuadratureRole::diagnostic);
|
||||
|
||||
CHECK(
|
||||
pressureForceQuery.role ==
|
||||
mean_field::quadrature::QuadratureRole::discretization
|
||||
);
|
||||
CHECK(pressureForceQuery.role == mean_field::quadrature::QuadratureRole::discretization);
|
||||
|
||||
CHECK(pressureIntegralQuery.domain == mean_field::utils::DOMAINS::STELLAR);
|
||||
|
||||
@@ -515,20 +391,16 @@ TEST_CASE(
|
||||
* controls.
|
||||
*/
|
||||
mean_field::quadrature::RuleSet ruleSet =
|
||||
mean_field::quadrature::make_rule_set(
|
||||
mean_field::quadrature::Mode::production
|
||||
);
|
||||
mean_field::quadrature::make_rule_set(mean_field::quadrature::Mode::production);
|
||||
|
||||
ruleSet.pressure_integral.boost = 3;
|
||||
ruleSet.pressure_force.boost = 5;
|
||||
|
||||
const mean_field::quadrature::Policy policy(std::move(ruleSet));
|
||||
|
||||
const mean_field::quadrature::Resolution pressureIntegralResolution =
|
||||
policy.resolve(pressureIntegralQuery);
|
||||
const mean_field::quadrature::Resolution pressureIntegralResolution = policy.resolve(pressureIntegralQuery);
|
||||
|
||||
const mean_field::quadrature::Resolution pressureForceResolution =
|
||||
policy.resolve(pressureForceQuery);
|
||||
const mean_field::quadrature::Resolution pressureForceResolution = policy.resolve(pressureForceQuery);
|
||||
|
||||
CHECK(pressureIntegralResolution.base_order == 14);
|
||||
|
||||
@@ -544,14 +416,12 @@ TEST_CASE(
|
||||
}
|
||||
|
||||
TEST_CASE(
|
||||
"Stage Four Pressure Quadrature Exactly Integrates An N Three Polynomial",
|
||||
tags::barotrope &tags::pressure &tags::pressure_gradient &tags::quadrature
|
||||
&tags::accuracy
|
||||
"Pressure Quadrature Exactly Integrates An N Three Polynomial",
|
||||
tags::barotrope &tags::pressure &tags::pressure_gradient &tags::quadrature &tags::accuracy
|
||||
) {
|
||||
using EnthalpyField = mean_field::field::Field<mean_field::field::Enthalpy>;
|
||||
using EnthalpyField = mean_field::field::Field<mean_field::field::Enthalpy>;
|
||||
|
||||
constexpr int enthalpyOrder =
|
||||
mean_field::field::Enthalpy::Scalar::familyOrder;
|
||||
constexpr int enthalpyOrder = mean_field::field::Enthalpy::Scalar::familyOrder;
|
||||
|
||||
constexpr int pressureExtraOrder = 3 * enthalpyOrder;
|
||||
|
||||
@@ -565,29 +435,19 @@ TEST_CASE(
|
||||
const mean_field::physics::PolytropicBarotrope barotrope(3.0, 0.25);
|
||||
|
||||
constexpr mean_field::quadrature::Query pressureIntegralQuery =
|
||||
EnthalpyField::make_query<
|
||||
mean_field::field::Enthalpy::Form::PressureIntegral>(
|
||||
mean_field::quadrature::QuadratureRole::diagnostic, 0,
|
||||
std::array<int, 1>{pressureExtraOrder},
|
||||
mean_field::utils::DOMAINS::STELLAR,
|
||||
mean_field::quadrature::MappingKind::affine
|
||||
EnthalpyField::make_query<mean_field::field::Enthalpy::Form::PressureIntegral>(
|
||||
mean_field::quadrature::QuadratureRole::diagnostic, 0, std::array<int, 1>{pressureExtraOrder},
|
||||
mean_field::utils::DOMAINS::STELLAR, mean_field::quadrature::MappingKind::affine
|
||||
);
|
||||
|
||||
constexpr mean_field::quadrature::Query pressureForceQuery =
|
||||
EnthalpyField::make_query<
|
||||
mean_field::field::Enthalpy::Form::PressureForce>(
|
||||
mean_field::quadrature::QuadratureRole::discretization, 0,
|
||||
std::array<int, 1>{pressureExtraOrder},
|
||||
mean_field::utils::DOMAINS::STELLAR,
|
||||
mean_field::quadrature::MappingKind::affine
|
||||
EnthalpyField::make_query<mean_field::field::Enthalpy::Form::PressureForce>(
|
||||
mean_field::quadrature::QuadratureRole::discretization, 0, std::array<int, 1>{pressureExtraOrder},
|
||||
mean_field::utils::DOMAINS::STELLAR, mean_field::quadrature::MappingKind::affine
|
||||
);
|
||||
|
||||
const mean_field::quadrature::RuleFactory ruleFactory{
|
||||
mean_field::quadrature::Policy(
|
||||
mean_field::quadrature::make_rule_set(
|
||||
mean_field::quadrature::Mode::production
|
||||
)
|
||||
)
|
||||
mean_field::quadrature::Policy(mean_field::quadrature::make_rule_set(mean_field::quadrature::Mode::production))
|
||||
};
|
||||
|
||||
const mean_field::quadrature::MfemRule pressureIntegralRule =
|
||||
@@ -606,21 +466,17 @@ TEST_CASE(
|
||||
*
|
||||
* P = x^12 y^12 z^12 / 4.
|
||||
*/
|
||||
const double numericalPressureIntegral =
|
||||
polytropic_barotrope_test_utils::integrate_cube(
|
||||
*pressureIntegralRule.integration_rule,
|
||||
[&barotrope](const mfem::IntegrationPoint &integrationPoint) {
|
||||
const double coordinateProduct = integrationPoint.x *
|
||||
integrationPoint.y *
|
||||
integrationPoint.z;
|
||||
const double numericalPressureIntegral = polytropic_barotrope_test_utils::integrate_cube(
|
||||
*pressureIntegralRule.integration_rule, [&barotrope](const mfem::IntegrationPoint &integrationPoint) {
|
||||
const double coordinateProduct = integrationPoint.x * integrationPoint.y * integrationPoint.z;
|
||||
|
||||
const double enthalpy = std::pow(coordinateProduct, 3.0);
|
||||
const double enthalpy = std::pow(coordinateProduct, 3.0);
|
||||
|
||||
return barotrope.pressure_from_enthalpy(enthalpy);
|
||||
}
|
||||
);
|
||||
return barotrope.pressure_from_enthalpy(enthalpy);
|
||||
}
|
||||
);
|
||||
|
||||
const double analyticPressureIntegral = 0.25 / std::pow(13.0, 3.0);
|
||||
const double analyticPressureIntegral = 0.25 / std::pow(13.0, 3.0);
|
||||
|
||||
/*
|
||||
* Choose a representable vector test function whose
|
||||
@@ -633,51 +489,34 @@ TEST_CASE(
|
||||
* -P div(w)
|
||||
* = -x^14 y^14 z^14 / 4.
|
||||
*/
|
||||
const double numericalPressureForceIntegral =
|
||||
polytropic_barotrope_test_utils::integrate_cube(
|
||||
*pressureForceRule.integration_rule,
|
||||
[&barotrope](const mfem::IntegrationPoint &integrationPoint) {
|
||||
const double coordinateProduct = integrationPoint.x *
|
||||
integrationPoint.y *
|
||||
integrationPoint.z;
|
||||
const double numericalPressureForceIntegral = polytropic_barotrope_test_utils::integrate_cube(
|
||||
*pressureForceRule.integration_rule, [&barotrope](const mfem::IntegrationPoint &integrationPoint) {
|
||||
const double coordinateProduct = integrationPoint.x * integrationPoint.y * integrationPoint.z;
|
||||
|
||||
const double enthalpy = std::pow(coordinateProduct, 3.0);
|
||||
const double enthalpy = std::pow(coordinateProduct, 3.0);
|
||||
|
||||
const double pressure =
|
||||
barotrope.pressure_from_enthalpy(enthalpy);
|
||||
const double pressure = barotrope.pressure_from_enthalpy(enthalpy);
|
||||
|
||||
const double testDivergence =
|
||||
integrationPoint.x * integrationPoint.x *
|
||||
integrationPoint.y * integrationPoint.y *
|
||||
integrationPoint.z * integrationPoint.z;
|
||||
const double testDivergence = integrationPoint.x * integrationPoint.x * integrationPoint.y *
|
||||
integrationPoint.y * integrationPoint.z * integrationPoint.z;
|
||||
|
||||
return -pressure * testDivergence;
|
||||
}
|
||||
);
|
||||
return -pressure * testDivergence;
|
||||
}
|
||||
);
|
||||
|
||||
const double analyticPressureForceIntegral = -0.25 / std::pow(15.0, 3.0);
|
||||
|
||||
INFO(
|
||||
"Pressure-integral quadrature order = "
|
||||
<< pressureIntegralRule.resolution.order
|
||||
);
|
||||
INFO("Pressure-integral quadrature order = " << pressureIntegralRule.resolution.order);
|
||||
|
||||
INFO(
|
||||
"Pressure-force quadrature order = "
|
||||
<< pressureForceRule.resolution.order
|
||||
);
|
||||
INFO("Pressure-force quadrature order = " << pressureForceRule.resolution.order);
|
||||
|
||||
INFO("Numerical pressure integral = " << numericalPressureIntegral);
|
||||
|
||||
INFO("Analytic pressure integral = " << analyticPressureIntegral);
|
||||
|
||||
INFO(
|
||||
"Numerical pressure-force integral = " << numericalPressureForceIntegral
|
||||
);
|
||||
INFO("Numerical pressure-force integral = " << numericalPressureForceIntegral);
|
||||
|
||||
INFO(
|
||||
"Analytic pressure-force integral = " << analyticPressureForceIntegral
|
||||
);
|
||||
INFO("Analytic pressure-force integral = " << analyticPressureForceIntegral);
|
||||
|
||||
CHECK(pressureIntegralRule.resolution.base_order == 12);
|
||||
|
||||
@@ -687,13 +526,7 @@ TEST_CASE(
|
||||
|
||||
CHECK(pressureForceRule.resolution.order == 14);
|
||||
|
||||
CHECK_THAT(
|
||||
numericalPressureIntegral,
|
||||
Catch::Matchers::WithinAbs(analyticPressureIntegral, 5.0e-14)
|
||||
);
|
||||
CHECK_THAT(numericalPressureIntegral, Catch::Matchers::WithinAbs(analyticPressureIntegral, 5.0e-14));
|
||||
|
||||
CHECK_THAT(
|
||||
numericalPressureForceIntegral,
|
||||
Catch::Matchers::WithinAbs(analyticPressureForceIntegral, 5.0e-14)
|
||||
);
|
||||
CHECK_THAT(numericalPressureForceIntegral, Catch::Matchers::WithinAbs(analyticPressureForceIntegral, 5.0e-14));
|
||||
}
|
||||
Reference in New Issue
Block a user