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:
2026-08-23 10:13:53 -04:00
parent dc912fd15e
commit 0f3ca8050b
137 changed files with 29975 additions and 16389 deletions

View File

@@ -108,12 +108,9 @@ export namespace mean_field::quadrature {
const Query &query,
const mfem::Geometry::Type geometry
) const {
const Resolution resolution = policy.resolve(query);
const mfem::IntegrationRule &integration_rule =
mfem::IntRules.Get(geometry, resolution.order);
return {
.resolution = resolution, .integration_rule = &integration_rule
};
const Resolution resolution = policy.resolve(query);
const mfem::IntegrationRule &integration_rule = mfem::IntRules.Get(geometry, resolution.order);
return {.resolution = resolution, .integration_rule = &integration_rule};
}
MfemRule RuleFactory::get(
@@ -146,12 +143,10 @@ export namespace mean_field::quadrature {
"The H(div) element order does not match the registered gravity "
"flux."
);
const Query query =
GravityField::make_query<field::Gravity::Form::HDivMass>(
role, transformation.OrderW(), {}, domain, mapping
);
const auto [resolution, integration_rule] =
get(query, element.GetGeomType());
const Query query = GravityField::make_query<field::Gravity::Form::HDivMass>(
role, transformation.OrderW(), {}, domain, mapping
);
const auto [resolution, integration_rule] = get(query, element.GetGeomType());
integrator.SetIntegrationRule(*integration_rule);
return resolution;
}
@@ -176,13 +171,11 @@ export namespace mean_field::quadrature {
"The divergence test element does not match the registered "
"gravity potential."
);
const Query query =
GravityField::make_query<field::Gravity::Form::DivergenceCoupling>(
role, transformation.OrderW(), {}, domain, mapping
);
const Query query = GravityField::make_query<field::Gravity::Form::DivergenceCoupling>(
role, transformation.OrderW(), {}, domain, mapping
);
const auto [resolution, integration_rule] =
get(query, trial_element.GetGeomType());
const auto [resolution, integration_rule] = get(query, trial_element.GetGeomType());
integrator.SetIntegrationRule(*integration_rule);
return resolution;
}
@@ -200,12 +193,8 @@ export namespace mean_field::quadrature {
"The boundary element does not match the registered gravity-flux "
"normal trace."
);
const Query query =
GravityField::make_query<field::Gravity::Form::Boundary>(
role, 0, {}, domain, mapping
);
const auto [resolution, integration_rule] =
get(query, boundary_element.GetGeomType());
const Query query = GravityField::make_query<field::Gravity::Form::Boundary>(role, 0, {}, domain, mapping);
const auto [resolution, integration_rule] = get(query, boundary_element.GetGeomType());
integrator.SetIntegrationRule(*integration_rule);
return resolution;
}
@@ -230,13 +219,11 @@ export namespace mean_field::quadrature {
"The gravity-source coefficient order does not match the "
"registered density field."
);
const Query query =
GravityField::make_query<field::Gravity::Form::SourceLinear>(
role, transformation.OrderW(), {}, domain, mapping
);
const Query query = GravityField::make_query<field::Gravity::Form::SourceLinear>(
role, transformation.OrderW(), {}, domain, mapping
);
const auto [resolution, integration_rule] =
get(query, test_element.GetGeomType());
const auto [resolution, integration_rule] = get(query, test_element.GetGeomType());
integrator.SetIntegrationRule(*integration_rule);
return resolution;
}
@@ -271,17 +258,14 @@ export namespace mean_field::quadrature {
"gravity potential."
);
MFEM_VERIFY(
coefficient_order == 0,
"The mapped gravity-source coefficient order must be zero; "
"density order is supplied by the registered trial field."
coefficient_order == 0, "The mapped gravity-source coefficient order must be zero; "
"density order is supplied by the registered trial field."
);
const Query query = GravityField::make_query<field::Gravity::Form::SourceProjection>(
role, transformation.OrderW(), {}, domain, mapping
);
const Query query =
GravityField::make_query<field::Gravity::Form::SourceProjection>(
role, transformation.OrderW(), {}, domain, mapping
);
const auto [resolution, integration_rule] =
get(query, transformation.GetGeometryType());
const auto [resolution, integration_rule] = get(query, transformation.GetGeometryType());
integrator.SetIntRule(integration_rule);
return resolution;
}
@@ -307,8 +291,7 @@ export namespace mean_field::quadrature {
.geometry_weight_order = transformation.OrderW()
};
const auto [resolution, integration_rule] =
get(query, velocity_element.GetGeomType());
const auto [resolution, integration_rule] = get(query, velocity_element.GetGeomType());
integrator.SetIntegrationRule(*integration_rule);
return resolution;
}
@@ -323,8 +306,7 @@ export namespace mean_field::quadrature {
const utils::DOMAINS domain,
const MappingKind mapping
) const {
const auto [resolution, integration_rule] =
get(term, role, geometry, base_order, domain, mapping);
const auto [resolution, integration_rule] = get(term, role, geometry, base_order, domain, mapping);
integrator.SetIntegrationRule(*integration_rule);
return resolution;
}

