currently the barotope and the pressure force operator are migrated to the new support system
115 lines
4.3 KiB
C++
115 lines
4.3 KiB
C++
module;
|
|
|
|
#include <concepts>
|
|
#include <memory>
|
|
#include <type_traits>
|
|
#include <utility>
|
|
|
|
export module mean_field:model.stellar;
|
|
|
|
export import :eos.base;
|
|
export import :model.structure.base;
|
|
export import :surface.base;
|
|
|
|
export namespace mean_field::models {
|
|
template <typename Candidate>
|
|
concept StructurePrescription =
|
|
std::derived_from<std::remove_cvref_t<Candidate>, mean_field::models::structure::StructureBase>;
|
|
|
|
template <typename Candidate>
|
|
concept SurfacePrescription = std::derived_from<std::remove_cvref_t<Candidate>, mean_field::surface::SurfaceBase>;
|
|
|
|
/*
|
|
* Public ownership facade for a physical structure prescription and its
|
|
* stellar-surface prescription.
|
|
*
|
|
* The concrete prescriptions are allocated once at construction. Their
|
|
* stable addresses allow future prepared operators and contexts to borrow
|
|
* references without making ownership part of the user-facing API.
|
|
*/
|
|
class StellarModel final {
|
|
public:
|
|
template <
|
|
StructurePrescription StructureType,
|
|
SurfacePrescription SurfaceType>
|
|
explicit StellarModel(
|
|
StructureType &&structurePrescription,
|
|
SurfaceType &&surfacePrescription
|
|
)
|
|
: StellarModel(
|
|
std::make_unique<std::remove_cvref_t<StructureType>>(
|
|
std::forward<StructureType>(structurePrescription)
|
|
),
|
|
std::make_unique<std::remove_cvref_t<SurfaceType>>(std::forward<SurfaceType>(surfacePrescription))
|
|
) {
|
|
}
|
|
|
|
~StellarModel() = default;
|
|
|
|
StellarModel(const StellarModel &) = delete;
|
|
|
|
StellarModel &operator=(const StellarModel &) = delete;
|
|
|
|
StellarModel(StellarModel &&) noexcept = default;
|
|
|
|
StellarModel &operator=(StellarModel &&) noexcept = default;
|
|
|
|
[[nodiscard]] const mean_field::models::structure::StructureBase &structurePrescription() const noexcept {
|
|
return *m_structurePrescription;
|
|
}
|
|
|
|
[[nodiscard]] const mean_field::surface::SurfaceBase &surfacePrescription() const noexcept {
|
|
return *m_surfacePrescription;
|
|
}
|
|
|
|
[[nodiscard]] const mean_field::eos::EquationOfState &equationOfState() const noexcept {
|
|
return m_structurePrescription->equationOfState();
|
|
}
|
|
|
|
[[nodiscard]] double targetMass() const noexcept {
|
|
return m_structurePrescription->targetMass();
|
|
}
|
|
|
|
[[nodiscard]] mean_field::models::structure::StructureSeed
|
|
makeInitialSeed(const mean_field::models::structure::StructureSeedRequest &request) const {
|
|
return m_structurePrescription->makeInitialSeed(request);
|
|
}
|
|
|
|
[[nodiscard]] const mean_field::surface::ResolvedSurfaceCondition &resolvedSurfaceCondition() const noexcept {
|
|
return m_resolvedSurfaceCondition;
|
|
}
|
|
|
|
private:
|
|
explicit StellarModel(
|
|
std::unique_ptr<mean_field::models::structure::StructureBase> structurePrescription,
|
|
std::unique_ptr<mean_field::surface::SurfaceBase> surfacePrescription
|
|
)
|
|
: m_structurePrescription(std::move(structurePrescription)),
|
|
m_surfacePrescription(std::move(surfacePrescription)),
|
|
m_resolvedSurfaceCondition(validateAndResolve(
|
|
*m_structurePrescription,
|
|
*m_surfacePrescription
|
|
)) {
|
|
}
|
|
|
|
[[nodiscard]] static mean_field::surface::ResolvedSurfaceCondition validateAndResolve(
|
|
const mean_field::models::structure::StructureBase &structurePrescription,
|
|
const mean_field::surface::SurfaceBase &surfacePrescription
|
|
) {
|
|
structurePrescription.validate();
|
|
|
|
const mean_field::eos::EquationOfState &equationOfState = structurePrescription.equationOfState();
|
|
|
|
surfacePrescription.validate(equationOfState);
|
|
|
|
return surfacePrescription.resolve(equationOfState);
|
|
}
|
|
|
|
std::unique_ptr<mean_field::models::structure::StructureBase> m_structurePrescription;
|
|
|
|
std::unique_ptr<mean_field::surface::SurfaceBase> m_surfacePrescription;
|
|
|
|
mean_field::surface::ResolvedSurfaceCondition m_resolvedSurfaceCondition;
|
|
};
|
|
} // namespace mean_field::models
|