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:
@@ -2,6 +2,7 @@ module;
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <catch2/internal/catch_stringref.hpp>
|
||||
#include <concepts>
|
||||
#include <string>
|
||||
|
||||
#include <mfem.hpp>
|
||||
@@ -86,6 +87,27 @@ export namespace test_utils {
|
||||
} // namespace test_utils
|
||||
|
||||
export namespace gravity_prepared_test_utils {
|
||||
using DomainSchema = mean_field::utils::domain::CoreEnvelopeVacuumDomainSchema;
|
||||
|
||||
template <typename FieldT> inline mean_field::field::FieldDofMap make_field_map(const mean_field::fem::FEM &f) {
|
||||
if constexpr (std::same_as<FieldT, mean_field::field::Density>) {
|
||||
return mean_field::field::make_field_dof_map<FieldT, DomainSchema>(*f.densityFes);
|
||||
} else if constexpr (std::same_as<FieldT, mean_field::field::Displacement>) {
|
||||
return mean_field::field::make_field_dof_map<FieldT, DomainSchema>(*f.displacementFes);
|
||||
} else {
|
||||
static_assert(std::same_as<FieldT, mean_field::field::Gravity>);
|
||||
return mean_field::field::make_field_dof_map<FieldT, DomainSchema>(*f.gravityFluxFes);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FieldT>
|
||||
inline mfem::Vector gather_field(
|
||||
const mean_field::fem::FEM &f,
|
||||
const mfem::Vector &true_vector
|
||||
) {
|
||||
return make_field_map<FieldT>(f).gather(true_vector);
|
||||
}
|
||||
|
||||
inline mfem::Vector make_deterministic_vector(
|
||||
const int size,
|
||||
const double phase = 0.0
|
||||
@@ -207,59 +229,193 @@ export namespace gravity_prepared_test_utils {
|
||||
}
|
||||
} // namespace gravity_prepared_test_utils
|
||||
|
||||
export namespace field_dof_test_utils {
|
||||
using DomainSchema = mean_field::utils::domain::CoreEnvelopeVacuumDomainSchema;
|
||||
|
||||
template <typename FieldT>
|
||||
inline mean_field::field::FieldDofMap make_map(const mfem::ParFiniteElementSpace &finiteElementSpace) {
|
||||
return mean_field::field::make_field_dof_map<FieldT, DomainSchema>(finiteElementSpace);
|
||||
}
|
||||
|
||||
template <typename FieldT>
|
||||
inline mfem::Vector make_deterministic_supported_vector(
|
||||
const mfem::ParFiniteElementSpace &finiteElementSpace,
|
||||
const double phase
|
||||
) {
|
||||
const mean_field::field::FieldDofMap map = make_map<FieldT>(finiteElementSpace);
|
||||
const mfem::Vector full =
|
||||
gravity_prepared_test_utils::make_deterministic_vector(map.full_size(), phase);
|
||||
return map.gather(full);
|
||||
}
|
||||
|
||||
inline mfem::Vector make_supported_displacement(
|
||||
const mean_field::fem::FEM &f,
|
||||
const double phase
|
||||
) {
|
||||
const mean_field::field::FieldDofMap map =
|
||||
make_map<mean_field::field::Displacement>(*f.displacementFes);
|
||||
return map.gather(gravity_prepared_test_utils::make_displacement(f, phase));
|
||||
}
|
||||
|
||||
inline void apply_hydrostatic_reference(
|
||||
const mean_field::fem::FEM &f,
|
||||
const mean_field::physics::RigidRotation &rotation,
|
||||
const mfem::Vector &enthalpy,
|
||||
const mfem::Vector &gravityPotential,
|
||||
const mfem::Vector &displacement,
|
||||
const double bernoulliConstant,
|
||||
mfem::Vector &residual
|
||||
) {
|
||||
const mean_field::field::FieldDofMap enthalpyMap =
|
||||
make_map<mean_field::field::Enthalpy>(*f.enthalpyFes);
|
||||
const mean_field::field::FieldDofMap gravityPotentialMap =
|
||||
make_map<mean_field::field::Gravity>(*f.gravityPotentialFes);
|
||||
const mean_field::field::FieldDofMap displacementMap =
|
||||
make_map<mean_field::field::Displacement>(*f.displacementFes);
|
||||
|
||||
mfem::Vector enthalpyTrue(enthalpyMap.full_size());
|
||||
mfem::Vector gravityPotentialTrue(gravityPotentialMap.full_size());
|
||||
mfem::Vector displacementTrue(displacementMap.full_size());
|
||||
mfem::Vector residualTrue;
|
||||
|
||||
enthalpyMap.scatter(enthalpy, enthalpyTrue);
|
||||
gravityPotentialMap.scatter(gravityPotential, gravityPotentialTrue);
|
||||
displacementMap.scatter(displacement, displacementTrue);
|
||||
|
||||
mean_field::operators::kernels::apply_hydrostatic_equilibrium(
|
||||
f, *f.domainMapperStateless, rotation, enthalpyTrue, gravityPotentialTrue, displacementTrue,
|
||||
bernoulliConstant, residualTrue
|
||||
);
|
||||
|
||||
residual.SetSize(enthalpyMap.reduced_size());
|
||||
enthalpyMap.gather(residualTrue, residual);
|
||||
}
|
||||
} // namespace field_dof_test_utils
|
||||
|
||||
export namespace tags {
|
||||
inline constexpr auto geometry = make_tag("geometry");
|
||||
inline constexpr auto physics = make_tag("physics");
|
||||
inline constexpr auto unit = make_tag("unit");
|
||||
inline constexpr auto mesh = make_tag("mesh");
|
||||
inline constexpr auto integration = make_tag("integration");
|
||||
inline constexpr auto solver = make_tag("solver");
|
||||
inline constexpr auto integrator = make_tag("integrator");
|
||||
inline constexpr auto mapping = make_tag("mapping");
|
||||
inline constexpr auto utils = make_tag("utils");
|
||||
inline constexpr auto mfem_operators = make_tag("operators");
|
||||
inline constexpr auto initialization = make_tag("initialization");
|
||||
inline constexpr auto accuracy = make_tag("accuracy");
|
||||
inline constexpr auto closure = make_tag("closure");
|
||||
inline constexpr auto kernels = make_tag("kernels");
|
||||
inline constexpr auto surface = make_tag("surface");
|
||||
inline constexpr auto model = make_tag("model");
|
||||
inline constexpr auto geometry = make_tag("geometry");
|
||||
inline constexpr auto physics = make_tag("physics");
|
||||
inline constexpr auto unit = make_tag("unit");
|
||||
inline constexpr auto mesh = make_tag("mesh");
|
||||
inline constexpr auto integration = make_tag("integration");
|
||||
inline constexpr auto solver = make_tag("solver");
|
||||
inline constexpr auto integrator = make_tag("integrator");
|
||||
inline constexpr auto mapping = make_tag("mapping");
|
||||
inline constexpr auto utils = make_tag("utils");
|
||||
inline constexpr auto mfem_operators = make_tag("operators");
|
||||
inline constexpr auto initialization = make_tag("initialization");
|
||||
inline constexpr auto accuracy = make_tag("accuracy");
|
||||
inline constexpr auto closure = make_tag("closure");
|
||||
inline constexpr auto kernels = make_tag("kernels");
|
||||
inline constexpr auto surface = make_tag("surface");
|
||||
inline constexpr auto model = make_tag("model");
|
||||
|
||||
inline constexpr auto field = sub_tag(mesh & physics, "field");
|
||||
inline constexpr auto field = sub_tag(mesh & physics, "field");
|
||||
|
||||
inline constexpr auto legacy_comparison = make_tag("legacy_comparison");
|
||||
inline constexpr auto pressure = sub_tag(physics, "pressure");
|
||||
inline constexpr auto legacy_comparison = make_tag("legacy_comparison");
|
||||
inline constexpr auto pressure = sub_tag(physics, "pressure");
|
||||
|
||||
inline constexpr auto hydro = sub_tag(physics, "hydro");
|
||||
inline constexpr auto jacobian = sub_tag(integration & physics, "jacobian");
|
||||
inline constexpr auto residuals = sub_tag(integration & physics, "residuals");
|
||||
inline constexpr auto volume = sub_tag(mesh & geometry, "volume");
|
||||
inline constexpr auto quadrature = sub_tag(mesh & geometry & solver, "quadrature");
|
||||
inline constexpr auto convergence = sub_tag(solver, "convergence");
|
||||
inline constexpr auto transformations = sub_tag(mesh & geometry, "transformations");
|
||||
inline constexpr auto hydro = sub_tag(physics, "hydro");
|
||||
inline constexpr auto jacobian = sub_tag(integration & physics, "jacobian");
|
||||
inline constexpr auto residuals = sub_tag(integration & physics, "residuals");
|
||||
inline constexpr auto volume = sub_tag(mesh & geometry, "volume");
|
||||
inline constexpr auto quadrature = sub_tag(mesh & geometry & solver, "quadrature");
|
||||
inline constexpr auto convergence = sub_tag(solver, "convergence");
|
||||
inline constexpr auto transformations = sub_tag(mesh & geometry, "transformations");
|
||||
|
||||
inline constexpr auto h_refinement = sub_tag(mesh & convergence, "h_refinement");
|
||||
inline constexpr auto p_refinement = sub_tag(mesh & convergence, "p_refinement");
|
||||
inline constexpr auto h_refinement = sub_tag(mesh & convergence, "h_refinement");
|
||||
inline constexpr auto p_refinement = sub_tag(mesh & convergence, "p_refinement");
|
||||
|
||||
inline constexpr auto analytic_comparison = sub_tag(solver & physics & residuals, "analytic_comparison");
|
||||
inline constexpr auto self_consistency = sub_tag(solver & physics, "self_consistency");
|
||||
inline constexpr auto analytic_comparison = sub_tag(solver & physics & residuals, "analytic_comparison");
|
||||
inline constexpr auto self_consistency = sub_tag(solver & physics, "self_consistency");
|
||||
|
||||
inline constexpr auto centrifugal = sub_tag(solver & physics, "centrifugal");
|
||||
inline constexpr auto advection = sub_tag(solver & physics, "advection");
|
||||
inline constexpr auto coriolis = sub_tag(solver & physics, "coriolis");
|
||||
inline constexpr auto gravity = sub_tag(solver & physics, "gravity");
|
||||
inline constexpr auto enthalpy = sub_tag(solver & physics, "enthalpy");
|
||||
inline constexpr auto barotrope = sub_tag(physics, "barotrope");
|
||||
inline constexpr auto mass_continuity = sub_tag(solver & physics, "mass_continuity");
|
||||
inline constexpr auto pressure_gradient = sub_tag(solver & physics, "pressure_gradient");
|
||||
inline constexpr auto viscosity = sub_tag(solver & physics, "viscosity");
|
||||
inline constexpr auto centrifugal = sub_tag(solver & physics, "centrifugal");
|
||||
inline constexpr auto advection = sub_tag(solver & physics, "advection");
|
||||
inline constexpr auto coriolis = sub_tag(solver & physics, "coriolis");
|
||||
inline constexpr auto gravity = sub_tag(solver & physics, "gravity");
|
||||
inline constexpr auto enthalpy = sub_tag(solver & physics, "enthalpy");
|
||||
inline constexpr auto barotrope = sub_tag(physics, "barotrope");
|
||||
inline constexpr auto mass_continuity = sub_tag(solver & physics, "mass_continuity");
|
||||
inline constexpr auto pressure_gradient = sub_tag(solver & physics, "pressure_gradient");
|
||||
inline constexpr auto viscosity = sub_tag(solver & physics, "viscosity");
|
||||
|
||||
inline constexpr auto compactification = sub_tag(mesh & mapping, "compactification");
|
||||
inline constexpr auto kelvin = sub_tag(compactification, "kelvin");
|
||||
inline constexpr auto compactification = sub_tag(mesh & mapping, "compactification");
|
||||
inline constexpr auto kelvin = sub_tag(compactification, "kelvin");
|
||||
|
||||
inline constexpr auto prepared = sub_tag(solver & physics, "prepared");
|
||||
inline constexpr auto contexts = sub_tag(solver, "contexts");
|
||||
inline constexpr auto prepared = sub_tag(solver & physics, "prepared");
|
||||
inline constexpr auto contexts = sub_tag(solver, "contexts");
|
||||
|
||||
inline constexpr auto domain = sub_tag(mesh, "domain");
|
||||
inline constexpr auto domain = sub_tag(mesh, "domain");
|
||||
|
||||
// Canonical gravity-suite tags. These intentionally compose leaf tags
|
||||
// exactly once so Catch2 output remains useful and free of repeated
|
||||
// [solver]/[physics] entries inherited from older composite tags.
|
||||
inline constexpr auto gravity_unit = gravity & unit;
|
||||
inline constexpr auto gravity_integration = gravity & integration;
|
||||
inline constexpr auto gravity_operator = gravity & mfem_operators;
|
||||
inline constexpr auto gravity_prepared = gravity & make_tag("prepared");
|
||||
inline constexpr auto gravity_context = gravity & make_tag("context");
|
||||
inline constexpr auto gravity_kernel = gravity & kernels;
|
||||
inline constexpr auto gravity_accuracy = gravity & accuracy;
|
||||
inline constexpr auto gravity_legacy = gravity & legacy_comparison;
|
||||
inline constexpr auto gravity_operator_unit = gravity_operator & unit;
|
||||
inline constexpr auto gravity_operator_integration = gravity_operator & integration;
|
||||
inline constexpr auto gravity_operator_convergence = gravity_operator & integration & make_tag("convergence");
|
||||
inline constexpr auto gravity_analytic = gravity & integration & make_tag("analytic_comparison");
|
||||
inline constexpr auto gravity_consistency = gravity & integration & make_tag("self_consistency");
|
||||
inline constexpr auto gravity_prepared_jacobian = gravity_prepared & integration & make_tag("jacobian");
|
||||
inline constexpr auto gravity_prepared_unit = gravity_prepared & unit;
|
||||
inline constexpr auto gravity_prepared_jacobian_accuracy = gravity_prepared_jacobian & accuracy;
|
||||
inline constexpr auto gravity_kernel_accuracy = gravity_kernel & accuracy;
|
||||
inline constexpr auto gravity_kernel_integration = gravity_kernel & integration;
|
||||
inline constexpr auto gravity_kernel_convergence = gravity_kernel & integration & make_tag("convergence");
|
||||
inline constexpr auto gravity_analytic_accuracy = gravity_analytic & accuracy;
|
||||
inline constexpr auto gravity_analytic_initialization = gravity_analytic & initialization;
|
||||
inline constexpr auto gravity_consistency_initialization = gravity_consistency & initialization;
|
||||
|
||||
inline constexpr auto barotrope_prepared = barotrope & solver & make_tag("prepared");
|
||||
inline constexpr auto barotrope_prepared_jacobian = barotrope_prepared & integration & make_tag("jacobian");
|
||||
inline constexpr auto barotrope_context = barotrope & solver & make_tag("context");
|
||||
inline constexpr auto barotrope_context_integration = barotrope_context & integration;
|
||||
inline constexpr auto barotrope_prepared_analytic =
|
||||
barotrope_prepared & integration & make_tag("analytic_comparison");
|
||||
inline constexpr auto barotrope_prepared_jacobian_accuracy = barotrope_prepared_jacobian & accuracy;
|
||||
inline constexpr auto barotrope_prepared_jacobian_geometry = barotrope_prepared_jacobian & geometry;
|
||||
inline constexpr auto barotrope_prepared_jacobian_unit = barotrope_prepared_jacobian & unit;
|
||||
|
||||
// Canonical hydrostatic-suite tags. The leaf tags are composed directly
|
||||
// so inherited [physics]/[solver] tags appear only once.
|
||||
inline constexpr auto barotrope_hydrostatic = barotrope & solver & make_tag("hydro");
|
||||
inline constexpr auto barotrope_hydrostatic_context = barotrope_hydrostatic & make_tag("context");
|
||||
inline constexpr auto barotrope_hydrostatic_prepared = barotrope_hydrostatic & make_tag("prepared");
|
||||
inline constexpr auto barotrope_hydrostatic_prepared_residual =
|
||||
barotrope_hydrostatic_prepared & integration & make_tag("residual");
|
||||
inline constexpr auto barotrope_hydrostatic_prepared_jacobian =
|
||||
barotrope_hydrostatic_prepared & integration & make_tag("jacobian");
|
||||
inline constexpr auto barotrope_hydrostatic_prepared_analytic =
|
||||
barotrope_hydrostatic_prepared & integration & make_tag("analytic_comparison");
|
||||
|
||||
inline constexpr auto barotrope_mass_normalization =
|
||||
barotrope & solver & make_tag("mass_normalization");
|
||||
inline constexpr auto barotrope_mass_normalization_context =
|
||||
barotrope_mass_normalization & make_tag("context");
|
||||
inline constexpr auto barotrope_mass_normalization_prepared =
|
||||
barotrope_mass_normalization & make_tag("prepared");
|
||||
inline constexpr auto barotrope_mass_normalization_jacobian =
|
||||
barotrope_mass_normalization_prepared & integration & make_tag("jacobian");
|
||||
inline constexpr auto barotrope_mass_normalization_analytic =
|
||||
barotrope_mass_normalization_prepared & integration & make_tag("analytic_comparison");
|
||||
|
||||
inline constexpr auto rotation_prepared = centrifugal & make_tag("prepared");
|
||||
inline constexpr auto rotation_context = centrifugal & make_tag("context");
|
||||
inline constexpr auto rotation_analytic = centrifugal & integration & make_tag("analytic_comparison");
|
||||
inline constexpr auto rotation_context_unit = rotation_context & unit;
|
||||
inline constexpr auto rotation_prepared_unit = rotation_prepared & unit;
|
||||
inline constexpr auto rotation_prepared_jacobian = rotation_prepared & integration & make_tag("jacobian");
|
||||
inline constexpr auto rotation_prepared_jacobian_accuracy = rotation_prepared_jacobian & accuracy;
|
||||
inline constexpr auto rotation_kernel_accuracy = centrifugal & kernels & accuracy;
|
||||
inline constexpr auto rotation_analytic_unit = rotation_analytic & unit;
|
||||
inline constexpr auto rotation_analytic_accuracy = rotation_analytic & accuracy;
|
||||
inline constexpr auto rotation_analytic_accuracy_geometry = rotation_analytic_accuracy & geometry;
|
||||
|
||||
} // namespace tags
|
||||
|
||||
Reference in New Issue
Block a user