GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 65.4% 134 / 0 / 205
Functions: 63.3% 38 / 0 / 60
Branches: 50.0% 91 / 0 / 182

src/model/CurveRectangularHyperbola2.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 "CurveRectangularHyperbola2.hpp"
7 #include "CurveRectangularHyperbola2_Impl.hpp"
8
9 #include <utilities/idd/IddFactory.hxx>
10
11 #include <utilities/idd/OS_Curve_RectangularHyperbola2_FieldEnums.hxx>
12 #include <utilities/idd/IddEnums.hxx>
13
14 #include "../utilities/core/Assert.hpp"
15
16 #include <cmath>
17
18 using namespace std;
19
20 namespace openstudio {
21 namespace model {
22
23 namespace detail {
24
25 30 CurveRectangularHyperbola2_Impl::CurveRectangularHyperbola2_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
26 30 : Curve_Impl(idfObject, model, keepHandle) {
27
4/6
✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
✓ Branch 7 taken 30 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 30 times.
✗ Branch 13 not taken.
30 OS_ASSERT(idfObject.iddObject().type() == CurveRectangularHyperbola2::iddObjectType());
28 30 }
29
30 ✗ CurveRectangularHyperbola2_Impl::CurveRectangularHyperbola2_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model,
31 ✗ bool keepHandle)
32 ✗ : Curve_Impl(other, model, keepHandle) {
33 ✗ OS_ASSERT(other.iddObject().type() == CurveRectangularHyperbola2::iddObjectType());
34 ✗ }
35
36 8 CurveRectangularHyperbola2_Impl::CurveRectangularHyperbola2_Impl(const CurveRectangularHyperbola2_Impl& other, Model_Impl* model, bool keepHandle)
37 8 : Curve_Impl(other, model, keepHandle) {}
38
39 ✗ const std::vector<std::string>& CurveRectangularHyperbola2_Impl::outputVariableNames() const {
40 ✗ static const std::vector<std::string> result{"Performance Curve Output Value", "Performance Curve Input Variable 1 Value"};
41 ✗ return result;
42 ✗ }
43
44 ✗ IddObjectType CurveRectangularHyperbola2_Impl::iddObjectType() const {
45 ✗ return CurveRectangularHyperbola2::iddObjectType();
46 }
47
48 ✗ int CurveRectangularHyperbola2_Impl::numVariables() const {
49 ✗ return 1;
50 }
51
52 8 double CurveRectangularHyperbola2_Impl::evaluate(const std::vector<double>& independentVariables) const {
53
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
8 OS_ASSERT(independentVariables.size() == 1u);
54
55 8 double x = independentVariables[0];
56
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 6 times.
8 if (x < minimumValueofx()) {
57
5/5
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
2 LOG(Warn, "Supplied x is below the minimumValueofx, resetting it.");
58 2 x = minimumValueofx();
59 }
60
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 6 times.
8 if (x > maximumValueofx()) {
61
5/5
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
2 LOG(Warn, "Supplied x is above the maximumValueofx, resetting it.");
62 2 x = maximumValueofx();
63 }
64
65 8 double result = coefficient1C1() * x;
66 8 double temp = coefficient2C2() + x;
67 8 result /= temp;
68 8 result += coefficient3C3() * x;
69
70
3/3
✓ Branch 1 taken 8 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 6 times.
16 if (boost::optional<double> _minVal = minimumCurveOutput()) {
71
1/1
✓ Branch 1 taken 2 times.
2 double minVal = _minVal.get();
72
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 if (result < minVal) {
73
5/5
✓ 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.
1 LOG(Warn, "Calculated curve output is below minimumCurveOutput, resetting it.");
74 1 result = minVal;
75 }
76 }
77
78
3/3
✓ Branch 1 taken 8 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 6 times.
16 if (boost::optional<double> _maxVal = maximumCurveOutput()) {
79
1/1
✓ Branch 1 taken 2 times.
2 double maxVal = _maxVal.get();
80
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 if (result > maxVal) {
81
5/5
✓ 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.
1 LOG(Warn, "Calculated curve output is above maximumCurveOutput, resetting it.");
82 1 result = maxVal;
83 }
84 }
85
86 8 return result;
87 }
88
89 18 double CurveRectangularHyperbola2_Impl::coefficient1C1() const {
90
1/1
✓ Branch 1 taken 18 times.
18 boost::optional<double> value = getDouble(OS_Curve_RectangularHyperbola2Fields::Coefficient1C1, true);
91
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 4 not taken.
18 OS_ASSERT(value);
92
1/1
✓ Branch 1 taken 18 times.
36 return value.get();
93 }
94
95 18 double CurveRectangularHyperbola2_Impl::coefficient2C2() const {
96
1/1
✓ Branch 1 taken 18 times.
18 boost::optional<double> value = getDouble(OS_Curve_RectangularHyperbola2Fields::Coefficient2C2, true);
97
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 4 not taken.
18 OS_ASSERT(value);
98
1/1
✓ Branch 1 taken 18 times.
36 return value.get();
99 }
100
101 18 double CurveRectangularHyperbola2_Impl::coefficient3C3() const {
102
1/1
✓ Branch 1 taken 18 times.
18 boost::optional<double> value = getDouble(OS_Curve_RectangularHyperbola2Fields::Coefficient3C3, true);
103
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 4 not taken.
18 OS_ASSERT(value);
104
1/1
✓ Branch 1 taken 18 times.
36 return value.get();
105 }
106
107 20 double CurveRectangularHyperbola2_Impl::minimumValueofx() const {
108
1/1
✓ Branch 1 taken 20 times.
20 boost::optional<double> value = getDouble(OS_Curve_RectangularHyperbola2Fields::MinimumValueofx, true);
109
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 4 not taken.
20 OS_ASSERT(value);
110
1/1
✓ Branch 1 taken 20 times.
40 return value.get();
111 }
112
113 20 double CurveRectangularHyperbola2_Impl::maximumValueofx() const {
114
1/1
✓ Branch 1 taken 20 times.
20 boost::optional<double> value = getDouble(OS_Curve_RectangularHyperbola2Fields::MaximumValueofx, true);
115
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 4 not taken.
20 OS_ASSERT(value);
116
1/1
✓ Branch 1 taken 20 times.
40 return value.get();
117 }
118
119 19 boost::optional<double> CurveRectangularHyperbola2_Impl::minimumCurveOutput() const {
120 19 return getDouble(OS_Curve_RectangularHyperbola2Fields::MinimumCurveOutput, true);
121 }
122
123 19 boost::optional<double> CurveRectangularHyperbola2_Impl::maximumCurveOutput() const {
124 19 return getDouble(OS_Curve_RectangularHyperbola2Fields::MaximumCurveOutput, true);
125 }
126
127 ✗ std::string CurveRectangularHyperbola2_Impl::inputUnitTypeforx() const {
128 ✗ boost::optional<std::string> value = getString(OS_Curve_RectangularHyperbola2Fields::InputUnitTypeforx, true);
129 ✗ OS_ASSERT(value);
130 ✗ return value.get();
131 ✗ }
132
133 8 bool CurveRectangularHyperbola2_Impl::isInputUnitTypeforxDefaulted() const {
134 8 return isEmpty(OS_Curve_RectangularHyperbola2Fields::InputUnitTypeforx);
135 }
136
137 ✗ std::string CurveRectangularHyperbola2_Impl::outputUnitType() const {
138 ✗ boost::optional<std::string> value = getString(OS_Curve_RectangularHyperbola2Fields::OutputUnitType, true);
139 ✗ OS_ASSERT(value);
140 ✗ return value.get();
141 ✗ }
142
143 8 bool CurveRectangularHyperbola2_Impl::isOutputUnitTypeDefaulted() const {
144 8 return isEmpty(OS_Curve_RectangularHyperbola2Fields::OutputUnitType);
145 }
146
147 21 bool CurveRectangularHyperbola2_Impl::setCoefficient1C1(double coefficient1C1) {
148 21 bool result = setDouble(OS_Curve_RectangularHyperbola2Fields::Coefficient1C1, coefficient1C1);
149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 OS_ASSERT(result);
150 21 return result;
151 }
152
153 21 bool CurveRectangularHyperbola2_Impl::setCoefficient2C2(double coefficient2C2) {
154 21 bool result = setDouble(OS_Curve_RectangularHyperbola2Fields::Coefficient2C2, coefficient2C2);
155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 OS_ASSERT(result);
156 21 return result;
157 }
158
159 21 bool CurveRectangularHyperbola2_Impl::setCoefficient3C3(double coefficient3C3) {
160 21 bool result = setDouble(OS_Curve_RectangularHyperbola2Fields::Coefficient3C3, coefficient3C3);
161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 OS_ASSERT(result);
162 21 return result;
163 }
164
165 21 bool CurveRectangularHyperbola2_Impl::setMinimumValueofx(double minimumValueofx) {
166 21 bool result = setDouble(OS_Curve_RectangularHyperbola2Fields::MinimumValueofx, minimumValueofx);
167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 OS_ASSERT(result);
168 21 return result;
169 }
170
171 21 bool CurveRectangularHyperbola2_Impl::setMaximumValueofx(double maximumValueofx) {
172 21 bool result = setDouble(OS_Curve_RectangularHyperbola2Fields::MaximumValueofx, maximumValueofx);
173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 OS_ASSERT(result);
174 21 return result;
175 }
176
177 21 bool CurveRectangularHyperbola2_Impl::setMinimumCurveOutput(boost::optional<double> minimumCurveOutput) {
178 21 bool result = false;
179
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if (minimumCurveOutput) {
180 21 result = setDouble(OS_Curve_RectangularHyperbola2Fields::MinimumCurveOutput, minimumCurveOutput.get());
181 } else {
182 ✗ result = setString(OS_Curve_RectangularHyperbola2Fields::MinimumCurveOutput, "");
183 }
184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 OS_ASSERT(result);
185 21 return result;
186 }
187
188 ✗ void CurveRectangularHyperbola2_Impl::resetMinimumCurveOutput() {
189 ✗ bool result = setString(OS_Curve_RectangularHyperbola2Fields::MinimumCurveOutput, "");
190 ✗ OS_ASSERT(result);
191 ✗ }
192
193 21 bool CurveRectangularHyperbola2_Impl::setMaximumCurveOutput(boost::optional<double> maximumCurveOutput) {
194 21 bool result = false;
195
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if (maximumCurveOutput) {
196 21 result = setDouble(OS_Curve_RectangularHyperbola2Fields::MaximumCurveOutput, maximumCurveOutput.get());
197 } else {
198 ✗ result = setString(OS_Curve_RectangularHyperbola2Fields::MaximumCurveOutput, "");
199 }
200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 OS_ASSERT(result);
201 21 return result;
202 }
203
204 ✗ void CurveRectangularHyperbola2_Impl::resetMaximumCurveOutput() {
205 ✗ bool result = setString(OS_Curve_RectangularHyperbola2Fields::MaximumCurveOutput, "");
206 ✗ OS_ASSERT(result);
207 ✗ }
208
209 ✗ bool CurveRectangularHyperbola2_Impl::setInputUnitTypeforx(const std::string& inputUnitTypeforx) {
210 ✗ bool result = setString(OS_Curve_RectangularHyperbola2Fields::InputUnitTypeforx, inputUnitTypeforx);
211 ✗ return result;
212 }
213
214 ✗ void CurveRectangularHyperbola2_Impl::resetInputUnitTypeforx() {
215 ✗ bool result = setString(OS_Curve_RectangularHyperbola2Fields::InputUnitTypeforx, "");
216 ✗ OS_ASSERT(result);
217 ✗ }
218
219 ✗ bool CurveRectangularHyperbola2_Impl::setOutputUnitType(const std::string& outputUnitType) {
220 ✗ bool result = setString(OS_Curve_RectangularHyperbola2Fields::OutputUnitType, outputUnitType);
221 ✗ return result;
222 }
223
224 ✗ void CurveRectangularHyperbola2_Impl::resetOutputUnitType() {
225 ✗ bool result = setString(OS_Curve_RectangularHyperbola2Fields::OutputUnitType, "");
226 ✗ OS_ASSERT(result);
227 ✗ }
228
229 } // namespace detail
230
231 30 CurveRectangularHyperbola2::CurveRectangularHyperbola2(const Model& model) : Curve(CurveRectangularHyperbola2::iddObjectType(), model) {
232
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 5 not taken.
30 OS_ASSERT(getImpl<detail::CurveRectangularHyperbola2_Impl>());
233
1/1
✓ Branch 1 taken 30 times.
30 setDouble(OS_Curve_RectangularHyperbola2Fields::Coefficient1C1, 1.0);
234
1/1
✓ Branch 1 taken 30 times.
30 setDouble(OS_Curve_RectangularHyperbola2Fields::Coefficient2C2, 1.0);
235
1/1
✓ Branch 1 taken 30 times.
30 setDouble(OS_Curve_RectangularHyperbola2Fields::Coefficient3C3, 1.0);
236
1/1
✓ Branch 1 taken 30 times.
30 setDouble(OS_Curve_RectangularHyperbola2Fields::MinimumValueofx, 0.0);
237
1/1
✓ Branch 1 taken 30 times.
30 setDouble(OS_Curve_RectangularHyperbola2Fields::MaximumValueofx, 1.0);
238 30 }
239
240 7789 IddObjectType CurveRectangularHyperbola2::iddObjectType() {
241
1/1
✓ Branch 1 taken 7789 times.
7789 IddObjectType result(IddObjectType::OS_Curve_RectangularHyperbola2);
242 7789 return result;
243 }
244
245 ✗ std::vector<std::string> CurveRectangularHyperbola2::validInputUnitTypeforxValues() {
246 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_Curve_RectangularHyperbola2Fields::InputUnitTypeforx);
247 }
248
249 ✗ std::vector<std::string> CurveRectangularHyperbola2::validOutputUnitTypeValues() {
250 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_Curve_RectangularHyperbola2Fields::OutputUnitType);
251 }
252
253 10 double CurveRectangularHyperbola2::coefficient1C1() const {
254
1/1
✓ Branch 3 taken 10 times.
10 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->coefficient1C1();
255 }
256
257 10 double CurveRectangularHyperbola2::coefficient2C2() const {
258
1/1
✓ Branch 3 taken 10 times.
10 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->coefficient2C2();
259 }
260
261 10 double CurveRectangularHyperbola2::coefficient3C3() const {
262
1/1
✓ Branch 3 taken 10 times.
10 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->coefficient3C3();
263 }
264
265 10 double CurveRectangularHyperbola2::minimumValueofx() const {
266
1/1
✓ Branch 3 taken 10 times.
10 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->minimumValueofx();
267 }
268
269 10 double CurveRectangularHyperbola2::maximumValueofx() const {
270
1/1
✓ Branch 3 taken 10 times.
10 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->maximumValueofx();
271 }
272
273 11 boost::optional<double> CurveRectangularHyperbola2::minimumCurveOutput() const {
274
1/1
✓ Branch 3 taken 11 times.
11 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->minimumCurveOutput();
275 }
276
277 11 boost::optional<double> CurveRectangularHyperbola2::maximumCurveOutput() const {
278
1/1
✓ Branch 3 taken 11 times.
11 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->maximumCurveOutput();
279 }
280
281 ✗ std::string CurveRectangularHyperbola2::inputUnitTypeforx() const {
282 ✗ return getImpl<detail::CurveRectangularHyperbola2_Impl>()->inputUnitTypeforx();
283 }
284
285 8 bool CurveRectangularHyperbola2::isInputUnitTypeforxDefaulted() const {
286
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->isInputUnitTypeforxDefaulted();
287 }
288
289 ✗ std::string CurveRectangularHyperbola2::outputUnitType() const {
290 ✗ return getImpl<detail::CurveRectangularHyperbola2_Impl>()->outputUnitType();
291 }
292
293 8 bool CurveRectangularHyperbola2::isOutputUnitTypeDefaulted() const {
294
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->isOutputUnitTypeDefaulted();
295 }
296
297 21 bool CurveRectangularHyperbola2::setCoefficient1C1(double coefficient1C1) {
298
1/1
✓ Branch 3 taken 21 times.
21 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->setCoefficient1C1(coefficient1C1);
299 }
300
301 21 bool CurveRectangularHyperbola2::setCoefficient2C2(double coefficient2C2) {
302
1/1
✓ Branch 3 taken 21 times.
21 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->setCoefficient2C2(coefficient2C2);
303 }
304
305 21 bool CurveRectangularHyperbola2::setCoefficient3C3(double coefficient3C3) {
306
1/1
✓ Branch 3 taken 21 times.
21 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->setCoefficient3C3(coefficient3C3);
307 }
308
309 21 bool CurveRectangularHyperbola2::setMinimumValueofx(double minimumValueofx) {
310
1/1
✓ Branch 3 taken 21 times.
21 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->setMinimumValueofx(minimumValueofx);
311 }
312
313 21 bool CurveRectangularHyperbola2::setMaximumValueofx(double maximumValueofx) {
314
1/1
✓ Branch 3 taken 21 times.
21 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->setMaximumValueofx(maximumValueofx);
315 }
316
317 21 bool CurveRectangularHyperbola2::setMinimumCurveOutput(double minimumCurveOutput) {
318
2/2
✓ Branch 3 taken 21 times.
✓ Branch 6 taken 21 times.
21 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->setMinimumCurveOutput(minimumCurveOutput);
319 }
320
321 ✗ void CurveRectangularHyperbola2::resetMinimumCurveOutput() {
322 ✗ getImpl<detail::CurveRectangularHyperbola2_Impl>()->resetMinimumCurveOutput();
323 ✗ }
324
325 21 bool CurveRectangularHyperbola2::setMaximumCurveOutput(double maximumCurveOutput) {
326
2/2
✓ Branch 3 taken 21 times.
✓ Branch 6 taken 21 times.
21 return getImpl<detail::CurveRectangularHyperbola2_Impl>()->setMaximumCurveOutput(maximumCurveOutput);
327 }
328
329 ✗ void CurveRectangularHyperbola2::resetMaximumCurveOutput() {
330 ✗ getImpl<detail::CurveRectangularHyperbola2_Impl>()->resetMaximumCurveOutput();
331 ✗ }
332
333 ✗ bool CurveRectangularHyperbola2::setInputUnitTypeforx(const std::string& inputUnitTypeforx) {
334 ✗ return getImpl<detail::CurveRectangularHyperbola2_Impl>()->setInputUnitTypeforx(inputUnitTypeforx);
335 }
336
337 ✗ void CurveRectangularHyperbola2::resetInputUnitTypeforx() {
338 ✗ getImpl<detail::CurveRectangularHyperbola2_Impl>()->resetInputUnitTypeforx();
339 ✗ }
340
341 ✗ bool CurveRectangularHyperbola2::setOutputUnitType(const std::string& outputUnitType) {
342 ✗ return getImpl<detail::CurveRectangularHyperbola2_Impl>()->setOutputUnitType(outputUnitType);
343 }
344
345 ✗ void CurveRectangularHyperbola2::resetOutputUnitType() {
346 ✗ getImpl<detail::CurveRectangularHyperbola2_Impl>()->resetOutputUnitType();
347 ✗ }
348
349 /// @cond
350
1/1
✓ Branch 3 taken 8 times.
8 CurveRectangularHyperbola2::CurveRectangularHyperbola2(std::shared_ptr<detail::CurveRectangularHyperbola2_Impl> impl) : Curve(std::move(impl)) {}
351 /// @endcond
352
353 } // namespace model
354 } // namespace openstudio
355