diff --git a/src/include/serif/discretization/quadrature/backend/mfem/mfem_resolver.hpp b/src/include/serif/discretization/quadrature/backend/mfem/mfem_resolver.hpp index 1be94a8..d785614 100644 --- a/src/include/serif/discretization/quadrature/backend/mfem/mfem_resolver.hpp +++ b/src/include/serif/discretization/quadrature/backend/mfem/mfem_resolver.hpp @@ -1,10 +1,11 @@ #pragma once #include +#include +#include #include "mfem/fem/geom.hpp" #include "mfem/fem/intrules.hpp" -#include "serif/discretization/blocks/traits.hpp" #include "serif/discretization/quadrature/rules.hpp" #include "serif/discretization/quadrature/backend/order.hpp" @@ -16,6 +17,8 @@ #include "serif/discretization/quadrature/backend/mfem/concepts.hpp" #include "serif/discretization/quadrature/backend/mfem/mfem_static_order.hpp" +#include "serif/utils/format/strings.hpp" + // We may want to consider renaming this file to runtime to stick to convention. The reason // I did not initially is that this is more specific than pure runtime projection of compile // time invariants (which is what most of the other files named runtime.hpp do). Something to think @@ -43,7 +46,7 @@ namespace serif::discretization::quadrature::backend::mfem { }; struct MFEMRule final { - Resolution resolution; + Resolution resolution{}; const ::mfem::IntegrationRule *integration_rule = nullptr; }; @@ -85,4 +88,33 @@ namespace serif::discretization::quadrature::backend::mfem { private: Policy m_policy; }; -} \ No newline at end of file +} + +template <> +struct std::formatter : std::formatter { + template + auto format(const serif::discretization::quadrature::backend::mfem::MFEMQuadratureContext& mfem_context, FormatContext& fc) { + std::unordered_map<::mfem::Geometry::Type, std::string> MFEM_GEOM_TYPE_NAME_MAP { + {::mfem::Geometry::INVALID, "INVALID"}, + {::mfem::Geometry::POINT, "POINT"}, + {::mfem::Geometry::SEGMENT, "SEGMENT"}, + {::mfem::Geometry::SQUARE, "SQUARE"}, + {::mfem::Geometry::TETRAHEDRON, "TETRAHEDRON"}, + {::mfem::Geometry::CUBE, "CUBE"}, + {::mfem::Geometry::PRISM, "PRISM"}, + {::mfem::Geometry::PYRAMID, "PYRAMID"}, + {::mfem::Geometry::NUM_GEOMETRIES, std::format("NUM_GEOMETRIES={}", static_cast(mfem::Geometry::NUM_GEOMETRIES))} + }; + return std::formatter::format( + std::format( + "MFEMQuadratureContext(form={}, geom_type={}, geom_weight_order={}, dynamic_orders={}, domains={}, mapping={})", + mfem_context.role, + MFEM_GEOM_TYPE_NAME_MAP.at(mfem_context.geometry), + mfem_context.geometry_weight_order, + serif::utils::misc::format::join(mfem_context.dynamic_orders, ", "), + mfem_context.domain, + mfem_context.mapping + ), fc); + } + +}; \ No newline at end of file diff --git a/src/include/serif/utils/error/errors.hpp b/src/include/serif/utils/error/errors.hpp index 91165b3..5d2f0ea 100644 --- a/src/include/serif/utils/error/errors.hpp +++ b/src/include/serif/utils/error/errors.hpp @@ -71,7 +71,7 @@ namespace serif::utils::errors { // Note if we move to C++26 we can replace this with a more standard and less convoluted // formated static_assert. - sizeof(serif_error_printer); + [[maybe_unused]] std::size_t error_kick = sizeof(serif_error_printer); } } } diff --git a/src/include/serif/utils/format/strings.hpp b/src/include/serif/utils/format/strings.hpp new file mode 100644 index 0000000..9a69e09 --- /dev/null +++ b/src/include/serif/utils/format/strings.hpp @@ -0,0 +1,19 @@ +#pragma once +#include +#include +#include +#include +#include + +namespace serif::utils::misc::format { + template + std::string join(const std::span& elements, std::string_view delimiter) + { + std::string out; + for (const auto& element : elements) { + out = std::format("{}{}{}", out, delimiter, element); + } + + return out; + } +} \ No newline at end of file diff --git a/src/include/serif/utils/misc/terminal/colors.hpp b/src/include/serif/utils/misc/terminal/colors.hpp index 5ad224b..5e38f5d 100644 --- a/src/include/serif/utils/misc/terminal/colors.hpp +++ b/src/include/serif/utils/misc/terminal/colors.hpp @@ -3,6 +3,7 @@ #include #include #include +#include #include namespace serif::utils::misc::terminal { @@ -71,4 +72,4 @@ namespace serif::utils::misc::terminal { return std::string_view(term) != "dumb"; } -} \ No newline at end of file +} diff --git a/tests/sandbox/dimensions_sandbox.cpp b/tests/sandbox/dimensions_sandbox.cpp index 8a1ae5b..fedca07 100644 --- a/tests/sandbox/dimensions_sandbox.cpp +++ b/tests/sandbox/dimensions_sandbox.cpp @@ -1,5 +1,6 @@ #include "serif/dimensions/runtime/concepts.hpp" +#include int main() { puts("Hello, world!\n"); -} \ No newline at end of file +}