feat(utils/projection): infrastructure for projecting some known field into FEM space
This commit is contained in:
4
src/include/serif/utils/projection/projection.hpp
Normal file
4
src/include/serif/utils/projection/projection.hpp
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#include "serif/utils/projection/radial.hpp"
|
||||
#include "serif/backend/mfem/projection/radial.hpp"
|
||||
27
src/include/serif/utils/projection/radial.hpp
Normal file
27
src/include/serif/utils/projection/radial.hpp
Normal 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);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user