feat(quadrature): quadrature system brought over
Ported and dramatically cleaned up the quadrature system. This includes centralizing all field definitions
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
#include "serif/dimensions/runtime/concepts.hpp"
|
||||
|
||||
int main() {
|
||||
puts("Hello, world!\n");
|
||||
}
|
||||
@@ -6,11 +6,26 @@
|
||||
#include "serif/discretization/domain/schema/validation/results.hpp"
|
||||
#include "stroid/stroid.h"
|
||||
#include "serif/discretization/blocks/base.hpp"
|
||||
#include "serif/dimensions/runtime/runtime.hpp"
|
||||
#include "serif/discretization/forms/forms.hpp"
|
||||
#include "serif/discretization/forms/form_traits.hpp"
|
||||
#include "serif/discretization/blocks/concepts.hpp"
|
||||
#include "serif/discretization/forms/concept.hpp"
|
||||
#include "serif/discretization/forms/runtime.hpp"
|
||||
#include "serif/discretization/blocks/runtime.hpp"
|
||||
#include "serif/discretization/blocks/concepts.hpp"
|
||||
#include "serif/discretization/blocks/traits.hpp"
|
||||
#include "serif/discretization/blocks/concepts.hpp"
|
||||
#include "serif/utils/misc/concepts/enumeration.hpp"
|
||||
#include "serif/discretization/forms/operands.hpp"
|
||||
|
||||
#include "serif/utils/misc/concepts/filter.hpp"
|
||||
|
||||
int main() {
|
||||
using serif::discretization::domain::schema::validation::SchemaValidationResult;
|
||||
using serif::discretization::domain::schema::validation::validate_schema;
|
||||
using serif::discretization::domain::schema::CoreEnvelopeVacuumDomainSchema;
|
||||
using namespace serif::discretization::blocks;
|
||||
|
||||
const auto smesh_result = stroid::IO::LoadStroidMesh("sandbox.smesh");
|
||||
if (not smesh_result.has_value()) {
|
||||
@@ -21,4 +36,18 @@ int main() {
|
||||
|
||||
SchemaValidationResult result = validate_schema<CoreEnvelopeVacuumDomainSchema>(*smesh.mesh);
|
||||
std::println("{}", result);
|
||||
|
||||
std::println("{}", serif::discretization::forms::mass<serif::discretization::blocks::gravity::gradient, serif::discretization::blocks::gravity::gradient>::name);
|
||||
|
||||
using AllTerms = serif::utils::types::TypeList<
|
||||
density::mass,
|
||||
displacement::vector,
|
||||
surface_deformation::coefficients,
|
||||
surface_deformation::shape_equilibrium,
|
||||
gravity::potential,
|
||||
gravity::gradient,
|
||||
enthalpy::specific
|
||||
>;
|
||||
|
||||
using SpatialTerms = serif::utils::misc::concepts::FilterT<AllTerms, IsSpatialTerm>;
|
||||
}
|
||||
@@ -3,9 +3,24 @@
|
||||
#include "serif/eos/models/polytropic.hpp"
|
||||
#include "serif/eos/evaluation.hpp"
|
||||
#include "serif/dimensions/type_alias.hpp"
|
||||
#include "serif/discretization/blocks/base.hpp"
|
||||
#include "serif/discretization/blocks/fields.hpp"
|
||||
#include "serif/discretization/domain/physical_domains.hpp"
|
||||
#include "serif/eos/runtime/details.hpp"
|
||||
#include "serif/eos/runtime/concepts.hpp"
|
||||
#include "serif/eos/runtime/views.hpp"
|
||||
int main() {
|
||||
const serif::eos::models::Polytrope polytrope(1, 0.6);
|
||||
std::println("Density: {}", serif::eos::evaluate<serif::dimensions::Density>(polytrope, serif::dimensions::SpecificEnthalpyValue{1.0}).value());
|
||||
const serif::eos::runtime::EOSView view(polytrope);
|
||||
const auto result = view.try_evaluate<serif::dimensions::Density>(serif::dimensions::SpecificEnthalpyValue{1.0});
|
||||
if (result.has_value()) {
|
||||
std::println("From runtime view: Density: {}", result->value());
|
||||
} else {
|
||||
std::println("From runtime view: EOS view is unavailable.");
|
||||
}
|
||||
|
||||
std::println("{}", serif::discretization::blocks::gravity::name);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,26 +1,17 @@
|
||||
#include "serif/utils/misc/finite.hpp"
|
||||
#include "serif/utils/error/codes.hpp"
|
||||
#include <limits>
|
||||
|
||||
enum class [[maybe_unused]] TestErrorCode {
|
||||
NotFinite
|
||||
};
|
||||
|
||||
namespace {
|
||||
class test_exception : public std::runtime_error {
|
||||
public:
|
||||
test_exception(TestErrorCode error_code, const std::string& message)
|
||||
: std::runtime_error(message), m_error_code(error_code) {}
|
||||
|
||||
TestErrorCode error_code() const noexcept {
|
||||
return m_error_code;
|
||||
}
|
||||
private:
|
||||
TestErrorCode m_error_code;
|
||||
test_exception(const std::string& message)
|
||||
: std::runtime_error(message) {}
|
||||
};
|
||||
}
|
||||
|
||||
int main() {
|
||||
double a = std::numeric_limits<double>::infinity();
|
||||
|
||||
serif::utils::misc::validate_finite<test_exception>(a, TestErrorCode::NotFinite);
|
||||
serif::utils::misc::validate_finite<test_exception, serif::utils::errors::SERiFErrorCode::NON_FINITE_VALUE_ERROR>(a);
|
||||
}
|
||||
@@ -2,13 +2,16 @@ sandboxes = [
|
||||
'discritization_sandbox',
|
||||
'eos_sandbox',
|
||||
'finite_sandbox',
|
||||
'dimensions_sandbox',
|
||||
'quadrature_sandbox',
|
||||
'meta_sandbox',
|
||||
]
|
||||
|
||||
foreach sandbox: sandboxes
|
||||
executable(
|
||||
sandbox,
|
||||
sandbox + '.cpp',
|
||||
dependencies: [serif_dep, stroid_dep],
|
||||
dependencies: [serif_dep, stroid_dep, nameof_dep],
|
||||
build_rpath: mfem_runtime_prefix == '' ? '' : mfem_runtime_prefix / 'lib',
|
||||
)
|
||||
endforeach
|
||||
|
||||
8
tests/sandbox/meta_sandbox.cpp
Normal file
8
tests/sandbox/meta_sandbox.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "serif/meta/names.hpp"
|
||||
#include "serif/utils/error/errors.hpp"
|
||||
|
||||
int main() {
|
||||
using namespace serif::utils::errors;
|
||||
puts("Hello, world!\n");
|
||||
serif_assert<SERiFErrorCode::EOS_ERROR, "This is a message that should be seen at compile time. I am now going to make this very long to make sure that it does not get truncated. If you want to exercise this turn the following bool to false (generally set to true to allow compilation)", true>();
|
||||
}
|
||||
120
tests/sandbox/quadrature_sandbox.cpp
Normal file
120
tests/sandbox/quadrature_sandbox.cpp
Normal file
@@ -0,0 +1,120 @@
|
||||
#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/rules.hpp"
|
||||
#include "serif/discretization/quadrature/policy.hpp"
|
||||
#include "serif/discretization/quadrature/backend/mfem/mfem_static_order.hpp"
|
||||
#include "serif/discretization/quadrature/backend/order.hpp"
|
||||
#include "serif/discretization/quadrature/backend/mfem/concepts.hpp"
|
||||
#include "serif/discretization/quadrature/backend/mfem/configure.hpp"
|
||||
#include "serif/discretization/quadrature/backend/mfem/mfem_resolver.hpp"
|
||||
|
||||
#include <print>
|
||||
|
||||
int main() {
|
||||
using namespace serif::discretization::quadrature;
|
||||
using namespace serif::discretization::domain;
|
||||
using namespace serif::discretization::forms;
|
||||
|
||||
using GravityMassForm = divergence<serif::discretization::blocks::gravity::gradient, serif::discretization::blocks::gravity::gradient>;
|
||||
|
||||
auto query = make_query<GravityMassForm>(
|
||||
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<GravityMassForm>(
|
||||
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<GravityMassForm>(
|
||||
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
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user