feat(utils/projection): infrastructure for projecting some known field into FEM space

This commit is contained in:
2026-11-09 13:40:31 -05:00
parent 7134f99d7c
commit c854fcc590
2 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
#pragma once
#include "serif/utils/projection/radial.hpp"
#include "serif/backend/mfem/projection/radial.hpp"

View File

@@ -0,0 +1,27 @@
#pragma once
#include <concepts>
#include <expected>
#include <functional>
#include <string>
#include <type_traits>
namespace serif::utils::projection {
using RadialValue = std::expected<double, std::string>;
/** @brief A radial profile accepts physical radius and returns a value or a numerical rejection. */
template <typename Function>
concept RadialFunction = std::invocable<const Function&, double> &&
(std::same_as<std::invoke_result_t<const Function&, double>, double> ||
std::same_as<std::invoke_result_t<const Function&, double>, RadialValue>);
namespace detail {
/** @brief Borrow a profile for one synchronous projection without requiring it to be copyable. */
template <RadialFunction Function>
[[nodiscard]] std::function<RadialValue(double)> checked_profile(const Function& function) {
return [&function](const double radius) -> RadialValue {
return std::invoke(function, radius);
};
}
}
}