src/model/Curve.cpp
| 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 | #include "Curve.hpp" | ||
| 7 | #include "Curve_Impl.hpp" | ||
| 8 | |||
| 9 | #include "ParentObject.hpp" | ||
| 10 | #include "ParentObject_Impl.hpp" | ||
| 11 | |||
| 12 | #include "../utilities/core/Assert.hpp" | ||
| 13 | |||
| 14 | namespace openstudio { | ||
| 15 | namespace model { | ||
| 16 | |||
| 17 | namespace detail { | ||
| 18 | |||
| 19 | 6951 | Curve_Impl::Curve_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) : ResourceObject_Impl(idfObject, model, keepHandle) {} | |
| 20 | |||
| 21 | 900 | Curve_Impl::Curve_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 22 | 900 | : ResourceObject_Impl(other, model, keepHandle) {} | |
| 23 | |||
| 24 | 4370 | Curve_Impl::Curve_Impl(const Curve_Impl& other, Model_Impl* model, bool keepHandle) : ResourceObject_Impl(other, model, keepHandle) {} | |
| 25 | |||
| 26 | 269 | boost::optional<ParentObject> Curve_Impl::parent() const { | |
| 27 |
2/2✓ Branch 1 taken 269 times.
✓ Branch 4 taken 269 times.
|
269 | ParentObjectVector parents = getObject<Curve>().getModelObjectSources<ParentObject>(); |
| 28 |
2/2✓ Branch 1 taken 144 times.
✓ Branch 2 taken 125 times.
|
269 | if (parents.size() > 1u) { |
| 29 |
8/8✓ Branch 1 taken 144 times.
✓ Branch 4 taken 144 times.
✓ Branch 7 taken 144 times.
✓ Branch 10 taken 144 times.
✓ Branch 13 taken 144 times.
✓ Branch 17 taken 144 times.
✓ Branch 20 taken 144 times.
✓ Branch 23 taken 144 times.
|
144 | LOG(Error, "This Curve, " << briefDescription() << " has multiple parents. Returning the first."); |
| 30 | } | ||
| 31 |
2/2✓ Branch 1 taken 265 times.
✓ Branch 2 taken 4 times.
|
269 | if (!parents.empty()) { |
| 32 |
1/1✓ Branch 2 taken 265 times.
|
265 | return parents[0]; |
| 33 | } | ||
| 34 | 4 | return boost::none; | |
| 35 | 269 | } | |
| 36 | |||
| 37 | 89 | double Curve_Impl::evaluate(double x) const { | |
| 38 |
2/2✓ Branch 1 taken 89 times.
✓ Branch 4 taken 88 times.
|
267 | return evaluate(DoubleVector(1u, x)); |
| 39 | } | ||
| 40 | |||
| 41 | 64 | double Curve_Impl::evaluate(double x, double y) const { | |
| 42 |
1/1✓ Branch 1 taken 64 times.
|
64 | DoubleVector values(2u); |
| 43 | 64 | values[0] = x; | |
| 44 | 64 | values[1] = y; | |
| 45 |
1/1✓ Branch 1 taken 64 times.
|
128 | return evaluate(values); |
| 46 | 64 | } | |
| 47 | |||
| 48 | 20 | double Curve_Impl::evaluate(double x, double y, double z) const { | |
| 49 |
1/1✓ Branch 1 taken 20 times.
|
20 | DoubleVector values(3u); |
| 50 | 20 | values[0] = x; | |
| 51 | 20 | values[1] = y; | |
| 52 | 20 | values[2] = z; | |
| 53 |
1/1✓ Branch 1 taken 20 times.
|
40 | return evaluate(values); |
| 54 | 20 | } | |
| 55 | |||
| 56 | 1 | double Curve_Impl::evaluate(double w, double x, double y, double z) const { | |
| 57 |
1/1✓ Branch 1 taken 1 time.
|
1 | DoubleVector values(4u); |
| 58 | 1 | values[0] = w; | |
| 59 | 1 | values[1] = x; | |
| 60 | 1 | values[2] = y; | |
| 61 | 1 | values[3] = z; | |
| 62 |
1/1✓ Branch 1 taken 1 time.
|
2 | return evaluate(values); |
| 63 | 1 | } | |
| 64 | |||
| 65 | 1 | double Curve_Impl::evaluate(double v, double w, double x, double y, double z) const { | |
| 66 |
1/1✓ Branch 1 taken 1 time.
|
1 | DoubleVector values(5u); |
| 67 | 1 | values[0] = v; | |
| 68 | 1 | values[1] = w; | |
| 69 | 1 | values[2] = x; | |
| 70 | 1 | values[3] = y; | |
| 71 | 1 | values[4] = z; | |
| 72 |
1/1✓ Branch 1 taken 1 time.
|
2 | return evaluate(values); |
| 73 | 1 | } | |
| 74 | |||
| 75 | ✗ | std::vector<EMSActuatorNames> Curve_Impl::emsActuatorNames() const { | |
| 76 | ✗ | std::vector<EMSActuatorNames> actuators{{"Curve", "Curve Result"}}; | |
| 77 | ✗ | return actuators; | |
| 78 | ✗ | } | |
| 79 | |||
| 80 | ✗ | std::vector<std::string> Curve_Impl::emsInternalVariableNames() const { | |
| 81 | ✗ | std::vector<std::string> types; | |
| 82 | ✗ | return types; | |
| 83 | } | ||
| 84 | } // namespace detail | ||
| 85 | |||
| 86 | 29 | int Curve::numVariables() const { | |
| 87 |
1/1✓ Branch 3 taken 28 times.
|
29 | return getImpl<detail::Curve_Impl>()->numVariables(); |
| 88 | } | ||
| 89 | |||
| 90 | ✗ | double Curve::evaluate(const std::vector<double>& x) const { | |
| 91 | ✗ | return getImpl<detail::Curve_Impl>()->evaluate(x); | |
| 92 | } | ||
| 93 | |||
| 94 | 89 | double Curve::evaluate(double x) const { | |
| 95 |
1/1✓ Branch 3 taken 88 times.
|
89 | return getImpl<detail::Curve_Impl>()->evaluate(x); |
| 96 | } | ||
| 97 | |||
| 98 | 64 | double Curve::evaluate(double x, double y) const { | |
| 99 |
1/1✓ Branch 3 taken 64 times.
|
64 | return getImpl<detail::Curve_Impl>()->evaluate(x, y); |
| 100 | } | ||
| 101 | |||
| 102 | 20 | double Curve::evaluate(double x, double y, double z) const { | |
| 103 |
1/1✓ Branch 3 taken 20 times.
|
20 | return getImpl<detail::Curve_Impl>()->evaluate(x, y, z); |
| 104 | } | ||
| 105 | |||
| 106 | 1 | double Curve::evaluate(double w, double x, double y, double z) const { | |
| 107 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::Curve_Impl>()->evaluate(w, x, y, z); |
| 108 | } | ||
| 109 | |||
| 110 | 1 | double Curve::evaluate(double v, double w, double x, double y, double z) const { | |
| 111 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::Curve_Impl>()->evaluate(v, w, x, y, z); |
| 112 | } | ||
| 113 | |||
| 114 | /// @cond | ||
| 115 | 6046 | Curve::Curve(IddObjectType type, const Model& model) : ResourceObject(type, model) { | |
| 116 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 6046 times.
✗ Branch 5 not taken.
|
6046 | OS_ASSERT(getImpl<detail::Curve_Impl>()); |
| 117 | 6046 | } | |
| 118 | |||
| 119 |
1/1✓ Branch 3 taken 9830 times.
|
9830 | Curve::Curve(std::shared_ptr<detail::Curve_Impl> impl) : ResourceObject(std::move(impl)) {} |
| 120 | /// @endcond | ||
| 121 | |||
| 122 | } // namespace model | ||
| 123 | } // namespace openstudio | ||
| 124 |