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/CurveRectangularHyperbola1.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 "CurveRectangularHyperbola1.hpp"
7 #include "CurveRectangularHyperbola1_Impl.hpp"
8
9 #include <utilities/idd/IddFactory.hxx>
10
11 #include <utilities/idd/OS_Curve_RectangularHyperbola1_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 9 CurveRectangularHyperbola1_Impl::CurveRectangularHyperbola1_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
26 9 : Curve_Impl(idfObject, model, keepHandle) {
27
4/6
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 9 times.
✗ Branch 13 not taken.
9 OS_ASSERT(idfObject.iddObject().type() == CurveRectangularHyperbola1::iddObjectType());
28 9 }
29
30 ✗ CurveRectangularHyperbola1_Impl::CurveRectangularHyperbola1_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() == CurveRectangularHyperbola1::iddObjectType());
34 ✗ }
35
36 2 CurveRectangularHyperbola1_Impl::CurveRectangularHyperbola1_Impl(const CurveRectangularHyperbola1_Impl& other, Model_Impl* model, bool keepHandle)
37 2 : Curve_Impl(other, model, keepHandle) {}
38
39 ✗ const std::vector<std::string>& CurveRectangularHyperbola1_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 CurveRectangularHyperbola1_Impl::iddObjectType() const {
45 ✗ return CurveRectangularHyperbola1::iddObjectType();
46 }
47
48 ✗ int CurveRectangularHyperbola1_Impl::numVariables() const {
49 ✗ return 1;
50 }
51
52 8 double CurveRectangularHyperbola1_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();
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 12 double CurveRectangularHyperbola1_Impl::coefficient1C1() const {
90
1/1
✓ Branch 1 taken 12 times.
12 boost::optional<double> value = getDouble(OS_Curve_RectangularHyperbola1Fields::Coefficient1C1, true);
91
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 4 not taken.
12 OS_ASSERT(value);
92
1/1
✓ Branch 1 taken 12 times.
24 return value.get();
93 }
94
95 12 double CurveRectangularHyperbola1_Impl::coefficient2C2() const {
96
1/1
✓ Branch 1 taken 12 times.
12 boost::optional<double> value = getDouble(OS_Curve_RectangularHyperbola1Fields::Coefficient2C2, true);
97
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 4 not taken.
12 OS_ASSERT(value);
98
1/1
✓ Branch 1 taken 12 times.
24 return value.get();
99 }
100
101 12 double CurveRectangularHyperbola1_Impl::coefficient3C3() const {
102
1/1
✓ Branch 1 taken 12 times.
12 boost::optional<double> value = getDouble(OS_Curve_RectangularHyperbola1Fields::Coefficient3C3, true);
103
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 4 not taken.
12 OS_ASSERT(value);
104
1/1
✓ Branch 1 taken 12 times.
24 return value.get();
105 }
106
107 14 double CurveRectangularHyperbola1_Impl::minimumValueofx() const {
108
1/1
✓ Branch 1 taken 14 times.
14 boost::optional<double> value = getDouble(OS_Curve_RectangularHyperbola1Fields::MinimumValueofx, true);
109
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 4 not taken.
14 OS_ASSERT(value);
110
1/1
✓ Branch 1 taken 14 times.
28 return value.get();
111 }
112
113 14 double CurveRectangularHyperbola1_Impl::maximumValueofx() const {
114
1/1
✓ Branch 1 taken 14 times.
14 boost::optional<double> value = getDouble(OS_Curve_RectangularHyperbola1Fields::MaximumValueofx, true);
115
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 4 not taken.
14 OS_ASSERT(value);
116
1/1
✓ Branch 1 taken 14 times.
28 return value.get();
117 }
118
119 13 boost::optional<double> CurveRectangularHyperbola1_Impl::minimumCurveOutput() const {
120 13 return getDouble(OS_Curve_RectangularHyperbola1Fields::MinimumCurveOutput, true);
121 }
122
123 13 boost::optional<double> CurveRectangularHyperbola1_Impl::maximumCurveOutput() const {
124 13 return getDouble(OS_Curve_RectangularHyperbola1Fields::MaximumCurveOutput, true);
125 }
126
127 ✗ std::string CurveRectangularHyperbola1_Impl::inputUnitTypeforx() const {
128 ✗ boost::optional<std::string> value = getString(OS_Curve_RectangularHyperbola1Fields::InputUnitTypeforx, true);
129 ✗ OS_ASSERT(value);
130 ✗ return value.get();
131 ✗ }
132
133 2 bool CurveRectangularHyperbola1_Impl::isInputUnitTypeforxDefaulted() const {
134 2 return isEmpty(OS_Curve_RectangularHyperbola1Fields::InputUnitTypeforx);
135 }
136
137 ✗ std::string CurveRectangularHyperbola1_Impl::outputUnitType() const {
138 ✗ boost::optional<std::string> value = getString(OS_Curve_RectangularHyperbola1Fields::OutputUnitType, true);
139 ✗ OS_ASSERT(value);
140 ✗ return value.get();
141 ✗ }
142
143 2 bool CurveRectangularHyperbola1_Impl::isOutputUnitTypeDefaulted() const {
144 2 return isEmpty(OS_Curve_RectangularHyperbola1Fields::OutputUnitType);
145 }
146
147 6 bool CurveRectangularHyperbola1_Impl::setCoefficient1C1(double coefficient1C1) {
148 6 bool result = setDouble(OS_Curve_RectangularHyperbola1Fields::Coefficient1C1, coefficient1C1);
149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 OS_ASSERT(result);
150 6 return result;
151 }
152
153 6 bool CurveRectangularHyperbola1_Impl::setCoefficient2C2(double coefficient2C2) {
154 6 bool result = setDouble(OS_Curve_RectangularHyperbola1Fields::Coefficient2C2, coefficient2C2);
155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 OS_ASSERT(result);
156 6 return result;
157 }
158
159 6 bool CurveRectangularHyperbola1_Impl::setCoefficient3C3(double coefficient3C3) {
160 6 bool result = setDouble(OS_Curve_RectangularHyperbola1Fields::Coefficient3C3, coefficient3C3);
161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 OS_ASSERT(result);
162 6 return result;
163 }
164
165 6 bool CurveRectangularHyperbola1_Impl::setMinimumValueofx(double minimumValueofx) {
166 6 bool result = setDouble(OS_Curve_RectangularHyperbola1Fields::MinimumValueofx, minimumValueofx);
167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 OS_ASSERT(result);
168 6 return result;
169 }
170
171 6 bool CurveRectangularHyperbola1_Impl::setMaximumValueofx(double maximumValueofx) {
172 6 bool result = setDouble(OS_Curve_RectangularHyperbola1Fields::MaximumValueofx, maximumValueofx);
173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 OS_ASSERT(result);
174 6 return result;
175 }
176
177 6 bool CurveRectangularHyperbola1_Impl::setMinimumCurveOutput(boost::optional<double> minimumCurveOutput) {
178 6 bool result = false;
179
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (minimumCurveOutput) {
180 6 result = setDouble(OS_Curve_RectangularHyperbola1Fields::MinimumCurveOutput, minimumCurveOutput.get());
181 } else {
182 ✗ result = setString(OS_Curve_RectangularHyperbola1Fields::MinimumCurveOutput, "");
183 }
184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 OS_ASSERT(result);
185 6 return result;
186 }
187
188 ✗ void CurveRectangularHyperbola1_Impl::resetMinimumCurveOutput() {
189 ✗ bool result = setString(OS_Curve_RectangularHyperbola1Fields::MinimumCurveOutput, "");
190 ✗ OS_ASSERT(result);
191 ✗ }
192
193 6 bool CurveRectangularHyperbola1_Impl::setMaximumCurveOutput(boost::optional<double> maximumCurveOutput) {
194 6 bool result = false;
195
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (maximumCurveOutput) {
196 6 result = setDouble(OS_Curve_RectangularHyperbola1Fields::MaximumCurveOutput, maximumCurveOutput.get());
197 } else {
198 ✗ result = setString(OS_Curve_RectangularHyperbola1Fields::MaximumCurveOutput, "");
199 }
200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 OS_ASSERT(result);
201 6 return result;
202 }
203
204 ✗ void CurveRectangularHyperbola1_Impl::resetMaximumCurveOutput() {
205 ✗ bool result = setString(OS_Curve_RectangularHyperbola1Fields::MaximumCurveOutput, "");
206 ✗ OS_ASSERT(result);
207 ✗ }
208
209 ✗ bool CurveRectangularHyperbola1_Impl::setInputUnitTypeforx(const std::string& inputUnitTypeforx) {
210 ✗ bool result = setString(OS_Curve_RectangularHyperbola1Fields::InputUnitTypeforx, inputUnitTypeforx);
211 ✗ return result;
212 }
213
214 ✗ void CurveRectangularHyperbola1_Impl::resetInputUnitTypeforx() {
215 ✗ bool result = setString(OS_Curve_RectangularHyperbola1Fields::InputUnitTypeforx, "");
216 ✗ OS_ASSERT(result);
217 ✗ }
218
219 ✗ bool CurveRectangularHyperbola1_Impl::setOutputUnitType(const std::string& outputUnitType) {
220 ✗ bool result = setString(OS_Curve_RectangularHyperbola1Fields::OutputUnitType, outputUnitType);
221 ✗ return result;
222 }
223
224 ✗ void CurveRectangularHyperbola1_Impl::resetOutputUnitType() {
225 ✗ bool result = setString(OS_Curve_RectangularHyperbola1Fields::OutputUnitType, "");
226 ✗ OS_ASSERT(result);
227 ✗ }
228
229 } // namespace detail
230
231 9 CurveRectangularHyperbola1::CurveRectangularHyperbola1(const Model& model) : Curve(CurveRectangularHyperbola1::iddObjectType(), model) {
232
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 5 not taken.
9 OS_ASSERT(getImpl<detail::CurveRectangularHyperbola1_Impl>());
233
1/1
✓ Branch 1 taken 9 times.
9 setDouble(OS_Curve_RectangularHyperbola1Fields::Coefficient1C1, 1.0);
234
1/1
✓ Branch 1 taken 9 times.
9 setDouble(OS_Curve_RectangularHyperbola1Fields::Coefficient2C2, 1.0);
235
1/1
✓ Branch 1 taken 9 times.
9 setDouble(OS_Curve_RectangularHyperbola1Fields::Coefficient3C3, 0.0);
236
1/1
✓ Branch 1 taken 9 times.
9 setDouble(OS_Curve_RectangularHyperbola1Fields::MinimumValueofx, 0.0);
237
1/1
✓ Branch 1 taken 9 times.
9 setDouble(OS_Curve_RectangularHyperbola1Fields::MaximumValueofx, 1.0);
238 9 }
239
240 7747 IddObjectType CurveRectangularHyperbola1::iddObjectType() {
241
1/1
✓ Branch 1 taken 7747 times.
7747 IddObjectType result(IddObjectType::OS_Curve_RectangularHyperbola1);
242 7747 return result;
243 }
244
245 ✗ std::vector<std::string> CurveRectangularHyperbola1::validInputUnitTypeforxValues() {
246 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_Curve_RectangularHyperbola1Fields::InputUnitTypeforx);
247 }
248
249 ✗ std::vector<std::string> CurveRectangularHyperbola1::validOutputUnitTypeValues() {
250 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_Curve_RectangularHyperbola1Fields::OutputUnitType);
251 }
252
253 4 double CurveRectangularHyperbola1::coefficient1C1() const {
254
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->coefficient1C1();
255 }
256
257 4 double CurveRectangularHyperbola1::coefficient2C2() const {
258
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->coefficient2C2();
259 }
260
261 4 double CurveRectangularHyperbola1::coefficient3C3() const {
262
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->coefficient3C3();
263 }
264
265 4 double CurveRectangularHyperbola1::minimumValueofx() const {
266
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->minimumValueofx();
267 }
268
269 4 double CurveRectangularHyperbola1::maximumValueofx() const {
270
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->maximumValueofx();
271 }
272
273 5 boost::optional<double> CurveRectangularHyperbola1::minimumCurveOutput() const {
274
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->minimumCurveOutput();
275 }
276
277 5 boost::optional<double> CurveRectangularHyperbola1::maximumCurveOutput() const {
278
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->maximumCurveOutput();
279 }
280
281 ✗ std::string CurveRectangularHyperbola1::inputUnitTypeforx() const {
282 ✗ return getImpl<detail::CurveRectangularHyperbola1_Impl>()->inputUnitTypeforx();
283 }
284
285 2 bool CurveRectangularHyperbola1::isInputUnitTypeforxDefaulted() const {
286
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->isInputUnitTypeforxDefaulted();
287 }
288
289 ✗ std::string CurveRectangularHyperbola1::outputUnitType() const {
290 ✗ return getImpl<detail::CurveRectangularHyperbola1_Impl>()->outputUnitType();
291 }
292
293 2 bool CurveRectangularHyperbola1::isOutputUnitTypeDefaulted() const {
294
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->isOutputUnitTypeDefaulted();
295 }
296
297 6 bool CurveRectangularHyperbola1::setCoefficient1C1(double coefficient1C1) {
298
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->setCoefficient1C1(coefficient1C1);
299 }
300
301 6 bool CurveRectangularHyperbola1::setCoefficient2C2(double coefficient2C2) {
302
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->setCoefficient2C2(coefficient2C2);
303 }
304
305 6 bool CurveRectangularHyperbola1::setCoefficient3C3(double coefficient3C3) {
306
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->setCoefficient3C3(coefficient3C3);
307 }
308
309 6 bool CurveRectangularHyperbola1::setMinimumValueofx(double minimumValueofx) {
310
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->setMinimumValueofx(minimumValueofx);
311 }
312
313 6 bool CurveRectangularHyperbola1::setMaximumValueofx(double maximumValueofx) {
314
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->setMaximumValueofx(maximumValueofx);
315 }
316
317 6 bool CurveRectangularHyperbola1::setMinimumCurveOutput(double minimumCurveOutput) {
318
2/2
✓ Branch 3 taken 6 times.
✓ Branch 6 taken 6 times.
6 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->setMinimumCurveOutput(minimumCurveOutput);
319 }
320
321 ✗ void CurveRectangularHyperbola1::resetMinimumCurveOutput() {
322 ✗ getImpl<detail::CurveRectangularHyperbola1_Impl>()->resetMinimumCurveOutput();
323 ✗ }
324
325 6 bool CurveRectangularHyperbola1::setMaximumCurveOutput(double maximumCurveOutput) {
326
2/2
✓ Branch 3 taken 6 times.
✓ Branch 6 taken 6 times.
6 return getImpl<detail::CurveRectangularHyperbola1_Impl>()->setMaximumCurveOutput(maximumCurveOutput);
327 }
328
329 ✗ void CurveRectangularHyperbola1::resetMaximumCurveOutput() {
330 ✗ getImpl<detail::CurveRectangularHyperbola1_Impl>()->resetMaximumCurveOutput();
331 ✗ }
332
333 ✗ bool CurveRectangularHyperbola1::setInputUnitTypeforx(const std::string& inputUnitTypeforx) {
334 ✗ return getImpl<detail::CurveRectangularHyperbola1_Impl>()->setInputUnitTypeforx(inputUnitTypeforx);
335 }
336
337 ✗ void CurveRectangularHyperbola1::resetInputUnitTypeforx() {
338 ✗ getImpl<detail::CurveRectangularHyperbola1_Impl>()->resetInputUnitTypeforx();
339 ✗ }
340
341 ✗ bool CurveRectangularHyperbola1::setOutputUnitType(const std::string& outputUnitType) {
342 ✗ return getImpl<detail::CurveRectangularHyperbola1_Impl>()->setOutputUnitType(outputUnitType);
343 }
344
345 ✗ void CurveRectangularHyperbola1::resetOutputUnitType() {
346 ✗ getImpl<detail::CurveRectangularHyperbola1_Impl>()->resetOutputUnitType();
347 ✗ }
348
349 /// @cond
350
1/1
✓ Branch 3 taken 2 times.
2 CurveRectangularHyperbola1::CurveRectangularHyperbola1(std::shared_ptr<detail::CurveRectangularHyperbola1_Impl> impl) : Curve(std::move(impl)) {}
351 /// @endcond
352
353 } // namespace model
354 } // namespace openstudio
355