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_jacobian_test_utils {
|
||||
mean_field::operators::context::hydrostatic::
|
||||
HydrostaticEquilibriumDependencies
|
||||
make_dependencies() {
|
||||
mean_field::operators::context::hydrostatic::HydrostaticEquilibriumDependencies make_dependencies() {
|
||||
return {
|
||||
.discretization = {.identity = 307, .revision = 2},
|
||||
.enthalpy = {.identity = 311, .revision = 3},
|
||||
@@ -18,8 +16,7 @@ namespace prepared_hydrostatic_jacobian_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_jacobian_test_utils {
|
||||
const mean_field::fem::FEM &f,
|
||||
const double phase = 0.23
|
||||
) {
|
||||
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.41
|
||||
) {
|
||||
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) {
|
||||
@@ -83,15 +76,13 @@ namespace prepared_hydrostatic_jacobian_test_utils {
|
||||
mfem::Vector residualMinus;
|
||||
|
||||
mean_field::operators::kernels::apply_hydrostatic_equilibrium(
|
||||
f, *f.domainMapperStateless, rotation, enthalpyPlus,
|
||||
gravityPotentialPlus, displacement, bernoulliConstantPlus,
|
||||
residualPlus
|
||||
f, *f.domainMapperStateless, rotation, enthalpyPlus, gravityPotentialPlus, displacement,
|
||||
bernoulliConstantPlus, residualPlus
|
||||
);
|
||||
|
||||
mean_field::operators::kernels::apply_hydrostatic_equilibrium(
|
||||
f, *f.domainMapperStateless, rotation, enthalpyMinus,
|
||||
gravityPotentialMinus, displacement, bernoulliConstantMinus,
|
||||
residualMinus
|
||||
f, *f.domainMapperStateless, rotation, enthalpyMinus, gravityPotentialMinus, displacement,
|
||||
bernoulliConstantMinus, residualMinus
|
||||
);
|
||||
|
||||
// The two states are separated by one complete variation:
|
||||
@@ -105,9 +96,7 @@ namespace prepared_hydrostatic_jacobian_test_utils {
|
||||
const mfem::Vector &expected,
|
||||
MPI_Comm communicator
|
||||
) {
|
||||
return gravity_prepared_test_utils::relative_error(
|
||||
actual, expected, communicator
|
||||
);
|
||||
return gravity_prepared_test_utils::relative_error(actual, expected, communicator);
|
||||
}
|
||||
} // namespace prepared_hydrostatic_jacobian_test_utils
|
||||
|
||||
@@ -116,42 +105,33 @@ TEST_CASE(
|
||||
"Differences",
|
||||
tags::barotrope &tags::hydro &tags::jacobian &tags::prepared &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_jacobian_test_utils::make_enthalpy(f);
|
||||
const mfem::Vector enthalpy = prepared_hydrostatic_jacobian_test_utils::make_enthalpy(f);
|
||||
|
||||
const mfem::Vector gravityPotential =
|
||||
prepared_hydrostatic_jacobian_test_utils::make_gravity_potential(f);
|
||||
const mfem::Vector gravityPotential = prepared_hydrostatic_jacobian_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.39;
|
||||
constexpr double bernoulliConstant = 0.39;
|
||||
|
||||
const mean_field::physics::RigidRotation rotation =
|
||||
prepared_hydrostatic_jacobian_test_utils::make_rotation();
|
||||
const mean_field::physics::RigidRotation rotation = prepared_hydrostatic_jacobian_test_utils::make_rotation();
|
||||
|
||||
const auto report = preparedOperator.Prepare(
|
||||
const auto report = preparedOperator.Prepare(
|
||||
prepared_hydrostatic_jacobian_test_utils::make_state(
|
||||
enthalpy, gravityPotential, displacement, bernoulliConstant
|
||||
),
|
||||
prepared_hydrostatic_jacobian_test_utils::make_dependencies(), rotation
|
||||
);
|
||||
|
||||
const mfem::Vector enthalpyVariation =
|
||||
prepared_hydrostatic_jacobian_test_utils::make_enthalpy(f, 0.71);
|
||||
const mfem::Vector enthalpyVariation = prepared_hydrostatic_jacobian_test_utils::make_enthalpy(f, 0.71);
|
||||
|
||||
const mfem::Vector gravityPotentialVariation =
|
||||
prepared_hydrostatic_jacobian_test_utils::make_gravity_potential(
|
||||
f, 0.83
|
||||
);
|
||||
prepared_hydrostatic_jacobian_test_utils::make_gravity_potential(f, 0.83);
|
||||
|
||||
constexpr double bernoulliConstantVariation = -0.31;
|
||||
|
||||
@@ -160,21 +140,14 @@ TEST_CASE(
|
||||
mfem::Vector bernoulliConstantAction;
|
||||
mfem::Vector combinedAction;
|
||||
|
||||
preparedOperator.ApplyEnthalpyJacobianAction(
|
||||
enthalpyVariation, enthalpyAction
|
||||
);
|
||||
preparedOperator.ApplyEnthalpyJacobianAction(enthalpyVariation, enthalpyAction);
|
||||
|
||||
preparedOperator.ApplyGravityPotentialJacobianAction(
|
||||
gravityPotentialVariation, gravityPotentialAction
|
||||
);
|
||||
preparedOperator.ApplyGravityPotentialJacobianAction(gravityPotentialVariation, gravityPotentialAction);
|
||||
|
||||
preparedOperator.ApplyBernoulliConstantJacobianAction(
|
||||
bernoulliConstantVariation, bernoulliConstantAction
|
||||
);
|
||||
preparedOperator.ApplyBernoulliConstantJacobianAction(bernoulliConstantVariation, bernoulliConstantAction);
|
||||
|
||||
preparedOperator.ApplyAlgebraicJacobianAction(
|
||||
enthalpyVariation, gravityPotentialVariation,
|
||||
bernoulliConstantVariation, combinedAction
|
||||
enthalpyVariation, gravityPotentialVariation, bernoulliConstantVariation, combinedAction
|
||||
);
|
||||
|
||||
mfem::Vector enthalpyPlus(enthalpy);
|
||||
@@ -188,9 +161,8 @@ TEST_CASE(
|
||||
mfem::Vector enthalpyReference;
|
||||
|
||||
prepared_hydrostatic_jacobian_test_utils::centered_residual_difference(
|
||||
f, rotation, enthalpyPlus, enthalpyMinus, gravityPotential,
|
||||
gravityPotential, displacement, bernoulliConstant, bernoulliConstant,
|
||||
enthalpyReference
|
||||
f, rotation, enthalpyPlus, enthalpyMinus, gravityPotential, gravityPotential, displacement, bernoulliConstant,
|
||||
bernoulliConstant, enthalpyReference
|
||||
);
|
||||
|
||||
enthalpyPlus = enthalpy;
|
||||
@@ -203,8 +175,7 @@ TEST_CASE(
|
||||
mfem::Vector gravityPotentialReference;
|
||||
|
||||
prepared_hydrostatic_jacobian_test_utils::centered_residual_difference(
|
||||
f, rotation, enthalpy, enthalpy, gravityPotentialPlus,
|
||||
gravityPotentialMinus, displacement, bernoulliConstant,
|
||||
f, rotation, enthalpy, enthalpy, gravityPotentialPlus, gravityPotentialMinus, displacement, bernoulliConstant,
|
||||
bernoulliConstant, gravityPotentialReference
|
||||
);
|
||||
|
||||
@@ -214,9 +185,8 @@ TEST_CASE(
|
||||
mfem::Vector bernoulliConstantReference;
|
||||
|
||||
prepared_hydrostatic_jacobian_test_utils::centered_residual_difference(
|
||||
f, rotation, enthalpy, enthalpy, gravityPotential, gravityPotential,
|
||||
displacement, bernoulliConstant + 0.5 * bernoulliConstantVariation,
|
||||
bernoulliConstant - 0.5 * bernoulliConstantVariation,
|
||||
f, rotation, enthalpy, enthalpy, gravityPotential, gravityPotential, displacement,
|
||||
bernoulliConstant + 0.5 * bernoulliConstantVariation, bernoulliConstant - 0.5 * bernoulliConstantVariation,
|
||||
bernoulliConstantReference
|
||||
);
|
||||
|
||||
@@ -230,10 +200,9 @@ TEST_CASE(
|
||||
mfem::Vector combinedReference;
|
||||
|
||||
prepared_hydrostatic_jacobian_test_utils::centered_residual_difference(
|
||||
f, rotation, enthalpyPlus, enthalpyMinus, gravityPotentialPlus,
|
||||
gravityPotentialMinus, displacement,
|
||||
bernoulliConstant + 0.5 * bernoulliConstantVariation,
|
||||
bernoulliConstant - 0.5 * bernoulliConstantVariation, combinedReference
|
||||
f, rotation, enthalpyPlus, enthalpyMinus, gravityPotentialPlus, gravityPotentialMinus, displacement,
|
||||
bernoulliConstant + 0.5 * bernoulliConstantVariation, bernoulliConstant - 0.5 * bernoulliConstantVariation,
|
||||
combinedReference
|
||||
);
|
||||
|
||||
mfem::Vector sumOfBlocks(enthalpyAction);
|
||||
@@ -241,30 +210,21 @@ TEST_CASE(
|
||||
sumOfBlocks += bernoulliConstantAction;
|
||||
|
||||
const double enthalpyError =
|
||||
prepared_hydrostatic_jacobian_test_utils::relative_error(
|
||||
enthalpyAction, enthalpyReference, f.mesh->GetComm()
|
||||
);
|
||||
prepared_hydrostatic_jacobian_test_utils::relative_error(enthalpyAction, enthalpyReference, f.mesh->GetComm());
|
||||
|
||||
const double gravityPotentialError =
|
||||
prepared_hydrostatic_jacobian_test_utils::relative_error(
|
||||
gravityPotentialAction, gravityPotentialReference, f.mesh->GetComm()
|
||||
);
|
||||
const double gravityPotentialError = prepared_hydrostatic_jacobian_test_utils::relative_error(
|
||||
gravityPotentialAction, gravityPotentialReference, f.mesh->GetComm()
|
||||
);
|
||||
|
||||
const double bernoulliConstantError =
|
||||
prepared_hydrostatic_jacobian_test_utils::relative_error(
|
||||
bernoulliConstantAction, bernoulliConstantReference,
|
||||
f.mesh->GetComm()
|
||||
);
|
||||
const double bernoulliConstantError = prepared_hydrostatic_jacobian_test_utils::relative_error(
|
||||
bernoulliConstantAction, bernoulliConstantReference, f.mesh->GetComm()
|
||||
);
|
||||
|
||||
const double combinedError =
|
||||
prepared_hydrostatic_jacobian_test_utils::relative_error(
|
||||
combinedAction, combinedReference, f.mesh->GetComm()
|
||||
);
|
||||
prepared_hydrostatic_jacobian_test_utils::relative_error(combinedAction, combinedReference, f.mesh->GetComm());
|
||||
|
||||
const double blockSumError =
|
||||
prepared_hydrostatic_jacobian_test_utils::relative_error(
|
||||
combinedAction, sumOfBlocks, f.mesh->GetComm()
|
||||
);
|
||||
prepared_hydrostatic_jacobian_test_utils::relative_error(combinedAction, sumOfBlocks, f.mesh->GetComm());
|
||||
|
||||
INFO("Enthalpy block error = " << enthalpyError);
|
||||
INFO("Gravity-potential block error = " << gravityPotentialError);
|
||||
@@ -293,30 +253,23 @@ TEST_CASE(
|
||||
"Geometry",
|
||||
tags::barotrope &tags::hydro &tags::jacobian &tags::prepared &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_jacobian_test_utils::make_enthalpy(f);
|
||||
mfem::Vector enthalpy = prepared_hydrostatic_jacobian_test_utils::make_enthalpy(f);
|
||||
|
||||
mfem::Vector gravityPotential =
|
||||
prepared_hydrostatic_jacobian_test_utils::make_gravity_potential(f);
|
||||
mfem::Vector gravityPotential = prepared_hydrostatic_jacobian_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.37;
|
||||
double bernoulliConstant = 0.37;
|
||||
|
||||
mean_field::physics::RigidRotation rotation =
|
||||
prepared_hydrostatic_jacobian_test_utils::make_rotation(0.8);
|
||||
mean_field::physics::RigidRotation rotation = prepared_hydrostatic_jacobian_test_utils::make_rotation(0.8);
|
||||
|
||||
auto dependencies =
|
||||
prepared_hydrostatic_jacobian_test_utils::make_dependencies();
|
||||
auto dependencies = prepared_hydrostatic_jacobian_test_utils::make_dependencies();
|
||||
|
||||
preparedOperator.Prepare(
|
||||
prepared_hydrostatic_jacobian_test_utils::make_state(
|
||||
@@ -325,32 +278,25 @@ TEST_CASE(
|
||||
dependencies, rotation
|
||||
);
|
||||
|
||||
const mfem::Vector enthalpyVariation =
|
||||
prepared_hydrostatic_jacobian_test_utils::make_enthalpy(f, 0.67);
|
||||
const mfem::Vector enthalpyVariation = prepared_hydrostatic_jacobian_test_utils::make_enthalpy(f, 0.67);
|
||||
|
||||
const mfem::Vector gravityPotentialVariation =
|
||||
prepared_hydrostatic_jacobian_test_utils::make_gravity_potential(
|
||||
f, 0.79
|
||||
);
|
||||
prepared_hydrostatic_jacobian_test_utils::make_gravity_potential(f, 0.79);
|
||||
|
||||
constexpr double bernoulliConstantVariation = 0.28;
|
||||
|
||||
mfem::Vector initialAction;
|
||||
|
||||
preparedOperator.ApplyAlgebraicJacobianAction(
|
||||
enthalpyVariation, gravityPotentialVariation,
|
||||
bernoulliConstantVariation, initialAction
|
||||
enthalpyVariation, gravityPotentialVariation, bernoulliConstantVariation, initialAction
|
||||
);
|
||||
|
||||
enthalpy = prepared_hydrostatic_jacobian_test_utils::make_enthalpy(f, 1.13);
|
||||
enthalpy = prepared_hydrostatic_jacobian_test_utils::make_enthalpy(f, 1.13);
|
||||
|
||||
gravityPotential =
|
||||
prepared_hydrostatic_jacobian_test_utils::make_gravity_potential(
|
||||
f, 1.31
|
||||
);
|
||||
gravityPotential = prepared_hydrostatic_jacobian_test_utils::make_gravity_potential(f, 1.31);
|
||||
|
||||
bernoulliConstant = 0.62;
|
||||
rotation = prepared_hydrostatic_jacobian_test_utils::make_rotation(1.4);
|
||||
rotation = prepared_hydrostatic_jacobian_test_utils::make_rotation(1.4);
|
||||
|
||||
++dependencies.enthalpy.revision;
|
||||
++dependencies.gravityPotential.revision;
|
||||
@@ -367,8 +313,7 @@ TEST_CASE(
|
||||
mfem::Vector baseStateChangedAction;
|
||||
|
||||
preparedOperator.ApplyAlgebraicJacobianAction(
|
||||
enthalpyVariation, gravityPotentialVariation,
|
||||
bernoulliConstantVariation, baseStateChangedAction
|
||||
enthalpyVariation, gravityPotentialVariation, bernoulliConstantVariation, baseStateChangedAction
|
||||
);
|
||||
|
||||
CHECK_FALSE(baseStateReport.contextReport.preparedGeometryState);
|
||||
@@ -382,19 +327,15 @@ TEST_CASE(
|
||||
) == 0.0
|
||||
);
|
||||
|
||||
const mfem::Vector secondEnthalpyVariation =
|
||||
prepared_hydrostatic_jacobian_test_utils::make_enthalpy(f, 1.57);
|
||||
const mfem::Vector secondEnthalpyVariation = prepared_hydrostatic_jacobian_test_utils::make_enthalpy(f, 1.57);
|
||||
|
||||
const mfem::Vector secondGravityPotentialVariation =
|
||||
prepared_hydrostatic_jacobian_test_utils::make_gravity_potential(
|
||||
f, 1.73
|
||||
);
|
||||
prepared_hydrostatic_jacobian_test_utils::make_gravity_potential(f, 1.73);
|
||||
|
||||
mfem::Vector secondDirectionAction;
|
||||
|
||||
preparedOperator.ApplyAlgebraicJacobianAction(
|
||||
secondEnthalpyVariation, secondGravityPotentialVariation, -0.19,
|
||||
secondDirectionAction
|
||||
secondEnthalpyVariation, secondGravityPotentialVariation, -0.19, secondDirectionAction
|
||||
);
|
||||
|
||||
CHECK(preparedOperator.GetAlgebraicJacobianStatistics().preparations == 1);
|
||||
@@ -413,8 +354,7 @@ TEST_CASE(
|
||||
mfem::Vector geometryChangedAction;
|
||||
|
||||
preparedOperator.ApplyAlgebraicJacobianAction(
|
||||
enthalpyVariation, gravityPotentialVariation,
|
||||
bernoulliConstantVariation, geometryChangedAction
|
||||
enthalpyVariation, gravityPotentialVariation, bernoulliConstantVariation, geometryChangedAction
|
||||
);
|
||||
|
||||
mfem::Vector enthalpyPlus(enthalpy);
|
||||
@@ -432,31 +372,23 @@ TEST_CASE(
|
||||
mfem::Vector geometryReference;
|
||||
|
||||
prepared_hydrostatic_jacobian_test_utils::centered_residual_difference(
|
||||
f, rotation, enthalpyPlus, enthalpyMinus, gravityPotentialPlus,
|
||||
gravityPotentialMinus, displacement,
|
||||
bernoulliConstant + 0.5 * bernoulliConstantVariation,
|
||||
bernoulliConstant - 0.5 * bernoulliConstantVariation, geometryReference
|
||||
f, rotation, enthalpyPlus, enthalpyMinus, gravityPotentialPlus, gravityPotentialMinus, displacement,
|
||||
bernoulliConstant + 0.5 * bernoulliConstantVariation, bernoulliConstant - 0.5 * bernoulliConstantVariation,
|
||||
geometryReference
|
||||
);
|
||||
|
||||
const double geometryReferenceError =
|
||||
prepared_hydrostatic_jacobian_test_utils::relative_error(
|
||||
geometryChangedAction, geometryReference, f.mesh->GetComm()
|
||||
);
|
||||
|
||||
const double geometryEffect =
|
||||
prepared_hydrostatic_jacobian_test_utils::relative_error(
|
||||
geometryChangedAction, initialAction, f.mesh->GetComm()
|
||||
);
|
||||
|
||||
INFO(
|
||||
"Geometry-updated algebraic Jacobian error = " << geometryReferenceError
|
||||
const double geometryReferenceError = prepared_hydrostatic_jacobian_test_utils::relative_error(
|
||||
geometryChangedAction, geometryReference, f.mesh->GetComm()
|
||||
);
|
||||
|
||||
INFO(
|
||||
"Algebraic Jacobian change after deformation update = "
|
||||
<< geometryEffect
|
||||
const double geometryEffect = prepared_hydrostatic_jacobian_test_utils::relative_error(
|
||||
geometryChangedAction, initialAction, f.mesh->GetComm()
|
||||
);
|
||||
|
||||
INFO("Geometry-updated algebraic Jacobian error = " << geometryReferenceError);
|
||||
|
||||
INFO("Algebraic Jacobian change after deformation update = " << geometryEffect);
|
||||
|
||||
const auto &statistics = preparedOperator.GetAlgebraicJacobianStatistics();
|
||||
|
||||
CHECK(geometryReport.contextReport.preparedGeometryState);
|
||||
|
||||
Reference in New Issue
Block a user