GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 83.8% 98 / 0 / 117
Functions: 86.8% 33 / 0 / 38
Branches: 66.1% 78 / 0 / 118

src/model/CurveFunctionalPressureDrop.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 "CurveFunctionalPressureDrop.hpp"
7 #include "CurveFunctionalPressureDrop_Impl.hpp"
8
9 #include <utilities/idd/OS_Curve_Functional_PressureDrop_FieldEnums.hxx>
10 #include <utilities/idd/IddEnums.hxx>
11
12 #include "../utilities/core/Assert.hpp"
13
14 #include <cmath>
15
16 using namespace std;
17
18 namespace openstudio {
19 namespace model {
20
21 namespace detail {
22
23 1 CurveFunctionalPressureDrop_Impl::CurveFunctionalPressureDrop_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
24 1 : Curve_Impl(idfObject, model, keepHandle) {
25
4/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 13 not taken.
1 OS_ASSERT(idfObject.iddObject().type() == CurveFunctionalPressureDrop::iddObjectType());
26 1 }
27
28 ✗ CurveFunctionalPressureDrop_Impl::CurveFunctionalPressureDrop_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model,
29 ✗ bool keepHandle)
30 ✗ : Curve_Impl(other, model, keepHandle) {
31 ✗ OS_ASSERT(other.iddObject().type() == CurveFunctionalPressureDrop::iddObjectType());
32 ✗ }
33
34 ✗ CurveFunctionalPressureDrop_Impl::CurveFunctionalPressureDrop_Impl(const CurveFunctionalPressureDrop_Impl& other, Model_Impl* model,
35 ✗ bool keepHandle)
36 ✗ : Curve_Impl(other, model, keepHandle) {}
37
38 ✗ const std::vector<std::string>& CurveFunctionalPressureDrop_Impl::outputVariableNames() const {
39 static const std::vector<std::string> result{// Curve Input 1: MassFlow
40 "Performance Curve Input Variable 1 Value",
41
42 // Curve Input 2: Density
43 "Performance Curve Input Variable 2 Value",
44
45 // Curve Input 3: Velocity
46 "Performance Curve Input Variable 3 Value",
47
48 // Curve Output: the resultant value
49 ✗ "Performance Curve Output Value"};
50 ✗ return result;
51 ✗ }
52
53 ✗ IddObjectType CurveFunctionalPressureDrop_Impl::iddObjectType() const {
54 ✗ return CurveFunctionalPressureDrop::iddObjectType();
55 }
56
57 1 int CurveFunctionalPressureDrop_Impl::numVariables() const {
58
17/17
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 37 taken 1 time.
✓ Branch 40 taken 1 time.
✓ Branch 43 taken 1 time.
✓ Branch 46 taken 1 time.
✓ Branch 50 taken 1 time.
✓ Branch 53 taken 1 time.
1 LOG_AND_THROW("CurveFunctionalPressureDrop must be evaluated by EnergyPlus, in the context of "
59 << "plant pressure simulations. Therefore, numVariables and evaluate are not applicable " << "for this curve type.");
60 }
61
62 1 double CurveFunctionalPressureDrop_Impl::evaluate(const std::vector<double>& /*independentVariables*/) const {
63
17/17
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 37 taken 1 time.
✓ Branch 40 taken 1 time.
✓ Branch 43 taken 1 time.
✓ Branch 46 taken 1 time.
✓ Branch 50 taken 1 time.
✓ Branch 53 taken 1 time.
1 LOG_AND_THROW("CurveFunctionalPressureDrop must be evaluated by EnergyPlus, in the context of "
64 << "plant pressure simulations. Therefore, numVariables and evaluate are not applicable " << "for this curve type.");
65 }
66
67 2 double CurveFunctionalPressureDrop_Impl::diameter() const {
68
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<double> value = getDouble(OS_Curve_Functional_PressureDropFields::Diameter, true);
69
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
2 OS_ASSERT(value);
70
1/1
✓ Branch 1 taken 2 times.
4 return value.get();
71 }
72
73 5 boost::optional<double> CurveFunctionalPressureDrop_Impl::minorLossCoefficient() const {
74 5 return getDouble(OS_Curve_Functional_PressureDropFields::MinorLossCoefficient, true);
75 }
76
77 5 boost::optional<double> CurveFunctionalPressureDrop_Impl::length() const {
78 5 return getDouble(OS_Curve_Functional_PressureDropFields::Length, true);
79 }
80
81 5 boost::optional<double> CurveFunctionalPressureDrop_Impl::roughness() const {
82 5 return getDouble(OS_Curve_Functional_PressureDropFields::Roughness, true);
83 }
84
85 5 boost::optional<double> CurveFunctionalPressureDrop_Impl::fixedFrictionFactor() const {
86 5 return getDouble(OS_Curve_Functional_PressureDropFields::FixedFrictionFactor, true);
87 }
88
89 2 bool CurveFunctionalPressureDrop_Impl::setDiameter(double diameter) {
90 2 bool result = setDouble(OS_Curve_Functional_PressureDropFields::Diameter, diameter);
91 2 return result;
92 }
93
94 2 bool CurveFunctionalPressureDrop_Impl::setMinorLossCoefficient(boost::optional<double> minorLossCoefficient) {
95 2 bool result = false;
96
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (minorLossCoefficient) {
97 2 result = setDouble(OS_Curve_Functional_PressureDropFields::MinorLossCoefficient, minorLossCoefficient.get());
98 } else {
99 ✗ result = setString(OS_Curve_Functional_PressureDropFields::MinorLossCoefficient, "");
100 }
101 2 return result;
102 }
103
104 1 void CurveFunctionalPressureDrop_Impl::resetMinorLossCoefficient() {
105
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_Curve_Functional_PressureDropFields::MinorLossCoefficient, "");
106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
107 1 }
108
109 2 bool CurveFunctionalPressureDrop_Impl::setLength(boost::optional<double> length) {
110 2 bool result = false;
111
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (length) {
112 2 result = setDouble(OS_Curve_Functional_PressureDropFields::Length, length.get());
113 } else {
114 ✗ result = setString(OS_Curve_Functional_PressureDropFields::Length, "");
115 }
116 2 return result;
117 }
118
119 1 void CurveFunctionalPressureDrop_Impl::resetLength() {
120
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_Curve_Functional_PressureDropFields::Length, "");
121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
122 1 }
123
124 2 bool CurveFunctionalPressureDrop_Impl::setRoughness(boost::optional<double> roughness) {
125 2 bool result = false;
126
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (roughness) {
127 2 result = setDouble(OS_Curve_Functional_PressureDropFields::Roughness, roughness.get());
128 } else {
129 ✗ result = setString(OS_Curve_Functional_PressureDropFields::Roughness, "");
130 }
131 2 return result;
132 }
133
134 1 void CurveFunctionalPressureDrop_Impl::resetRoughness() {
135
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_Curve_Functional_PressureDropFields::Roughness, "");
136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
137 1 }
138
139 2 bool CurveFunctionalPressureDrop_Impl::setFixedFrictionFactor(boost::optional<double> fixedFrictionFactor) {
140 2 bool result = false;
141
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (fixedFrictionFactor) {
142 2 result = setDouble(OS_Curve_Functional_PressureDropFields::FixedFrictionFactor, fixedFrictionFactor.get());
143 } else {
144 ✗ result = setString(OS_Curve_Functional_PressureDropFields::FixedFrictionFactor, "");
145 }
146 2 return result;
147 }
148
149 1 void CurveFunctionalPressureDrop_Impl::resetFixedFrictionFactor() {
150
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_Curve_Functional_PressureDropFields::FixedFrictionFactor, "");
151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
152 1 }
153
154 } // namespace detail
155
156 1 CurveFunctionalPressureDrop::CurveFunctionalPressureDrop(const Model& model) : Curve(CurveFunctionalPressureDrop::iddObjectType(), model) {
157
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 5 not taken.
1 OS_ASSERT(getImpl<detail::CurveFunctionalPressureDrop_Impl>());
158
1/1
✓ Branch 1 taken 1 time.
1 setDouble(OS_Curve_Functional_PressureDropFields::Diameter, 0.05);
159 1 }
160
161 7601 IddObjectType CurveFunctionalPressureDrop::iddObjectType() {
162
1/1
✓ Branch 1 taken 7601 times.
7601 IddObjectType result(IddObjectType::OS_Curve_Functional_PressureDrop);
163 7601 return result;
164 }
165
166 2 double CurveFunctionalPressureDrop::diameter() const {
167
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::CurveFunctionalPressureDrop_Impl>()->diameter();
168 }
169
170 5 boost::optional<double> CurveFunctionalPressureDrop::minorLossCoefficient() const {
171
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::CurveFunctionalPressureDrop_Impl>()->minorLossCoefficient();
172 }
173
174 5 boost::optional<double> CurveFunctionalPressureDrop::length() const {
175
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::CurveFunctionalPressureDrop_Impl>()->length();
176 }
177
178 5 boost::optional<double> CurveFunctionalPressureDrop::roughness() const {
179
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::CurveFunctionalPressureDrop_Impl>()->roughness();
180 }
181
182 5 boost::optional<double> CurveFunctionalPressureDrop::fixedFrictionFactor() const {
183
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::CurveFunctionalPressureDrop_Impl>()->fixedFrictionFactor();
184 }
185
186 2 bool CurveFunctionalPressureDrop::setDiameter(double diameter) {
187
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::CurveFunctionalPressureDrop_Impl>()->setDiameter(diameter);
188 }
189
190 2 bool CurveFunctionalPressureDrop::setMinorLossCoefficient(double minorLossCoefficient) {
191
2/2
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
2 return getImpl<detail::CurveFunctionalPressureDrop_Impl>()->setMinorLossCoefficient(minorLossCoefficient);
192 }
193
194 1 void CurveFunctionalPressureDrop::resetMinorLossCoefficient() {
195
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::CurveFunctionalPressureDrop_Impl>()->resetMinorLossCoefficient();
196 1 }
197
198 2 bool CurveFunctionalPressureDrop::setLength(double length) {
199
2/2
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
2 return getImpl<detail::CurveFunctionalPressureDrop_Impl>()->setLength(length);
200 }
201
202 1 void CurveFunctionalPressureDrop::resetLength() {
203
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::CurveFunctionalPressureDrop_Impl>()->resetLength();
204 1 }
205
206 2 bool CurveFunctionalPressureDrop::setRoughness(double roughness) {
207
2/2
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
2 return getImpl<detail::CurveFunctionalPressureDrop_Impl>()->setRoughness(roughness);
208 }
209
210 1 void CurveFunctionalPressureDrop::resetRoughness() {
211
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::CurveFunctionalPressureDrop_Impl>()->resetRoughness();
212 1 }
213
214 2 bool CurveFunctionalPressureDrop::setFixedFrictionFactor(double fixedFrictionFactor) {
215
2/2
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 2 times.
2 return getImpl<detail::CurveFunctionalPressureDrop_Impl>()->setFixedFrictionFactor(fixedFrictionFactor);
216 }
217
218 1 void CurveFunctionalPressureDrop::resetFixedFrictionFactor() {
219
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::CurveFunctionalPressureDrop_Impl>()->resetFixedFrictionFactor();
220 1 }
221
222 /// @cond
223 ✗ CurveFunctionalPressureDrop::CurveFunctionalPressureDrop(std::shared_ptr<detail::CurveFunctionalPressureDrop_Impl> impl) : Curve(std::move(impl)) {}
224 /// @endcond
225
226 } // namespace model
227 } // namespace openstudio
228