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:
@@ -5,9 +5,7 @@ import mean_field;
|
||||
import test_helpers;
|
||||
|
||||
namespace prepared_hydrostatic_test_utils {
|
||||
static mean_field::operators::context::hydrostatic::
|
||||
HydrostaticEquilibriumDependencies
|
||||
make_dependencies() {
|
||||
static mean_field::operators::context::hydrostatic::HydrostaticEquilibriumDependencies make_dependencies() {
|
||||
return {
|
||||
.discretization = {.identity = 211, .revision = 2},
|
||||
.enthalpy = {.identity = 223, .revision = 3},
|
||||
@@ -18,8 +16,7 @@ namespace prepared_hydrostatic_test_utils {
|
||||
};
|
||||
}
|
||||
|
||||
mean_field::operators::context::hydrostatic::HydrostaticEquilibriumStateView
|
||||
make_state(
|
||||
mean_field::operators::context::hydrostatic::HydrostaticEquilibriumStateView make_state(
|
||||
const mfem::Vector &enthalpy,
|
||||
const mfem::Vector &gravityPotential,
|
||||
const mfem::Vector &displacement,
|
||||
@@ -37,18 +34,14 @@ namespace prepared_hydrostatic_test_utils {
|
||||
const mean_field::fem::FEM &f,
|
||||
const double phase = 0.19
|
||||
) {
|
||||
return gravity_prepared_test_utils::make_deterministic_vector(
|
||||
f.enthalpyFes->GetTrueVSize(), phase
|
||||
);
|
||||
return gravity_prepared_test_utils::make_deterministic_vector(f.enthalpyFes->GetTrueVSize(), phase);
|
||||
}
|
||||
|
||||
mfem::Vector make_gravity_potential(
|
||||
const mean_field::fem::FEM &f,
|
||||
const double phase = 0.37
|
||||
) {
|
||||
return gravity_prepared_test_utils::make_deterministic_vector(
|
||||
f.gravityPotentialFes->GetTrueVSize(), phase
|
||||
);
|
||||
return gravity_prepared_test_utils::make_deterministic_vector(f.gravityPotentialFes->GetTrueVSize(), phase);
|
||||
}
|
||||
|
||||
mean_field::physics::RigidRotation make_rotation(const double scale = 1.0) {
|
||||
@@ -72,39 +65,30 @@ TEST_CASE(
|
||||
"Prepared Hydrostatic Residual Matches Stateless Kernel",
|
||||
tags::barotrope &tags::hydro &tags::prepared &tags::residuals &tags::unit
|
||||
) {
|
||||
auto args = test_utils::setup_args();
|
||||
auto args = test_utils::setup_args();
|
||||
|
||||
mean_field::fem::FEM f =
|
||||
mean_field::fem::setup_fem(args.mesh_file, args, 0);
|
||||
mean_field::fem::FEM f = mean_field::fem::setup_fem(args.mesh_file, args, 0);
|
||||
|
||||
mean_field::operators::PreparedHydrostaticEquilibriumOperator
|
||||
preparedOperator(f, *f.domainMapperStateless);
|
||||
mean_field::operators::PreparedHydrostaticEquilibriumOperator preparedOperator(f, *f.domainMapperStateless);
|
||||
|
||||
const mfem::Vector enthalpy =
|
||||
prepared_hydrostatic_test_utils::make_enthalpy(f);
|
||||
const mfem::Vector enthalpy = prepared_hydrostatic_test_utils::make_enthalpy(f);
|
||||
|
||||
const mfem::Vector gravityPotential =
|
||||
prepared_hydrostatic_test_utils::make_gravity_potential(f);
|
||||
const mfem::Vector gravityPotential = prepared_hydrostatic_test_utils::make_gravity_potential(f);
|
||||
|
||||
const mfem::Vector displacement =
|
||||
gravity_prepared_test_utils::make_displacement(f, 0.73);
|
||||
const mfem::Vector displacement = gravity_prepared_test_utils::make_displacement(f, 0.73);
|
||||
|
||||
constexpr double bernoulliConstant = 0.41;
|
||||
constexpr double bernoulliConstant = 0.41;
|
||||
|
||||
const mean_field::physics::RigidRotation rotation =
|
||||
prepared_hydrostatic_test_utils::make_rotation();
|
||||
const mean_field::physics::RigidRotation rotation = prepared_hydrostatic_test_utils::make_rotation();
|
||||
|
||||
const auto dependencies =
|
||||
prepared_hydrostatic_test_utils::make_dependencies();
|
||||
const auto dependencies = prepared_hydrostatic_test_utils::make_dependencies();
|
||||
|
||||
CHECK_FALSE(preparedOperator.IsPrepared());
|
||||
CHECK(preparedOperator.GetResidualPreparationCount() == 0);
|
||||
CHECK(preparedOperator.GetResidualApplicationCount() == 0);
|
||||
|
||||
const auto report = preparedOperator.Prepare(
|
||||
prepared_hydrostatic_test_utils::make_state(
|
||||
enthalpy, gravityPotential, displacement, bernoulliConstant
|
||||
),
|
||||
prepared_hydrostatic_test_utils::make_state(enthalpy, gravityPotential, displacement, bernoulliConstant),
|
||||
dependencies, rotation
|
||||
);
|
||||
|
||||
@@ -114,13 +98,12 @@ TEST_CASE(
|
||||
preparedOperator.BuildResidual(preparedResidual);
|
||||
|
||||
mean_field::operators::kernels::apply_hydrostatic_equilibrium(
|
||||
f, *f.domainMapperStateless, rotation, enthalpy, gravityPotential,
|
||||
displacement, bernoulliConstant, referenceResidual
|
||||
f, *f.domainMapperStateless, rotation, enthalpy, gravityPotential, displacement, bernoulliConstant,
|
||||
referenceResidual
|
||||
);
|
||||
|
||||
const double relativeError = gravity_prepared_test_utils::relative_error(
|
||||
preparedResidual, referenceResidual, f.mesh->GetComm()
|
||||
);
|
||||
const double relativeError =
|
||||
gravity_prepared_test_utils::relative_error(preparedResidual, referenceResidual, f.mesh->GetComm());
|
||||
|
||||
INFO("Prepared hydrostatic residual relative error = " << relativeError);
|
||||
|
||||
@@ -150,41 +133,33 @@ TEST_CASE(
|
||||
"Prepared Hydrostatic Residual Reuses And Selectively Rebuilds Data",
|
||||
tags::barotrope &tags::hydro &tags::prepared &tags::residuals &tags::unit
|
||||
) {
|
||||
auto args = test_utils::setup_args();
|
||||
auto args = test_utils::setup_args();
|
||||
|
||||
mean_field::fem::FEM f =
|
||||
mean_field::fem::setup_fem(args.mesh_file, args, 0);
|
||||
mean_field::fem::FEM f = mean_field::fem::setup_fem(args.mesh_file, args, 0);
|
||||
|
||||
mean_field::operators::PreparedHydrostaticEquilibriumOperator
|
||||
preparedOperator(f, *f.domainMapperStateless);
|
||||
mean_field::operators::PreparedHydrostaticEquilibriumOperator preparedOperator(f, *f.domainMapperStateless);
|
||||
|
||||
mfem::Vector enthalpy = prepared_hydrostatic_test_utils::make_enthalpy(f);
|
||||
mfem::Vector enthalpy = prepared_hydrostatic_test_utils::make_enthalpy(f);
|
||||
|
||||
mfem::Vector gravityPotential =
|
||||
prepared_hydrostatic_test_utils::make_gravity_potential(f);
|
||||
mfem::Vector gravityPotential = prepared_hydrostatic_test_utils::make_gravity_potential(f);
|
||||
|
||||
mfem::Vector displacement =
|
||||
gravity_prepared_test_utils::make_displacement(f, 0.42);
|
||||
mfem::Vector displacement = gravity_prepared_test_utils::make_displacement(f, 0.42);
|
||||
|
||||
double bernoulliConstant = 0.36;
|
||||
double bernoulliConstant = 0.36;
|
||||
|
||||
const mfem::Vector initialEnthalpy(enthalpy);
|
||||
const mfem::Vector initialGravityPotential(gravityPotential);
|
||||
const mfem::Vector initialDisplacement(displacement);
|
||||
const double initialBernoulliConstant = bernoulliConstant;
|
||||
const double initialBernoulliConstant = bernoulliConstant;
|
||||
|
||||
const mean_field::physics::RigidRotation initialRotation =
|
||||
prepared_hydrostatic_test_utils::make_rotation(0.80);
|
||||
const mean_field::physics::RigidRotation initialRotation = prepared_hydrostatic_test_utils::make_rotation(0.80);
|
||||
|
||||
const mean_field::physics::RigidRotation changedRotation =
|
||||
prepared_hydrostatic_test_utils::make_rotation(1.25);
|
||||
const mean_field::physics::RigidRotation changedRotation = prepared_hydrostatic_test_utils::make_rotation(1.25);
|
||||
|
||||
auto dependencies = prepared_hydrostatic_test_utils::make_dependencies();
|
||||
auto dependencies = prepared_hydrostatic_test_utils::make_dependencies();
|
||||
|
||||
preparedOperator.Prepare(
|
||||
prepared_hydrostatic_test_utils::make_state(
|
||||
enthalpy, gravityPotential, displacement, bernoulliConstant
|
||||
),
|
||||
prepared_hydrostatic_test_utils::make_state(enthalpy, gravityPotential, displacement, bernoulliConstant),
|
||||
dependencies, initialRotation
|
||||
);
|
||||
|
||||
@@ -197,9 +172,7 @@ TEST_CASE(
|
||||
bernoulliConstant += 0.23;
|
||||
|
||||
const auto unchangedReport = preparedOperator.Prepare(
|
||||
prepared_hydrostatic_test_utils::make_state(
|
||||
enthalpy, gravityPotential, displacement, bernoulliConstant
|
||||
),
|
||||
prepared_hydrostatic_test_utils::make_state(enthalpy, gravityPotential, displacement, bernoulliConstant),
|
||||
dependencies, changedRotation
|
||||
);
|
||||
|
||||
@@ -209,11 +182,7 @@ TEST_CASE(
|
||||
CHECK_FALSE(unchangedReport.DidAnyWork());
|
||||
CHECK_FALSE(unchangedReport.updatedRotation);
|
||||
CHECK_FALSE(unchangedReport.preparedResidual);
|
||||
CHECK(
|
||||
gravity_prepared_test_utils::relative_error(
|
||||
unchangedResidual, initialResidual, f.mesh->GetComm()
|
||||
) == 0.0
|
||||
);
|
||||
CHECK(gravity_prepared_test_utils::relative_error(unchangedResidual, initialResidual, f.mesh->GetComm()) == 0.0);
|
||||
CHECK(preparedOperator.GetResidualPreparationCount() == 1);
|
||||
|
||||
// Only the enthalpy stamp changes. The altered potential,
|
||||
@@ -221,9 +190,7 @@ TEST_CASE(
|
||||
++dependencies.enthalpy.revision;
|
||||
|
||||
const auto enthalpyReport = preparedOperator.Prepare(
|
||||
prepared_hydrostatic_test_utils::make_state(
|
||||
enthalpy, gravityPotential, displacement, bernoulliConstant
|
||||
),
|
||||
prepared_hydrostatic_test_utils::make_state(enthalpy, gravityPotential, displacement, bernoulliConstant),
|
||||
dependencies, changedRotation
|
||||
);
|
||||
|
||||
@@ -233,9 +200,8 @@ TEST_CASE(
|
||||
preparedOperator.BuildResidual(enthalpyResidual);
|
||||
|
||||
mean_field::operators::kernels::apply_hydrostatic_equilibrium(
|
||||
f, *f.domainMapperStateless, initialRotation, enthalpy,
|
||||
initialGravityPotential, initialDisplacement, initialBernoulliConstant,
|
||||
enthalpyReference
|
||||
f, *f.domainMapperStateless, initialRotation, enthalpy, initialGravityPotential, initialDisplacement,
|
||||
initialBernoulliConstant, enthalpyReference
|
||||
);
|
||||
|
||||
CHECK_FALSE(enthalpyReport.contextReport.preparedStaticDependencies);
|
||||
@@ -245,17 +211,13 @@ TEST_CASE(
|
||||
CHECK_FALSE(enthalpyReport.updatedRotation);
|
||||
CHECK(enthalpyReport.preparedResidual);
|
||||
CHECK(
|
||||
gravity_prepared_test_utils::relative_error(
|
||||
enthalpyResidual, enthalpyReference, f.mesh->GetComm()
|
||||
) < 2.0e-12
|
||||
gravity_prepared_test_utils::relative_error(enthalpyResidual, enthalpyReference, f.mesh->GetComm()) < 2.0e-12
|
||||
);
|
||||
|
||||
++dependencies.rotation.revision;
|
||||
|
||||
const auto rotationReport = preparedOperator.Prepare(
|
||||
prepared_hydrostatic_test_utils::make_state(
|
||||
enthalpy, gravityPotential, displacement, bernoulliConstant
|
||||
),
|
||||
prepared_hydrostatic_test_utils::make_state(enthalpy, gravityPotential, displacement, bernoulliConstant),
|
||||
dependencies, changedRotation
|
||||
);
|
||||
|
||||
@@ -265,9 +227,8 @@ TEST_CASE(
|
||||
preparedOperator.BuildResidual(rotationResidual);
|
||||
|
||||
mean_field::operators::kernels::apply_hydrostatic_equilibrium(
|
||||
f, *f.domainMapperStateless, changedRotation, enthalpy,
|
||||
initialGravityPotential, initialDisplacement, initialBernoulliConstant,
|
||||
rotationReference
|
||||
f, *f.domainMapperStateless, changedRotation, enthalpy, initialGravityPotential, initialDisplacement,
|
||||
initialBernoulliConstant, rotationReference
|
||||
);
|
||||
|
||||
CHECK_FALSE(rotationReport.contextReport.preparedStaticDependencies);
|
||||
@@ -277,17 +238,13 @@ TEST_CASE(
|
||||
CHECK(rotationReport.updatedRotation);
|
||||
CHECK(rotationReport.preparedResidual);
|
||||
CHECK(
|
||||
gravity_prepared_test_utils::relative_error(
|
||||
rotationResidual, rotationReference, f.mesh->GetComm()
|
||||
) < 2.0e-12
|
||||
gravity_prepared_test_utils::relative_error(rotationResidual, rotationReference, f.mesh->GetComm()) < 2.0e-12
|
||||
);
|
||||
|
||||
++dependencies.displacement.revision;
|
||||
|
||||
const auto displacementReport = preparedOperator.Prepare(
|
||||
prepared_hydrostatic_test_utils::make_state(
|
||||
enthalpy, gravityPotential, displacement, bernoulliConstant
|
||||
),
|
||||
prepared_hydrostatic_test_utils::make_state(enthalpy, gravityPotential, displacement, bernoulliConstant),
|
||||
dependencies, changedRotation
|
||||
);
|
||||
|
||||
@@ -297,9 +254,8 @@ TEST_CASE(
|
||||
preparedOperator.BuildResidual(displacementResidual);
|
||||
|
||||
mean_field::operators::kernels::apply_hydrostatic_equilibrium(
|
||||
f, *f.domainMapperStateless, changedRotation, enthalpy,
|
||||
initialGravityPotential, displacement, initialBernoulliConstant,
|
||||
displacementReference
|
||||
f, *f.domainMapperStateless, changedRotation, enthalpy, initialGravityPotential, displacement,
|
||||
initialBernoulliConstant, displacementReference
|
||||
);
|
||||
|
||||
CHECK_FALSE(displacementReport.contextReport.preparedStaticDependencies);
|
||||
@@ -309,9 +265,8 @@ TEST_CASE(
|
||||
CHECK_FALSE(displacementReport.updatedRotation);
|
||||
CHECK(displacementReport.preparedResidual);
|
||||
CHECK(
|
||||
gravity_prepared_test_utils::relative_error(
|
||||
displacementResidual, displacementReference, f.mesh->GetComm()
|
||||
) < 2.0e-12
|
||||
gravity_prepared_test_utils::relative_error(displacementResidual, displacementReference, f.mesh->GetComm()) <
|
||||
2.0e-12
|
||||
);
|
||||
|
||||
const auto &statistics = preparedOperator.GetContextPreparationStatistics();
|
||||
@@ -324,9 +279,7 @@ TEST_CASE(
|
||||
CHECK(preparedOperator.GetResidualApplicationCount() == 5);
|
||||
|
||||
const double displacementEffect =
|
||||
gravity_prepared_test_utils::relative_error(
|
||||
displacementResidual, rotationResidual, f.mesh->GetComm()
|
||||
);
|
||||
gravity_prepared_test_utils::relative_error(displacementResidual, rotationResidual, f.mesh->GetComm());
|
||||
|
||||
INFO("Residual change after displacement update = " << displacementEffect);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user