GCC Code Coverage Report


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

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