Files
MeanField/libmeanfield/interface/models/compiled_fixed_central_density.cppm

96 lines
3.7 KiB
C++

module;
#include <concepts>
#include <type_traits>
export module mean_field:model.compiled_fixed_central_density;
export import :eos.polytrope;
export import :field.registry;
export import :model.compiled_fixed_mass;
export import :utils.blocks;
export namespace mean_field::models {
struct CentralDensityLayoutRequest final {
using SpecificationType = FixedCentralDensity;
using GeneratedValueType = BorderFor<FixedCentralDensity>;
using GeneratedResidualType = ResidualFor<FixedCentralDensity>;
using ValueBlockType = utils::blocks::fixed_central_density::central_value::value;
using ResidualBlockType = utils::blocks::fixed_central_density::central_value::residual;
using TermType = utils::blocks::fixed_central_density::central_value;
using StateValueBlockTypes = ModelTypeList<utils::blocks::enthalpy::specific::value>;
static constexpr ConstraintRowInjection rowInjection = ConstraintRowInjection::solver_border;
static constexpr std::size_t valueArity = GeneratedValueType::scalarArity;
static constexpr std::size_t residualArity = GeneratedResidualType::scalarArity;
template <typename Form> [[nodiscard]] static consteval auto valueBlock() {
return utils::blocks::get_value_block<Form>(TermType{});
}
template <typename Form> [[nodiscard]] static consteval auto residualBlock() {
return utils::blocks::get_residual_block<Form>(TermType{});
}
};
class CompiledFixedCentralDensity final {
public:
using SpecificationType = FixedCentralDensity;
using LayoutRequest = CentralDensityLayoutRequest;
using BorderType = typename LayoutRequest::GeneratedValueType;
using ResidualType = typename LayoutRequest::GeneratedResidualType;
using CarrierField = field::Enthalpy;
using BorderField = field::CentralDensityBorder;
CompiledFixedCentralDensity(
const FixedCentralDensity specification,
const eos::Polytrope &equationOfState
)
: m_specification(specification),
m_equationOfState(equationOfState),
m_targetEnthalpy(
eos::evaluate<eos::quantity::SpecificEnthalpy>(
m_equationOfState,
m_specification.targetDensity()
)
) {
}
[[nodiscard]] const FixedCentralDensity &specification() const noexcept {
return m_specification;
}
[[nodiscard]] dimensions::DensityValue targetDensity() const noexcept {
return m_specification.targetDensity();
}
[[nodiscard]] dimensions::SpecificEnthalpyValue targetEnthalpy() const noexcept {
return m_targetEnthalpy;
}
[[nodiscard]] dimensions::DensityValue
densityFromEnthalpy(const dimensions::SpecificEnthalpyValue enthalpy) const {
return eos::evaluate<eos::quantity::Density>(m_equationOfState, enthalpy);
}
[[nodiscard]] static consteval LayoutRequest layoutRequest() noexcept {
return {};
}
private:
FixedCentralDensity m_specification;
eos::Polytrope m_equationOfState;
dimensions::SpecificEnthalpyValue m_targetEnthalpy;
};
[[nodiscard]] inline CompiledFixedCentralDensity compileConstraint(
const FixedCentralDensity specification,
const eos::Polytrope &equationOfState
) {
return {specification, equationOfState};
}
static_assert(ConstraintLayoutRequestType<CentralDensityLayoutRequest>);
static_assert(CompiledConstraint<CompiledFixedCentralDensity>);
} // namespace mean_field::models