feat(support): continued migration to new field dof support system
mass normaliztion, gravity, displacement, and hydrostatic equilibrium are now migrated
This commit is contained in:
@@ -26,14 +26,25 @@ namespace mass_normalization_test_utils {
|
||||
);
|
||||
|
||||
[[nodiscard]] mean_field::operators::MassNormalizationLayout make_layout(const mean_field::fem::FEM &f) {
|
||||
const auto densityMap =
|
||||
field_dof_test_utils::make_map<mean_field::field::Density>(*f.densityFes);
|
||||
const auto displacementMap =
|
||||
field_dof_test_utils::make_map<mean_field::field::Displacement>(*f.displacementFes);
|
||||
const auto gravityFluxMap =
|
||||
field_dof_test_utils::make_map<mean_field::field::Gravity>(*f.gravityFluxFes);
|
||||
const auto gravityPotentialMap =
|
||||
field_dof_test_utils::make_map<mean_field::field::Gravity>(*f.gravityPotentialFes);
|
||||
const auto enthalpyMap =
|
||||
field_dof_test_utils::make_map<mean_field::field::Enthalpy>(*f.enthalpyFes);
|
||||
|
||||
const std::array<int, CoupledForm::value_block_count> valueSizes{
|
||||
f.densityFes->GetTrueVSize(), f.displacementFes->GetTrueVSize(), f.gravityFluxFes->GetTrueVSize(),
|
||||
f.gravityPotentialFes->GetTrueVSize(), f.enthalpyFes->GetTrueVSize(), 1
|
||||
densityMap.reduced_size(), displacementMap.reduced_size(), gravityFluxMap.reduced_size(),
|
||||
gravityPotentialMap.reduced_size(), enthalpyMap.reduced_size(), 1
|
||||
};
|
||||
|
||||
const std::array<int, CoupledForm::residual_block_count> residualSizes{
|
||||
f.gravityFluxFes->GetTrueVSize(), f.gravityPotentialFes->GetTrueVSize(), f.densityFes->GetTrueVSize(),
|
||||
f.displacementFes->GetTrueVSize(), f.enthalpyFes->GetTrueVSize(), 1
|
||||
gravityFluxMap.reduced_size(), gravityPotentialMap.reduced_size(), densityMap.reduced_size(),
|
||||
displacementMap.reduced_size(), enthalpyMap.reduced_size(), 1
|
||||
};
|
||||
|
||||
return {valueSizes, residualSizes};
|
||||
@@ -163,10 +174,10 @@ namespace mass_normalization_test_utils {
|
||||
gravityPotential = 0.0;
|
||||
|
||||
context.Prepare(
|
||||
{.density = density,
|
||||
.displacement = displacement,
|
||||
.gravity_gradient = gravityGradient,
|
||||
.gravity_potential = gravityPotential},
|
||||
{.density = context.GetDensityMap().gather(density),
|
||||
.displacement = context.GetDisplacementMap().gather(displacement),
|
||||
.gravity_gradient = context.GetGravityGradientMap().gather(gravityGradient),
|
||||
.gravity_potential = context.GetGravityPotentialMap().gather(gravityPotential)},
|
||||
make_gravity_revisions(dependencies, gravityGradientRevision, gravityPotentialRevision)
|
||||
);
|
||||
}
|
||||
@@ -189,7 +200,7 @@ namespace mass_normalization_test_utils {
|
||||
|
||||
TEST_CASE(
|
||||
"Prepared Mass Normalization Has The Analytic Affine Volume Scaling",
|
||||
tags::barotrope &tags::prepared &tags::analytic_comparison
|
||||
tags::barotrope_mass_normalization_analytic
|
||||
) {
|
||||
using Operator = mean_field::operators::PreparedMassNormalizationOperator;
|
||||
|
||||
@@ -265,7 +276,7 @@ TEST_CASE(
|
||||
|
||||
TEST_CASE(
|
||||
"Prepared Mass Normalization Density Jacobian Matches Centered Difference",
|
||||
tags::barotrope &tags::prepared &tags::jacobian &tags::accuracy
|
||||
tags::barotrope_mass_normalization_jacobian &tags::accuracy
|
||||
) {
|
||||
mean_field::utils::Args args = test_utils::setup_args();
|
||||
mean_field::fem::FEM f = mean_field::fem::setup_fem(args.mesh_file, args, 0);
|
||||
@@ -285,8 +296,10 @@ TEST_CASE(
|
||||
mean_field::operators::PreparedMassNormalizationOperator massOperator(f, *f.domainMapperStateless, gravityContext);
|
||||
massOperator.Prepare({.targetMass = 1.23}, dependencies);
|
||||
|
||||
const mfem::Vector reducedDensityDirection = gravityContext.GetDensityMap().gather(densityDirection);
|
||||
|
||||
mfem::Vector analyticAction;
|
||||
massOperator.ApplyDensityJacobianAction(densityDirection, analyticAction);
|
||||
massOperator.ApplyDensityJacobianAction(reducedDensityDirection, analyticAction);
|
||||
|
||||
constexpr double epsilon = 1.0e-3;
|
||||
mfem::Vector densityPlus(density);
|
||||
@@ -312,7 +325,7 @@ TEST_CASE(
|
||||
|
||||
TEST_CASE(
|
||||
"Prepared Mass Normalization Geometry Jacobian Matches Centered Difference",
|
||||
tags::barotrope &tags::prepared &tags::jacobian &tags::geometry
|
||||
tags::barotrope_mass_normalization_jacobian &tags::geometry
|
||||
) {
|
||||
mean_field::utils::Args args = test_utils::setup_args();
|
||||
mean_field::fem::FEM f = mean_field::fem::setup_fem(args.mesh_file, args, 0);
|
||||
@@ -332,8 +345,11 @@ TEST_CASE(
|
||||
mean_field::operators::PreparedMassNormalizationOperator massOperator(f, *f.domainMapperStateless, gravityContext);
|
||||
massOperator.Prepare({.targetMass = 1.11}, dependencies);
|
||||
|
||||
const mfem::Vector reducedDisplacementDirection =
|
||||
gravityContext.GetDisplacementMap().gather(displacementDirection);
|
||||
|
||||
mfem::Vector analyticAction;
|
||||
massOperator.ApplyDisplacementJacobianAction(displacementDirection, analyticAction);
|
||||
massOperator.ApplyDisplacementJacobianAction(reducedDisplacementDirection, analyticAction);
|
||||
|
||||
constexpr double epsilon = 1.0e-6;
|
||||
mfem::Vector displacementPlus(displacement);
|
||||
@@ -359,7 +375,7 @@ TEST_CASE(
|
||||
|
||||
TEST_CASE(
|
||||
"Prepared Mass Normalization Selectively Refreshes Its Cached State",
|
||||
tags::barotrope &tags::prepared &tags::contexts &tags::integration
|
||||
tags::barotrope_mass_normalization_context &tags::integration
|
||||
) {
|
||||
mean_field::utils::Args args = test_utils::setup_args();
|
||||
mean_field::fem::FEM f = mean_field::fem::setup_fem(args.mesh_file, args, 0);
|
||||
@@ -439,7 +455,7 @@ TEST_CASE(
|
||||
|
||||
TEST_CASE(
|
||||
"Prepared Mass Normalization Complete Action And Coupled Routing Are Exact",
|
||||
tags::barotrope &tags::prepared &tags::jacobian &tags::mfem_operators
|
||||
tags::barotrope_mass_normalization_jacobian
|
||||
) {
|
||||
mean_field::utils::Args args = test_utils::setup_args();
|
||||
mean_field::fem::FEM f = mean_field::fem::setup_fem(args.mesh_file, args, 0);
|
||||
@@ -460,13 +476,19 @@ TEST_CASE(
|
||||
mean_field::operators::PreparedMassNormalizationOperator massOperator(f, *f.domainMapperStateless, gravityContext);
|
||||
massOperator.Prepare({.targetMass = 1.19}, dependencies);
|
||||
|
||||
const mfem::Vector reducedDensityDirection = gravityContext.GetDensityMap().gather(densityDirection);
|
||||
const mfem::Vector reducedDisplacementDirection =
|
||||
gravityContext.GetDisplacementMap().gather(displacementDirection);
|
||||
|
||||
mfem::Vector densityAction;
|
||||
mfem::Vector displacementAction;
|
||||
mfem::Vector completeAction;
|
||||
|
||||
massOperator.ApplyDensityJacobianAction(densityDirection, densityAction);
|
||||
massOperator.ApplyDisplacementJacobianAction(displacementDirection, displacementAction);
|
||||
massOperator.ApplyCompleteJacobianAction(densityDirection, displacementDirection, completeAction);
|
||||
massOperator.ApplyDensityJacobianAction(reducedDensityDirection, densityAction);
|
||||
massOperator.ApplyDisplacementJacobianAction(reducedDisplacementDirection, displacementAction);
|
||||
massOperator.ApplyCompleteJacobianAction(
|
||||
reducedDensityDirection, reducedDisplacementDirection, completeAction
|
||||
);
|
||||
|
||||
CHECK(
|
||||
mass_normalization_test_utils::relative_error(completeAction(0), densityAction(0) + displacementAction(0)) <
|
||||
@@ -476,16 +498,26 @@ TEST_CASE(
|
||||
const auto layout = mass_normalization_test_utils::make_layout(f);
|
||||
mean_field::operators::PreparedMassNormalizationJacobianOperator adapter(layout, massOperator);
|
||||
|
||||
CHECK(
|
||||
layout.size(mass_normalization_test_utils::densityValue) ==
|
||||
gravityContext.GetDensityMap().reduced_size()
|
||||
);
|
||||
CHECK(
|
||||
layout.size(mass_normalization_test_utils::displacementValue) ==
|
||||
gravityContext.GetDisplacementMap().reduced_size()
|
||||
);
|
||||
CHECK(gravityContext.GetDensityMap().inactive_size() > 0);
|
||||
|
||||
mfem::Vector direction(layout.value_offsets().Last());
|
||||
direction = 0.0;
|
||||
|
||||
for (int entry = 0; entry < densityDirection.Size(); ++entry) {
|
||||
direction(layout.offset(mass_normalization_test_utils::densityValue) + entry) = densityDirection(entry);
|
||||
for (int entry = 0; entry < reducedDensityDirection.Size(); ++entry) {
|
||||
direction(layout.offset(mass_normalization_test_utils::densityValue) + entry) = reducedDensityDirection(entry);
|
||||
}
|
||||
|
||||
for (int entry = 0; entry < displacementDirection.Size(); ++entry) {
|
||||
for (int entry = 0; entry < reducedDisplacementDirection.Size(); ++entry) {
|
||||
direction(layout.offset(mass_normalization_test_utils::displacementValue) + entry) =
|
||||
displacementDirection(entry);
|
||||
reducedDisplacementDirection(entry);
|
||||
}
|
||||
|
||||
mfem::Vector coupledAction;
|
||||
@@ -505,4 +537,4 @@ TEST_CASE(
|
||||
CHECK(&massOperator.GetFEM() == &f);
|
||||
CHECK(&massOperator.GetGravityContext() == &gravityContext);
|
||||
CHECK(adapter.GetLayout().residual_offsets().Last() == layout.residual_offsets().Last());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user