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:
@@ -1,6 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <string_view>
|
||||
#include <span>
|
||||
#include <array>
|
||||
#include <format>
|
||||
#include <numeric>
|
||||
|
||||
#include "serif/discretization/domain/types.hpp"
|
||||
#include "serif/utils/misc/std_helper/cleaning.hpp"
|
||||
@@ -17,10 +22,33 @@ namespace serif::discretization::domain {
|
||||
concept IsBoundary = AIsBaseClassOfB<T, Boundary>;
|
||||
|
||||
// A DomainSet is several volumes treated as one. StellarDomains
|
||||
// (core + envelope) is the motivating example.
|
||||
// (core + envelope) is a motivating example.
|
||||
template <IsDomain... DomainTs>
|
||||
struct DomainSet {
|
||||
static constexpr std::size_t count = CountVariadicArguments<DomainTs...>();
|
||||
|
||||
static inline const std::array<std::string_view, count> names{
|
||||
DomainTs::name...
|
||||
};
|
||||
};
|
||||
|
||||
// Do not make the constructors of this class explicit. We want to be able to pass a single domain or a domain set to functions that take a DomainOrSet.
|
||||
class DomainOrSet final {
|
||||
public:
|
||||
template <IsDomain DomainT>
|
||||
// ReSharper disable once CppNonExplicitConvertingConstructor
|
||||
constexpr DomainOrSet(DomainT) noexcept : m_domains(&DomainT::name, 1) {}
|
||||
|
||||
template <IsDomain... DomainTs>
|
||||
// ReSharper disable once CppNonExplicitConvertingConstructor
|
||||
constexpr DomainOrSet(DomainSet<DomainTs...>) noexcept : m_domains(DomainSet<DomainTs...>::names) {}
|
||||
|
||||
[[nodiscard]] constexpr std::span<const std::string_view> domains() const noexcept {
|
||||
return m_domains;
|
||||
}
|
||||
|
||||
private:
|
||||
std::span<const std::string_view> m_domains;
|
||||
};
|
||||
|
||||
template <IsBoundary... BoundaryTs>
|
||||
@@ -53,3 +81,25 @@ namespace serif::discretization::domain {
|
||||
template <typename BoundaryT, typename BoundaryIDT>
|
||||
concept BoundaryIsIdentifiedBy = utils::misc::std_helper::SameType<BoundaryT, typename BoundaryIDT::boundary_type>;
|
||||
}
|
||||
|
||||
template <>
|
||||
struct std::formatter<serif::discretization::domain::DomainOrSet> : std::formatter<std::string_view> {
|
||||
template <typename FormatContext>
|
||||
auto format(const serif::discretization::domain::DomainOrSet& dos, FormatContext& ctx) const {
|
||||
auto join = [&](std::span<const std::string_view> strings, std::string_view delimiter) {
|
||||
return std::accumulate(
|
||||
strings.begin(),
|
||||
strings.end(),
|
||||
std::string{},
|
||||
[delimiter](std::string acc, std::string_view s) {
|
||||
if (!acc.empty()) {
|
||||
acc += delimiter;
|
||||
}
|
||||
acc += s;
|
||||
return acc;
|
||||
}
|
||||
);
|
||||
};
|
||||
return std::formatter<std::string_view>::format(std::format("DomainOrSet(domains=[{}])", join(dos.domains(), ", ")), ctx);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user