module; #include #include export module mean_field:model.compiled_fixed_mass; export import :field.registry; export import :model.specifications; export import :utils.blocks; export namespace mean_field::models { enum class ConstraintRowInjection { append, solver_border }; template < ModelSpecification Specification, typename GeneratedValue, typename GeneratedResidual, typename ValueBlock, typename ResidualBlock, typename Term, typename... StateValueBlocks> struct ConstraintLayoutRequest final { using SpecificationType = Specification; using GeneratedValueType = GeneratedValue; using GeneratedResidualType = GeneratedResidual; using ValueBlockType = ValueBlock; using ResidualBlockType = ResidualBlock; using TermType = Term; using StateValueBlockTypes = ModelTypeList; static constexpr ConstraintRowInjection rowInjection = ConstraintRowInjection::append; static constexpr std::size_t valueArity = GeneratedValue::scalarArity; static constexpr std::size_t residualArity = GeneratedResidual::scalarArity; template [[nodiscard]] static consteval auto valueBlock() { return utils::blocks::get_value_block
(Term{}); } template [[nodiscard]] static consteval auto residualBlock() { return utils::blocks::get_residual_block(Term{}); } }; template concept ConstraintLayoutRequestType = requires { typename std::remove_cvref_t::SpecificationType; typename std::remove_cvref_t::GeneratedValueType; typename std::remove_cvref_t::GeneratedResidualType; typename std::remove_cvref_t::ValueBlockType; typename std::remove_cvref_t::ResidualBlockType; typename std::remove_cvref_t::StateValueBlockTypes; requires ModelSpecification::SpecificationType>; requires std::remove_cvref_t::valueArity == std::remove_cvref_t::residualArity; }; using FixedMassLayoutRequest = ConstraintLayoutRequest< FixedTotalMass, MultiplierFor, ResidualFor, utils::blocks::fixed_total_mass::mass_normalization::value, utils::blocks::fixed_total_mass::mass_normalization::residual, utils::blocks::fixed_total_mass::mass_normalization, utils::blocks::density::mass::value, utils::blocks::displacement::geometry::value>; class CompiledFixedMass final { public: using SpecificationType = FixedTotalMass; using LayoutRequest = FixedMassLayoutRequest; using MultiplierType = typename LayoutRequest::GeneratedValueType; using ResidualType = typename LayoutRequest::GeneratedResidualType; // In the current barotropic formulation, the multiplier generated by // FixedTotalMass is realized by the historical scalar C field. using MultiplierField = field::BarotropicConstant; explicit CompiledFixedMass(const FixedTotalMass specification) noexcept : m_specification(specification) { } [[nodiscard]] const FixedTotalMass &specification() const noexcept { return m_specification; } [[nodiscard]] dimensions::MassValue targetMass() const noexcept { return m_specification.targetMass(); } [[nodiscard]] static consteval LayoutRequest layoutRequest() noexcept { return {}; } private: FixedTotalMass m_specification; }; template concept CompiledConstraint = requires(const std::remove_cvref_t &constraint) { typename std::remove_cvref_t::SpecificationType; typename std::remove_cvref_t::LayoutRequest; requires ModelSpecification::SpecificationType>; requires ConstraintLayoutRequestType::LayoutRequest>; { constraint.specification() } noexcept -> std::same_as::SpecificationType &>; { constraint.layoutRequest() } noexcept -> std::same_as::LayoutRequest>; }; [[nodiscard]] inline CompiledFixedMass compileConstraint(const FixedTotalMass specification) noexcept { return CompiledFixedMass{specification}; } static_assert(ConstraintLayoutRequestType); static_assert(CompiledConstraint); } // namespace mean_field::models