GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 78.7% 107 / 0 / 136
Functions: 89.2% 33 / 0 / 37
Branches: 51.6% 97 / 0 / 188

src/model/SurfacePropertyLocalEnvironment.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 "SurfacePropertyLocalEnvironment.hpp"
7 #include "SurfacePropertyLocalEnvironment_Impl.hpp"
8
9 #include "PlanarSurface.hpp"
10 #include "PlanarSurface_Impl.hpp"
11 #include "Surface.hpp"
12 #include "Surface_Impl.hpp"
13 #include "SubSurface.hpp"
14 #include "SubSurface_Impl.hpp"
15 #include "Schedule.hpp"
16 #include "Schedule_Impl.hpp"
17 #include "Model.hpp"
18
19 #include "SurfacePropertySurroundingSurfaces.hpp"
20 #include "SurfacePropertySurroundingSurfaces_Impl.hpp"
21 #include "SurfacePropertyGroundSurfaces.hpp"
22 #include "SurfacePropertyGroundSurfaces_Impl.hpp"
23 //#include "OutdoorAirNode.hpp"
24 // #include "OutdoorAirNode_Impl.hpp"
25 #include "ScheduleTypeLimits.hpp"
26 #include "ScheduleTypeRegistry.hpp"
27
28 #include <utilities/idd/IddEnums.hxx>
29 #include <utilities/idd/OS_SurfaceProperty_LocalEnvironment_FieldEnums.hxx>
30
31 #include "../utilities/core/Assert.hpp"
32
33 namespace openstudio {
34 namespace model {
35
36 namespace detail {
37
38 6 SurfacePropertyLocalEnvironment_Impl::SurfacePropertyLocalEnvironment_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
39 6 : ModelObject_Impl(idfObject, model, keepHandle) {
40
4/6
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 6 times.
✗ Branch 13 not taken.
6 OS_ASSERT(idfObject.iddObject().type() == SurfacePropertyLocalEnvironment::iddObjectType());
41 6 }
42
43 ✗ SurfacePropertyLocalEnvironment_Impl::SurfacePropertyLocalEnvironment_Impl(const openstudio::detail::WorkspaceObject_Impl& other,
44 ✗ Model_Impl* model, bool keepHandle)
45 ✗ : ModelObject_Impl(other, model, keepHandle) {
46 ✗ OS_ASSERT(other.iddObject().type() == SurfacePropertyLocalEnvironment::iddObjectType());
47 ✗ }
48
49 5 SurfacePropertyLocalEnvironment_Impl::SurfacePropertyLocalEnvironment_Impl(const SurfacePropertyLocalEnvironment_Impl& other, Model_Impl* model,
50 5 bool keepHandle)
51 5 : ModelObject_Impl(other, model, keepHandle) {}
52
53 ✗ const std::vector<std::string>& SurfacePropertyLocalEnvironment_Impl::outputVariableNames() const {
54 ✗ static std::vector<std::string> result;
55 ✗ if (result.empty()) {
56 }
57 ✗ return result;
58 }
59
60 ✗ IddObjectType SurfacePropertyLocalEnvironment_Impl::iddObjectType() const {
61 ✗ return SurfacePropertyLocalEnvironment::iddObjectType();
62 }
63
64 ✗ std::vector<ScheduleTypeKey> SurfacePropertyLocalEnvironment_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
65 ✗ std::vector<ScheduleTypeKey> result;
66 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
67 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
68 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
69 ✗ if (std::find(b, e, OS_SurfaceProperty_LocalEnvironmentFields::ExternalShadingFractionScheduleName) != e) {
70 ✗ result.emplace_back("SurfacePropertyLocalEnvironment", "External Shading Fraction");
71 }
72 ✗ return result;
73 ✗ }
74
75 11 boost::optional<PlanarSurface> SurfacePropertyLocalEnvironment_Impl::optionalExteriorSurface() const {
76
3/4
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 8 taken 11 times.
✗ Branch 9 not taken.
22 if (auto mo_ = getObject<ModelObject>().getModelObjectTarget<ModelObject>(OS_SurfaceProperty_LocalEnvironmentFields::ExteriorSurfaceName)) {
77
3/3
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
11 return mo_->cast<PlanarSurface>();
78 11 }
79 ✗ return boost::none;
80 }
81
82 11 PlanarSurface SurfacePropertyLocalEnvironment_Impl::exteriorSurface() const {
83
1/1
✓ Branch 1 taken 11 times.
11 boost::optional<PlanarSurface> value = optionalExteriorSurface();
84
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
11 if (!value) {
85 ✗ LOG_AND_THROW(briefDescription() << " does not have an Exterior Surface attached.");
86 }
87
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
22 return value.get();
88 11 }
89
90 23 boost::optional<Surface> SurfacePropertyLocalEnvironment_Impl::exteriorSurfaceAsSurface() const {
91
2/2
✓ Branch 1 taken 23 times.
✓ Branch 4 taken 23 times.
23 return getObject<ModelObject>().getModelObjectTarget<Surface>(OS_SurfaceProperty_LocalEnvironmentFields::ExteriorSurfaceName);
92 }
93
94 14 boost::optional<SubSurface> SurfacePropertyLocalEnvironment_Impl::exteriorSurfaceAsSubSurface() const {
95
2/2
✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
14 return getObject<ModelObject>().getModelObjectTarget<SubSurface>(OS_SurfaceProperty_LocalEnvironmentFields::ExteriorSurfaceName);
96 }
97
98 13 boost::optional<Schedule> SurfacePropertyLocalEnvironment_Impl::externalShadingFractionSchedule() const {
99
2/2
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
13 return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_SurfaceProperty_LocalEnvironmentFields::ExternalShadingFractionScheduleName);
100 }
101
102 15 boost::optional<SurfacePropertySurroundingSurfaces> SurfacePropertyLocalEnvironment_Impl::surfacePropertySurroundingSurfaces() const {
103
1/1
✓ Branch 1 taken 15 times.
30 return getObject<ModelObject>().getModelObjectTarget<SurfacePropertySurroundingSurfaces>(
104
1/1
✓ Branch 1 taken 15 times.
30 OS_SurfaceProperty_LocalEnvironmentFields::SurroundingSurfacesObjectName);
105 }
106
107 11 boost::optional<SurfacePropertyGroundSurfaces> SurfacePropertyLocalEnvironment_Impl::surfacePropertyGroundSurfaces() const {
108
1/1
✓ Branch 1 taken 11 times.
22 return getObject<ModelObject>().getModelObjectTarget<SurfacePropertyGroundSurfaces>(
109
1/1
✓ Branch 1 taken 11 times.
22 OS_SurfaceProperty_LocalEnvironmentFields::GroundSurfacesObjectName);
110 }
111
112 9 bool SurfacePropertyLocalEnvironment_Impl::setExteriorSurface(const PlanarSurface& surface) {
113
114 9 boost::optional<SurfacePropertyLocalEnvironment> currentLocalEnv;
115
3/3
✓ Branch 1 taken 9 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 3 times.
18 if (auto s_ = surface.optionalCast<Surface>()) {
116
3/3
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
6 currentLocalEnv = s_->surfacePropertyLocalEnvironment();
117
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 } else if (auto s_ = surface.optionalCast<SubSurface>()) {
118
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 currentLocalEnv = s_->surfacePropertyLocalEnvironment();
119 } else {
120 ✗ LOG(Error,
121 "SurfacePropertyLocalEnvironment currently only accepts Surface and SubSurface, object isn't accepted: " << surface.briefDescription());
122 ✗ return false;
123 12 }
124
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 8 times.
9 if (currentLocalEnv) {
125
5/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 time.
1 if (currentLocalEnv->handle() == this->handle()) {
126 ✗ return true;
127 }
128
8/8
✓ 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 17 taken 1 time.
✓ Branch 20 taken 1 time.
✓ Branch 23 taken 1 time.
1 LOG(Warn, "Surface " << surface.nameString()
129 << " already has a SurfacePropertyLocalEnvironment attached, and it will be **removed**. Please check your inputs.");
130
131
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 currentLocalEnv->remove();
132 }
133
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 return setPointer(OS_SurfaceProperty_LocalEnvironmentFields::ExteriorSurfaceName, surface.handle());
134 9 }
135
136 3 bool SurfacePropertyLocalEnvironment_Impl::setExternalShadingFractionSchedule(Schedule& schedule) {
137
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
12 bool result = setSchedule(OS_SurfaceProperty_LocalEnvironmentFields::ExternalShadingFractionScheduleName, "SurfacePropertyLocalEnvironment",
138 "External Shading Fraction", schedule);
139 3 return result;
140 }
141
142 1 void SurfacePropertyLocalEnvironment_Impl::resetExternalShadingFractionSchedule() {
143
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_SurfaceProperty_LocalEnvironmentFields::ExternalShadingFractionScheduleName, "");
144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
145 1 }
146
147 4 bool SurfacePropertyLocalEnvironment_Impl::setSurfacePropertySurroundingSurfaces(
148 const SurfacePropertySurroundingSurfaces& surfacePropertySurroundingSurfaces) {
149
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 bool result = setPointer(OS_SurfaceProperty_LocalEnvironmentFields::SurroundingSurfacesObjectName, surfacePropertySurroundingSurfaces.handle());
150 4 return result;
151 }
152
153 1 void SurfacePropertyLocalEnvironment_Impl::resetSurfacePropertySurroundingSurfaces() {
154
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_SurfaceProperty_LocalEnvironmentFields::SurroundingSurfacesObjectName, "");
155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
156 1 }
157
158 2 bool SurfacePropertyLocalEnvironment_Impl::setSurfacePropertyGroundSurfaces(const SurfacePropertyGroundSurfaces& surfacePropertyGroundSurfaces) {
159
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 bool result = setPointer(OS_SurfaceProperty_LocalEnvironmentFields::GroundSurfacesObjectName, surfacePropertyGroundSurfaces.handle());
160 2 return result;
161 }
162
163 1 void SurfacePropertyLocalEnvironment_Impl::resetSurfacePropertyGroundSurfaces() {
164
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_SurfaceProperty_LocalEnvironmentFields::GroundSurfacesObjectName, "");
165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
166 1 }
167
168 //boost::optional<OutdoorAirNode> SurfacePropertyLocalEnvironment_Impl::outdoorAirNode() const {
169 //return getObject<ModelObject>().getModelObjectTarget<OutdoorAirNode>(OS_SurfaceProperty_LocalEnvironmentFields::OutdoorAirNodeName);
170 //}
171
172 //bool SurfacePropertyLocalEnvironment_Impl::setOutdoorAirNode(const OutdoorAirNode& outdoorAirNode) {
173 //bool result = setPointer(OS_SurfaceProperty_LocalEnvironmentFields::OutdoorAirNodeName, outdoorAirNode.handle());
174 //return result;
175 //}
176
177 //void SurfacePropertyLocalEnvironment_Impl::resetOutdoorAirNode() {
178 //bool result = setString(OS_SurfaceProperty_LocalEnvironmentFields::OutdoorAirNodeName, "");
179 //OS_ASSERT(result);
180 //}
181
182 } // namespace detail
183
184 5 SurfacePropertyLocalEnvironment::SurfacePropertyLocalEnvironment(const Surface& surface)
185
3/3
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
5 : ModelObject(SurfacePropertyLocalEnvironment::iddObjectType(), surface.model()) {
186
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 5 not taken.
5 OS_ASSERT(getImpl<detail::SurfacePropertyLocalEnvironment_Impl>());
187
188
1/1
✓ Branch 1 taken 5 times.
5 bool ok = setExteriorSurface(surface);
189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!ok) {
190 ✗ this->remove();
191 ✗ LOG_AND_THROW("Cannot create a SurfacePropertyLocalEnvironment pointing to " << surface.briefDescription());
192 }
193 5 }
194
195 1 SurfacePropertyLocalEnvironment::SurfacePropertyLocalEnvironment(const SubSurface& subSurface)
196
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 : ModelObject(SurfacePropertyLocalEnvironment::iddObjectType(), subSurface.model()) {
197
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 5 not taken.
1 OS_ASSERT(getImpl<detail::SurfacePropertyLocalEnvironment_Impl>());
198
199
1/1
✓ Branch 1 taken 1 time.
1 bool ok = setExteriorSurface(subSurface);
200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (!ok) {
201 ✗ this->remove();
202 ✗ LOG_AND_THROW("Cannot create a SurfacePropertyLocalEnvironment pointing to " << subSurface.briefDescription());
203 }
204 1 }
205
206 11294 IddObjectType SurfacePropertyLocalEnvironment::iddObjectType() {
207
1/1
✓ Branch 1 taken 11294 times.
11294 return {IddObjectType::OS_SurfaceProperty_LocalEnvironment};
208 }
209
210 11 PlanarSurface SurfacePropertyLocalEnvironment::exteriorSurface() const {
211
1/1
✓ Branch 3 taken 11 times.
11 return getImpl<detail::SurfacePropertyLocalEnvironment_Impl>()->exteriorSurface();
212 }
213
214 23 boost::optional<Surface> SurfacePropertyLocalEnvironment::exteriorSurfaceAsSurface() const {
215
1/1
✓ Branch 3 taken 23 times.
23 return getImpl<ImplType>()->exteriorSurfaceAsSurface();
216 }
217
218 14 boost::optional<SubSurface> SurfacePropertyLocalEnvironment::exteriorSurfaceAsSubSurface() const {
219
1/1
✓ Branch 3 taken 14 times.
14 return getImpl<ImplType>()->exteriorSurfaceAsSubSurface();
220 }
221
222 13 boost::optional<Schedule> SurfacePropertyLocalEnvironment::externalShadingFractionSchedule() const {
223
1/1
✓ Branch 3 taken 13 times.
13 return getImpl<detail::SurfacePropertyLocalEnvironment_Impl>()->externalShadingFractionSchedule();
224 }
225
226 15 boost::optional<SurfacePropertySurroundingSurfaces> SurfacePropertyLocalEnvironment::surfacePropertySurroundingSurfaces() const {
227
1/1
✓ Branch 3 taken 15 times.
15 return getImpl<detail::SurfacePropertyLocalEnvironment_Impl>()->surfacePropertySurroundingSurfaces();
228 }
229
230 11 boost::optional<SurfacePropertyGroundSurfaces> SurfacePropertyLocalEnvironment::surfacePropertyGroundSurfaces() const {
231
1/1
✓ Branch 3 taken 11 times.
11 return getImpl<detail::SurfacePropertyLocalEnvironment_Impl>()->surfacePropertyGroundSurfaces();
232 }
233
234 9 bool SurfacePropertyLocalEnvironment::setExteriorSurface(const PlanarSurface& surface) {
235
1/1
✓ Branch 3 taken 9 times.
9 return getImpl<detail::SurfacePropertyLocalEnvironment_Impl>()->setExteriorSurface(surface);
236 }
237
238 3 bool SurfacePropertyLocalEnvironment::setExternalShadingFractionSchedule(Schedule& schedule) {
239
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::SurfacePropertyLocalEnvironment_Impl>()->setExternalShadingFractionSchedule(schedule);
240 }
241
242 1 void SurfacePropertyLocalEnvironment::resetExternalShadingFractionSchedule() {
243
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::SurfacePropertyLocalEnvironment_Impl>()->resetExternalShadingFractionSchedule();
244 1 }
245
246 4 bool SurfacePropertyLocalEnvironment::setSurfacePropertySurroundingSurfaces(
247 const SurfacePropertySurroundingSurfaces& surfacePropertySurroundingSurfaces) {
248
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::SurfacePropertyLocalEnvironment_Impl>()->setSurfacePropertySurroundingSurfaces(surfacePropertySurroundingSurfaces);
249 }
250
251 1 void SurfacePropertyLocalEnvironment::resetSurfacePropertySurroundingSurfaces() {
252
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::SurfacePropertyLocalEnvironment_Impl>()->resetSurfacePropertySurroundingSurfaces();
253 1 }
254
255 2 bool SurfacePropertyLocalEnvironment::setSurfacePropertyGroundSurfaces(const SurfacePropertyGroundSurfaces& surfacePropertyGroundSurfaces) {
256
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::SurfacePropertyLocalEnvironment_Impl>()->setSurfacePropertyGroundSurfaces(surfacePropertyGroundSurfaces);
257 }
258
259 1 void SurfacePropertyLocalEnvironment::resetSurfacePropertyGroundSurfaces() {
260
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::SurfacePropertyLocalEnvironment_Impl>()->resetSurfacePropertyGroundSurfaces();
261 1 }
262
263 //boost::optional<OutdoorAirNode> SurfacePropertyLocalEnvironment::outdoorAirNode() const {
264 //return getImpl<detail::SurfacePropertyLocalEnvironment_Impl>()->outdoorAirNode();
265 //}
266
267 //bool SurfacePropertyLocalEnvironment::setOutdoorAirNode(const OutdoorAirNode& outdoorAirNode) {
268 //return getImpl<detail::SurfacePropertyLocalEnvironment_Impl>()->setOutdoorAirNode(outdoorAirNode);
269 //}
270
271 //void SurfacePropertyLocalEnvironment::resetOutdoorAirNode() {
272 //getImpl<detail::SurfacePropertyLocalEnvironment_Impl>()->resetOutdoorAirNode();
273 //}
274
275 /// @cond
276 40 SurfacePropertyLocalEnvironment::SurfacePropertyLocalEnvironment(std::shared_ptr<detail::SurfacePropertyLocalEnvironment_Impl> impl)
277
1/1
✓ Branch 3 taken 40 times.
40 : ModelObject(std::move(impl)) {}
278 /// @endcond
279
280 } // namespace model
281 } // namespace openstudio
282