Files
MeanField_SERiF/tests/sandbox/quadrature_sandbox.cpp
Emily Boudreaux cb20faeb3d test(tests): added test suite
The test suite is extensive. Note that LLMs were used to aid in the development of the test suite. All LLM generated code was manually reviewed.
2026-11-09 13:53:17 -05:00

116 lines
2.9 KiB
C++

#include "serif/discretization/quadrature/rules.hpp"
#include "serif/discretization/quadrature/query.hpp"
#include "serif/discretization/forms/concept.hpp"
#include "serif/discretization/forms/forms.hpp"
#include "serif/discretization/quadrature/policy.hpp"
#include <print>
/** @brief Compare quadrature policies; the deliberately negative order demonstrates input validation. */
int main() {
using namespace serif::discretization::quadrature;
using namespace serif::discretization::domain;
using namespace serif::discretization::forms;
using PotentialMassForm = mass<serif::discretization::blocks::gravity::potential, serif::discretization::blocks::gravity::potential>;
auto query = make_query<PotentialMassForm>(
QuadratureRole::discretization,
AllDomains{},
MappingKind::affine,
3,
-4,
0,
0
);
std::println("{}", query);
RuleSet defaultRuleSet;
Policy defaultPolicy(defaultRuleSet);
const auto [base_order, boost, order, used_fixed_order] = defaultPolicy.resolve(query);
std::println(
"Default policy: base_order={}, boost={}, order={}, used_fixed_order={}",
base_order,
boost,
order,
used_fixed_order
);
RuleSet boostedRuleSet;
boostedRuleSet.set_fallback_control(
RuleControl{
.fixed_order = std::nullopt,
.boost = 1
}
);
boostedRuleSet.set_role_control(
QuadratureRole::discretization,
RuleControl{
.fixed_order = std::nullopt,
.boost = 2
}
);
boostedRuleSet.set_form_control<PotentialMassForm>(
RuleControl{
.fixed_order = std::nullopt,
.boost = 3
}
);
Policy boostedPolicy(boostedRuleSet);
const Resolution boostedResolution = boostedPolicy.resolve(query);
std::println(
"Boosted policy: base_order={}, boost={}, order={}, used_fixed_order={}",
boostedResolution.base_order,
boostedResolution.boost,
boostedResolution.order,
boostedResolution.used_fixed_order
);
RuleSet fixedRuleSet;
fixedRuleSet.set_fallback_control(
RuleControl{
.fixed_order = std::nullopt,
.boost = 1
}
);
fixedRuleSet.set_role_control(
QuadratureRole::discretization,
RuleControl{
.fixed_order = std::nullopt,
.boost = 2
}
);
fixedRuleSet.set_form_control<PotentialMassForm>(
RuleControl{
.fixed_order = 11,
.boost = 3
}
);
Policy fixedPolicy(fixedRuleSet);
const Resolution fixedResolution = fixedPolicy.resolve(query);
std::println(
"Fixed policy: base_order={}, boost={}, order={}, used_fixed_order={}",
fixedResolution.base_order,
fixedResolution.boost,
fixedResolution.order,
fixedResolution.used_fixed_order
);
}