Began working on mfem_resolver formatters
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#pragma once
|
||||
#include <span>
|
||||
#include <format>
|
||||
#include <unordered_map>
|
||||
|
||||
#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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
struct std::formatter<serif::discretization::quadrature::backend::mfem::MFEMQuadratureContext> : std::formatter<std::string> {
|
||||
template <typename FormatContext>
|
||||
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<int>(mfem::Geometry::NUM_GEOMETRIES))}
|
||||
};
|
||||
return std::formatter<std::string>::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);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -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<message, code>);
|
||||
[[maybe_unused]] std::size_t error_kick = sizeof(serif_error_printer<message, code>);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
src/include/serif/utils/format/strings.hpp
Normal file
19
src/include/serif/utils/format/strings.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <span>
|
||||
#include <format>
|
||||
#include <type_traits>
|
||||
|
||||
namespace serif::utils::misc::format {
|
||||
template <typename T>
|
||||
std::string join(const std::span<T>& elements, std::string_view delimiter)
|
||||
{
|
||||
std::string out;
|
||||
for (const auto& element : elements) {
|
||||
out = std::format("{}{}{}", out, delimiter, element);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <string_view>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <utility>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace serif::utils::misc::terminal {
|
||||
@@ -71,4 +72,4 @@ namespace serif::utils::misc::terminal {
|
||||
|
||||
return std::string_view(term) != "dumb";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "serif/dimensions/runtime/concepts.hpp"
|
||||
#include <cstdio>
|
||||
|
||||
int main() {
|
||||
puts("Hello, world!\n");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user