feat(surface): major work on implementing surface constraints in a presciption agnostic manner
This commit is contained in:
65
libmeanfield/interface/surface/constant.cppm
Normal file
65
libmeanfield/interface/surface/constant.cppm
Normal file
@@ -0,0 +1,65 @@
|
||||
module;
|
||||
|
||||
#include <cmath>
|
||||
#include <format>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
|
||||
export module mean_field:surface.constant;
|
||||
|
||||
export import :eos.quantities;
|
||||
|
||||
export namespace mean_field::surface {
|
||||
struct PressureSurfaceDescriptor final {
|
||||
double targetPressure;
|
||||
};
|
||||
|
||||
/*
|
||||
* The only physical surface prescription currently supported by
|
||||
* MeanField. It says nothing about which thermodynamic variable appears
|
||||
* in a nonlinear state vector; resolving pressure into that representation
|
||||
* is an EOS responsibility.
|
||||
*/
|
||||
class ConstantPressureSurface final {
|
||||
public:
|
||||
using PhysicalQuantity = eos::quantity::Pressure;
|
||||
using TargetValue = eos::PressureValue;
|
||||
|
||||
explicit ConstantPressureSurface(const TargetValue targetPressure) : m_targetPressure(targetPressure) {
|
||||
if (!std::isfinite(targetPressure.value())) {
|
||||
throw std::invalid_argument(
|
||||
std::format(
|
||||
"The target surface pressure must be finite. Instead P = {} was provided.",
|
||||
targetPressure.value()
|
||||
)
|
||||
);
|
||||
}
|
||||
if (targetPressure.value() < 0.0) {
|
||||
throw std::invalid_argument(
|
||||
std::format(
|
||||
"The target surface pressure must be non-negative. Instead P = {} was provided.",
|
||||
targetPressure.value()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] TargetValue targetPressure() const noexcept {
|
||||
return m_targetPressure;
|
||||
}
|
||||
|
||||
[[nodiscard]] PressureSurfaceDescriptor descriptor() const noexcept {
|
||||
return PressureSurfaceDescriptor{.targetPressure = m_targetPressure.value()};
|
||||
}
|
||||
|
||||
private:
|
||||
TargetValue m_targetPressure;
|
||||
};
|
||||
|
||||
template <typename Candidate>
|
||||
concept ConstantPressureSurfaceType = std::same_as<std::remove_cvref_t<Candidate>, ConstantPressureSurface>;
|
||||
|
||||
// Familiar physical terminology retained as a synonym, not as a second
|
||||
// surface-condition type.
|
||||
using Isobaric = ConstantPressureSurface;
|
||||
} // namespace mean_field::surface
|
||||
Reference in New Issue
Block a user