The full rewrite of mean_field into something maintainable is progressing. dimensions is mostly done, discritization (domain, blocks, and fields) is done, and eos is progressing quickly
83 lines
3.2 KiB
C++
83 lines
3.2 KiB
C++
#pragma once
|
|
|
|
#include "serif/dimensions/quantities.hpp"
|
|
#include "serif/utils/misc/concepts/numeric.hpp"
|
|
|
|
namespace serif::dimensions {
|
|
template <ThermodynamicQuantityType Quantity>
|
|
struct WithRespectTo final {};
|
|
|
|
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 {
|
|
return PartialDerivative<OutputQuantity, InputQuantity>{lhs.m_value + rhs.m_value};
|
|
}
|
|
|
|
friend constexpr PartialDerivative<OutputQuantity, InputQuantity> operator-(
|
|
const PartialDerivative<OutputQuantity, InputQuantity>& lhs,
|
|
const PartialDerivative<OutputQuantity, InputQuantity>& rhs
|
|
) noexcept {
|
|
return PartialDerivative<OutputQuantity, InputQuantity>{lhs.m_value - rhs.m_value};
|
|
}
|
|
|
|
template <utils::misc::concepts::IsNumeric Scalar>
|
|
friend constexpr PartialDerivative<OutputQuantity, InputQuantity> operator*(
|
|
const PartialDerivative<OutputQuantity, InputQuantity>& lhs,
|
|
const Scalar& rhs
|
|
) noexcept {
|
|
return PartialDerivative<OutputQuantity, InputQuantity>{lhs.m_value * rhs};
|
|
}
|
|
|
|
template <utils::misc::concepts::IsNumeric Scalar>
|
|
friend constexpr PartialDerivative<OutputQuantity, InputQuantity> operator*(
|
|
const Scalar& lhs,
|
|
const PartialDerivative<OutputQuantity, InputQuantity>& rhs
|
|
) noexcept {
|
|
return PartialDerivative<OutputQuantity, InputQuantity>{lhs * rhs.m_value};
|
|
}
|
|
|
|
template <utils::misc::concepts::IsNumeric Scalar>
|
|
friend constexpr PartialDerivative<OutputQuantity, InputQuantity> operator/(
|
|
const PartialDerivative<OutputQuantity, InputQuantity>& lhs,
|
|
const Scalar& rhs
|
|
) noexcept {
|
|
return PartialDerivative<OutputQuantity, InputQuantity>{lhs.m_value / rhs};
|
|
}
|
|
|
|
template <utils::misc::concepts::IsNumeric Scalar>
|
|
friend constexpr std::partial_ordering operator<=>(
|
|
const PartialDerivative<OutputQuantity, InputQuantity>& lhs,
|
|
Scalar rhs
|
|
) noexcept {
|
|
return lhs.m_value <=> rhs;
|
|
}
|
|
|
|
template <utils::misc::concepts::IsNumeric Scalar>
|
|
friend constexpr std::partial_ordering operator<=>(
|
|
Scalar lhs,
|
|
const PartialDerivative<OutputQuantity, InputQuantity>& rhs
|
|
) noexcept {
|
|
return 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;
|
|
};
|
|
} |