Program Listing for File SpecsynLibWR.hpp

↰ Return to documentation for file (src/specsyn/SpecsynLibWR.hpp)

#ifndef SPECSYNLIBWR_HPP
#define SPECSYNLIBWR_HPP

#include "../io/SimControls.hpp"
#include "Specsyn.hpp"
#include "SpecsynCommons.hpp"
#include "SpecsynLib.hpp"
#include <array>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <mdspan> // NOLINT(misc-include-cleaner)
#include <string>
#include <utility>
#include <vector>

namespace specsyn
{

    template <OOBPolicy Policy>
    class SpecsynLibWR : public SpecsynLib<Policy>
    {
    public:

        SpecsynLibWR(
            const std::string& spectraName,
            double fehMin,
            double fehMax,
            const std::string& registryName,
            double wlMin,
            double wlMax,
            std::size_t nWl,
            const io::SimControls& controls);

        [[nodiscard]] auto spec(const Specsyn::StarData& props, double feh) const
        -> std::vector<double> override;

        [[nodiscard]] auto specForce(const Specsyn::StarData& props, double feh) const
        -> std::vector<double> override;

        enum class WRType : std::uint8_t
        {
            None,    // NOLINT(readability-identifier-naming) -- capitalized to match WNE/WNL/WC's fixed spectral-classification naming below, rather than the project's usual camelBack enum-constant convention
            WNE,     // NOLINT(readability-identifier-naming) -- WNE is a fixed spectral-classification abbreviation; lowercasing it would make it unrecognizable
            WNLH20,  // NOLINT(readability-identifier-naming) -- see WNE
            WNLH40,  // NOLINT(readability-identifier-naming) -- see WNE
            WNLH60,  // NOLINT(readability-identifier-naming) -- see WNE
            WC       // NOLINT(readability-identifier-naming) -- see WNE
        };

        [[nodiscard]] static auto getWRType(
            const Specsyn::StarData& props,
            const std::array<std::pair<double, double>, 3>& wnlTeffRanges,
            double normalLogTeffMax) -> WRType;

        [[nodiscard]] auto type() const -> WRType { return type_; }

        void setWNLTeffRanges(const std::array<std::pair<double, double>, 3>& ranges)
        {
            wnlTeffRanges_ = ranges;
        }

        void setNormalLogTeffMax(const double logTeffMax)
        {
            normalLogTeffMax_ = logTeffMax;
        }

        [[nodiscard]] auto wnlTeffRanges() const -> const std::array<std::pair<double, double>, 3>&
        {
            return wnlTeffRanges_;
        }

        [[nodiscard]] auto normalLogTeffMax() const -> double { return normalLogTeffMax_; }

        [[nodiscard]] auto logTeff() const -> const std::vector<double>& { return logTeff_; }

        [[nodiscard]] auto fehMin() const -> double override { return FeH_.front(); }

        [[nodiscard]] auto fehMax() const -> double override { return FeH_.back(); }

    private:

        [[nodiscard]] auto computeRawLogRt(const Specsyn::StarData& props, double feh) const -> double;

        using ScalarGrid = std::mdspan<double, std::dextents<std::size_t, 3>>; // NOLINT(misc-include-cleaner) -- see the identical NOLINT on SpecsynLib.hpp's SpectraGrid alias

        // References into the parent class's dim1_/dim2_/dim3_, named
        // for what they actually hold in this (FeH, log_rt, log_teff)
        // specialization -- see SpecsynLibNoWind's identical FeH_,
        // logg_, Teff_ pattern, and its own NOLINT justification for
        // why these are references rather than owned copies.
        std::vector<double>& FeH_;      // NOLINT(readability-identifier-naming, cppcoreguidelines-avoid-const-or-ref-data-members)
        std::vector<double>& logRt_;    // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members)
        std::vector<double>& logTeff_;  // NOLINT(readability-identifier-naming, cppcoreguidelines-avoid-const-or-ref-data-members)

        std::vector<double> logL_;
        ScalarGrid logLGrid_;
        std::vector<double> dInf_;

        WRType type_;

        std::array<std::pair<double, double>, 3> wnlTeffRanges_ = {{
            {std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()},
            {std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()},
            {std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()},
        }};

        double normalLogTeffMax_ = std::numeric_limits<double>::quiet_NaN();
    };

} // namespace specsyn

#endif // SPECSYNLIBWR_HPP