146 lines
4.7 KiB
C++
146 lines
4.7 KiB
C++
module;
|
|
|
|
#include <compare>
|
|
#include <concepts>
|
|
|
|
export module mean_field:eos.quantities;
|
|
export import :dimensions.quantities;
|
|
|
|
export namespace mean_field::eos {
|
|
// Compatibility names for the thermodynamic subset now owned by the
|
|
// general dimensions partition.
|
|
using ThermodynamicQuantity = dimensions::ThermodynamicQuantity;
|
|
|
|
template <typename Candidate>
|
|
concept ThermodynamicQuantityType = dimensions::ThermodynamicQuantityType<Candidate>;
|
|
|
|
namespace quantity {
|
|
using Density = dimensions::quantity::Density;
|
|
using Pressure = dimensions::quantity::Pressure;
|
|
using SpecificEnthalpy = dimensions::quantity::SpecificEnthalpy;
|
|
} // namespace quantity
|
|
|
|
template <typename T>
|
|
concept Numeric = dimensions::Numeric<T>;
|
|
|
|
template <ThermodynamicQuantityType Quantity> using QuantityValue = dimensions::QuantityValue<Quantity>;
|
|
|
|
using DensityValue = dimensions::DensityValue;
|
|
using PressureValue = dimensions::PressureValue;
|
|
using SpecificEnthalpyValue = dimensions::SpecificEnthalpyValue;
|
|
|
|
template <typename Candidate> using IsQuantityValue = dimensions::IsQuantityValue<Candidate>;
|
|
|
|
template <typename Candidate>
|
|
concept QuantityValueType =
|
|
dimensions::QuantityValueType<Candidate> && ThermodynamicQuantityType<dimensions::QuantityOfT<Candidate>>;
|
|
|
|
template <typename Candidate> using QuantityOf = dimensions::QuantityOf<Candidate>;
|
|
|
|
template <QuantityValueType Value> using QuantityOfT = dimensions::QuantityOfT<Value>;
|
|
|
|
template <ThermodynamicQuantityType OutputQuantity, ThermodynamicQuantityType InputQuantity>
|
|
class PartialDerivative final {
|
|
public:
|
|
explicit constexpr PartialDerivative(const double value) noexcept : m_value(value) {
|
|
}
|
|
|
|
[[nodiscard]] constexpr double value() const noexcept {
|
|
return m_value;
|
|
}
|
|
|
|
friend constexpr PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity>
|
|
operator+(
|
|
const PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity> &lhs,
|
|
const PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity> &rhs
|
|
) noexcept;
|
|
|
|
friend constexpr PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity>
|
|
operator-(
|
|
const PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity> &lhs,
|
|
const PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity> &rhs
|
|
) noexcept;
|
|
|
|
template <Numeric Scalar>
|
|
friend constexpr PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity>
|
|
operator*(
|
|
const PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity> &,
|
|
Scalar
|
|
) noexcept;
|
|
|
|
template <Numeric Scalar>
|
|
friend constexpr PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity>
|
|
operator*(
|
|
Scalar,
|
|
const PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity> &
|
|
) noexcept;
|
|
|
|
template <Numeric Scalar>
|
|
friend constexpr PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity>
|
|
operator/(
|
|
const PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity> &,
|
|
Scalar
|
|
) noexcept;
|
|
|
|
template <Numeric Scalar>
|
|
friend constexpr std::partial_ordering operator<=>(
|
|
const PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity> &lhs,
|
|
Scalar rhs
|
|
) noexcept {
|
|
return lhs.m_value <=> static_cast<double>(rhs);
|
|
}
|
|
|
|
template <Numeric Scalar>
|
|
friend constexpr std::partial_ordering operator<=>(
|
|
Scalar lhs,
|
|
const PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity> &rhs
|
|
) noexcept {
|
|
return static_cast<double>(lhs) <=> rhs.m_value;
|
|
}
|
|
|
|
friend constexpr std::partial_ordering operator<=>(
|
|
const PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity> &lhs,
|
|
const PartialDerivative<
|
|
OutputQuantity,
|
|
InputQuantity> &rhs
|
|
) noexcept {
|
|
return lhs.m_value <=> rhs.m_value;
|
|
}
|
|
|
|
private:
|
|
double m_value;
|
|
};
|
|
|
|
template <ThermodynamicQuantityType Quantity> struct WithRespectTo final { };
|
|
} // namespace mean_field::eos
|