GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 82.1% 225 / 0 / 274
Functions: 93.8% 61 / 0 / 65
Branches: 58.3% 210 / 0 / 360

src/model/SurfacePropertySurroundingSurfaces.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 "SurfacePropertySurroundingSurfaces.hpp"
7 #include "SurfacePropertySurroundingSurfaces_Impl.hpp"
8
9 #include "Schedule.hpp"
10 #include "Schedule_Impl.hpp"
11 #include "ScheduleTypeLimits.hpp"
12 #include "ScheduleTypeRegistry.hpp"
13 #include "ModelExtensibleGroup.hpp"
14 #include "SurfacePropertyLocalEnvironment.hpp"
15 #include "SurfacePropertyLocalEnvironment_Impl.hpp"
16
17 #include "../utilities/core/Assert.hpp"
18 #include "../utilities/core/Compare.hpp"
19 #include "../utilities/units/Unit.hpp"
20
21 #include <utilities/idd/IddEnums.hxx>
22 #include <utilities/idd/OS_SurfaceProperty_SurroundingSurfaces_FieldEnums.hxx>
23
24 namespace openstudio {
25 namespace model {
26
27 /***************************************************************************************************************************************************
28 * S U R R O U N D I N G S U R F A C E G R O U P W R A P P E R *
29 **************************************************************************************************************************************************/
30
31 53 SurroundingSurfaceGroup::SurroundingSurfaceGroup(std::string surroundingSurfaceName, double viewFactor, const Schedule& temperatureSchedule)
32
1/1
✓ Branch 3 taken 53 times.
53 : m_surroundingSurfaceName(std::move(surroundingSurfaceName)), m_viewFactor(viewFactor), m_tempSch(temperatureSchedule) {
33
34 // Matches the maximum value in IDD
35
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 51 times.
53 if (m_viewFactor > 1) {
36
17/17
✓ 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.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 25 taken 2 times.
✓ Branch 28 taken 2 times.
✓ Branch 31 taken 2 times.
✓ Branch 34 taken 2 times.
✓ Branch 37 taken 2 times.
✓ Branch 40 taken 2 times.
✓ Branch 43 taken 2 times.
✓ Branch 46 taken 2 times.
✓ Branch 50 taken 2 times.
✓ Branch 53 taken 2 times.
2 LOG_AND_THROW("Unable to create SurroundingSurfaceGroup, View Factor of " << m_viewFactor << " cannot be more than 1.");
37
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 } else if (m_viewFactor < 0) {
38 ✗ LOG_AND_THROW("Unable to create SurroundingSurfaceGroup, View Factor of " << m_viewFactor << " cannot be less than 0.");
39 }
40
41
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
51 if (m_surroundingSurfaceName.empty()) {
42 ✗ LOG_AND_THROW("Unable to create SurroundingSurfaceGroup, SurroundingSurfaceName cannot be empty.");
43 }
44 55 }
45
46 84 std::string SurroundingSurfaceGroup::surroundingSurfaceName() const {
47 84 return m_surroundingSurfaceName;
48 }
49
50 62 double SurroundingSurfaceGroup::viewFactor() const {
51 62 return m_viewFactor;
52 }
53
54 62 Schedule SurroundingSurfaceGroup::temperatureSchedule() const {
55 62 return m_tempSch;
56 }
57
58 4 std::ostream& operator<<(std::ostream& out, const openstudio::model::SurroundingSurfaceGroup& surroundingSurfaceGroup) {
59
6/6
✓ Branch 2 taken 4 times.
✓ Branch 5 taken 4 times.
✓ Branch 8 taken 4 times.
✓ Branch 11 taken 4 times.
✓ Branch 14 taken 4 times.
✓ Branch 17 taken 4 times.
4 out << "(Surface = '" << surroundingSurfaceGroup.surroundingSurfaceName() << "', " << "View Factor = " << surroundingSurfaceGroup.viewFactor()
60
6/6
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
4 << ", " << "Schedule = '" << surroundingSurfaceGroup.temperatureSchedule().nameString() << "')";
61 4 return out;
62 }
63
64 namespace detail {
65
66 7 SurfacePropertySurroundingSurfaces_Impl::SurfacePropertySurroundingSurfaces_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
67 7 : ModelObject_Impl(idfObject, model, keepHandle) {
68
4/6
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 13 not taken.
7 OS_ASSERT(idfObject.iddObject().type() == SurfacePropertySurroundingSurfaces::iddObjectType());
69 7 }
70
71 ✗ SurfacePropertySurroundingSurfaces_Impl::SurfacePropertySurroundingSurfaces_Impl(const openstudio::detail::WorkspaceObject_Impl& other,
72 ✗ Model_Impl* model, bool keepHandle)
73 ✗ : ModelObject_Impl(other, model, keepHandle) {
74 ✗ OS_ASSERT(other.iddObject().type() == SurfacePropertySurroundingSurfaces::iddObjectType());
75 ✗ }
76
77 5 SurfacePropertySurroundingSurfaces_Impl::SurfacePropertySurroundingSurfaces_Impl(const SurfacePropertySurroundingSurfaces_Impl& other,
78 5 Model_Impl* model, bool keepHandle)
79 5 : ModelObject_Impl(other, model, keepHandle) {}
80
81 ✗ const std::vector<std::string>& SurfacePropertySurroundingSurfaces_Impl::outputVariableNames() const {
82 ✗ static std::vector<std::string> result;
83 ✗ if (result.empty()) {
84 }
85 ✗ return result;
86 }
87
88 ✗ IddObjectType SurfacePropertySurroundingSurfaces_Impl::iddObjectType() const {
89 ✗ return SurfacePropertySurroundingSurfaces::iddObjectType();
90 }
91
92 ✗ std::vector<ScheduleTypeKey> SurfacePropertySurroundingSurfaces_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
93 ✗ std::vector<ScheduleTypeKey> result;
94
95 {
96 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
97 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
98 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
99 ✗ if (std::find(b, e, OS_SurfaceProperty_SurroundingSurfacesFields::SkyTemperatureScheduleName) != e) {
100 ✗ result.emplace_back("SurfacePropertySurroundingSurfaces", "Sky Temperature");
101 }
102 ✗ if (std::find(b, e, OS_SurfaceProperty_SurroundingSurfacesFields::GroundTemperatureScheduleName) != e) {
103 ✗ result.emplace_back("SurfacePropertySurroundingSurfaces", "Ground Temperature");
104 }
105 ✗ }
106
107 {
108 // This is unusual, but there is also a schedule in the Extensible Fields
109 ✗ UnsignedVector fieldIndices;
110 ✗ for (const ModelExtensibleGroup& group : castVector<ModelExtensibleGroup>(extensibleGroups())) {
111 ✗ UnsignedVector thisFieldIndices = group.getSourceFieldIndices(schedule.handle());
112 ✗ fieldIndices.insert(fieldIndices.end(), thisFieldIndices.begin(), thisFieldIndices.end());
113 ✗ }
114
115 // Make unique, have to sort before calling unique, unique only works on consecutive elements
116 ✗ std::sort(fieldIndices.begin(), fieldIndices.end());
117 ✗ fieldIndices.erase(std::unique(fieldIndices.begin(), fieldIndices.end()), fieldIndices.end());
118
119 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
120 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
121 ✗ if (std::find(b, e, OS_SurfaceProperty_SurroundingSurfacesExtensibleFields::SurroundingSurfaceTemperatureScheduleName) != e) {
122 ✗ result.emplace_back("SurfacePropertySurroundingSurfaces", "Surrounding Surface Temperature Schedule");
123 }
124 ✗ }
125
126 ✗ return result;
127 ✗ }
128
129 11 boost::optional<double> SurfacePropertySurroundingSurfaces_Impl::skyViewFactor() const {
130 11 return getDouble(OS_SurfaceProperty_SurroundingSurfacesFields::SkyViewFactor, true);
131 }
132
133 3 bool SurfacePropertySurroundingSurfaces_Impl::isSkyViewFactorAutocalculated() const {
134 3 bool result = false;
135
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<std::string> value = getString(OS_SurfaceProperty_SurroundingSurfacesFields::SkyViewFactor, true);
136
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (value) {
137
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 result = openstudio::istringEqual(value.get(), "autocalculate");
138 }
139 3 return result;
140 3 }
141
142 13 boost::optional<Schedule> SurfacePropertySurroundingSurfaces_Impl::skyTemperatureSchedule() const {
143
2/2
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
13 return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_SurfaceProperty_SurroundingSurfacesFields::SkyTemperatureScheduleName);
144 }
145
146 11 boost::optional<double> SurfacePropertySurroundingSurfaces_Impl::groundViewFactor() const {
147 11 return getDouble(OS_SurfaceProperty_SurroundingSurfacesFields::GroundViewFactor, true);
148 }
149
150 3 bool SurfacePropertySurroundingSurfaces_Impl::isGroundViewFactorAutocalculated() const {
151 3 bool result = false;
152
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<std::string> value = getString(OS_SurfaceProperty_SurroundingSurfacesFields::GroundViewFactor, true);
153
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (value) {
154
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
6 result = openstudio::istringEqual(value.get(), "autocalculate");
155 }
156 3 return result;
157 3 }
158
159 9 boost::optional<Schedule> SurfacePropertySurroundingSurfaces_Impl::groundTemperatureSchedule() const {
160
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_SurfaceProperty_SurroundingSurfacesFields::GroundTemperatureScheduleName);
161 }
162
163 5 bool SurfacePropertySurroundingSurfaces_Impl::setSkyViewFactor(double skyViewFactor) {
164 5 bool result = setDouble(OS_SurfaceProperty_SurroundingSurfacesFields::SkyViewFactor, skyViewFactor);
165 5 return result;
166 }
167
168 8 void SurfacePropertySurroundingSurfaces_Impl::autocalculateSkyViewFactor() {
169
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
16 bool result = setString(OS_SurfaceProperty_SurroundingSurfacesFields::SkyViewFactor, "autocalculate");
170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 OS_ASSERT(result);
171 8 }
172
173 3 bool SurfacePropertySurroundingSurfaces_Impl::setSkyTemperatureSchedule(Schedule& schedule) {
174
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
12 bool result = setSchedule(OS_SurfaceProperty_SurroundingSurfacesFields::SkyTemperatureScheduleName, "SurfacePropertySurroundingSurfaces",
175 "Sky Temperature", schedule);
176 3 return result;
177 }
178
179 1 void SurfacePropertySurroundingSurfaces_Impl::resetSkyTemperatureSchedule() {
180
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_SurfaceProperty_SurroundingSurfacesFields::SkyTemperatureScheduleName, "");
181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
182 1 }
183
184 5 bool SurfacePropertySurroundingSurfaces_Impl::setGroundViewFactor(double groundViewFactor) {
185 5 bool result = setDouble(OS_SurfaceProperty_SurroundingSurfacesFields::GroundViewFactor, groundViewFactor);
186 5 return result;
187 }
188
189 8 void SurfacePropertySurroundingSurfaces_Impl::autocalculateGroundViewFactor() {
190
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
16 bool result = setString(OS_SurfaceProperty_SurroundingSurfacesFields::GroundViewFactor, "autocalculate");
191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 OS_ASSERT(result);
192 8 }
193
194 3 bool SurfacePropertySurroundingSurfaces_Impl::setGroundTemperatureSchedule(Schedule& schedule) {
195
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
12 bool result = setSchedule(OS_SurfaceProperty_SurroundingSurfacesFields::GroundTemperatureScheduleName, "SurfacePropertySurroundingSurfaces",
196 "Ground Temperature", schedule);
197 3 return result;
198 }
199
200 1 void SurfacePropertySurroundingSurfaces_Impl::resetGroundTemperatureSchedule() {
201
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_SurfaceProperty_SurroundingSurfacesFields::GroundTemperatureScheduleName, "");
202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
203 1 }
204
205 // Extensible groups
206
207 94 unsigned int SurfacePropertySurroundingSurfaces_Impl::numberofSurroundingSurfaceGroups() const {
208 94 return numExtensibleGroups();
209 }
210
211 23 boost::optional<unsigned> SurfacePropertySurroundingSurfaces_Impl::surroundingSurfaceGroupIndex(const std::string& surroundingSurfaceName) const {
212 23 boost::optional<unsigned> result;
213
214 // Find with custom predicate, checking handle equality between the toSurface and the fromSurface pairs
215 // We do it with extensibleGroups() (rather than surroundingSurfaceGroups()) and getString to avoid overhead
216 // of manipulating actual model objects (getTarget, then create a SurroundingSurfaceGroups wrapper, get handle convert to string...)
217 // and speed up the routine
218
2/2
✓ Branch 1 taken 23 times.
✓ Branch 4 taken 23 times.
23 auto egs = castVector<WorkspaceExtensibleGroup>(extensibleGroups());
219
1/1
✓ Branch 3 taken 23 times.
23 auto it = std::find_if(egs.begin(), egs.end(), [&surroundingSurfaceName](const WorkspaceExtensibleGroup& eg) {
220
3/3
✓ Branch 1 taken 37 times.
✓ Branch 4 taken 37 times.
✓ Branch 7 taken 37 times.
74 return openstudio::istringEqual(eg.getField(OS_SurfaceProperty_SurroundingSurfacesExtensibleFields::SurroundingSurfaceName).get(),
221 74 surroundingSurfaceName);
222 });
223
224 // If found, we compute the index by using std::distance between the start of vector and the iterator returned by std::find_if
225
2/2
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 19 times.
23 if (it != egs.end()) {
226
1/1
✓ Branch 2 taken 4 times.
8 result = std::distance(egs.begin(), it);
227 }
228
229 23 return result;
230 23 }
231
232 boost::optional<unsigned>
233 22 SurfacePropertySurroundingSurfaces_Impl::surroundingSurfaceGroupIndex(const SurroundingSurfaceGroup& surroundingSurfaceGroup) const {
234
2/2
✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
22 return surroundingSurfaceGroupIndex(surroundingSurfaceGroup.surroundingSurfaceName());
235 }
236
237 33 boost::optional<SurroundingSurfaceGroup> SurfacePropertySurroundingSurfaces_Impl::getSurroundingSurfaceGroup(unsigned groupIndex) const {
238
239 33 boost::optional<SurroundingSurfaceGroup> result;
240
241
3/3
✓ Branch 1 taken 33 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 32 times.
33 if (groupIndex >= numberofSurroundingSurfaceGroups()) {
242
13/13
✓ 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 22 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 32 taken 1 time.
✓ Branch 35 taken 1 time.
✓ Branch 38 taken 1 time.
1 LOG(Error, "Asked to get SurroundingSurfaceGroup with index " << groupIndex << ", but " << briefDescription() << " has just "
243 << numberofSurroundingSurfaceGroups() << " SurroundingSurfaceGroups.");
244 1 return result;
245 }
246
247
2/2
✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
32 auto group = getExtensibleGroup(groupIndex).cast<ModelExtensibleGroup>();
248
249
1/1
✓ Branch 1 taken 32 times.
32 boost::optional<std::string> surfaceName_ = group.getString(OS_SurfaceProperty_SurroundingSurfacesExtensibleFields::SurroundingSurfaceName);
250
1/1
✓ Branch 1 taken 32 times.
32 boost::optional<double> viewFactor_ = group.getDouble(OS_SurfaceProperty_SurroundingSurfacesExtensibleFields::SurroundingSurfaceViewFactor);
251 boost::optional<Schedule> tempSch_ =
252
1/1
✓ Branch 1 taken 32 times.
32 group.getModelObjectTarget<Schedule>(OS_SurfaceProperty_SurroundingSurfacesExtensibleFields::SurroundingSurfaceTemperatureScheduleName);
253
254
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
32 if (!surfaceName_) {
255 ✗ LOG(Error, "Could not retrieve SurroundingSurfaceName for extensible group " << group.groupIndex() << ".");
256 }
257
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
32 if (!viewFactor_) {
258 ✗ LOG(Error, "Could not retrieve SurroundingSurfaceViewFactor for extensible group " << group.groupIndex() << ".");
259 }
260
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
32 if (!tempSch_) {
261 ✗ LOG(Error, "Could not retrieve SurroundingSurfaceTemperatureScheduleName for extensible group " << group.groupIndex() << ".");
262 }
263
264
6/6
✓ Branch 1 taken 32 times.
✓ Branch 4 taken 32 times.
✓ Branch 7 taken 32 times.
✓ Branch 10 taken 32 times.
✓ Branch 13 taken 32 times.
✓ Branch 16 taken 32 times.
32 result = SurroundingSurfaceGroup(surfaceName_.get(), viewFactor_.get(), tempSch_.get());
265
266 32 return result;
267 32 }
268
269 20 bool SurfacePropertySurroundingSurfaces_Impl::addSurroundingSurfaceGroup(const SurroundingSurfaceGroup& surroundingSurfaceGroup) {
270
271 // Bounds checking happens in the SurroundingSurfaceGroup ctor
272
273 // Check if viewFactor already exists
274
1/1
✓ Branch 1 taken 20 times.
20 boost::optional<unsigned> _existingIndex = surroundingSurfaceGroupIndex(surroundingSurfaceGroup);
275
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 18 times.
20 if (_existingIndex) {
276
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 boost::optional<SurroundingSurfaceGroup> _group = getSurroundingSurfaceGroup(_existingIndex.get());
277
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
2 OS_ASSERT(_group);
278
13/13
✓ 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.
✓ Branch 16 taken 2 times.
✓ Branch 19 taken 2 times.
✓ Branch 22 taken 2 times.
✓ Branch 25 taken 2 times.
✓ Branch 28 taken 2 times.
✓ Branch 32 taken 2 times.
✓ Branch 35 taken 2 times.
✓ Branch 38 taken 2 times.
2 LOG(Warn, "For " << briefDescription() << ", SurroundingSurfaceGroup already exists, will be modified in place from " << _group.get()
279 << " to " << surroundingSurfaceGroup << ".");
280 2 }
281
282 // If existing, get it, otherwise Push an extensible group. ModelExtensibleGroup cannot be default-constructed, so use a ternary operator
283 // Given that we will potentially push many extensible groups
284 // we will suffer from going through the internal checks in WorkspaceObject, especially in setPointer,
285 // and performance will be roughly O(n^2) when adding groups.
286 // So to improve the performance we pushExtensible group without validity check, and call setPointer without validity check (`isValid`)
287 20 std::vector<std::string> temp;
288
2/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
4 ModelExtensibleGroup eg = (_existingIndex ? getExtensibleGroup(_existingIndex.get()).cast<ModelExtensibleGroup>()
289
9/11
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 18 times.
✓ Branch 3 taken 2 times.
✓ Branch 6 taken 18 times.
✓ Branch 9 taken 18 times.
✓ Branch 11 taken 18 times.
✓ Branch 12 taken 2 times.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 18 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
22 : pushExtensibleGroup(temp, false).cast<ModelExtensibleGroup>());
290
291 20 bool result = false;
292
293
1/1
✓ Branch 1 taken 20 times.
20 bool surfaceNameOk = eg.setString(OS_SurfaceProperty_SurroundingSurfacesExtensibleFields::SurroundingSurfaceName,
294
1/1
✓ Branch 1 taken 20 times.
40 surroundingSurfaceGroup.surroundingSurfaceName());
295
296 bool viewFactorOk =
297
2/2
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
20 eg.setDouble(OS_SurfaceProperty_SurroundingSurfacesExtensibleFields::SurroundingSurfaceViewFactor, surroundingSurfaceGroup.viewFactor());
298
299
1/1
✓ Branch 1 taken 20 times.
20 auto sch = surroundingSurfaceGroup.temperatureSchedule();
300 bool schOk =
301
2/2
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
20 eg.setPointer(OS_SurfaceProperty_SurroundingSurfacesExtensibleFields::SurroundingSurfaceTemperatureScheduleName, sch.handle(), false);
302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (!schOk) {
303 ✗ LOG(Error, "Unable to add View Factor which has an incompatible toSurface object to " << briefDescription());
304 ✗ OS_ASSERT(false);
305 }
306
307
3/6
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
20 if (surfaceNameOk && viewFactorOk && schOk) {
308 20 result = true;
309 } else {
310 // Something went wrong
311 // So erase the new extensible group
312 ✗ getObject<ModelObject>().eraseExtensibleGroup(eg.groupIndex());
313 ✗ result = false;
314 }
315 20 return result;
316 20 }
317
318 // Overloads, it creates a SurroundingSurfaceGroup wrapper, then call `addSurroundingSurfaceGroup(const SurroundingSurfaceGroup& surroundingSurfaceGroup)`
319 11 bool SurfacePropertySurroundingSurfaces_Impl::addSurroundingSurfaceGroup(const std::string& surroundingSurfaceName, double viewFactor,
320 const Schedule& temperatureSchedule) {
321
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 SurroundingSurfaceGroup surroundingSurfaceGroup(surroundingSurfaceName, viewFactor, temperatureSchedule);
322
1/1
✓ Branch 1 taken 11 times.
22 return addSurroundingSurfaceGroup(surroundingSurfaceGroup);
323 11 }
324
325 1 bool SurfacePropertySurroundingSurfaces_Impl::addSurroundingSurfaceGroups(const std::vector<SurroundingSurfaceGroup>& surroundingSurfaceGroups) {
326 1 bool result = true;
327
328
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 1 time.
4 for (const auto& surroundingSurfaceGroup : surroundingSurfaceGroups) {
329
1/1
✓ Branch 1 taken 3 times.
3 bool thisResult = addSurroundingSurfaceGroup(surroundingSurfaceGroup);
330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!thisResult) {
331 ✗ LOG(Error,
332 "Could not add surroundingSurfaceGroup " << surroundingSurfaceGroup << " to " << briefDescription() << ". Continuing with others.");
333 // OS_ASSERT(false);
334 // result = false;
335 }
336 }
337
338 1 return result;
339 }
340
341 3 bool SurfacePropertySurroundingSurfaces_Impl::removeSurroundingSurfaceGroup(unsigned groupIndex) {
342 3 bool result = false;
343
344 3 unsigned int num = numberofSurroundingSurfaceGroups();
345
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
3 if (groupIndex < num) {
346
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 getObject<ModelObject>().eraseExtensibleGroup(groupIndex);
347 1 result = true;
348 }
349 3 return result;
350 }
351
352 1 void SurfacePropertySurroundingSurfaces_Impl::removeAllSurroundingSurfaceGroups() {
353
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 getObject<ModelObject>().clearExtensibleGroups();
354 1 }
355
356 8 std::vector<SurroundingSurfaceGroup> SurfacePropertySurroundingSurfaces_Impl::surroundingSurfaceGroups() const {
357 8 std::vector<SurroundingSurfaceGroup> result;
358
359
3/3
✓ Branch 1 taken 35 times.
✓ Branch 3 taken 27 times.
✓ Branch 4 taken 8 times.
35 for (unsigned i = 0; i < numberofSurroundingSurfaceGroups(); ++i) {
360
361
1/1
✓ Branch 1 taken 27 times.
27 boost::optional<SurroundingSurfaceGroup> group_ = getSurroundingSurfaceGroup(i);
362
363 // getViewFactor is responsible for handling error and issuing Error log messages.
364 // Here we add it to the result array if it worked, and if it didn't, we keep going
365 // We just issue a message about index so user can delete it easily
366
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if (group_) {
367
2/2
✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
27 result.push_back(group_.get());
368 } else {
369 ✗ LOG(Error, briefDescription() << " has an invalid SurroundingSurfaceGroup group at index " << i);
370 }
371 27 }
372
373 8 return result;
374 ✗ }
375
376 // Helper
377 3 boost::optional<SurfacePropertyLocalEnvironment> SurfacePropertySurroundingSurfaces_Impl::surfacePropertyLocalEnvironment() const {
378 std::vector<SurfacePropertyLocalEnvironment> localEnvs =
379
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 getObject<ModelObject>().getModelObjectSources<SurfacePropertyLocalEnvironment>(SurfacePropertyLocalEnvironment::iddObjectType());
380
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 2 times.
3 if (localEnvs.empty()) {
381 1 return boost::none;
382
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 } else if (localEnvs.size() == 1) {
383
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return localEnvs.at(0);
384 } else {
385 ✗ LOG(Error, "More than one SurfacePropertyLocalEnvironments point to this SurfacePropertySurroundingSurfaces");
386 ✗ return boost::none;
387 }
388 3 }
389
390 } // namespace detail
391
392 7 SurfacePropertySurroundingSurfaces::SurfacePropertySurroundingSurfaces(const Model& model)
393 7 : ModelObject(SurfacePropertySurroundingSurfaces::iddObjectType(), model) {
394
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 5 not taken.
7 OS_ASSERT(getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>());
395
396
1/1
✓ Branch 1 taken 7 times.
7 autocalculateSkyViewFactor();
397
1/1
✓ Branch 1 taken 7 times.
7 autocalculateGroundViewFactor();
398 // TODO: Appropriately handle the following required object-list fields.
399 7 }
400
401 7744 IddObjectType SurfacePropertySurroundingSurfaces::iddObjectType() {
402
1/1
✓ Branch 1 taken 7744 times.
7744 return {IddObjectType::OS_SurfaceProperty_SurroundingSurfaces};
403 }
404
405 11 boost::optional<double> SurfacePropertySurroundingSurfaces::skyViewFactor() const {
406
1/1
✓ Branch 3 taken 11 times.
11 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->skyViewFactor();
407 }
408
409 3 bool SurfacePropertySurroundingSurfaces::isSkyViewFactorAutocalculated() const {
410
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->isSkyViewFactorAutocalculated();
411 }
412
413 13 boost::optional<Schedule> SurfacePropertySurroundingSurfaces::skyTemperatureSchedule() const {
414
1/1
✓ Branch 3 taken 13 times.
13 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->skyTemperatureSchedule();
415 }
416
417 11 boost::optional<double> SurfacePropertySurroundingSurfaces::groundViewFactor() const {
418
1/1
✓ Branch 3 taken 11 times.
11 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->groundViewFactor();
419 }
420
421 3 bool SurfacePropertySurroundingSurfaces::isGroundViewFactorAutocalculated() const {
422
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->isGroundViewFactorAutocalculated();
423 }
424
425 9 boost::optional<Schedule> SurfacePropertySurroundingSurfaces::groundTemperatureSchedule() const {
426
1/1
✓ Branch 3 taken 9 times.
9 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->groundTemperatureSchedule();
427 }
428
429 5 bool SurfacePropertySurroundingSurfaces::setSkyViewFactor(double skyViewFactor) {
430
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->setSkyViewFactor(skyViewFactor);
431 }
432
433 8 void SurfacePropertySurroundingSurfaces::autocalculateSkyViewFactor() {
434
1/1
✓ Branch 3 taken 8 times.
8 getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->autocalculateSkyViewFactor();
435 8 }
436
437 3 bool SurfacePropertySurroundingSurfaces::setSkyTemperatureSchedule(Schedule& schedule) {
438
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->setSkyTemperatureSchedule(schedule);
439 }
440
441 1 void SurfacePropertySurroundingSurfaces::resetSkyTemperatureSchedule() {
442
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->resetSkyTemperatureSchedule();
443 1 }
444
445 5 bool SurfacePropertySurroundingSurfaces::setGroundViewFactor(double groundViewFactor) {
446
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->setGroundViewFactor(groundViewFactor);
447 }
448
449 8 void SurfacePropertySurroundingSurfaces::autocalculateGroundViewFactor() {
450
1/1
✓ Branch 3 taken 8 times.
8 getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->autocalculateGroundViewFactor();
451 8 }
452
453 3 bool SurfacePropertySurroundingSurfaces::setGroundTemperatureSchedule(Schedule& schedule) {
454
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->setGroundTemperatureSchedule(schedule);
455 }
456
457 1 void SurfacePropertySurroundingSurfaces::resetGroundTemperatureSchedule() {
458
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->resetGroundTemperatureSchedule();
459 1 }
460
461 3 boost::optional<SurfacePropertyLocalEnvironment> SurfacePropertySurroundingSurfaces::surfacePropertyLocalEnvironment() const {
462
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->surfacePropertyLocalEnvironment();
463 }
464
465 // Extensible fields
466
467 8 std::vector<SurroundingSurfaceGroup> SurfacePropertySurroundingSurfaces::surroundingSurfaceGroups() const {
468
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->surroundingSurfaceGroups();
469 }
470
471 22 unsigned int SurfacePropertySurroundingSurfaces::numberofSurroundingSurfaceGroups() const {
472
1/1
✓ Branch 3 taken 22 times.
22 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->numberofSurroundingSurfaceGroups();
473 }
474
475 boost::optional<unsigned>
476 2 SurfacePropertySurroundingSurfaces::surroundingSurfaceGroupIndex(const SurroundingSurfaceGroup& surroundingSurfaceGroup) const {
477
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->surroundingSurfaceGroupIndex(surroundingSurfaceGroup);
478 }
479 1 boost::optional<unsigned> SurfacePropertySurroundingSurfaces::surroundingSurfaceGroupIndex(const std::string& surroundingSurfaceName) const {
480
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->surroundingSurfaceGroupIndex(surroundingSurfaceName);
481 }
482
483 4 boost::optional<SurroundingSurfaceGroup> SurfacePropertySurroundingSurfaces::getSurroundingSurfaceGroup(unsigned groupIndex) const {
484
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->getSurroundingSurfaceGroup(groupIndex);
485 }
486
487 6 bool SurfacePropertySurroundingSurfaces::addSurroundingSurfaceGroup(const SurroundingSurfaceGroup& surroundingSurfaceGroup) {
488
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->addSurroundingSurfaceGroup(surroundingSurfaceGroup);
489 }
490
491 // Overloads, it creates a SurroundingSurfaceGroup wrapper, then call `addSurroundingSurfaceGroup(const SurroundingSurfaceGroup& surroundingSurfaceGroup)`
492 11 bool SurfacePropertySurroundingSurfaces::addSurroundingSurfaceGroup(const std::string& surroundingSurfaceName, double viewFactor,
493 const Schedule& temperatureSchedule) {
494
1/1
✓ Branch 3 taken 11 times.
22 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->addSurroundingSurfaceGroup(surroundingSurfaceName, viewFactor,
495 22 temperatureSchedule);
496 }
497
498 1 bool SurfacePropertySurroundingSurfaces::addSurroundingSurfaceGroups(const std::vector<SurroundingSurfaceGroup>& surroundingSurfaceGroups) {
499
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->addSurroundingSurfaceGroups(surroundingSurfaceGroups);
500 }
501
502 3 bool SurfacePropertySurroundingSurfaces::removeSurroundingSurfaceGroup(unsigned groupIndex) {
503
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->removeSurroundingSurfaceGroup(groupIndex);
504 }
505
506 1 void SurfacePropertySurroundingSurfaces::removeAllSurroundingSurfaceGroups() {
507
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::SurfacePropertySurroundingSurfaces_Impl>()->removeAllSurroundingSurfaceGroups();
508 1 }
509
510 /// @cond
511 19 SurfacePropertySurroundingSurfaces::SurfacePropertySurroundingSurfaces(std::shared_ptr<detail::SurfacePropertySurroundingSurfaces_Impl> impl)
512
1/1
✓ Branch 3 taken 19 times.
19 : ModelObject(std::move(impl)) {}
513 /// @endcond
514
515 } // namespace model
516 } // namespace openstudio
517