View File

@@ -14,6 +14,7 @@ export namespace mean_field::quadrature {
gravity_hdiv_mass,
gravity_divergence,
gravity_source,
gravity_force,
gravity_boundary,
centrifugal,
density_projection,
@@ -32,12 +33,7 @@ export namespace mean_field::quadrature {
error_norm
};
enum class QuadratureRole {
discretization,
preconditioner,
diagnostic,
projection
};
enum class QuadratureRole { discretization, preconditioner, diagnostic, projection };
enum class MappingKind { none, affine, general, kelvin };
@@ -59,6 +55,7 @@ export namespace mean_field::quadrature {
RuleControl gravity_hdiv_mass;
RuleControl gravity_divergence;
RuleControl gravity_source;
RuleControl gravity_force;
RuleControl gravity_boundary;
RuleControl centrifugal;
RuleControl density_projection;
@@ -130,6 +127,7 @@ export namespace mean_field::quadrature {
QuadratureTermOptions gravity_hdiv_mass;
QuadratureTermOptions gravity_divergence;
QuadratureTermOptions gravity_source;
QuadratureTermOptions gravity_force;
QuadratureTermOptions gravity_boundary;
QuadratureTermOptions centrifugal;
QuadratureTermOptions density_projection;
@@ -211,35 +209,20 @@ export namespace mean_field::quadrature {
if (fixed_order.has_value()) {
if (*fixed_order < 0) {
throw std::invalid_argument(
"Quadrature fixed order cannot be negative."
);
throw std::invalid_argument("Quadrature fixed order cannot be negative.");
}
return {
.base_order = base_order,
.boost = 0,
.order = *fixed_order,
.used_fixed_order = true
};
return {.base_order = base_order, .boost = 0, .order = *fixed_order, .used_fixed_order = true};
}
const int boost =
rule_set.fallback.boost + role_control.boost + term_control.boost;
const int boost = rule_set.fallback.boost + role_control.boost + term_control.boost;
const int order = base_order + boost;
if (order < 0) {
throw std::invalid_argument(
"Resolved quadrature order cannot be negative."
);
throw std::invalid_argument("Resolved quadrature order cannot be negative.");
}
return {
.base_order = base_order,
.boost = boost,
.order = order,
.used_fixed_order = false
};
return {.base_order = base_order, .boost = boost, .order = order, .used_fixed_order = false};
}
const RuleControl &Policy::get_control(const Term term) const {
switch (term) {
@@ -249,6 +232,8 @@ export namespace mean_field::quadrature {
return rule_set.gravity_divergence;
case Term::gravity_source:
return rule_set.gravity_source;
case Term::gravity_force:
return rule_set.gravity_force;
case Term::gravity_boundary:
return rule_set.gravity_boundary;
case Term::centrifugal:
@@ -289,18 +274,14 @@ export namespace mean_field::quadrature {
int Policy::compute_base_order(const Query &query) {
if (query.base_order.has_value()) {
if (*query.base_order < 0) {
throw std::invalid_argument(
"Quadrature base order cannot be negative."
);
throw std::invalid_argument("Quadrature base order cannot be negative.");
}
return *query.base_order;
}
if (query.trial_order < 0 || query.test_order < 0 ||
query.coefficient_order < 0 || query.geometry_weight_order < 0) {
throw std::invalid_argument(
"Quadrature query orders cannot be negative."
);
if (query.trial_order < 0 || query.test_order < 0 || query.coefficient_order < 0 ||
query.geometry_weight_order < 0) {
throw std::invalid_argument("Quadrature query orders cannot be negative.");
}
int trial_order = query.trial_order;
@@ -308,12 +289,10 @@ export namespace mean_field::quadrature {
trial_order = std::max(0, trial_order - 1);
}
return trial_order + query.test_order + query.coefficient_order +
query.geometry_weight_order;
return trial_order + query.test_order + query.coefficient_order + query.geometry_weight_order;
}
const RuleControl &
Policy::get_role_control(const QuadratureRole role) const {
const RuleControl &Policy::get_role_control(const QuadratureRole role) const {
switch (role) {
case QuadratureRole::discretization:
return rule_set.roles.discretization;