src/model/Curve.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #ifndef MODEL_CURVE_HPP | ||
| 7 | #define MODEL_CURVE_HPP | ||
| 8 | |||
| 9 | #include "ModelAPI.hpp" | ||
| 10 | #include "ResourceObject.hpp" | ||
| 11 | |||
| 12 | namespace openstudio { | ||
| 13 | namespace model { | ||
| 14 | |||
| 15 | namespace detail { | ||
| 16 | |||
| 17 | class Curve_Impl; | ||
| 18 | |||
| 19 | } // namespace detail | ||
| 20 | |||
| 21 | /** Curve is a ModelObject that serves as a base class for a number of specific types of curves, | ||
| 22 | * each of which is a function of one, two, or three variables. Curve requires its derived | ||
| 23 | * classes to implement numVariables and evaluate. For examples of objects that use \link Curve | ||
| 24 | * Curves \endlink, see CoilCoolingDXSingleSpeed and PumpVariableSpeed. */ | ||
| 25 | class MODEL_API Curve : public ResourceObject | ||
| 26 | { | ||
| 27 | public: | ||
| 28 | /** @name Constructors and Destructors */ | ||
| 29 | //@{ | ||
| 30 | |||
| 31 | 31113 | virtual ~Curve() override = default; | |
| 32 | // Default the copy and move operators because the virtual dtor is explicit | ||
| 33 | 3512 | Curve(const Curve& other) = default; | |
| 34 | 11796 | Curve(Curve&& other) = default; | |
| 35 | ✗ | Curve& operator=(const Curve&) = default; | |
| 36 | 360 | Curve& operator=(Curve&&) = default; | |
| 37 | |||
| 38 | //@} | ||
| 39 | /** @name Other */ | ||
| 40 | //@{ | ||
| 41 | |||
| 42 | /** Returns the number of independent variable values required to evaluate this Curve. | ||
| 43 | * Typically 1 <= numVariables() <= 3. */ | ||
| 44 | int numVariables() const; | ||
| 45 | |||
| 46 | /** Returns the value of this Curve at x. Throws if x.size() != numVariables(), or if the curve | ||
| 47 | * cannot be evaluated for some type-specific reason. */ | ||
| 48 | double evaluate(const std::vector<double>& x) const; | ||
| 49 | |||
| 50 | /** Convenience overload that throws if numVariables() != 1. */ | ||
| 51 | double evaluate(double x) const; | ||
| 52 | |||
| 53 | /** Convenience overload that throws if numVariables() != 2. */ | ||
| 54 | double evaluate(double x, double y) const; | ||
| 55 | |||
| 56 | /** Convenience overload that throws if numVariables() != 3. */ | ||
| 57 | double evaluate(double x, double y, double z) const; | ||
| 58 | |||
| 59 | /** Convenience overload that throws if numVariables() != 4. */ | ||
| 60 | double evaluate(double w, double x, double y, double z) const; | ||
| 61 | |||
| 62 | /** Convenience overload that throws if numVariables() != 5. */ | ||
| 63 | double evaluate(double v, double w, double x, double y, double z) const; | ||
| 64 | |||
| 65 | //@} | ||
| 66 | protected: | ||
| 67 | /// @cond | ||
| 68 | using ImplType = detail::Curve_Impl; | ||
| 69 | |||
| 70 | Curve(IddObjectType type, const Model& model); | ||
| 71 | |||
| 72 | explicit Curve(std::shared_ptr<detail::Curve_Impl> impl); | ||
| 73 | |||
| 74 | friend class detail::Curve_Impl; | ||
| 75 | friend class Model; | ||
| 76 | friend class IdfObject; | ||
| 77 | friend class openstudio::detail::IdfObject_Impl; | ||
| 78 | /// @endcond | ||
| 79 | private: | ||
| 80 | REGISTER_LOGGER("openstudio.model.Curve"); | ||
| 81 | }; | ||
| 82 | |||
| 83 | /** \relates Curve*/ | ||
| 84 | using OptionalCurve = boost::optional<Curve>; | ||
| 85 | |||
| 86 | /** \relates Curve*/ | ||
| 87 | using CurveVector = std::vector<Curve>; | ||
| 88 | |||
| 89 | } // namespace model | ||
| 90 | } // namespace openstudio | ||
| 91 | |||
| 92 | #endif // MODEL_CURVE_HPP | ||
| 93 |