GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 83.4% 1204 / 0 / 1443
Functions: 78.4% 156 / 0 / 199
Branches: 68.0% 1691 / 0 / 2487

src/model/Surface.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 "Surface.hpp"
7 #include "Surface_Impl.hpp"
8 #include "ComfortViewFactorAngles.hpp"
9 #include "ComfortViewFactorAngles_Impl.hpp"
10 #include "Model.hpp"
11 #include "Model_Impl.hpp"
12 #include "Space.hpp"
13 #include "Space_Impl.hpp"
14 #include "SubSurface.hpp"
15 #include "SubSurface_Impl.hpp"
16 #include "ShadingSurfaceGroup.hpp"
17 #include "ShadingSurfaceGroup_Impl.hpp"
18 #include "ConstructionBase.hpp"
19 #include "ConstructionBase_Impl.hpp"
20 #include "LayeredConstruction.hpp"
21 #include "LayeredConstruction_Impl.hpp"
22 #include "StandardsInformationConstruction.hpp"
23 #include "DaylightingDeviceShelf.hpp"
24 #include "ShadingSurface.hpp"
25 #include "InteriorPartitionSurfaceGroup.hpp"
26 #include "InteriorPartitionSurface.hpp"
27 #include "SurfaceControlMovableInsulation.hpp"
28 #include "SurfaceControlMovableInsulation_Impl.hpp"
29 #include "SurfacePropertyOtherSideCoefficients.hpp"
30 #include "SurfacePropertyOtherSideCoefficients_Impl.hpp"
31 #include "SurfacePropertyOtherSideConditionsModel.hpp"
32 #include "SurfacePropertyOtherSideConditionsModel_Impl.hpp"
33 #include "SurfacePropertyConvectionCoefficients.hpp"
34 #include "SurfacePropertyConvectionCoefficients_Impl.hpp"
35 #include "SurfacePropertyLocalEnvironment.hpp"
36 #include "SurfacePropertyLocalEnvironment_Impl.hpp"
37 #include "AirflowNetworkSurface.hpp"
38 #include "AirflowNetworkSurface_Impl.hpp"
39 #include "AirflowNetworkDetailedOpening.hpp"
40 #include "AirflowNetworkDetailedOpening_Impl.hpp"
41 #include "AirflowNetworkCrack.hpp"
42 #include "AirflowNetworkCrack_Impl.hpp"
43 #include "AirflowNetworkSimpleOpening.hpp"
44 #include "AirflowNetworkSimpleOpening_Impl.hpp"
45 #include "AirflowNetworkEffectiveLeakageArea.hpp"
46 #include "AirflowNetworkEffectiveLeakageArea_Impl.hpp"
47 #include "AirflowNetworkHorizontalOpening.hpp"
48 #include "AirflowNetworkHorizontalOpening_Impl.hpp"
49 #include "AirflowNetworkSpecifiedFlowRate.hpp"
50 #include "AirflowNetworkSpecifiedFlowRate_Impl.hpp"
51 #include "FoundationKiva.hpp"
52 #include "FoundationKiva_Impl.hpp"
53 #include "FoundationKivaSettings.hpp"
54 #include "FoundationKivaSettings_Impl.hpp"
55 #include "SurfacePropertyExposedFoundationPerimeter.hpp"
56 #include "SurfacePropertyExposedFoundationPerimeter_Impl.hpp"
57
58 #include <utilities/idd/IddFactory.hxx>
59
60 #include <utilities/idd/OS_Surface_FieldEnums.hxx>
61 #include <utilities/idd/IddEnums.hxx>
62
63 #include "../utilities/geometry/Transformation.hpp"
64 #include "../utilities/geometry/Geometry.hpp"
65 #include "../utilities/geometry/Intersection.hpp"
66 #include "../utilities/core/Assert.hpp"
67
68 #include "../utilities/sql/SqlFile.hpp"
69
70 #include <iterator> // std::make_move_iterator
71 #include <numeric> // std::accumulate
72
73 using boost::to_upper_copy;
74
75 namespace openstudio {
76 namespace model {
77
78 namespace detail {
79
80 48604 Surface_Impl::Surface_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) : PlanarSurface_Impl(idfObject, model, keepHandle) {
81
4/6
✓ Branch 1 taken 48604 times.
✓ Branch 4 taken 48604 times.
✓ Branch 7 taken 48604 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 48604 times.
✗ Branch 13 not taken.
48604 OS_ASSERT(idfObject.iddObject().type() == Surface::iddObjectType());
82 48604 }
83
84 22524 Surface_Impl::Surface_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
85 22524 : PlanarSurface_Impl(other, model, keepHandle) {
86
4/6
✓ Branch 1 taken 22524 times.
✓ Branch 4 taken 22524 times.
✓ Branch 7 taken 22524 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 22524 times.
✗ Branch 13 not taken.
22524 OS_ASSERT(other.iddObject().type() == Surface::iddObjectType());
87 22524 }
88
89 13399 Surface_Impl::Surface_Impl(const Surface_Impl& other, Model_Impl* model, bool keepHandle) : PlanarSurface_Impl(other, model, keepHandle) {}
90
91 3565 boost::optional<ParentObject> Surface_Impl::parent() const {
92 3565 boost::optional<ParentObject> result;
93
2/2
✓ Branch 1 taken 3565 times.
✓ Branch 4 taken 3565 times.
3565 result = this->space();
94 3565 return result;
95 ✗ }
96
97 3689 bool Surface_Impl::setParent(ParentObject& newParent) {
98 3689 bool result = false;
99
2/3
✓ Branch 1 taken 3689 times.
✓ Branch 4 taken 3689 times.
✗ Branch 5 not taken.
7378 if (newParent.optionalCast<Space>()) {
100
2/2
✓ Branch 1 taken 3689 times.
✓ Branch 4 taken 3689 times.
3689 result = this->setSpace(newParent.cast<Space>());
101 }
102 3689 return result;
103 }
104
105 7794 std::vector<ModelObject> Surface_Impl::children() const {
106 7794 std::vector<ModelObject> result;
107
108 // subSurfaces
109
1/1
✓ Branch 1 taken 7794 times.
7794 SubSurfaceVector subSurfaces = this->subSurfaces();
110
1/1
✓ Branch 5 taken 7794 times.
7794 result.insert(result.end(), subSurfaces.begin(), subSurfaces.end());
111
112 std::vector<AirflowNetworkSurface> myAFNItems =
113
3/3
✓ Branch 1 taken 7794 times.
✓ Branch 4 taken 7794 times.
✓ Branch 7 taken 7794 times.
7794 getObject<ModelObject>().getModelObjectSources<AirflowNetworkSurface>(AirflowNetworkSurface::iddObjectType());
114
1/1
✓ Branch 5 taken 7794 times.
7794 result.insert(result.end(), myAFNItems.begin(), myAFNItems.end());
115
116
3/3
✓ Branch 1 taken 7794 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 7791 times.
15588 if (boost::optional<SurfacePropertyExposedFoundationPerimeter> prop = this->surfacePropertyExposedFoundationPerimeter()) {
117
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 result.push_back(prop.get());
118 7794 }
119
120 15588 return result;
121 7794 }
122
123 240 std::vector<IdfObject> Surface_Impl::remove() {
124
1/1
✓ Branch 1 taken 240 times.
240 boost::optional<Surface> adjacentSurface = this->adjacentSurface();
125
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 173 times.
240 if (adjacentSurface) {
126
1/1
✓ Branch 1 taken 67 times.
67 this->resetAdjacentSurface();
127 }
128
129
1/1
✓ Branch 1 taken 240 times.
240 Surface surface = getObject<Surface>();
130
3/3
✓ Branch 1 taken 240 times.
✓ Branch 8 taken 1 time.
✓ Branch 9 taken 240 times.
241 for (ComfortViewFactorAngles& comfortViewFactorAngles : surface.getModelObjectSources<ComfortViewFactorAngles>()) {
131
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<unsigned> index = comfortViewFactorAngles.angleFactorIndex(surface)) {
132
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 comfortViewFactorAngles.removeAngleFactor(index.get());
133 }
134 240 }
135
136
1/1
✓ Branch 1 taken 240 times.
480 return ParentObject_Impl::remove();
137 240 }
138
139 3563 ModelObject Surface_Impl::clone(Model model) const {
140
2/2
✓ Branch 1 taken 3563 times.
✓ Branch 4 taken 3563 times.
3563 ModelObject newParentAsModelObject = ModelObject_Impl::clone(model);
141
1/1
✓ Branch 1 taken 3563 times.
3563 auto newParent = newParentAsModelObject.cast<ParentObject>();
142
143
3/3
✓ Branch 1 taken 3563 times.
✓ Branch 8 taken 160 times.
✓ Branch 9 taken 3563 times.
3723 for (const ModelObject& child : children()) {
144
2/2
✓ Branch 1 taken 160 times.
✓ Branch 4 taken 160 times.
160 ModelObject newChild = child.clone(model);
145
1/1
✓ Branch 1 taken 160 times.
160 newChild.setParent(newParent);
146
3/3
✓ Branch 1 taken 160 times.
✓ Branch 3 taken 156 times.
✓ Branch 4 taken 4 times.
320 if (auto ss_ = child.optionalCast<SubSurface>()) {
147
4/4
✓ Branch 1 taken 156 times.
✓ Branch 4 taken 156 times.
✓ Branch 7 taken 156 times.
✓ Branch 10 taken 156 times.
156 newChild.cast<SubSurface>().setSubSurfaceType(ss_->subSurfaceType());
148 160 }
149 3723 }
150
151
1/1
✓ Branch 1 taken 3563 times.
3563 auto coefficients = surfacePropertyConvectionCoefficients();
152
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3561 times.
3563 if (coefficients) {
153
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 auto coefficientsClone = coefficients->clone(model).cast<SurfacePropertyConvectionCoefficients>();
154
1/1
✓ Branch 1 taken 2 times.
2 coefficientsClone.setSurface(newParentAsModelObject);
155 2 }
156
157 // TODO: do we clone the SurfacePropertyLocalEnvironment?
158
159
1/1
✓ Branch 1 taken 3563 times.
3563 auto foundation = adjacentFoundation();
160
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3561 times.
3563 if (foundation) {
161
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 auto foundationClone = foundation->clone(model).cast<FoundationKiva>();
162
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 newParentAsModelObject.cast<Surface>().setAdjacentFoundation(foundationClone);
163 2 }
164
165 7126 return newParentAsModelObject;
166 3563 }
167
168 ✗ std::vector<IddObjectType> Surface_Impl::allowableChildTypes() const {
169 ✗ return std::vector<IddObjectType>{IddObjectType::OS_SubSurface};
170 }
171
172 192 const std::vector<std::string>& Surface_Impl::outputVariableNames() const {
173 static const std::vector<std::string> result{
174 // Face temperatures and convection
175 "Surface Inside Face Temperature",
176 "Surface Inside Face Interior Movable Insulation Temperature",
177 "Surface Outside Face Temperature",
178 "Surface Inside Face Adjacent Air Temperature",
179 "Surface Inside Face Convection Heat Transfer Coefficient",
180 "Surface Inside Face Convection Heat Gain Rate",
181 "Surface Inside Face Convection Heat Gain Rate per Area",
182 "Surface Inside Face Convection Heat Gain Energy",
183 "Surface Inside Face Convection Classification Index",
184 "Surface Inside Face Convection Model Equation Index",
185 "Surface Inside Face Convection Reference Air Index",
186 "Surface Outside Face Convection Heat Transfer Coefficient",
187 "Surface Outside Face Convection Heat Gain Rate",
188 "Surface Outside Face Convection Heat Gain Rate per Area",
189 "Surface Outside Face Convection Heat Gain Energy",
190 "Surface Outside Face Convection Classification Index",
191 "Surface Outside Face Forced Convection Model Equation Index",
192 "Surface Outside Face Natural Convection Model Equation Index",
193 // Thermal (longwave) radiation exchange
194 "Surface Inside Face Net Surface Thermal Radiation Heat Gain Rate",
195 "Surface Inside Face Net Surface Thermal Radiation Heat Gain Rate per Area",
196 "Surface Inside Face Net Surface Thermal Radiation Heat Gain Energy",
197 "Surface Outside Face Net Thermal Radiation Heat Gain Rate",
198 "Surface Outside Face Net Thermal Radiation Heat Gain Rate per Area",
199 "Surface Outside Face Net Thermal Radiation Heat Gain Energy",
200 "Surface Outside Face Thermal Radiation to Air Heat Transfer Coefficient",
201 "Surface Outside Face Thermal Radiation to Air Heat Transfer Rate",
202 "Surface Outside Face Thermal Radiation to Sky Heat Transfer Coefficient",
203 "Surface Outside Face Thermal Radiation to Ground Heat Transfer Coefficient",
204 "Surface Outside Face Thermal Radiation to Surrounding Surfaces Heat Transfer Coefficient",
205 "Surface Outside Face Surrounding Surfaces Average Temperature",
206 "Surface Outside Face Heat Emission to Air Rate",
207 // Solar and internal-gains radiation absorbed/transmitted at this surface
208 "Surface Inside Face Solar Radiation Heat Gain Rate",
209 "Surface Inside Face Solar Radiation Heat Gain Rate per Area",
210 "Surface Inside Face Solar Radiation Heat Gain Energy",
211 "Surface Inside Face Beam Solar Radiation Heat Gain Rate",
212 "Surface Inside Face Absorbed Shortwave Radiation Rate",
213 "Surface Inside Face Lights Radiation Heat Gain Rate",
214 "Surface Inside Face Lights Radiation Heat Gain Rate per Area",
215 "Surface Inside Face Lights Radiation Heat Gain Energy",
216 "Surface Inside Face Internal Gains Radiation Heat Gain Rate",
217 "Surface Inside Face Internal Gains Radiation Heat Gain Rate per Area",
218 "Surface Inside Face Internal Gains Radiation Heat Gain Energy",
219 "Surface Inside Face System Radiation Heat Gain Rate",
220 "Surface Inside Face System Radiation Heat Gain Rate per Area",
221 "Surface Inside Face System Radiation Heat Gain Energy",
222 "Surface Inside Face Exterior Windows Incident Beam Solar Radiation Rate",
223 "Surface Inside Face Exterior Windows Incident Beam Solar Radiation Rate per Area",
224 "Surface Inside Face Exterior Windows Incident Beam Solar Radiation Energy",
225 "Surface Inside Face Interior Windows Incident Beam Solar Radiation Rate",
226 "Surface Inside Face Interior Windows Incident Beam Solar Radiation Rate per Area",
227 "Surface Inside Face Interior Windows Incident Beam Solar Radiation Energy",
228 "Surface Inside Face Initial Transmitted Diffuse Absorbed Solar Radiation Rate",
229 "Surface Inside Face Initial Transmitted Diffuse Transmitted Out Window Solar Radiation Rate",
230 "Surface Outside Face Solar Radiation Heat Gain Rate",
231 "Surface Outside Face Solar Radiation Heat Gain Rate per Area",
232 "Surface Outside Face Solar Radiation Heat Gain Energy",
233 "Surface Outside Face Incident Solar Radiation Rate per Area",
234 "Surface Outside Face Incident Beam Solar Radiation Rate per Area",
235 "Surface Outside Face Incident Sky Diffuse Solar Radiation Rate per Area",
236 "Surface Outside Face Incident Ground Diffuse Solar Radiation Rate per Area",
237 "Surface Outside Face Incident Sky Diffuse Ground Reflected Solar Radiation Rate per Area",
238 "Surface Outside Face Incident Sky Diffuse Surface Reflected Solar Radiation Rate per Area",
239 "Surface Outside Face Incident Beam To Beam Surface Reflected Solar Radiation Rate per Area",
240 "Surface Outside Face Incident Beam To Diffuse Surface Reflected Solar Radiation Rate per Area",
241 "Surface Outside Face Incident Beam To Diffuse Ground Reflected Solar Radiation Rate per Area",
242 "Surface Outside Face Beam Solar Incident Angle Cosine Value",
243 "Surface Anisotropic Sky Multiplier",
244 "Surface Outside Face Sunlit Area",
245 "Surface Outside Face Sunlit Fraction",
246 "Surface Thermal Absorptance",
247 "Surface Solar Absorptance",
248 // Conduction and heat storage (opaque surfaces)
249 "Surface Inside Face Conduction Heat Transfer Rate",
250 "Surface Inside Face Conduction Heat Gain Rate",
251 "Surface Inside Face Conduction Heat Loss Rate",
252 "Surface Inside Face Conduction Heat Transfer Rate per Area",
253 "Surface Inside Face Conduction Heat Transfer Energy",
254 "Surface Outside Face Conduction Heat Transfer Rate",
255 "Surface Outside Face Conduction Heat Gain Rate",
256 "Surface Outside Face Conduction Heat Loss Rate",
257 "Surface Outside Face Conduction Heat Transfer Rate per Area",
258 "Surface Outside Face Conduction Heat Transfer Energy",
259 "Surface Average Face Conduction Heat Transfer Rate",
260 "Surface Average Face Conduction Heat Gain Rate",
261 "Surface Average Face Conduction Heat Loss Rate",
262 "Surface Average Face Conduction Heat Transfer Rate per Area",
263 "Surface Average Face Conduction Heat Transfer Energy",
264 "Surface Heat Storage Rate",
265 "Surface Heat Storage Gain Rate",
266 "Surface Heat Storage Loss Rate",
267 "Surface Heat Storage Rate per Area",
268 "Surface Heat Storage Energy",
269 // Other Side Coefficients / Conditions Model heat source
270 "Surface Inside Face Heat Source Gain Rate per Area",
271 "Surface Outside Face Heat Source Gain Rate per Area",
272 // Exterior environment conditions
273 "Surface Outside Face Outdoor Air Drybulb Temperature",
274 "Surface Outside Face Outdoor Air Wetbulb Temperature",
275 "Surface Outside Face Outdoor Air Wind Speed",
276 "Surface Outside Face Outdoor Air Wind Direction",
277
278 // Advanced Variables available only if Output:Diagnostics 'DisplayAdvancedReportVariables' is on
279 "Surface Construction Index",
280
6/11
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 28 times.
✓ Branch 3 taken 164 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 164 times.
✓ Branch 10 taken 16072 times.
✓ Branch 11 taken 164 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
16592 };
281 192 return result;
282 492 }
283
284 104 IddObjectType Surface_Impl::iddObjectType() const {
285 104 return Surface::iddObjectType();
286 }
287
288 ✗ bool Surface_Impl::subtractFromGrossArea() const {
289 ✗ return false;
290 }
291
292 49648 boost::optional<ConstructionBase> Surface_Impl::construction() const {
293 // DLM: there is duplicate code in ForwardTranslator::resolveMatchedSurfaceConstructionConflicts
294 // if you update this code you must update that code
295
296 // DLM: I am not sure we should be doing this here at all, maybe this method should just
297 // return the same thing constructionWithSearchDistance does?
298
299
1/1
✓ Branch 1 taken 49648 times.
49648 boost::optional<std::pair<ConstructionBase, int>> constructionWithSearchDistance = this->constructionWithSearchDistance();
300
301
1/1
✓ Branch 1 taken 49648 times.
49648 model::OptionalSurface adjacentSurface = this->adjacentSurface();
302
2/2
✓ Branch 1 taken 36884 times.
✓ Branch 2 taken 12764 times.
49648 if (!adjacentSurface) {
303
2/2
✓ Branch 0 taken 18916 times.
✓ Branch 1 taken 17968 times.
36884 if (constructionWithSearchDistance) {
304
2/2
✓ Branch 1 taken 18916 times.
✓ Branch 4 taken 18916 times.
18916 return constructionWithSearchDistance->first;
305 }
306 17968 return boost::none;
307 }
308
309 boost::optional<std::pair<model::ConstructionBase, int>> adjacentConstructionWithSearchDistance =
310
2/2
✓ Branch 1 taken 12764 times.
✓ Branch 4 taken 12764 times.
12764 adjacentSurface->constructionWithSearchDistance();
311
312
6/6
✓ Branch 0 taken 10820 times.
✓ Branch 1 taken 1944 times.
✓ Branch 3 taken 860 times.
✓ Branch 4 taken 9960 times.
✓ Branch 5 taken 860 times.
✓ Branch 6 taken 11904 times.
12764 if (constructionWithSearchDistance && !adjacentConstructionWithSearchDistance) {
313 // return this construction
314
2/2
✓ Branch 1 taken 860 times.
✓ Branch 4 taken 860 times.
860 return constructionWithSearchDistance->first;
315 }
316
317
6/6
✓ Branch 1 taken 1944 times.
✓ Branch 2 taken 9960 times.
✓ Branch 3 taken 640 times.
✓ Branch 4 taken 1304 times.
✓ Branch 5 taken 640 times.
✓ Branch 6 taken 11264 times.
13848 if (!constructionWithSearchDistance && adjacentConstructionWithSearchDistance) {
318 // return adjacent construction
319
2/2
✓ Branch 1 taken 640 times.
✓ Branch 4 taken 640 times.
640 return adjacentConstructionWithSearchDistance->first;
320 }
321
322
5/6
✓ Branch 1 taken 1304 times.
✓ Branch 2 taken 9960 times.
✓ Branch 4 taken 1304 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1304 times.
✓ Branch 7 taken 9960 times.
11264 if (!constructionWithSearchDistance && !adjacentConstructionWithSearchDistance) {
323 // no constructions, nothing to be done
324 1304 return boost::none;
325 }
326
327 // both surfaces return a construction
328
329
7/7
✓ Branch 1 taken 9960 times.
✓ Branch 4 taken 9960 times.
✓ Branch 7 taken 9960 times.
✓ Branch 10 taken 9960 times.
✓ Branch 13 taken 9960 times.
✓ Branch 15 taken 8000 times.
✓ Branch 16 taken 1960 times.
9960 if (constructionWithSearchDistance->first.handle() == adjacentConstructionWithSearchDistance->first.handle()) {
330 // both surfaces have same construction
331
2/2
✓ Branch 1 taken 8000 times.
✓ Branch 4 taken 8000 times.
8000 return constructionWithSearchDistance->first;
332 }
333
334 // both surfaces return a construction and they are not the same
335
336
4/4
✓ Branch 1 taken 1960 times.
✓ Branch 4 taken 1960 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 1954 times.
1960 if (constructionWithSearchDistance->second < adjacentConstructionWithSearchDistance->second) {
337 // lower search distance to construction
338
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 return constructionWithSearchDistance->first;
339 }
340
341
4/4
✓ Branch 1 taken 1954 times.
✓ Branch 4 taken 1954 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 1948 times.
1954 if (constructionWithSearchDistance->second > adjacentConstructionWithSearchDistance->second) {
342 // lower search distance to adjacent construction
343
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 return adjacentConstructionWithSearchDistance->first;
344 }
345
346 // both surfaces return a construction, they are not the same, and both have same search distance
347
348
2/5
✓ Branch 1 taken 1948 times.
✓ Branch 4 taken 1948 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3896 if (constructionWithSearchDistance->first.optionalCast<model::LayeredConstruction>()
349
7/13
✓ Branch 1 taken 1948 times.
✓ Branch 4 taken 1948 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1948 times.
✓ Branch 10 taken 1948 times.
✓ Branch 13 taken 1948 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 1948 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1948 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
7792 && adjacentConstructionWithSearchDistance->first.optionalCast<model::LayeredConstruction>()) {
350
4/5
✓ Branch 1 taken 1948 times.
✓ Branch 4 taken 1948 times.
✓ Branch 7 taken 1948 times.
✓ Branch 9 taken 1948 times.
✗ Branch 10 not taken.
5844 if (constructionWithSearchDistance->first.cast<model::LayeredConstruction>().reverseEqualLayers(
351
2/2
✓ Branch 1 taken 1948 times.
✓ Branch 4 taken 1948 times.
3896 adjacentConstructionWithSearchDistance->first.cast<model::LayeredConstruction>())) {
352 // these constructions are reverse equal
353
2/2
✓ Branch 1 taken 1948 times.
✓ Branch 4 taken 1948 times.
1948 return constructionWithSearchDistance->first;
354 }
355 }
356
357 // give up for now, we can add more later
358 // DLM: should we return empty or this construction?
359 ✗ return constructionWithSearchDistance->first;
360 49648 }
361
362 63509 boost::optional<std::pair<ConstructionBase, int>> Surface_Impl::constructionWithSearchDistance() const {
363 63509 boost::optional<std::pair<ConstructionBase, int>> result;
364
365 boost::optional<ConstructionBase> construction =
366
2/2
✓ Branch 1 taken 63509 times.
✓ Branch 4 taken 63509 times.
63509 getObject<ModelObject>().getModelObjectTarget<ConstructionBase>(OS_SurfaceFields::ConstructionName);
367
2/2
✓ Branch 0 taken 20646 times.
✓ Branch 1 taken 42863 times.
63509 if (construction) {
368
3/3
✓ Branch 1 taken 20646 times.
✓ Branch 4 taken 20646 times.
✓ Branch 7 taken 20646 times.
20646 return std::make_pair(*construction, 0);
369 }
370
371
1/1
✓ Branch 1 taken 42863 times.
42863 boost::optional<Space> space = this->space();
372
2/2
✓ Branch 0 taken 42858 times.
✓ Branch 1 taken 5 times.
42863 if (space) {
373
3/3
✓ Branch 1 taken 42858 times.
✓ Branch 4 taken 42858 times.
✓ Branch 7 taken 42858 times.
42858 result = space->getDefaultConstructionWithSearchDistance(this->getObject<Surface>());
374 }
375 42863 return result;
376 63509 }
377
378 193 bool Surface_Impl::isConstructionDefaulted() const {
379 193 return isEmpty(OS_SurfaceFields::ConstructionName);
380 }
381
382 46059 bool Surface_Impl::setVertices(const std::vector<Point3d>& vertices) {
383 46059 bool result = PlanarSurface_Impl::setVertices(vertices);
384
385
2/2
✓ Branch 1 taken 26054 times.
✓ Branch 2 taken 20005 times.
46059 if (isEmpty(OS_SurfaceFields::SurfaceType)) {
386
2/2
✓ Branch 0 taken 26051 times.
✓ Branch 1 taken 3 times.
26054 if (result) {
387 26051 this->assignDefaultSurfaceType(false);
388 26050 this->assignDefaultBoundaryCondition(false);
389 26050 this->assignDefaultSunExposure(false);
390 26050 this->assignDefaultWindExposure(false);
391 26050 this->emitChangeSignals(); // emit signals here
392 } else {
393
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 LOG(Error, "Cannot compute default Surface properties.");
394 }
395 }
396
397 46058 return result;
398 }
399
400 3185 bool Surface_Impl::setConstruction(const ConstructionBase& construction) {
401
2/2
✓ Branch 1 taken 3185 times.
✓ Branch 4 taken 3185 times.
3185 return setPointer(OS_SurfaceFields::ConstructionName, construction.handle());
402 }
403
404 896 void Surface_Impl::resetConstruction() {
405
2/2
✓ Branch 1 taken 896 times.
✓ Branch 4 taken 896 times.
1792 setString(OS_SurfaceFields::ConstructionName, "");
406 896 }
407
408 357286 std::string Surface_Impl::surfaceType() const {
409
1/1
✓ Branch 1 taken 357286 times.
357286 boost::optional<std::string> value = getString(OS_SurfaceFields::SurfaceType, true, true);
410
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 357286 times.
✗ Branch 4 not taken.
357286 OS_ASSERT(value);
411
2/2
✓ Branch 1 taken 357286 times.
✓ Branch 4 taken 357286 times.
714572 return value.get();
412 357286 }
413
414 ✗ std::vector<std::string> Surface_Impl::surfaceTypeValues() const {
415 ✗ return Surface::validSurfaceTypeValues();
416 }
417
418 330856 std::string Surface_Impl::outsideBoundaryCondition() const {
419
1/1
✓ Branch 1 taken 330856 times.
330856 boost::optional<std::string> value = getString(OS_SurfaceFields::OutsideBoundaryCondition, true);
420
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 330856 times.
✗ Branch 4 not taken.
330856 OS_ASSERT(value);
421
2/2
✓ Branch 1 taken 330856 times.
✓ Branch 4 taken 330856 times.
661712 return value.get();
422 330856 }
423
424 ✗ std::vector<std::string> Surface_Impl::outsideBoundaryConditionValues() const {
425 ✗ return Surface::validOutsideBoundaryConditionValues();
426 }
427
428 311 bool Surface_Impl::isGroundSurface() const {
429
1/1
✓ Branch 1 taken 311 times.
311 std::string outsideBoundaryCondition = this->outsideBoundaryCondition();
430
431
11/21
✓ Branch 1 taken 311 times.
✓ Branch 4 taken 146 times.
✓ Branch 7 taken 146 times.
✓ Branch 9 taken 145 times.
✓ Branch 10 taken 1 time.
✓ Branch 12 taken 146 times.
✓ Branch 13 taken 165 times.
✓ Branch 14 taken 311 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 311 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 166 times.
✓ Branch 20 taken 145 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1225 if (istringEqual("Ground", outsideBoundaryCondition) || istringEqual("GroundFCfactorMethod", outsideBoundaryCondition)
432
7/12
✓ Branch 1 taken 145 times.
✓ Branch 4 taken 145 times.
✓ Branch 6 taken 145 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 145 times.
✓ Branch 10 taken 166 times.
✓ Branch 11 taken 146 times.
✓ Branch 12 taken 165 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
601 || istringEqual("GroundSlabPreprocessorAverage", outsideBoundaryCondition)
433
7/12
✓ Branch 1 taken 145 times.
✓ Branch 4 taken 145 times.
✓ Branch 6 taken 145 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 145 times.
✓ Branch 10 taken 166 times.
✓ Branch 11 taken 145 times.
✓ Branch 12 taken 166 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
601 || istringEqual("GroundSlabPreprocessorCore", outsideBoundaryCondition)
434
7/12
✓ Branch 1 taken 145 times.
✓ Branch 4 taken 145 times.
✓ Branch 6 taken 145 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 145 times.
✓ Branch 10 taken 166 times.
✓ Branch 11 taken 145 times.
✓ Branch 12 taken 166 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
601 || istringEqual("GroundSlabPreprocessorPerimeter", outsideBoundaryCondition)
435
7/12
✓ Branch 1 taken 145 times.
✓ Branch 4 taken 145 times.
✓ Branch 6 taken 145 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 145 times.
✓ Branch 10 taken 166 times.
✓ Branch 11 taken 145 times.
✓ Branch 12 taken 166 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
601 || istringEqual("GroundBasementPreprocessorAverageWall", outsideBoundaryCondition)
436
7/12
✓ Branch 1 taken 145 times.
✓ Branch 4 taken 145 times.
✓ Branch 6 taken 145 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 145 times.
✓ Branch 10 taken 166 times.
✓ Branch 11 taken 145 times.
✓ Branch 12 taken 166 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
601 || istringEqual("GroundBasementPreprocessorAverageFloor", outsideBoundaryCondition)
437
7/12
✓ Branch 1 taken 145 times.
✓ Branch 4 taken 145 times.
✓ Branch 6 taken 145 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 145 times.
✓ Branch 10 taken 166 times.
✓ Branch 11 taken 145 times.
✓ Branch 12 taken 166 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
601 || istringEqual("GroundBasementPreprocessorUpperWall", outsideBoundaryCondition)
438
19/29
✓ Branch 1 taken 311 times.
✓ Branch 3 taken 146 times.
✓ Branch 4 taken 165 times.
✓ Branch 6 taken 145 times.
✓ Branch 9 taken 145 times.
✓ Branch 11 taken 145 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 145 times.
✓ Branch 17 taken 145 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 145 times.
✓ Branch 21 taken 145 times.
✓ Branch 22 taken 166 times.
✓ Branch 24 taken 145 times.
✓ Branch 25 taken 166 times.
✓ Branch 26 taken 145 times.
✓ Branch 27 taken 166 times.
✓ Branch 29 taken 145 times.
✓ Branch 30 taken 166 times.
✓ Branch 31 taken 145 times.
✓ Branch 32 taken 166 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
1203 || istringEqual("GroundBasementPreprocessorLowerWall", outsideBoundaryCondition) || istringEqual("Foundation", outsideBoundaryCondition)) {
439 166 return true;
440 }
441
442 145 return false;
443 311 }
444
445 28315 std::string Surface_Impl::sunExposure() const {
446
1/1
✓ Branch 1 taken 28315 times.
28315 boost::optional<std::string> value = getString(OS_SurfaceFields::SunExposure, true);
447
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 28315 times.
✗ Branch 4 not taken.
28315 OS_ASSERT(value);
448
2/2
✓ Branch 1 taken 28315 times.
✓ Branch 4 taken 28315 times.
56630 return value.get();
449 28315 }
450
451 ✗ std::vector<std::string> Surface_Impl::sunExposureValues() const {
452 ✗ return Surface::validSunExposureValues();
453 }
454
455 3261 bool Surface_Impl::isSunExposureDefaulted() const {
456 3261 return isEmpty(OS_SurfaceFields::SunExposure);
457 }
458
459 27243 std::string Surface_Impl::windExposure() const {
460
1/1
✓ Branch 1 taken 27243 times.
27243 boost::optional<std::string> value = getString(OS_SurfaceFields::WindExposure, true);
461
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 27243 times.
✗ Branch 4 not taken.
27243 OS_ASSERT(value);
462
2/2
✓ Branch 1 taken 27243 times.
✓ Branch 4 taken 27243 times.
54486 return value.get();
463 27243 }
464
465 ✗ std::vector<std::string> Surface_Impl::windExposureValues() const {
466 ✗ return Surface::validWindExposureValues();
467 }
468
469 3261 bool Surface_Impl::isWindExposureDefaulted() const {
470 3261 return isEmpty(OS_SurfaceFields::WindExposure);
471 }
472
473 3261 boost::optional<double> Surface_Impl::viewFactortoGround() const {
474 3261 return getDouble(OS_SurfaceFields::ViewFactortoGround, true);
475 }
476
477 ✗ bool Surface_Impl::isViewFactortoGroundDefaulted() const {
478 ✗ return isEmpty(OS_SurfaceFields::ViewFactortoGround);
479 }
480
481 1 bool Surface_Impl::isViewFactortoGroundAutocalculated() const {
482 1 bool result = false;
483
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<std::string> value = getString(OS_SurfaceFields::ViewFactortoGround, true);
484
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (value) {
485
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
2 result = openstudio::istringEqual(value.get(), "Autocalculate");
486 }
487 1 return result;
488 1 }
489
490 ✗ boost::optional<double> Surface_Impl::numberofVertices() const {
491 ✗ return getDouble(OS_SurfaceFields::NumberofVertices, true);
492 }
493
494 ✗ bool Surface_Impl::isNumberofVerticesDefaulted() const {
495 ✗ return isEmpty(OS_SurfaceFields::NumberofVertices);
496 }
497
498 1 bool Surface_Impl::isNumberofVerticesAutocalculated() const {
499 1 bool result = false;
500
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<std::string> value = getString(OS_SurfaceFields::NumberofVertices, true);
501
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (value) {
502
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
2 result = openstudio::istringEqual(value.get(), "Autocalculate");
503 }
504 1 return result;
505 1 }
506
507 16338 bool Surface_Impl::setSurfaceType(const std::string& surfaceType) {
508 16338 return setSurfaceType(surfaceType, true);
509 }
510
511 69211 bool Surface_Impl::setSurfaceType(const std::string& surfaceType, bool driverMethod) {
512 69211 bool result = setString(OS_SurfaceFields::SurfaceType, surfaceType, true);
513
2/2
✓ Branch 0 taken 17112 times.
✓ Branch 1 taken 52099 times.
69211 if (driverMethod) {
514 17112 this->emitChangeSignals(); // emit signals here
515 }
516 69211 return result;
517 }
518
519 2064 bool Surface_Impl::setOutsideBoundaryCondition(const std::string& outsideBoundaryCondition) {
520 2064 return setOutsideBoundaryCondition(outsideBoundaryCondition, true);
521 }
522
523 54327 bool Surface_Impl::setOutsideBoundaryCondition(const std::string& outsideBoundaryCondition, bool driverMethod) {
524 54327 bool result = false;
525
526
1/1
✓ Branch 1 taken 54327 times.
54327 boost::optional<Surface> adjacentSurface = this->adjacentSurface();
527
1/1
✓ Branch 1 taken 54327 times.
54327 boost::optional<SurfacePropertyOtherSideCoefficients> surfacePropertyOtherSideCoefficients = this->surfacePropertyOtherSideCoefficients();
528 boost::optional<SurfacePropertyOtherSideConditionsModel> surfacePropertyOtherSideConditionsModel =
529
1/1
✓ Branch 1 taken 54327 times.
54327 this->surfacePropertyOtherSideConditionsModel();
530
531
4/4
✓ Branch 1 taken 54327 times.
✓ Branch 4 taken 54327 times.
✓ Branch 7 taken 95 times.
✓ Branch 8 taken 54232 times.
108654 if (istringEqual("Surface", outsideBoundaryCondition)) {
532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if (adjacentSurface) {
533 ✗ result = setString(OS_SurfaceFields::OutsideBoundaryCondition, outsideBoundaryCondition, true);
534 }
535
3/4
✓ Branch 1 taken 54232 times.
✓ Branch 4 taken 54232 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54232 times.
108464 } else if (istringEqual("OtherSideCoefficients", outsideBoundaryCondition)) {
536 ✗ if (surfacePropertyOtherSideCoefficients) {
537 ✗ result = setString(OS_SurfaceFields::OutsideBoundaryCondition, outsideBoundaryCondition, true);
538 }
539
3/4
✓ Branch 1 taken 54232 times.
✓ Branch 4 taken 54232 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54232 times.
108464 } else if (istringEqual("OtherSideConditionsModel", outsideBoundaryCondition)) {
540 ✗ if (surfacePropertyOtherSideConditionsModel) {
541 ✗ result = setString(OS_SurfaceFields::OutsideBoundaryCondition, outsideBoundaryCondition, true);
542 }
543 } else {
544
1/1
✓ Branch 1 taken 54232 times.
54232 this->resetAdjacentSurface();
545
1/1
✓ Branch 1 taken 54232 times.
54232 this->resetSurfacePropertyOtherSideCoefficients();
546
1/1
✓ Branch 1 taken 54232 times.
54232 this->resetSurfacePropertyOtherSideConditionsModel();
547
1/1
✓ Branch 1 taken 54232 times.
54232 result = setString(OS_SurfaceFields::OutsideBoundaryCondition, outsideBoundaryCondition, true);
548
2/2
✓ Branch 0 taken 54226 times.
✓ Branch 1 taken 6 times.
54232 if (result) {
549
1/1
✓ Branch 1 taken 54226 times.
54226 this->assignDefaultSunExposure(false);
550
1/1
✓ Branch 1 taken 54226 times.
54226 this->assignDefaultWindExposure(false);
551
552
4/4
✓ Branch 1 taken 54226 times.
✓ Branch 4 taken 54226 times.
✓ Branch 7 taken 834 times.
✓ Branch 8 taken 53392 times.
108452 if (istringEqual("Adiabatic", outsideBoundaryCondition)) {
553 // remove all subsurfaces
554 834 int n_subsurfaces = 0;
555
2/3
✓ Branch 1 taken 834 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 834 times.
834 for (auto& subSurface : subSurfaces()) {
556 ✗ subSurface.remove();
557 ✗ ++n_subsurfaces;
558 834 }
559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 834 times.
834 if (n_subsurfaces > 0) {
560 // Note JM 2019-03-05: Warn user, it's not obvious that this is happening and they might try to access again
561 // one of these subsurfaces which are now disconnected objects
562 ✗ LOG(Warn, "Setting the Outside Boundary Condition for Surface '" << this->nameString() << "' to 'Adiabatic', removed " << n_subsurfaces
563 << " SubSurfaces.");
564 }
565 }
566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 } else if (adjacentSurface) {
567 // restore the adjacent surface if set boundary condition fails
568 ✗ bool test = setAdjacentSurface(*adjacentSurface);
569 ✗ OS_ASSERT(test);
570
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 5 times.
6 } else if (surfacePropertyOtherSideCoefficients) {
571 // restore the surfacePropertyOtherSideCoefficientse if set boundary condition fails
572
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 bool test = setSurfacePropertyOtherSideCoefficients(*surfacePropertyOtherSideCoefficients);
573
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
1 OS_ASSERT(test);
574
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 4 times.
5 } else if (surfacePropertyOtherSideConditionsModel) {
575 // restore the surfacePropertyOtherSideConditionsModel if set boundary condition fails
576
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 bool test = setSurfacePropertyOtherSideConditionsModel(*surfacePropertyOtherSideConditionsModel);
577
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
1 OS_ASSERT(test);
578 }
579 }
580
581
2/2
✓ Branch 0 taken 2228 times.
✓ Branch 1 taken 52099 times.
54327 if (driverMethod) {
582
1/1
✓ Branch 1 taken 2228 times.
2228 this->emitChangeSignals(); // emit signals here
583 }
584
585 54327 return result;
586 54327 }
587
588 2141 bool Surface_Impl::setSunExposure(const std::string& sunExposure) {
589 2141 return setSunExposure(sunExposure, true);
590 }
591
592 139479 bool Surface_Impl::setSunExposure(const std::string& sunExposure, bool driverMethod) {
593 139479 bool result = setString(OS_SurfaceFields::SunExposure, sunExposure, true);
594
2/2
✓ Branch 0 taken 33154 times.
✓ Branch 1 taken 106325 times.
139479 if (driverMethod) {
595 33154 this->emitChangeSignals(); // emit signals here
596 }
597 139479 return result;
598 }
599
600 ✗ void Surface_Impl::resetSunExposure() {
601 ✗ bool result = setString(OS_SurfaceFields::SunExposure, "");
602 ✗ OS_ASSERT(result);
603 ✗ }
604
605 2141 bool Surface_Impl::setWindExposure(const std::string& windExposure) {
606 2141 return setWindExposure(windExposure, true);
607 }
608
609 139479 bool Surface_Impl::setWindExposure(const std::string& windExposure, bool driverMethod) {
610 139479 bool result = setString(OS_SurfaceFields::WindExposure, windExposure, true);
611
2/2
✓ Branch 0 taken 33154 times.
✓ Branch 1 taken 106325 times.
139479 if (driverMethod) {
612 33154 this->emitChangeSignals(); // emit signals here
613 }
614 139479 return result;
615 }
616
617 ✗ void Surface_Impl::resetWindExposure() {
618 ✗ bool result = setString(OS_SurfaceFields::WindExposure, "");
619 ✗ OS_ASSERT(result);
620 ✗ }
621
622 ✗ bool Surface_Impl::setViewFactortoGround(boost::optional<double> viewFactortoGround) {
623 ✗ bool result = false;
624 ✗ if (viewFactortoGround) {
625 ✗ result = setDouble(OS_SurfaceFields::ViewFactortoGround, viewFactortoGround.get());
626 } else {
627 ✗ result = setString(OS_SurfaceFields::ViewFactortoGround, "");
628 }
629 ✗ return result;
630 }
631
632 30 bool Surface_Impl::setViewFactortoGround(double viewFactortoGround) {
633 30 bool result = setDouble(OS_SurfaceFields::ViewFactortoGround, viewFactortoGround);
634 30 return result;
635 }
636
637 ✗ void Surface_Impl::resetViewFactortoGround() {
638 ✗ bool result = setString(OS_SurfaceFields::ViewFactortoGround, "");
639 ✗ OS_ASSERT(result);
640 ✗ }
641
642 1 void Surface_Impl::autocalculateViewFactortoGround() {
643
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_SurfaceFields::ViewFactortoGround, "Autocalculate");
644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
645 1 }
646
647 ✗ bool Surface_Impl::setNumberofVertices(boost::optional<double> numberofVertices) {
648 ✗ bool result = false;
649 ✗ if (numberofVertices) {
650 ✗ result = setDouble(OS_SurfaceFields::NumberofVertices, numberofVertices.get());
651 } else {
652 ✗ result = setString(OS_SurfaceFields::NumberofVertices, "");
653 }
654 ✗ return result;
655 }
656
657 ✗ bool Surface_Impl::setNumberofVertices(double numberofVertices) {
658 ✗ bool result = setDouble(OS_SurfaceFields::NumberofVertices, numberofVertices);
659 ✗ return result;
660 }
661
662 ✗ void Surface_Impl::resetNumberofVertices() {
663 ✗ bool result = setString(OS_SurfaceFields::NumberofVertices, "");
664 ✗ OS_ASSERT(result);
665 ✗ }
666
667 1 void Surface_Impl::autocalculateNumberofVertices() {
668
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_SurfaceFields::NumberofVertices, "Autocalculate");
669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
670 1 }
671
672 1470927 SubSurfaceVector Surface_Impl::subSurfaces() const {
673 1470927 SubSurfaceVector result;
674
1/1
✓ Branch 1 taken 1470927 times.
1470927 auto object = getObject<ModelObject>();
675
2/2
✓ Branch 1 taken 1470927 times.
✓ Branch 4 taken 1470927 times.
1470927 WorkspaceObjectVector idfSubSurfaces = object.getSources(IddObjectType(IddObjectType::OS_SubSurface));
676
2/2
✓ Branch 5 taken 25027 times.
✓ Branch 6 taken 1470927 times.
1495954 for (const WorkspaceObject& idfSubSurface : idfSubSurfaces) {
677
3/3
✓ Branch 1 taken 25027 times.
✓ Branch 4 taken 25027 times.
✓ Branch 7 taken 25027 times.
25027 OptionalSubSurface subSurface = this->model().getModelObject<SubSurface>(idfSubSurface.handle());
678
1/2
✓ Branch 0 taken 25027 times.
✗ Branch 1 not taken.
25027 if (subSurface) {
679
2/2
✓ Branch 1 taken 25027 times.
✓ Branch 4 taken 25027 times.
25027 result.push_back(*subSurface);
680 }
681 25027 }
682 2941854 return result;
683 1470927 }
684
685 57801 boost::optional<PlanarSurfaceGroup> Surface_Impl::planarSurfaceGroup() const {
686
2/2
✓ Branch 1 taken 57801 times.
✓ Branch 4 taken 57801 times.
57801 return boost::optional<PlanarSurfaceGroup>(this->space());
687 }
688
689 1187377 boost::optional<Space> Surface_Impl::space() const {
690 1187377 boost::optional<Space> result;
691
1/1
✓ Branch 1 taken 1187377 times.
1187377 OptionalWorkspaceObject space = getTarget(OS_SurfaceFields::SpaceName);
692
2/2
✓ Branch 0 taken 1186622 times.
✓ Branch 1 taken 755 times.
1187377 if (space) {
693
2/2
✓ Branch 1 taken 1186622 times.
✓ Branch 4 taken 1186622 times.
1186622 result = space->optionalCast<Space>();
694 }
695 2374754 return result;
696 1187377 }
697
698 2 boost::optional<double> Surface_Impl::uFactor() const {
699
1/1
✓ Branch 1 taken 2 times.
2 OptionalConstructionBase oConstruction = construction();
700 2 OptionalDouble result;
701
702
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (oConstruction) {
703 // from input
704
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 OptionalDouble inputResult = oConstruction->uFactor(filmResistance());
705
706 // from output
707
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalSqlFile sqlFile = model().sqlFile();
708
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalString constructionName = oConstruction->name();
709 2 OptionalDouble outputResult;
710
1/1
✓ Branch 1 taken 2 times.
2 OptionalString surfaceName = name();
711
712 // opaque exterior
713
6/10
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
4 if (sqlFile && constructionName && oConstruction->isOpaque()) {
714
1/1
✓ Branch 1 taken 2 times.
2 std::string query = R"(SELECT Value from TabularDataWithStrings
715 WHERE ReportName = 'EnvelopeSummary'
716 AND ReportForString = 'Entire Facility'
717 AND TableName = 'Opaque Exterior'
718 AND ColumnName = 'U-Factor with Film'
719 AND Units='W/m2-K'
720 AND RowName = ?;)";
721
4/4
✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 11 taken 2 times.
2 outputResult = sqlFile->execAndReturnFirstDouble(query, to_upper_copy(*surfaceName));
722 2 }
723
724 // fenestration
725
6/10
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
4 if (sqlFile && constructionName && oConstruction->isFenestration()) {
726 ✗ std::string query = R"(SELECT Value from TabularDataWithStrings
727 WHERE ReportName = 'EnvelopeSummary'
728 AND ReportForString = 'Entire Facility'
729 AND TableName = 'Exterior Fenestration'
730 AND ColumnName = 'Glass U-Factor'
731 AND Units='W/m2-K'
732 AND RowName = ?;)";
733 ✗ outputResult = sqlFile->execAndReturnFirstDouble(query, to_upper_copy(*surfaceName));
734 ✗ }
735
736
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (inputResult) {
737 2 result = inputResult;
738
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (outputResult) {
739
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.
6 compareInputAndOutput(*oConstruction, "uFactor", *inputResult, *outputResult, 1.0E-3);
740 }
741 } else {
742 ✗ result = outputResult;
743 }
744 2 }
745
746 2 return result;
747 2 }
748
749 2 boost::optional<double> Surface_Impl::thermalConductance() const {
750
1/1
✓ Branch 1 taken 2 times.
2 OptionalConstructionBase oConstruction = construction();
751 2 OptionalDouble result;
752
753
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (oConstruction) {
754 // from input
755
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 OptionalDouble inputResult = oConstruction->thermalConductance(filmResistance());
756
757 // from output
758
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalSqlFile sqlFile = model().sqlFile();
759
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalString constructionName = oConstruction->name();
760 2 OptionalDouble outputResult;
761
1/1
✓ Branch 1 taken 2 times.
2 OptionalString surfaceName = name();
762
763 // opaque exterior
764
6/10
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
4 if (sqlFile && constructionName && oConstruction->isOpaque()) {
765
1/1
✓ Branch 1 taken 2 times.
2 std::string query = R"(SELECT Value from TabularDataWithStrings
766 WHERE ReportName = 'EnvelopeSummary'
767 AND ReportForString = 'Entire Facility'
768 AND TableName = 'Opaque Exterior'
769 AND ColumnName = 'U-Factor no Film'
770 AND Units='W/m2-K'
771 AND RowName = ?;)";
772
4/4
✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 11 taken 2 times.
2 outputResult = sqlFile->execAndReturnFirstDouble(query, to_upper_copy(*surfaceName));
773 2 }
774
775 // fenestration
776
6/10
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
4 if (sqlFile && constructionName && oConstruction->isFenestration()) {
777
778 // get u-factor, then subtract film coefficients
779 ✗ std::string query = R"(SELECT Value from TabularDataWithStrings
780 WHERE ReportName = 'EnvelopeSummary'
781 AND ReportForString = 'Entire Facility'
782 AND TableName = 'Exterior Fenestration'
783 AND ColumnName = 'Glass U-Factor'
784 AND Units='W/m2-K'
785 AND RowName = ?;)";
786 ✗ outputResult = sqlFile->execAndReturnFirstDouble(query, to_upper_copy(*surfaceName));
787
788 ✗ if (outputResult) {
789 ✗ outputResult = 1.0 / (1.0 / (*outputResult) - filmResistance());
790 }
791 ✗ }
792
793
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (inputResult) {
794 2 result = inputResult;
795
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (outputResult) {
796
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.
6 compareInputAndOutput(*oConstruction, "thermal conductance", *inputResult, *outputResult, 1.0E-5);
797 }
798 } else {
799 ✗ result = outputResult;
800 }
801 2 }
802
803 2 return result;
804 2 }
805
806 ✗ bool Surface_Impl::setUFactor(double value) {
807 ✗ OptionalConstructionBase oConstruction = this->construction();
808 ✗ if (oConstruction) {
809 ✗ return oConstruction->setUFactor(value, filmResistance());
810 }
811 ✗ return false;
812 ✗ }
813
814 ✗ bool Surface_Impl::setThermalConductance(double value) {
815 ✗ OptionalConstructionBase oConstruction = this->construction();
816 ✗ if (oConstruction) {
817 ✗ return oConstruction->setConductance(value, filmResistance());
818 }
819 ✗ return false;
820 ✗ }
821
822 30082 bool Surface_Impl::setSpace(const Space& space) {
823
2/2
✓ Branch 1 taken 30082 times.
✓ Branch 4 taken 30082 times.
30082 return setPointer(OS_SurfaceFields::SpaceName, space.handle());
824 }
825
826 2321756 boost::optional<Surface> Surface_Impl::adjacentSurface() const {
827
2/2
✓ Branch 1 taken 2321756 times.
✓ Branch 4 taken 2321756 times.
2321756 return getObject<Surface>().getModelObjectTarget<Surface>(OS_SurfaceFields::OutsideBoundaryConditionObject);
828 }
829
830 15422 bool Surface_Impl::setAdjacentSurface(Surface& surface) {
831
832 // matching surface with self is ok for stories with multipliers
833 15422 bool isSameSurface = false;
834
5/5
✓ Branch 1 taken 15422 times.
✓ Branch 4 taken 15422 times.
✓ Branch 7 taken 15422 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 15419 times.
15422 if (surface.handle() == this->handle()) {
835 3 isSameSurface = true;
836 }
837
838 // matching surface with other surface in same space is ok for stories with multipliers
839 //boost::optional<Space> thisSpace = this->space();
840 //boost::optional<Space> otherSpace = surface.space();
841 //if (!thisSpace || !otherSpace || (thisSpace->handle() == otherSpace->handle())){
842 // return false;
843 //}
844
845
1/1
✓ Branch 1 taken 15422 times.
15422 boost::optional<Surface> adjacentSurface = this->adjacentSurface();
846
1/1
✓ Branch 1 taken 15422 times.
15422 boost::optional<Surface> otherAdjacentSurface = surface.adjacentSurface();
847
848 // if other surface is pointing to this
849 15422 bool isNewMatch = true;
850
10/10
✓ Branch 0 taken 7188 times.
✓ Branch 1 taken 8234 times.
✓ Branch 3 taken 7188 times.
✓ Branch 6 taken 7188 times.
✓ Branch 9 taken 7188 times.
✓ Branch 12 taken 7188 times.
✓ Branch 14 taken 7185 times.
✓ Branch 15 taken 3 times.
✓ Branch 16 taken 7185 times.
✓ Branch 17 taken 8237 times.
15422 if (otherAdjacentSurface && (otherAdjacentSurface->handle() == this->handle())) {
851 // if this is pointing to other surface
852
7/10
✓ Branch 0 taken 7185 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 7185 times.
✓ Branch 6 taken 7185 times.
✓ Branch 9 taken 7185 times.
✓ Branch 12 taken 7185 times.
✓ Branch 14 taken 7185 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 7185 times.
✗ Branch 17 not taken.
7185 if (adjacentSurface && (adjacentSurface->handle() == surface.handle())) {
853 7185 isNewMatch = false;
854 }
855 }
856
857 // this is basically testing if surface is in same model as this
858
2/2
✓ Branch 1 taken 15422 times.
✓ Branch 4 taken 15422 times.
15422 bool test = this->setPointer(OS_SurfaceFields::OutsideBoundaryConditionObject, surface.handle());
859
1/2
✓ Branch 0 taken 15422 times.
✗ Branch 1 not taken.
15422 if (test) {
860
861 // clean all other surfaces pointing to this (unless it is surface)
862
4/4
✓ Branch 1 taken 15422 times.
✓ Branch 4 taken 15422 times.
✓ Branch 11 taken 7193 times.
✓ Branch 12 taken 15422 times.
22615 for (const WorkspaceObject& wo : this->getSources(IddObjectType::OS_Surface)) {
863
5/5
✓ Branch 1 taken 7193 times.
✓ Branch 4 taken 7193 times.
✓ Branch 7 taken 7193 times.
✓ Branch 9 taken 7188 times.
✓ Branch 10 taken 5 times.
7193 if (wo.handle() == surface.handle()) {
864 7188 continue;
865 }
866
867
1/1
✓ Branch 1 taken 5 times.
5 auto otherSurface = wo.cast<Surface>();
868
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 test = otherSurface.setString(OS_SurfaceFields::OutsideBoundaryConditionObject, "");
869
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 3 not taken.
5 OS_ASSERT(test);
870
1/1
✓ Branch 1 taken 5 times.
5 otherSurface.assignDefaultBoundaryCondition();
871
1/1
✓ Branch 1 taken 5 times.
5 otherSurface.assignDefaultSunExposure();
872
1/1
✓ Branch 1 taken 5 times.
5 otherSurface.assignDefaultWindExposure();
873
874
3/3
✓ Branch 1 taken 5 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 5 times.
7 for (SubSurface& subSurface : otherSurface.subSurfaces()) {
875
1/1
✓ Branch 1 taken 2 times.
2 subSurface.resetAdjacentSubSurface();
876 5 }
877 15427 }
878
879
2/2
✓ Branch 0 taken 15419 times.
✓ Branch 1 taken 3 times.
15422 if (!isSameSurface) {
880 // clean all other surfaces pointing to surface (unless it is this)
881
4/4
✓ Branch 1 taken 15419 times.
✓ Branch 4 taken 15419 times.
✓ Branch 11 taken 15421 times.
✓ Branch 12 taken 15419 times.
30840 for (const WorkspaceObject& wo : surface.getSources(IddObjectType::OS_Surface)) {
882
5/5
✓ Branch 1 taken 15421 times.
✓ Branch 4 taken 15421 times.
✓ Branch 7 taken 15421 times.
✓ Branch 9 taken 15419 times.
✓ Branch 10 taken 2 times.
15421 if (wo.handle() == this->handle()) {
883 15419 continue;
884 }
885
886
1/1
✓ Branch 1 taken 2 times.
2 auto otherSurface = wo.cast<Surface>();
887
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 test = otherSurface.setString(OS_SurfaceFields::OutsideBoundaryConditionObject, "");
888
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
2 OS_ASSERT(test);
889
1/1
✓ Branch 1 taken 2 times.
2 otherSurface.assignDefaultBoundaryCondition();
890
1/1
✓ Branch 1 taken 2 times.
2 otherSurface.assignDefaultSunExposure();
891
1/1
✓ Branch 1 taken 2 times.
2 otherSurface.assignDefaultWindExposure();
892
893
3/3
✓ Branch 1 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 2 times.
4 for (SubSurface& subSurface : otherSurface.subSurfaces()) {
894
1/1
✓ Branch 1 taken 2 times.
2 subSurface.resetAdjacentSubSurface();
895 2 }
896 15421 }
897 }
898
899 // this and surface are newly pointing to each other, clean sub surfaces on both
900
2/2
✓ Branch 0 taken 8237 times.
✓ Branch 1 taken 7185 times.
15422 if (isNewMatch) {
901
3/3
✓ Branch 1 taken 8237 times.
✓ Branch 8 taken 158 times.
✓ Branch 9 taken 8237 times.
8395 for (SubSurface& subSurface : this->subSurfaces()) {
902
1/1
✓ Branch 1 taken 158 times.
158 subSurface.resetAdjacentSubSurface();
903 8237 }
904
2/2
✓ Branch 0 taken 8234 times.
✓ Branch 1 taken 3 times.
8237 if (!isSameSurface) {
905
3/3
✓ Branch 1 taken 8234 times.
✓ Branch 8 taken 50 times.
✓ Branch 9 taken 8234 times.
8284 for (SubSurface& subSurface : surface.subSurfaces()) {
906
1/1
✓ Branch 1 taken 50 times.
50 subSurface.resetAdjacentSubSurface();
907 8234 }
908 }
909 }
910
911 // pointer was set up above, it may be unset during calls to resetAdjacentSubSurface above, just reset it here
912
2/2
✓ Branch 1 taken 15422 times.
✓ Branch 4 taken 15422 times.
15422 bool test = this->setPointer(OS_SurfaceFields::OutsideBoundaryConditionObject, surface.handle());
913
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15422 times.
✗ Branch 3 not taken.
15422 OS_ASSERT(test);
914
2/2
✓ Branch 1 taken 15422 times.
✓ Branch 4 taken 15422 times.
30844 test = this->setString(OS_SurfaceFields::OutsideBoundaryCondition, "Surface");
915
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15422 times.
✗ Branch 3 not taken.
15422 OS_ASSERT(test);
916
1/1
✓ Branch 1 taken 15422 times.
15422 this->assignDefaultSunExposure();
917
1/1
✓ Branch 1 taken 15422 times.
15422 this->assignDefaultWindExposure();
918
919
2/2
✓ Branch 0 taken 15419 times.
✓ Branch 1 taken 3 times.
15422 if (!isSameSurface) {
920
2/2
✓ Branch 1 taken 15419 times.
✓ Branch 4 taken 15419 times.
15419 test = surface.setPointer(OS_SurfaceFields::OutsideBoundaryConditionObject, this->handle());
921
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15419 times.
✗ Branch 3 not taken.
15419 OS_ASSERT(test);
922
2/2
✓ Branch 1 taken 15419 times.
✓ Branch 4 taken 15419 times.
30838 test = surface.setString(OS_SurfaceFields::OutsideBoundaryCondition, "Surface");
923
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15419 times.
✗ Branch 3 not taken.
15419 OS_ASSERT(test);
924
1/1
✓ Branch 1 taken 15419 times.
15419 surface.assignDefaultSunExposure();
925
1/1
✓ Branch 1 taken 15419 times.
15419 surface.assignDefaultWindExposure();
926 }
927 }
928 15422 return test;
929 15422 }
930
931 54307 void Surface_Impl::resetAdjacentSurface() {
932
933 bool test;
934
935 // need to be careful to only call assignDefaultBoundaryCondition if adjacentSurface
936 // is set as assignDefaultBoundaryCondition can call resetAdjacentSurface
937
1/1
✓ Branch 1 taken 54307 times.
54307 boost::optional<Surface> adjacentSurface = this->adjacentSurface();
938
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 54233 times.
54307 if (adjacentSurface) {
939
2/2
✓ Branch 1 taken 74 times.
✓ Branch 4 taken 74 times.
148 test = setString(OS_SurfaceFields::OutsideBoundaryConditionObject, "");
940
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
✗ Branch 3 not taken.
74 OS_ASSERT(test);
941
1/1
✓ Branch 1 taken 74 times.
74 this->assignDefaultBoundaryCondition();
942
1/1
✓ Branch 1 taken 74 times.
74 this->assignDefaultSunExposure();
943
1/1
✓ Branch 1 taken 74 times.
74 this->assignDefaultWindExposure();
944 }
945
946 // unset all matched sub surfaces
947
3/3
✓ Branch 1 taken 54307 times.
✓ Branch 8 taken 48 times.
✓ Branch 9 taken 54307 times.
54355 for (SubSurface& subSurface : this->subSurfaces()) {
948
1/1
✓ Branch 1 taken 48 times.
48 subSurface.resetAdjacentSubSurface();
949 54307 }
950
951 // clean all other surfaces pointing to this
952
4/4
✓ Branch 1 taken 54307 times.
✓ Branch 4 taken 54307 times.
✓ Branch 11 taken 78 times.
✓ Branch 12 taken 54307 times.
54385 for (const WorkspaceObject& wo : this->getSources(IddObjectType::OS_Surface)) {
953
954
1/1
✓ Branch 1 taken 78 times.
78 auto otherSurface = wo.cast<Surface>();
955
2/2
✓ Branch 1 taken 78 times.
✓ Branch 4 taken 78 times.
78 test = otherSurface.setString(OS_SurfaceFields::OutsideBoundaryConditionObject, "");
956
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
✗ Branch 3 not taken.
78 OS_ASSERT(test);
957
1/1
✓ Branch 1 taken 78 times.
78 otherSurface.assignDefaultBoundaryCondition();
958
1/1
✓ Branch 1 taken 78 times.
78 otherSurface.assignDefaultSunExposure();
959
1/1
✓ Branch 1 taken 78 times.
78 otherSurface.assignDefaultWindExposure();
960
961
3/3
✓ Branch 1 taken 78 times.
✓ Branch 8 taken 17 times.
✓ Branch 9 taken 78 times.
95 for (SubSurface& subSurface : otherSurface.subSurfaces()) {
962
1/1
✓ Branch 1 taken 17 times.
17 subSurface.resetAdjacentSubSurface();
963 78 }
964 54385 }
965 54307 }
966
967 3275 boost::optional<SurfaceControlMovableInsulation> Surface_Impl::surfaceControlMovableInsulation() const {
968
1/1
✓ Branch 1 taken 3275 times.
3275 auto thisSurface = getObject<Surface>();
969 std::vector<SurfaceControlMovableInsulation> movableInsulations =
970
2/2
✓ Branch 1 taken 3275 times.
✓ Branch 4 taken 3275 times.
3275 thisSurface.getModelObjectSources<SurfaceControlMovableInsulation>(SurfaceControlMovableInsulation::iddObjectType());
971
2/2
✓ Branch 1 taken 3269 times.
✓ Branch 2 taken 6 times.
3275 if (movableInsulations.empty()) {
972 3269 return boost::none;
973
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
6 } else if (movableInsulations.size() == 1) {
974
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 return movableInsulations.at(0);
975 } else {
976 ✗ LOG(Error, "More than one SurfaceControlMovableInsulation points to this Surface");
977 ✗ return boost::none;
978 }
979 3275 }
980
981 6836 boost::optional<SurfacePropertyConvectionCoefficients> Surface_Impl::surfacePropertyConvectionCoefficients() const {
982
2/2
✓ Branch 1 taken 6836 times.
✓ Branch 4 taken 6836 times.
6836 std::vector<SurfacePropertyConvectionCoefficients> spccs(model().getConcreteModelObjects<SurfacePropertyConvectionCoefficients>());
983
1/1
✓ Branch 1 taken 6836 times.
6836 auto thisHandle = this->handle();
984 24 auto isNotPointingToMe = [&thisHandle](const auto& spcc) {
985
1/1
✓ Branch 1 taken 24 times.
24 OptionalSurface surface = spcc.surfaceAsSurface();
986
7/7
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 8 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 12 taken 7 times.
✓ Branch 13 taken 9 times.
48 return !surface || !(surface->handle() == thisHandle);
987 24 };
988
989
2/2
✓ Branch 5 taken 6836 times.
✓ Branch 9 taken 6836 times.
6836 spccs.erase(std::remove_if(spccs.begin(), spccs.end(), isNotPointingToMe), spccs.end());
990
991
2/2
✓ Branch 1 taken 6827 times.
✓ Branch 2 taken 9 times.
6836 if (spccs.empty()) {
992 6827 return boost::none;
993
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 } else if (spccs.size() == 1) {
994
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 return spccs.at(0);
995 } else {
996 ✗ LOG(Error, "More than one SurfacePropertyConvectionCoefficients points to this Surface");
997 ✗ return boost::none;
998 }
999 6836 }
1000
1001 3274 boost::optional<SurfacePropertyLocalEnvironment> Surface_Impl::surfacePropertyLocalEnvironment() const {
1002
1003 3274 std::vector<SurfacePropertyLocalEnvironment> result;
1004
4/4
✓ Branch 1 taken 3274 times.
✓ Branch 4 taken 3274 times.
✓ Branch 12 taken 18 times.
✓ Branch 13 taken 3274 times.
3292 for (auto& localEnv : model().getConcreteModelObjects<SurfacePropertyLocalEnvironment>()) {
1005
3/3
✓ Branch 1 taken 18 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 7 times.
36 if (auto surface_ = localEnv.exteriorSurfaceAsSurface()) {
1006
6/6
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✓ Branch 10 taken 11 times.
✓ Branch 12 taken 9 times.
✓ Branch 13 taken 2 times.
11 if (surface_->handle() == handle()) {
1007
1/1
✓ Branch 1 taken 9 times.
9 result.push_back(localEnv);
1008 }
1009 18 }
1010 3274 }
1011
2/2
✓ Branch 1 taken 3265 times.
✓ Branch 2 taken 9 times.
3274 if (result.empty()) {
1012 3265 return boost::none;
1013
1/2
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
9 } else if (result.size() == 1) {
1014
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 return result.at(0);
1015 } else {
1016 ✗ LOG(Error, "More than one SurfacePropertyLocalEnvironment points to this Surface");
1017 ✗ return boost::none;
1018 }
1019 3274 }
1020
1021 164088 boost::optional<SurfacePropertyOtherSideCoefficients> Surface_Impl::surfacePropertyOtherSideCoefficients() const {
1022
2/2
✓ Branch 1 taken 164088 times.
✓ Branch 4 taken 164088 times.
164088 return getObject<Surface>().getModelObjectTarget<SurfacePropertyOtherSideCoefficients>(OS_SurfaceFields::OutsideBoundaryConditionObject);
1023 }
1024
1025 3 bool Surface_Impl::setSurfacePropertyOtherSideCoefficients(const SurfacePropertyOtherSideCoefficients& otherSideCoefficients) {
1026
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<Surface> adjacentSurface = this->adjacentSurface();
1027
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
3 if (adjacentSurface) {
1028
1/1
✓ Branch 1 taken 1 time.
1 resetAdjacentSurface();
1029 }
1030
1031 // this is basically testing if surface is in same model as this
1032
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 bool test = this->setPointer(OS_SurfaceFields::OutsideBoundaryConditionObject, otherSideCoefficients.handle());
1033
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (test) {
1034
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 test = this->setString(OS_SurfaceFields::OutsideBoundaryCondition, "OtherSideCoefficients");
1035
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
3 OS_ASSERT(test);
1036
1/1
✓ Branch 1 taken 3 times.
3 this->assignDefaultSunExposure();
1037
1/1
✓ Branch 1 taken 3 times.
3 this->assignDefaultWindExposure();
1038 }
1039 3 return test;
1040 3 }
1041
1042 54232 void Surface_Impl::resetSurfacePropertyOtherSideCoefficients() {
1043 bool test;
1044
1045 // need to be careful to only call assignDefaultBoundaryCondition if surfacePropertyOtherSideCoefficients
1046 // is set as assignDefaultBoundaryCondition can call resetSurfacePropertyOtherSideCoefficients
1047
1/1
✓ Branch 1 taken 54232 times.
54232 boost::optional<SurfacePropertyOtherSideCoefficients> surfacePropertyOtherSideCoefficients = this->surfacePropertyOtherSideCoefficients();
1048
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 54230 times.
54232 if (surfacePropertyOtherSideCoefficients) {
1049
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 test = setString(OS_SurfaceFields::OutsideBoundaryConditionObject, "");
1050
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
2 OS_ASSERT(test);
1051
1/1
✓ Branch 1 taken 2 times.
2 this->assignDefaultBoundaryCondition();
1052
1/1
✓ Branch 1 taken 2 times.
2 this->assignDefaultSunExposure();
1053
1/1
✓ Branch 1 taken 2 times.
2 this->assignDefaultWindExposure();
1054 }
1055
1056 // reset all sub surfaces
1057
3/3
✓ Branch 1 taken 54232 times.
✓ Branch 8 taken 34 times.
✓ Branch 9 taken 54232 times.
54266 for (SubSurface& subSurface : this->subSurfaces()) {
1058
1/1
✓ Branch 1 taken 34 times.
34 subSurface.resetSurfacePropertyOtherSideCoefficients();
1059 54232 }
1060 54232 }
1061
1062 164092 boost::optional<SurfacePropertyOtherSideConditionsModel> Surface_Impl::surfacePropertyOtherSideConditionsModel() const {
1063
2/2
✓ Branch 1 taken 164092 times.
✓ Branch 4 taken 164092 times.
164092 return getObject<Surface>().getModelObjectTarget<SurfacePropertyOtherSideConditionsModel>(OS_SurfaceFields::OutsideBoundaryConditionObject);
1064 }
1065
1066 5 bool Surface_Impl::setSurfacePropertyOtherSideConditionsModel(const SurfacePropertyOtherSideConditionsModel& otherSideModel) {
1067
1/1
✓ Branch 1 taken 5 times.
5 boost::optional<Surface> adjacentSurface = this->adjacentSurface();
1068
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 4 times.
5 if (adjacentSurface) {
1069
1/1
✓ Branch 1 taken 1 time.
1 resetAdjacentSurface();
1070 }
1071
1072 // this is basically testing if surface is in same model as this
1073
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 bool test = this->setPointer(OS_SurfaceFields::OutsideBoundaryConditionObject, otherSideModel.handle());
1074
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (test) {
1075
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
10 test = this->setString(OS_SurfaceFields::OutsideBoundaryCondition, "OtherSideConditionsModel");
1076
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 3 not taken.
5 OS_ASSERT(test);
1077
1/1
✓ Branch 1 taken 5 times.
5 this->assignDefaultSunExposure();
1078
1/1
✓ Branch 1 taken 5 times.
5 this->assignDefaultWindExposure();
1079 }
1080 5 return test;
1081 5 }
1082
1083 54232 void Surface_Impl::resetSurfacePropertyOtherSideConditionsModel() {
1084 bool test;
1085
1086 // need to be careful to only call assignDefaultBoundaryCondition if surfacePropertyOtherSideConditionsModel
1087 // is set as assignDefaultBoundaryCondition can call resetSurfacePropertyOtherSideConditionsModel
1088 boost::optional<SurfacePropertyOtherSideConditionsModel> surfacePropertyOtherSideConditionsModel =
1089
1/1
✓ Branch 1 taken 54232 times.
54232 this->surfacePropertyOtherSideConditionsModel();
1090
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 54230 times.
54232 if (surfacePropertyOtherSideConditionsModel) {
1091
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
4 test = setString(OS_SurfaceFields::OutsideBoundaryConditionObject, "");
1092
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
2 OS_ASSERT(test);
1093
1/1
✓ Branch 1 taken 2 times.
2 this->assignDefaultBoundaryCondition();
1094
1/1
✓ Branch 1 taken 2 times.
2 this->assignDefaultSunExposure();
1095
1/1
✓ Branch 1 taken 2 times.
2 this->assignDefaultWindExposure();
1096 }
1097
1098 // reset all sub surfaces
1099
3/3
✓ Branch 1 taken 54232 times.
✓ Branch 8 taken 34 times.
✓ Branch 9 taken 54232 times.
54266 for (SubSurface& subSurface : this->subSurfaces()) {
1100
1/1
✓ Branch 1 taken 34 times.
34 subSurface.resetSurfacePropertyOtherSideConditionsModel();
1101 54232 }
1102 54232 }
1103
1104 664 bool Surface_Impl::intersect(Surface& otherSurface) {
1105
1/1
✓ Branch 1 taken 664 times.
664 boost::optional<SurfaceIntersection> intersection = computeIntersection(otherSurface);
1106 1328 return intersection.has_value();
1107 664 }
1108
1109 521325 boost::optional<SurfaceIntersection> Surface_Impl::computeIntersection(Surface& otherSurface) {
1110 521325 double tol = 0.01; // 1 cm tolerance
1111 521325 double areaTol = 0.001; // 10 cm2 tolerance
1112
1113 521325 constexpr bool extraLogging = false;
1114
1115
1/1
✓ Branch 1 taken 521325 times.
521325 boost::optional<Space> space = this->space();
1116
1/1
✓ Branch 1 taken 521325 times.
521325 boost::optional<Space> otherSpace = otherSurface.space();
1117
1118
11/13
✓ Branch 1 taken 521325 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 521325 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 521325 times.
✓ Branch 10 taken 521325 times.
✓ Branch 13 taken 521325 times.
✓ Branch 16 taken 521325 times.
✓ Branch 19 taken 521325 times.
✓ Branch 21 taken 3 times.
✓ Branch 22 taken 521322 times.
✓ Branch 23 taken 3 times.
✓ Branch 24 taken 521322 times.
521325 if (!space || !otherSpace || space->handle() == otherSpace->handle()) {
1119
5/5
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 LOG(Error, "Cannot find spaces for each surface in intersection or surfaces in same space.");
1120 3 return boost::none;
1121 }
1122
1123
7/16
✓ Branch 1 taken 521322 times.
✓ Branch 4 taken 521322 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 521322 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 521322 times.
✓ Branch 12 taken 521322 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 521322 times.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 521322 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
521322 if (!this->subSurfaces().empty() || !otherSurface.subSurfaces().empty()) {
1124 ✗ LOG(Error, "Subsurfaces are not allowed in intersection");
1125 ✗ return boost::none;
1126 }
1127
1128
7/16
✓ Branch 1 taken 521322 times.
✓ Branch 4 taken 521322 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 521322 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 521322 times.
✓ Branch 12 taken 521322 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 521322 times.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 521322 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1563966 if (this->adjacentSurface() || otherSurface.adjacentSurface()) {
1129 ✗ LOG(Error, "Adjacent surfaces are not allowed in intersection");
1130 ✗ return boost::none;
1131 }
1132
1133 // goes from local system to building coordinates
1134
2/2
✓ Branch 1 taken 521322 times.
✓ Branch 4 taken 521322 times.
521322 Transformation spaceTransformation = space->transformation();
1135
2/2
✓ Branch 1 taken 521322 times.
✓ Branch 4 taken 521322 times.
521322 Transformation otherSpaceTransformation = otherSpace->transformation();
1136
1137 // do the intersection in building coordinates
1138
1139
2/2
✓ Branch 1 taken 521322 times.
✓ Branch 4 taken 521322 times.
521322 Plane plane = spaceTransformation * this->plane();
1140
2/2
✓ Branch 1 taken 521322 times.
✓ Branch 4 taken 521322 times.
521322 Plane otherPlane = otherSpaceTransformation * otherSurface.plane();
1141
1142
3/3
✓ Branch 1 taken 521322 times.
✓ Branch 3 taken 496181 times.
✓ Branch 4 taken 25141 times.
521322 if (!plane.reverseEqual(otherPlane)) {
1143 //LOG(Info, "Planes are not reverse equal, intersection of '" << this->name().get() << "' with '" << otherSurface.name().get() << "' fails");
1144 496181 return boost::none;
1145 }
1146
1147 // get vertices in building coordinates
1148
2/2
✓ Branch 1 taken 25141 times.
✓ Branch 4 taken 25141 times.
25141 std::vector<Point3d> buildingVertices = spaceTransformation * this->vertices();
1149
2/2
✓ Branch 1 taken 25141 times.
✓ Branch 4 taken 25141 times.
25141 std::vector<Point3d> otherBuildingVertices = otherSpaceTransformation * otherSurface.vertices();
1150
1151
3/6
✓ Branch 1 taken 25141 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25141 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 25141 times.
25141 if ((buildingVertices.size() < 3) || (otherBuildingVertices.size() < 3)) {
1152 ✗ LOG(Error, "Fewer than 3 vertices, intersection of '" << this->name().get() << "' with '" << otherSurface.name().get() << "' fails");
1153 ✗ return boost::none;
1154 }
1155
1156 // goes from face coordinates of building vertices to building coordinates
1157
1/1
✓ Branch 1 taken 25141 times.
25141 Transformation faceTransformation;
1158
1/1
✓ Branch 1 taken 25141 times.
25141 Transformation faceTransformationInverse;
1159 try {
1160
1/1
✓ Branch 1 taken 25141 times.
25141 faceTransformation = Transformation::alignFace(buildingVertices);
1161
1/1
✓ Branch 1 taken 25141 times.
25141 faceTransformationInverse = faceTransformation.inverse();
1162 ✗ } catch (const std::exception&) {
1163 ✗ LOG(Error, "Cannot compute face transform, intersection of '" << this->name().get() << "' with '" << otherSurface.name().get() << "' fails");
1164 ✗ return boost::none;
1165 ✗ }
1166
1167 // put building vertices into face coordinates
1168
1/1
✓ Branch 1 taken 25141 times.
25141 std::vector<Point3d> faceVertices = faceTransformationInverse * buildingVertices;
1169
1/1
✓ Branch 1 taken 25141 times.
25141 std::vector<Point3d> otherFaceVertices = faceTransformationInverse * otherBuildingVertices;
1170
1171 // boost polygon wants vertices in clockwise order, faceVertices must be reversed, otherFaceVertices already CCW
1172
1/1
✓ Branch 3 taken 25141 times.
25141 std::reverse(faceVertices.begin(), faceVertices.end());
1173 //std::reverse(otherFaceVertices.begin(), otherFaceVertices.end());
1174
1175 //LOG(Info, "Trying intersection of '" << this->name().get() << "' with '" << otherSurface.name().get());
1176 if constexpr (extraLogging) {
1177 Point3dVectorVector tmp{faceVertices, otherFaceVertices};
1178 LOG(Debug, tmp);
1179 }
1180
1/1
✓ Branch 1 taken 25141 times.
25141 boost::optional<IntersectionResult> intersection = openstudio::intersect(faceVertices, otherFaceVertices, tol);
1181
2/2
✓ Branch 1 taken 18120 times.
✓ Branch 2 taken 7021 times.
25141 if (!intersection) {
1182 //LOG(Info, "No intersection");
1183 18120 return boost::none;
1184 }
1185
1186 if constexpr (extraLogging) {
1187 Point3dVectorVector tmp;
1188 Point3dVectorVector newPolys = intersection->newPolygons2();
1189 tmp.reserve(newPolys.size() + 1);
1190 tmp.push_back(intersection->polygon2());
1191 tmp.insert(tmp.end(), std::make_move_iterator(newPolys.begin()), std::make_move_iterator(newPolys.end()));
1192 LOG(Debug, tmp);
1193 }
1194
1195 // DA - Change tolerance. Current tolerance is 0.0001 which is 1cm2 which is unrealistic
1196 // tolerance could be fixed, say 10cm2 or as a proportion of the area of the polygon. 4cm2
1197 // on a polygon of area 570m2 is a tiny fraction
1198
1/1
✓ Branch 1 taken 7021 times.
7021 boost::optional<double> area1 = getArea(faceVertices);
1199
1/1
✓ Branch 1 taken 7021 times.
7021 boost::optional<double> area2 = getArea(otherFaceVertices);
1200
1/2
✓ Branch 0 taken 7021 times.
✗ Branch 1 not taken.
7021 if (area1) {
1201
5/5
✓ Branch 1 taken 7021 times.
✓ Branch 4 taken 7021 times.
✓ Branch 7 taken 7021 times.
✓ Branch 10 taken 182 times.
✓ Branch 11 taken 6839 times.
7021 if (std::abs(area1.get() - intersection->area1()) > areaTol) {
1202
14/14
✓ Branch 1 taken 182 times.
✓ Branch 4 taken 182 times.
✓ Branch 7 taken 182 times.
✓ Branch 10 taken 182 times.
✓ Branch 13 taken 182 times.
✓ Branch 16 taken 182 times.
✓ Branch 19 taken 182 times.
✓ Branch 22 taken 182 times.
✓ Branch 25 taken 182 times.
✓ Branch 28 taken 182 times.
✓ Branch 31 taken 182 times.
✓ Branch 35 taken 182 times.
✓ Branch 38 taken 182 times.
✓ Branch 41 taken 182 times.
182 LOG(Error, "Initial area of surface '" << this->nameString() << "' " << area1.get() << " does not equal post intersection area "
1203 << intersection->area1());
1204 if constexpr (extraLogging) {
1205 Point3dVectorVector tmp1{faceVertices, otherFaceVertices};
1206 LOG(Debug, tmp1);
1207 Point3dVectorVector tmp;
1208 tmp.push_back(intersection->polygon1());
1209 for (auto& x : intersection->newPolygons1())
1210 tmp.push_back(x);
1211 LOG(Debug, tmp);
1212 }
1213 }
1214 }
1215
1/2
✓ Branch 0 taken 7021 times.
✗ Branch 1 not taken.
7021 if (area2) {
1216
5/5
✓ Branch 1 taken 7021 times.
✓ Branch 4 taken 7021 times.
✓ Branch 7 taken 7021 times.
✓ Branch 10 taken 200 times.
✓ Branch 11 taken 6821 times.
7021 if (std::abs(area2.get() - intersection->area2()) > areaTol) {
1217
14/14
✓ Branch 1 taken 200 times.
✓ Branch 4 taken 200 times.
✓ Branch 7 taken 200 times.
✓ Branch 10 taken 200 times.
✓ Branch 13 taken 200 times.
✓ Branch 16 taken 200 times.
✓ Branch 19 taken 200 times.
✓ Branch 22 taken 200 times.
✓ Branch 25 taken 200 times.
✓ Branch 28 taken 200 times.
✓ Branch 31 taken 200 times.
✓ Branch 35 taken 200 times.
✓ Branch 38 taken 200 times.
✓ Branch 41 taken 200 times.
200 LOG(Error, "Initial area of other surface '" << otherSurface.nameString() << "' " << area2.get()
1218 << " does not equal post intersection area " << intersection->area2());
1219 if constexpr (extraLogging) {
1220 Point3dVectorVector tmp1{faceVertices, otherFaceVertices};
1221 LOG(Debug, tmp1);
1222 Point3dVectorVector tmp;
1223 tmp.push_back(intersection->polygon2());
1224 for (auto& x : intersection->newPolygons2())
1225 tmp.push_back(x);
1226 LOG(Debug, tmp);
1227 }
1228 }
1229 }
1230
1231 // non-zero intersection
1232 // could match here but will save that for other discrete operation
1233
2/2
✓ Branch 1 taken 7021 times.
✓ Branch 5 taken 7021 times.
7021 Surface surface(std::dynamic_pointer_cast<Surface_Impl>(this->shared_from_this()));
1234 7021 std::vector<Surface> newSurfaces;
1235 7021 std::vector<Surface> newOtherSurfaces;
1236
1237 //LOG(Debug, "Before intersection");
1238 //LOG(Debug, surface);
1239 //LOG(Debug, otherSurface);
1240
1241 // goes from building coordinates to local system
1242
1/1
✓ Branch 1 taken 7021 times.
7021 Transformation spaceTransformationInverse = spaceTransformation.inverse();
1243
1/1
✓ Branch 1 taken 7021 times.
7021 Transformation otherSpaceTransformationInverse = otherSpaceTransformation.inverse();
1244
1245
2/2
✓ Branch 1 taken 7021 times.
✓ Branch 4 taken 7021 times.
7021 std::vector<std::vector<Point3d>> newPolygons1 = intersection->newPolygons1();
1246
2/2
✓ Branch 1 taken 7021 times.
✓ Branch 4 taken 7021 times.
7021 std::vector<std::vector<Point3d>> newPolygons2 = intersection->newPolygons2();
1247
1248 // modify vertices for surface in this space
1249
3/3
✓ Branch 1 taken 7021 times.
✓ Branch 4 taken 7021 times.
✓ Branch 7 taken 7021 times.
7021 std::vector<Point3d> newBuildingVertices = faceTransformation * intersection->polygon1();
1250
1/1
✓ Branch 1 taken 7021 times.
7021 std::vector<Point3d> newVertices = spaceTransformationInverse * newBuildingVertices;
1251
1/1
✓ Branch 3 taken 7021 times.
7021 std::reverse(newVertices.begin(), newVertices.end());
1252
1/1
✓ Branch 1 taken 7021 times.
7021 newVertices = reorderULC(newVertices);
1253
1/1
✓ Branch 1 taken 7021 times.
7021 this->setVertices(newVertices);
1254 //this->setAdjacentSurface(otherSurface);
1255
1256 // modify vertices for surface in other space
1257
3/3
✓ Branch 1 taken 7021 times.
✓ Branch 4 taken 7021 times.
✓ Branch 7 taken 7021 times.
7021 std::vector<Point3d> newOtherBuildingVertices = faceTransformation * intersection->polygon2();
1258
1/1
✓ Branch 1 taken 7021 times.
7021 std::vector<Point3d> newOtherVertices = otherSpaceTransformationInverse * newOtherBuildingVertices;
1259
1/1
✓ Branch 1 taken 7021 times.
7021 newOtherVertices = reorderULC(newOtherVertices);
1260
1/1
✓ Branch 1 taken 7021 times.
7021 otherSurface.setVertices(newOtherVertices);
1261 //otherSurface.setAdjacentSurface(surface);
1262
1263
6/6
✓ Branch 1 taken 5518 times.
✓ Branch 2 taken 1503 times.
✓ Branch 4 taken 4904 times.
✓ Branch 5 taken 614 times.
✓ Branch 6 taken 2117 times.
✓ Branch 7 taken 4904 times.
7021 if (newPolygons1.empty() && newPolygons2.empty()) {
1264 // both surfaces intersect perfectly, no-op
1265 } else {
1266 // new surfaces are created
1267 // create new surfaces in this space
1268
2/2
✓ Branch 1 taken 1847 times.
✓ Branch 2 taken 2117 times.
3964 for (unsigned i = 0; i < newPolygons1.size(); ++i) {
1269
1270 // new surface in this space
1271
1/1
✓ Branch 2 taken 1847 times.
1847 newBuildingVertices = faceTransformation * newPolygons1[i];
1272
1/1
✓ Branch 1 taken 1847 times.
1847 newVertices = spaceTransformationInverse * newBuildingVertices;
1273
1/1
✓ Branch 3 taken 1847 times.
1847 std::reverse(newVertices.begin(), newVertices.end());
1274
1/1
✓ Branch 1 taken 1847 times.
1847 newVertices = reorderULC(newVertices);
1275
2/2
✓ Branch 1 taken 1847 times.
✓ Branch 4 taken 1847 times.
1847 Surface newSurface(newVertices, this->model());
1276
2/2
✓ Branch 1 taken 1847 times.
✓ Branch 4 taken 1847 times.
1847 newSurface.setSpace(*space);
1277
1/1
✓ Branch 1 taken 1847 times.
1847 newSurfaces.push_back(newSurface);
1278 1847 }
1279
1280 // create new surfaces in other space
1281
2/2
✓ Branch 1 taken 1356 times.
✓ Branch 2 taken 2117 times.
3473 for (unsigned i = 0; i < newPolygons2.size(); ++i) {
1282
1283 // new surface in other space
1284
1/1
✓ Branch 2 taken 1356 times.
1356 newOtherBuildingVertices = faceTransformation * newPolygons2[i];
1285
1/1
✓ Branch 1 taken 1356 times.
1356 newOtherVertices = otherSpaceTransformationInverse * newOtherBuildingVertices;
1286
1/1
✓ Branch 1 taken 1356 times.
1356 newOtherVertices = reorderULC(newOtherVertices);
1287
2/2
✓ Branch 1 taken 1356 times.
✓ Branch 4 taken 1356 times.
1356 Surface newOtherSurface(newOtherVertices, this->model());
1288
2/2
✓ Branch 1 taken 1356 times.
✓ Branch 4 taken 1356 times.
1356 newOtherSurface.setSpace(*otherSpace);
1289
1/1
✓ Branch 1 taken 1356 times.
1356 newOtherSurfaces.push_back(newOtherSurface);
1290 1356 }
1291 }
1292
1293
1/1
✓ Branch 1 taken 7021 times.
7021 SurfaceIntersection result(surface, otherSurface, newSurfaces, newOtherSurfaces);
1294
1295
14/14
✓ Branch 1 taken 7021 times.
✓ Branch 4 taken 7021 times.
✓ Branch 7 taken 7021 times.
✓ Branch 10 taken 7021 times.
✓ Branch 13 taken 7021 times.
✓ Branch 16 taken 7021 times.
✓ Branch 19 taken 7021 times.
✓ Branch 22 taken 7021 times.
✓ Branch 25 taken 7021 times.
✓ Branch 28 taken 7021 times.
✓ Branch 31 taken 7021 times.
✓ Branch 36 taken 7021 times.
✓ Branch 39 taken 7021 times.
✓ Branch 42 taken 7021 times.
7021 LOG(Info, "Intersection of '" << this->name().get() << "' with '" << otherSurface.name().get() << "' results in " << result);
1296
1297 //LOG(Debug, "After intersection");
1298 //LOG(Debug, surface);
1299 //LOG(Debug, otherSurface);
1300 //for (const Surface& s : newSurfaces){
1301 // LOG(Debug, s);
1302 //}
1303 //for (const Surface& s : newOtherSurfaces){
1304 // LOG(Debug, s);
1305 //}
1306
1307
1/1
✓ Branch 1 taken 7021 times.
7021 return result;
1308 521325 }
1309
1310 836 boost::optional<Surface> Surface_Impl::createAdjacentSurface(const Space& otherSpace) {
1311
1/1
✓ Branch 1 taken 836 times.
836 boost::optional<Space> space = this->space();
1312
7/10
✓ Branch 1 taken 836 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 836 times.
✓ Branch 7 taken 836 times.
✓ Branch 10 taken 836 times.
✓ Branch 13 taken 836 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 836 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 836 times.
836 if (!space || (space->handle() == otherSpace.handle())) {
1313 ✗ return boost::none;
1314 }
1315
1316
2/2
✓ Branch 1 taken 836 times.
✓ Branch 4 taken 836 times.
836 Transformation thisSpaceT = space->transformation();
1317
1/1
✓ Branch 1 taken 836 times.
836 Transformation otherSpaceT = otherSpace.transformation();
1318
2/2
✓ Branch 1 taken 836 times.
✓ Branch 4 taken 836 times.
836 Transformation transformation = otherSpaceT.inverse() * thisSpaceT;
1319
1320
2/2
✓ Branch 1 taken 836 times.
✓ Branch 4 taken 836 times.
836 std::vector<Point3d> vertices = transformation * this->vertices();
1321
1/1
✓ Branch 3 taken 836 times.
836 std::reverse(vertices.begin(), vertices.end());
1322
1323
1/1
✓ Branch 1 taken 836 times.
836 Model model = this->model();
1324
1325 // Be careful not to call clone as you will get duplicate sub surfaces
1326
1/1
✓ Branch 1 taken 836 times.
836 Surface otherSurface(vertices, model);
1327
4/4
✓ Branch 1 taken 836 times.
✓ Branch 4 taken 836 times.
✓ Branch 7 taken 836 times.
✓ Branch 10 taken 836 times.
836 otherSurface.setName(this->name().get() + " Reversed");
1328
1/1
✓ Branch 1 taken 836 times.
836 otherSurface.resetConstruction(); // this will use surface's construction on export, TODO: do something better
1329
1330
1/1
✓ Branch 1 taken 836 times.
836 std::string surfaceType = this->surfaceType();
1331
3/3
✓ Branch 1 taken 836 times.
✓ Branch 3 taken 40 times.
✓ Branch 4 taken 796 times.
836 if (surfaceType == "RoofCeiling") {
1332
2/2
✓ Branch 1 taken 40 times.
✓ Branch 4 taken 40 times.
80 otherSurface.setSurfaceType("Floor");
1333
3/3
✓ Branch 1 taken 796 times.
✓ Branch 3 taken 169 times.
✓ Branch 4 taken 627 times.
796 } else if (surfaceType == "Floor") {
1334
2/2
✓ Branch 1 taken 169 times.
✓ Branch 4 taken 169 times.
338 otherSurface.setSurfaceType("RoofCeiling");
1335
2/3
✓ Branch 1 taken 627 times.
✓ Branch 3 taken 627 times.
✗ Branch 4 not taken.
627 } else if (surfaceType == "Wall") {
1336
2/2
✓ Branch 1 taken 627 times.
✓ Branch 4 taken 627 times.
1254 otherSurface.setSurfaceType("Wall");
1337 }
1338
1339
1/1
✓ Branch 1 taken 836 times.
836 otherSurface.setSpace(otherSpace);
1340
1341
1/1
✓ Branch 1 taken 836 times.
836 this->setAdjacentSurface(otherSurface);
1342
1343
3/3
✓ Branch 1 taken 836 times.
✓ Branch 8 taken 108 times.
✓ Branch 9 taken 836 times.
944 for (SubSurface& subSurface : this->subSurfaces()) {
1344
2/2
✓ Branch 1 taken 108 times.
✓ Branch 4 taken 108 times.
108 vertices = transformation * subSurface.vertices();
1345
1/1
✓ Branch 3 taken 108 times.
108 std::reverse(vertices.begin(), vertices.end());
1346
1347
1/1
✓ Branch 1 taken 108 times.
108 SubSurface otherSubSurface(vertices, model);
1348
4/4
✓ Branch 1 taken 108 times.
✓ Branch 4 taken 108 times.
✓ Branch 7 taken 108 times.
✓ Branch 10 taken 108 times.
108 otherSubSurface.setName(subSurface.name().get() + " Reversed");
1349
1/1
✓ Branch 1 taken 108 times.
108 otherSubSurface.resetConstruction(); // this will use sub surface's construction on export, TODO: do something better
1350
2/2
✓ Branch 1 taken 108 times.
✓ Branch 4 taken 108 times.
108 otherSubSurface.setSubSurfaceType(subSurface.subSurfaceType());
1351
1/1
✓ Branch 1 taken 108 times.
108 otherSubSurface.setSurface(otherSurface);
1352
1/1
✓ Branch 1 taken 108 times.
108 otherSubSurface.setAdjacentSubSurface(subSurface);
1353 944 }
1354
1355
1/1
✓ Branch 1 taken 836 times.
836 return otherSurface;
1356 836 }
1357
1358 593 bool Surface_Impl::isPartOfEnvelope() const {
1359
1/1
✓ Branch 1 taken 593 times.
593 std::string bc = this->outsideBoundaryCondition();
1360
9/15
✓ Branch 1 taken 593 times.
✓ Branch 4 taken 593 times.
✓ Branch 6 taken 147 times.
✓ Branch 7 taken 446 times.
✓ Branch 9 taken 147 times.
✓ Branch 11 taken 33 times.
✓ Branch 12 taken 114 times.
✓ Branch 13 taken 593 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 593 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
1186 bool result = (istringEqual("Outdoors", bc) || this->isGroundSurface());
1361 593 return result;
1362 593 }
1363
1364 774 void Surface_Impl::assignDefaultSurfaceType() {
1365 774 assignDefaultSurfaceType(true);
1366 774 }
1367
1368 52874 void Surface_Impl::assignDefaultSurfaceType(bool driverMethod) {
1369 52874 double degTilt = radToDeg(this->tilt());
1370 52873 bool ok = true;
1371
2/2
✓ Branch 0 taken 7540 times.
✓ Branch 1 taken 45333 times.
52873 if (degTilt < 60) {
1372
2/2
✓ Branch 1 taken 7540 times.
✓ Branch 4 taken 7540 times.
15080 ok = setSurfaceType("RoofCeiling", driverMethod);
1373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7540 times.
7540 OS_ASSERT(ok);
1374
2/2
✓ Branch 0 taken 37895 times.
✓ Branch 1 taken 7438 times.
45333 } else if (degTilt < 179) {
1375
2/2
✓ Branch 1 taken 37895 times.
✓ Branch 4 taken 37895 times.
75790 ok = setSurfaceType("Wall", driverMethod);
1376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37895 times.
37895 OS_ASSERT(ok);
1377 } else {
1378
2/2
✓ Branch 1 taken 7438 times.
✓ Branch 4 taken 7438 times.
14876 ok = setSurfaceType("Floor", driverMethod);
1379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7438 times.
7438 OS_ASSERT(ok);
1380 }
1381 52873 }
1382
1383 164 void Surface_Impl::assignDefaultBoundaryCondition() {
1384 164 assignDefaultBoundaryCondition(true);
1385 164 }
1386
1387 52263 void Surface_Impl::assignDefaultBoundaryCondition(bool driverMethod) {
1388
2/3
✓ Branch 1 taken 52263 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52263 times.
104526 if (this->adjacentSurface()) {
1389 ✗ bool test = this->setOutsideBoundaryCondition("Surface", driverMethod);
1390 ✗ OS_ASSERT(test);
1391
2/3
✓ Branch 1 taken 52263 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52263 times.
104526 } else if (this->surfacePropertyOtherSideCoefficients()) {
1392 ✗ bool test = this->setOutsideBoundaryCondition("OtherSideCoefficients", driverMethod);
1393 ✗ OS_ASSERT(test);
1394
2/3
✓ Branch 1 taken 52263 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52263 times.
104526 } else if (this->surfacePropertyOtherSideConditionsModel()) {
1395 ✗ bool test = this->setOutsideBoundaryCondition("OtherSideConditionsModel", driverMethod);
1396 ✗ OS_ASSERT(test);
1397
2/3
✓ Branch 1 taken 52263 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52263 times.
104526 } else if (this->adjacentFoundation()) {
1398 ✗ bool test = this->setOutsideBoundaryCondition("Foundation", driverMethod);
1399 ✗ OS_ASSERT(test);
1400
5/5
✓ Branch 1 taken 52263 times.
✓ Branch 4 taken 52263 times.
✓ Branch 7 taken 52263 times.
✓ Branch 11 taken 7304 times.
✓ Branch 12 taken 44959 times.
156789 } else if (istringEqual("Floor", this->surfaceType())) {
1401
2/2
✓ Branch 1 taken 7304 times.
✓ Branch 4 taken 7304 times.
14608 bool test = this->setOutsideBoundaryCondition("Ground", driverMethod);
1402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7304 times.
7304 OS_ASSERT(test);
1403 } else {
1404
2/2
✓ Branch 1 taken 44959 times.
✓ Branch 4 taken 44959 times.
89918 bool test = this->setOutsideBoundaryCondition("Outdoors", driverMethod);
1405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44959 times.
44959 OS_ASSERT(test);
1406 }
1407 52263 }
1408
1409 31013 void Surface_Impl::assignDefaultSunExposure() {
1410 31013 assignDefaultSunExposure(true);
1411 31013 }
1412
1413 137338 void Surface_Impl::assignDefaultSunExposure(bool driverMethod) {
1414
1/1
✓ Branch 1 taken 137338 times.
137338 std::string outsideBoundaryCondition = this->outsideBoundaryCondition();
1415
4/4
✓ Branch 1 taken 137338 times.
✓ Branch 4 taken 137338 times.
✓ Branch 7 taken 90846 times.
✓ Branch 8 taken 46492 times.
274676 if (istringEqual("Outdoors", outsideBoundaryCondition)) {
1416
2/2
✓ Branch 1 taken 90846 times.
✓ Branch 4 taken 90846 times.
181692 bool test = this->setSunExposure("SunExposed", driverMethod);
1417
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 90846 times.
✗ Branch 3 not taken.
90846 OS_ASSERT(test);
1418
11/21
✓ Branch 1 taken 46492 times.
✓ Branch 4 taken 15651 times.
✓ Branch 7 taken 15651 times.
✓ Branch 9 taken 15648 times.
✓ Branch 10 taken 3 times.
✓ Branch 12 taken 15651 times.
✓ Branch 13 taken 30841 times.
✓ Branch 14 taken 46492 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 46492 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 46487 times.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
170778 } else if (istringEqual("Surface", outsideBoundaryCondition) || istringEqual("OtherSideCoefficients", outsideBoundaryCondition)
1419
16/24
✓ Branch 1 taken 15648 times.
✓ Branch 4 taken 15648 times.
✓ Branch 6 taken 14814 times.
✓ Branch 7 taken 834 times.
✓ Branch 9 taken 14814 times.
✓ Branch 12 taken 14814 times.
✓ Branch 14 taken 13 times.
✓ Branch 15 taken 14801 times.
✓ Branch 17 taken 14814 times.
✓ Branch 18 taken 31678 times.
✓ Branch 19 taken 15648 times.
✓ Branch 20 taken 30844 times.
✓ Branch 22 taken 15648 times.
✓ Branch 23 taken 30844 times.
✓ Branch 24 taken 15651 times.
✓ Branch 25 taken 30841 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
107416 || istringEqual("Adiabatic", outsideBoundaryCondition) || istringEqual("Ground", outsideBoundaryCondition)
1420
8/12
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 6 times.
✓ Branch 9 taken 13 times.
✓ Branch 10 taken 46479 times.
✓ Branch 11 taken 14814 times.
✓ Branch 12 taken 31678 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46518 || istringEqual("GroundFCfactorMethod", outsideBoundaryCondition)
1421
7/12
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 46485 times.
✓ Branch 11 taken 13 times.
✓ Branch 12 taken 46479 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46506 || istringEqual("GroundSlabPreprocessorAverage", outsideBoundaryCondition)
1422
7/12
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 46485 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 46485 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46506 || istringEqual("GroundSlabPreprocessorCore", outsideBoundaryCondition)
1423
7/12
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 46485 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 46485 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46506 || istringEqual("GroundSlabPreprocessorPerimeter", outsideBoundaryCondition)
1424
7/12
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 46485 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 46485 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46506 || istringEqual("GroundBasementPreprocessorAverageWall", outsideBoundaryCondition)
1425
7/12
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 46485 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 46485 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46506 || istringEqual("GroundBasementPreprocessorAverageFloor", outsideBoundaryCondition)
1426
7/12
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 46485 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 46485 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46506 || istringEqual("GroundBasementPreprocessorUpperWall", outsideBoundaryCondition)
1427
7/12
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 46485 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 46485 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46506 || istringEqual("GroundBasementPreprocessorLowerWall", outsideBoundaryCondition)
1428
13/17
✓ Branch 1 taken 46492 times.
✓ Branch 3 taken 15651 times.
✓ Branch 4 taken 30841 times.
✓ Branch 6 taken 7 times.
✓ Branch 9 taken 7 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 5 times.
✓ Branch 13 taken 7 times.
✓ Branch 14 taken 46485 times.
✓ Branch 16 taken 7 times.
✓ Branch 17 taken 46485 times.
✓ Branch 18 taken 7 times.
✓ Branch 19 taken 46485 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
108642 || istringEqual("Foundation", outsideBoundaryCondition)) {
1429
2/2
✓ Branch 1 taken 46487 times.
✓ Branch 4 taken 46487 times.
92974 bool test = this->setSunExposure("NoSun", driverMethod);
1430
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 46487 times.
✗ Branch 3 not taken.
46487 OS_ASSERT(test);
1431 } else {
1432
1/1
✓ Branch 1 taken 5 times.
5 std::string surfaceType = this->surfaceType();
1433
3/4
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
10 if (istringEqual("Floor", surfaceType)) {
1434 ✗ bool test = this->setSunExposure("NoSun", driverMethod);
1435 ✗ OS_ASSERT(test);
1436 } else {
1437
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
10 bool test = this->setSunExposure("SunExposed", driverMethod);
1438
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 3 not taken.
5 OS_ASSERT(test);
1439 }
1440 5 }
1441 137338 }
1442
1443 31013 void Surface_Impl::assignDefaultWindExposure() {
1444 31013 assignDefaultWindExposure(true);
1445 31013 }
1446
1447 137338 void Surface_Impl::assignDefaultWindExposure(bool driverMethod) {
1448
1/1
✓ Branch 1 taken 137338 times.
137338 std::string outsideBoundaryCondition = this->outsideBoundaryCondition();
1449
4/4
✓ Branch 1 taken 137338 times.
✓ Branch 4 taken 137338 times.
✓ Branch 7 taken 90846 times.
✓ Branch 8 taken 46492 times.
274676 if (istringEqual("Outdoors", outsideBoundaryCondition)) {
1450
2/2
✓ Branch 1 taken 90846 times.
✓ Branch 4 taken 90846 times.
181692 bool test = this->setWindExposure("WindExposed", driverMethod);
1451
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 90846 times.
✗ Branch 3 not taken.
90846 OS_ASSERT(test);
1452
11/21
✓ Branch 1 taken 46492 times.
✓ Branch 4 taken 15651 times.
✓ Branch 7 taken 15651 times.
✓ Branch 9 taken 15648 times.
✓ Branch 10 taken 3 times.
✓ Branch 12 taken 15651 times.
✓ Branch 13 taken 30841 times.
✓ Branch 14 taken 46492 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 46492 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 46487 times.
✓ Branch 20 taken 5 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
170778 } else if (istringEqual("Surface", outsideBoundaryCondition) || istringEqual("OtherSideCoefficients", outsideBoundaryCondition)
1453
16/24
✓ Branch 1 taken 15648 times.
✓ Branch 4 taken 15648 times.
✓ Branch 6 taken 14814 times.
✓ Branch 7 taken 834 times.
✓ Branch 9 taken 14814 times.
✓ Branch 12 taken 14814 times.
✓ Branch 14 taken 13 times.
✓ Branch 15 taken 14801 times.
✓ Branch 17 taken 14814 times.
✓ Branch 18 taken 31678 times.
✓ Branch 19 taken 15648 times.
✓ Branch 20 taken 30844 times.
✓ Branch 22 taken 15648 times.
✓ Branch 23 taken 30844 times.
✓ Branch 24 taken 15651 times.
✓ Branch 25 taken 30841 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
107416 || istringEqual("Adiabatic", outsideBoundaryCondition) || istringEqual("Ground", outsideBoundaryCondition)
1454
8/12
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 6 times.
✓ Branch 9 taken 13 times.
✓ Branch 10 taken 46479 times.
✓ Branch 11 taken 14814 times.
✓ Branch 12 taken 31678 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46518 || istringEqual("GroundFCfactorMethod", outsideBoundaryCondition)
1455
7/12
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 46485 times.
✓ Branch 11 taken 13 times.
✓ Branch 12 taken 46479 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46506 || istringEqual("GroundSlabPreprocessorAverage", outsideBoundaryCondition)
1456
7/12
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 46485 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 46485 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46506 || istringEqual("GroundSlabPreprocessorCore", outsideBoundaryCondition)
1457
7/12
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 46485 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 46485 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46506 || istringEqual("GroundSlabPreprocessorPerimeter", outsideBoundaryCondition)
1458
7/12
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 46485 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 46485 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46506 || istringEqual("GroundBasementPreprocessorAverageWall", outsideBoundaryCondition)
1459
7/12
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 46485 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 46485 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46506 || istringEqual("GroundBasementPreprocessorAverageFloor", outsideBoundaryCondition)
1460
7/12
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 46485 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 46485 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46506 || istringEqual("GroundBasementPreprocessorUpperWall", outsideBoundaryCondition)
1461
7/12
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 46485 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 46485 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46506 || istringEqual("GroundBasementPreprocessorLowerWall", outsideBoundaryCondition)
1462
13/17
✓ Branch 1 taken 46492 times.
✓ Branch 3 taken 15651 times.
✓ Branch 4 taken 30841 times.
✓ Branch 6 taken 7 times.
✓ Branch 9 taken 7 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 5 times.
✓ Branch 13 taken 7 times.
✓ Branch 14 taken 46485 times.
✓ Branch 16 taken 7 times.
✓ Branch 17 taken 46485 times.
✓ Branch 18 taken 7 times.
✓ Branch 19 taken 46485 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
108642 || istringEqual("Foundation", outsideBoundaryCondition)) {
1463
2/2
✓ Branch 1 taken 46487 times.
✓ Branch 4 taken 46487 times.
92974 bool test = this->setWindExposure("NoWind", driverMethod);
1464
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 46487 times.
✗ Branch 3 not taken.
46487 OS_ASSERT(test);
1465 } else {
1466
1/1
✓ Branch 1 taken 5 times.
5 std::string surfaceType = this->surfaceType();
1467
3/4
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
10 if (istringEqual("Floor", surfaceType)) {
1468 ✗ bool test = this->setWindExposure("NoWind", driverMethod);
1469 ✗ OS_ASSERT(test);
1470 } else {
1471
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
10 bool test = this->setWindExposure("WindExposed", driverMethod);
1472
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 3 not taken.
5 OS_ASSERT(test);
1473 }
1474 5 }
1475 137338 }
1476
1477 ✗ std::vector<ModelObject> Surface_Impl::subSurfacesAsModelObjects() const {
1478 ✗ ModelObjectVector result = castVector<ModelObject>(subSurfaces());
1479 ✗ return result;
1480 }
1481
1482 ✗ boost::optional<ModelObject> Surface_Impl::adjacentSurfaceAsModelObject() const {
1483 ✗ OptionalModelObject result;
1484 ✗ OptionalSurface intermediate = adjacentSurface();
1485 ✗ if (intermediate) {
1486 ✗ result = *intermediate;
1487 }
1488 ✗ return result;
1489 ✗ }
1490
1491 ✗ bool Surface_Impl::setSpaceAsModelObject(const boost::optional<ModelObject>& modelObject) {
1492 ✗ if (modelObject) {
1493 ✗ OptionalSpace intermediate = modelObject->optionalCast<Space>();
1494 ✗ if (intermediate) {
1495 ✗ return setSpace(*intermediate);
1496 }
1497 ✗ }
1498 ✗ return false;
1499 }
1500
1501 ✗ bool Surface_Impl::setAdjacentSurfaceAsModelObject(const boost::optional<ModelObject>& modelObject) {
1502 ✗ if (modelObject) {
1503 ✗ OptionalSurface intermediate = modelObject->optionalCast<Surface>();
1504 ✗ if (intermediate) {
1505 ✗ return setAdjacentSurface(*intermediate);
1506 } else {
1507 ✗ return false;
1508 }
1509 ✗ } else {
1510 ✗ resetAdjacentSurface();
1511 }
1512 ✗ return true;
1513 }
1514
1515 11 double Surface_Impl::filmResistance() const {
1516
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 double interiorResistance = PlanarSurface::stillAirFilmResistance(tilt());
1517
1/1
✓ Branch 1 taken 11 times.
11 std::string obc = this->outsideBoundaryCondition();
1518
1/1
✓ Branch 2 taken 11 times.
11 boost::to_lower(obc);
1519
2/3
✓ Branch 1 taken 11 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
11 if (obc == "outdoors") {
1520
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 return PlanarSurface::filmResistance(FilmResistanceType::MovingAir_15mph) + interiorResistance;
1521 ✗ } else if (isPartOfEnvelope()) {
1522 // ground, underground, or other side coefficients/conditions
1523 // assume one interiorResistance
1524 ✗ if ((obc == "othersidecoefficients") || (obc == "othersideconditionsmodel")) {
1525 ✗ LOG(Warn, "Returning film resistance for " << briefDescription()
1526 << " as if it was "
1527 "underground (one still air film resistance for the inside surface). This may not "
1528 "be correct as the outside boundary condition is '"
1529 << obc << "'.");
1530 }
1531 ✗ return interiorResistance;
1532 }
1533 ✗ return 2.0 * interiorResistance;
1534 11 }
1535
1536 30 double Surface_Impl::windowToWallRatio() const {
1537 30 double result = 0.0;
1538
1539
4/5
✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
✓ Branch 7 taken 30 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 30 times.
60 if (!istringEqual(this->surfaceType(), "Wall")) {
1540 ✗ return result;
1541 }
1542
1543 30 double grossArea = this->grossArea();
1544
1545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if (grossArea == 0) {
1546 ✗ return result;
1547 }
1548
1549 30 double roughOpeningArea = totalAreaOfSubSurfaces();
1550 30 double wwr = roughOpeningArea / grossArea;
1551
1552 30 return wwr;
1553 }
1554
1555 // Calculates and returns the toital area of the subsurfaces
1556 // If any subsurface extends outside the parent surface or overlaps an adjacent subsurface
1557 // then that subsurface's vertices rather than rough opening vertices are used to calculate the area
1558 // NOTE: I'm starting to think a better way to do this would be to use polygon booleans
1559 // 1 - Intersect the subsurface rough opening with the parent surface to get the area inside the parent surface
1560 // 2 - Add all the subsurface rough openings together (so overlap areas don't count twice)
1561 30 double Surface_Impl::totalAreaOfSubSurfaces() const {
1562 30 double tol = 0.01;
1563
1564 // There must be a simpler way - after all we are only intersetced in areas
1565 // 1 - Get the surface polygon flattened
1566 // 2 - Get all the sub-surface polygons with frame offset applied
1567 // 3 - STart with first poly
1568 // 4 - Does it overlap any other polys? (A & B)
1569 // 5 - Y: Get the combined area of the two polygons, remove polygon A & B from the list insert polygon C
1570 // N: Remove polygon A form the list add to finished polygon list
1571 // 6 When no more overlaps are detected we are finished. Get the total area of all the polygons
1572
1573 // Simple case - no sub-surfaces
1574
3/3
✓ Branch 1 taken 30 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 19 times.
30 if (this->subSurfaces().size() == 0) return 0;
1575
1576 // Flattened surface vertices
1577
3/3
✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
19 Transformation surfaceToXY = Transformation::alignFace(this->vertices()).inverse();
1578
2/2
✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
19 std::vector<Point3d> surfaceVertices = surfaceToXY * this->vertices();
1579 // Make sure the surface surface is oriented clockwise
1580
1/1
✓ Branch 1 taken 19 times.
19 auto norm = openstudio::getOutwardNormal(surfaceVertices);
1581
5/8
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 19 times.
✓ Branch 6 taken 19 times.
✓ Branch 8 taken 19 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 19 times.
✗ Branch 11 not taken.
19 if (norm && norm->z() > 0) {
1582
1/1
✓ Branch 3 taken 19 times.
19 std::reverse(surfaceVertices.begin(), surfaceVertices.end());
1583 }
1584
1585 19 Point3dVectorVector subSurfaces;
1586
1587 // Get the flattened sub surface vertices for windows
1588
3/3
✓ Branch 1 taken 19 times.
✓ Branch 8 taken 23 times.
✓ Branch 9 taken 19 times.
42 for (const SubSurface& subSurface : this->subSurfaces()) {
1589
20/36
✓ Branch 1 taken 23 times.
✓ Branch 4 taken 23 times.
✓ Branch 7 taken 23 times.
✓ Branch 9 taken 1 time.
✓ Branch 10 taken 22 times.
✓ Branch 12 taken 1 time.
✓ Branch 15 taken 1 time.
✓ Branch 18 taken 1 time.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 23 taken 22 times.
✓ Branch 25 taken 1 time.
✓ Branch 26 taken 22 times.
✓ Branch 28 taken 1 time.
✓ Branch 29 taken 22 times.
✓ Branch 30 taken 23 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 23 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 23 times.
✗ Branch 37 not taken.
✓ Branch 38 taken 22 times.
✓ Branch 39 taken 1 time.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
71 if (istringEqual(subSurface.subSurfaceType(), "FixedWindow") || istringEqual(subSurface.subSurfaceType(), "OperableWindow")) {
1590
2/2
✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
22 auto roughOpening = surfaceToXY * subSurface.roughOpeningVertices();
1591
1/1
✓ Branch 1 taken 22 times.
22 auto norm = openstudio::getOutwardNormal(roughOpening);
1592
7/8
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 22 times.
✓ Branch 6 taken 22 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 6 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 6 times.
22 if (norm && norm->z() > 0) {
1593
1/1
✓ Branch 3 taken 16 times.
16 std::reverse(roughOpening.begin(), roughOpening.end());
1594 }
1595
1/1
✓ Branch 1 taken 22 times.
22 subSurfaces.push_back(roughOpening);
1596 22 }
1597 19 }
1598
1599 // Add all the subsurfaces togther
1600
1/1
✓ Branch 1 taken 19 times.
19 auto finalSurfaces = openstudio::joinAll(subSurfaces, tol);
1601
1602 19 double area = 0;
1603 // No overlappingsurfaces so we can add up the surface areas including multipliers
1604
2/2
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 1 time.
19 if (finalSurfaces.size() == subSurfaces.size()) {
1605
3/3
✓ Branch 1 taken 18 times.
✓ Branch 8 taken 21 times.
✓ Branch 9 taken 18 times.
39 for (const auto& subSurface : this->subSurfaces()) {
1606
20/36
✓ Branch 1 taken 21 times.
✓ Branch 4 taken 21 times.
✓ Branch 7 taken 21 times.
✓ Branch 9 taken 1 time.
✓ Branch 10 taken 20 times.
✓ Branch 12 taken 1 time.
✓ Branch 15 taken 1 time.
✓ Branch 18 taken 1 time.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 23 taken 20 times.
✓ Branch 25 taken 1 time.
✓ Branch 26 taken 20 times.
✓ Branch 28 taken 1 time.
✓ Branch 29 taken 20 times.
✓ Branch 30 taken 21 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 21 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 21 times.
✗ Branch 37 not taken.
✓ Branch 38 taken 20 times.
✓ Branch 39 taken 1 time.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
65 if (istringEqual(subSurface.subSurfaceType(), "FixedWindow") || istringEqual(subSurface.subSurfaceType(), "OperableWindow")) {
1607
2/2
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
20 auto roughOpening = surfaceToXY * subSurface.roughOpeningVertices();
1608
3/3
✓ Branch 1 taken 20 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 19 times.
20 if (!openstudio::polygonInPolygon(roughOpening, surfaceVertices, tol)) {
1609
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 roughOpening = surfaceToXY * subSurface.vertices();
1610 }
1611
3/3
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 7 taken 20 times.
20 area += openstudio::getArea(roughOpening).value() * subSurface.multiplier();
1612 20 }
1613 18 }
1614
1615 18 return area;
1616 }
1617
1618
2/2
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 time.
3 for (const auto& subSurface : subSurfaces) {
1619
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 area += openstudio::getArea(subSurface).value();
1620 }
1621
1622 1 return area;
1623 19 }
1624
1625 130 double Surface_Impl::skylightToRoofRatio() const {
1626 130 double result = 0.0;
1627
1628
4/5
✓ Branch 1 taken 130 times.
✓ Branch 4 taken 130 times.
✓ Branch 7 taken 130 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 130 times.
260 if (!istringEqual(this->surfaceType(), "RoofCeiling")) {
1629 ✗ return result;
1630 }
1631
1632 130 double grossArea = this->grossArea();
1633
1634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130 times.
130 if (grossArea == 0) {
1635 ✗ return result;
1636 }
1637
1638 130 double skylightArea = 0.0;
1639
3/3
✓ Branch 1 taken 130 times.
✓ Branch 8 taken 563 times.
✓ Branch 9 taken 130 times.
693 for (const SubSurface& subSurface : this->subSurfaces()) {
1640
4/5
✓ Branch 1 taken 563 times.
✓ Branch 4 taken 563 times.
✓ Branch 7 taken 563 times.
✓ Branch 11 taken 563 times.
✗ Branch 12 not taken.
1126 if (istringEqual(subSurface.subSurfaceType(), "Skylight")) {
1641
2/2
✓ Branch 1 taken 563 times.
✓ Branch 4 taken 563 times.
563 skylightArea += subSurface.multiplier() * subSurface.netArea();
1642 }
1643 130 }
1644
1645 130 result = skylightArea / grossArea;
1646
1647 130 return result;
1648 }
1649
1650 20 double Surface_Impl::skylightToProjectedFloorRatio() const {
1651 20 double result = 0.0;
1652
1653
4/5
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 7 taken 20 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 20 times.
40 if (!istringEqual(this->surfaceType(), "RoofCeiling")) {
1654 ✗ return result;
1655 }
1656
1657
1/1
✓ Branch 1 taken 20 times.
20 Point3dVector vertices = this->vertices();
1658
3/3
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
✓ Branch 7 taken 20 times.
20 Plane horizontal(Point3d(0, 0, 0), Vector3d(0, 0, 1));
1659
1/1
✓ Branch 1 taken 20 times.
20 std::vector<Point3d> projectedVertics = horizontal.project(vertices);
1660
1661
1/1
✓ Branch 1 taken 20 times.
20 boost::optional<double> grossArea = getArea(projectedVertics);
1662
1663
4/7
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 20 times.
20 if (!grossArea || grossArea.get() == 0) {
1664 ✗ return result;
1665 }
1666
1667 20 double skylightArea = 0.0;
1668
3/3
✓ Branch 1 taken 20 times.
✓ Branch 8 taken 202 times.
✓ Branch 9 taken 20 times.
222 for (const SubSurface& subSurface : this->subSurfaces()) {
1669
4/5
✓ Branch 1 taken 202 times.
✓ Branch 4 taken 202 times.
✓ Branch 7 taken 202 times.
✓ Branch 11 taken 202 times.
✗ Branch 12 not taken.
404 if (istringEqual(subSurface.subSurfaceType(), "Skylight")) {
1670
2/2
✓ Branch 1 taken 202 times.
✓ Branch 4 taken 202 times.
202 skylightArea += subSurface.multiplier() * subSurface.netArea();
1671 }
1672 20 }
1673
1674
1/1
✓ Branch 1 taken 20 times.
20 result = skylightArea / grossArea.get();
1675
1676 20 return result;
1677 20 }
1678
1679 74 boost::optional<SubSurface> Surface_Impl::setWindowToWallRatio(double wwr) {
1680 74 return setWindowToWallRatio(wwr, 0.762, true);
1681 }
1682
1683 80 boost::optional<SubSurface> Surface_Impl::setWindowToWallRatio(double wwr, double desiredHeightOffset, bool heightOffsetFromFloor) {
1684 80 boost::optional<SubSurface> result;
1685 80 std::vector<SubSurface> tmp;
1686
1687 80 double viewGlassToWallRatio = 0;
1688 80 double daylightingGlassToWallRatio = 0;
1689 80 double desiredViewGlassSillHeight = 0;
1690 80 double desiredDaylightingGlassHeaderHeight = 0;
1691 80 double exteriorShadingProjectionFactor = 0;
1692 80 double interiorShelfProjectionFactor = 0;
1693 80 boost::optional<ConstructionBase> viewGlassConstruction;
1694 80 boost::optional<ConstructionBase> daylightingGlassConstruction;
1695
1696
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 1 time.
80 if (heightOffsetFromFloor) {
1697 79 viewGlassToWallRatio = wwr;
1698 79 desiredViewGlassSillHeight = desiredHeightOffset;
1699 } else {
1700 1 daylightingGlassToWallRatio = wwr;
1701 1 desiredDaylightingGlassHeaderHeight = desiredHeightOffset;
1702 }
1703
1704
1/1
✓ Branch 1 taken 80 times.
160 tmp = applyViewAndDaylightingGlassRatios(viewGlassToWallRatio, daylightingGlassToWallRatio, desiredViewGlassSillHeight,
1705 desiredDaylightingGlassHeaderHeight, exteriorShadingProjectionFactor, interiorShelfProjectionFactor,
1706 80 viewGlassConstruction, daylightingGlassConstruction);
1707
1708
2/2
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 10 times.
80 if (!tmp.empty()) {
1709
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
✗ Branch 4 not taken.
70 OS_ASSERT(tmp.size() == 1);
1710
1/1
✓ Branch 2 taken 70 times.
70 result = tmp[0];
1711 }
1712
1713 160 return result;
1714 80 }
1715
1716 203 std::vector<SubSurface> Surface_Impl::applyViewAndDaylightingGlassRatios(
1717 double viewGlassToWallRatio, double daylightingGlassToWallRatio, double desiredViewGlassSillHeight, double desiredDaylightingGlassHeaderHeight,
1718 double exteriorShadingProjectionFactor, double interiorShelfProjectionFactor, const boost::optional<ConstructionBase>& viewGlassConstruction,
1719 const boost::optional<ConstructionBase>& daylightingGlassConstruction) {
1720 203 std::vector<SubSurface> result;
1721
1722 // has to be a wall
1723
5/5
✓ Branch 1 taken 203 times.
✓ Branch 4 taken 203 times.
✓ Branch 7 taken 203 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 201 times.
406 if (!istringEqual(this->surfaceType(), "Wall")) {
1724 2 return result;
1725 }
1726
1727 // surface cannot have any non-window sub surfaces
1728
3/3
✓ Branch 1 taken 201 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 200 times.
202 for (const SubSurface& subSurface : this->subSurfaces()) {
1729
20/36
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 9 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 12 taken 1 time.
✓ Branch 15 taken 1 time.
✓ Branch 18 taken 1 time.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 23 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 26 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 29 taken 1 time.
✓ Branch 30 taken 2 times.
✗ Branch 31 not taken.
✓ Branch 33 taken 2 times.
✗ Branch 34 not taken.
✓ Branch 36 taken 2 times.
✗ Branch 37 not taken.
✓ Branch 38 taken 1 time.
✓ Branch 39 taken 1 time.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
8 if (istringEqual(subSurface.subSurfaceType(), "FixedWindow") || istringEqual(subSurface.subSurfaceType(), "OperableWindow")) {
1730 1 continue;
1731 }
1732 1 return result;
1733 201 }
1734
1735
1/1
✓ Branch 1 taken 200 times.
200 Point3dVector vertices = this->vertices();
1736 200 Point3dVector viewVertices;
1737 200 Point3dVector daylightingVertices;
1738 200 Point3dVector exteriorShadingVertices;
1739 200 Point3dVector interiorShelfVertices;
1740
1/1
✓ Branch 1 taken 200 times.
200 bool test = openstudio::applyViewAndDaylightingGlassRatios(viewGlassToWallRatio, daylightingGlassToWallRatio, desiredViewGlassSillHeight,
1741 desiredDaylightingGlassHeaderHeight, exteriorShadingProjectionFactor,
1742 interiorShelfProjectionFactor, vertices, viewVertices, daylightingVertices,
1743 exteriorShadingVertices, interiorShelfVertices);
1744
1745
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 192 times.
200 if (!test) {
1746 8 return result;
1747 }
1748
1749 // everything ok, remove all windows
1750
3/3
✓ Branch 1 taken 192 times.
✓ Branch 8 taken 1 time.
✓ Branch 9 taken 192 times.
193 for (SubSurface& subSurface : this->subSurfaces()) {
1751
11/36
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 time.
✗ Branch 12 not taken.
✗ Branch 15 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 1 time.
✗ Branch 25 not taken.
✓ Branch 26 taken 1 time.
✗ Branch 28 not taken.
✓ Branch 29 taken 1 time.
✓ Branch 30 taken 1 time.
✗ Branch 31 not taken.
✓ Branch 33 taken 1 time.
✗ Branch 34 not taken.
✓ Branch 36 taken 1 time.
✗ Branch 37 not taken.
✓ Branch 38 taken 1 time.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 46 not taken.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✗ Branch 49 not taken.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
3 if (istringEqual(subSurface.subSurfaceType(), "FixedWindow") || istringEqual(subSurface.subSurfaceType(), "OperableWindow")) {
1752
1/1
✓ Branch 1 taken 1 time.
1 subSurface.remove();
1753 }
1754 192 }
1755
1756 // add a new window
1757
1/1
✓ Branch 1 taken 192 times.
192 Model model = this->model();
1758
1/1
✓ Branch 1 taken 192 times.
192 auto thisSurface = this->getObject<Surface>();
1759
1/1
✓ Branch 1 taken 192 times.
192 boost::optional<Space> space = this->space();
1760
1761 192 boost::optional<SubSurface> viewWindow;
1762
2/2
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 12 times.
192 if (!viewVertices.empty()) {
1763
2/2
✓ Branch 1 taken 180 times.
✓ Branch 4 taken 180 times.
180 viewWindow = SubSurface(viewVertices, model);
1764
2/2
✓ Branch 1 taken 180 times.
✓ Branch 4 taken 180 times.
180 result.push_back(*viewWindow);
1765
2/2
✓ Branch 1 taken 180 times.
✓ Branch 4 taken 180 times.
180 viewWindow->setSurface(thisSurface);
1766
1767
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 69 times.
180 if (viewGlassConstruction) {
1768
3/3
✓ Branch 1 taken 111 times.
✓ Branch 4 taken 111 times.
✓ Branch 7 taken 111 times.
111 viewWindow->setConstruction(*viewGlassConstruction);
1769 }
1770 }
1771
1772 192 boost::optional<SubSurface> daylightingWindow;
1773
2/2
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 79 times.
192 if (!daylightingVertices.empty()) {
1774
2/2
✓ Branch 1 taken 113 times.
✓ Branch 4 taken 113 times.
113 daylightingWindow = SubSurface(daylightingVertices, model);
1775
2/2
✓ Branch 1 taken 113 times.
✓ Branch 4 taken 113 times.
113 result.push_back(*daylightingWindow);
1776
2/2
✓ Branch 1 taken 113 times.
✓ Branch 4 taken 113 times.
113 daylightingWindow->setSurface(thisSurface);
1777
1778
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 1 time.
113 if (daylightingGlassConstruction) {
1779
3/3
✓ Branch 1 taken 112 times.
✓ Branch 4 taken 112 times.
✓ Branch 7 taken 112 times.
112 daylightingWindow->setConstruction(*daylightingGlassConstruction);
1780 }
1781 }
1782
1783 192 boost::optional<DaylightingDeviceShelf> interiorShelf;
1784
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 190 times.
192 if (!interiorShelfVertices.empty()) {
1785
1/1
✓ Branch 1 taken 2 times.
2 InteriorPartitionSurfaceGroup interiorGroup(model);
1786
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (space) {
1787
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 interiorGroup.setSpace(*space);
1788 }
1789
1790
1/1
✓ Branch 1 taken 2 times.
2 InteriorPartitionSurface interiorSurface(interiorShelfVertices, model);
1791
1/1
✓ Branch 1 taken 2 times.
2 interiorSurface.setInteriorPartitionSurfaceGroup(interiorGroup);
1792
1793
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
2 OS_ASSERT(daylightingWindow);
1794
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 interiorShelf = DaylightingDeviceShelf(*daylightingWindow);
1795
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 interiorShelf->setInsideShelf(interiorSurface);
1796 2 }
1797
1798
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 191 times.
192 if (!exteriorShadingVertices.empty()) {
1799
1/1
✓ Branch 1 taken 1 time.
1 ShadingSurfaceGroup shadingGroup(model);
1800
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (space) {
1801
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 shadingGroup.setSpace(*space);
1802 }
1803
1804
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
1 OS_ASSERT(viewWindow);
1805
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 shadingGroup.setShadedSubSurface(*viewWindow);
1806
1807
1/1
✓ Branch 1 taken 1 time.
1 ShadingSurface shadingSurface(exteriorShadingVertices, model);
1808
1/1
✓ Branch 1 taken 1 time.
1 shadingSurface.setShadingSurfaceGroup(shadingGroup);
1809
1810 // EnergyPlus expects outside shelf to be on daylight window, we prefer to shade the view window so do not add this here
1811 //if (interiorShelf){
1812 // interiorShelf->setOutsideShelf(shadingSurface);
1813 //}
1814 1 }
1815
1816 192 return result;
1817 200 }
1818
1819 ✗ std::vector<ShadingSurfaceGroup> Surface_Impl::shadingSurfaceGroups() const {
1820 ✗ return getObject<ModelObject>().getModelObjectSources<ShadingSurfaceGroup>(ShadingSurfaceGroup::iddObjectType());
1821 }
1822
1823 struct PolygonAreaGreater
1824 {
1825 8 bool operator()(const Point3dVector& left, const Point3dVector& right) const {
1826
1/1
✓ Branch 1 taken 8 times.
8 boost::optional<double> leftA = getArea(left);
1827
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
8 if (!leftA) {
1828 ✗ leftA = 0;
1829 }
1830
1/1
✓ Branch 1 taken 8 times.
8 boost::optional<double> rightA = getArea(right);
1831
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
8 if (!rightA) {
1832 ✗ rightA = 0;
1833 }
1834
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
16 return (*leftA > *rightA);
1835 }
1836 };
1837
1838 1 std::vector<Surface> Surface_Impl::splitSurfaceForSubSurfaces() {
1839 1 std::vector<Surface> result;
1840
1841 1 double expand = 0.0254;
1842 1 double tol = 0.01; // should be less than expand
1843
1844 // has to be a wall
1845
4/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
2 if (!istringEqual(this->surfaceType(), "Wall")) {
1846 ✗ return result;
1847 }
1848
1849 // can't have adjacent surface
1850
2/3
✓ Branch 1 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
2 if (this->adjacentSurface()) {
1851 ✗ return result;
1852 }
1853
1854
1/1
✓ Branch 1 taken 1 time.
1 std::vector<SubSurface> subSurfaces = this->subSurfaces();
1855
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (subSurfaces.empty()) {
1856 // nothing to do
1857 ✗ return result;
1858 }
1859
1860
1/1
✓ Branch 1 taken 1 time.
1 Point3dVector vertices = this->vertices();
1861
1/1
✓ Branch 1 taken 1 time.
1 Transformation transformation = Transformation::alignFace(vertices);
1862
1/1
✓ Branch 1 taken 1 time.
1 Transformation inverseTransformation = transformation.inverse();
1863
1/1
✓ Branch 1 taken 1 time.
1 Point3dVector faceVertices = inverseTransformation * vertices;
1864
1865
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (faceVertices.size() < 3) {
1866 ✗ return result;
1867 }
1868
1869 // boost polygon wants vertices in clockwise order, faceVertices must be reversed
1870
1/1
✓ Branch 3 taken 1 time.
1 std::reverse(faceVertices.begin(), faceVertices.end());
1871
1872 // new coordinate system has z' in direction of outward normal, y' is up
1873 //double xmin = std::numeric_limits<double>::max();
1874 //double xmax = std::numeric_limits<double>::min();
1875 1 double ymin = std::numeric_limits<double>::max();
1876 1 double ymax = std::numeric_limits<double>::min();
1877
2/2
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 time.
5 for (const Point3d& faceVertex : faceVertices) {
1878 //xmin = std::min(xmin, faceVertex.x());
1879 //xmax = std::max(xmax, faceVertex.x());
1880
1/1
✓ Branch 1 taken 4 times.
4 ymin = std::min(ymin, faceVertex.y());
1881
1/1
✓ Branch 1 taken 4 times.
4 ymax = std::max(ymax, faceVertex.y());
1882 }
1883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 if (ymin > ymax) {
1884 ✗ return result;
1885 }
1886
1887 // create a mask for each sub surface
1888 1 std::vector<Point3dVector> masks;
1889 1 std::map<Handle, Point3dVector> handleToFaceVertexMap;
1890
2/2
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 1 time.
3 for (const SubSurface& subSurface : subSurfaces) {
1891
1892
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 Point3dVector subSurfaceFaceVertices = inverseTransformation * subSurface.vertices();
1893
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
2 if (subSurfaceFaceVertices.size() < 3) {
1894 ✗ continue;
1895 }
1896
1897 // boost polygon wants vertices in clockwise order, subSurfaceFaceVertices must be reversed
1898
1/1
✓ Branch 3 taken 2 times.
2 std::reverse(subSurfaceFaceVertices.begin(), subSurfaceFaceVertices.end());
1899
1900
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 handleToFaceVertexMap[subSurface.handle()] = subSurfaceFaceVertices;
1901
1902 2 double xmin = std::numeric_limits<double>::max();
1903 2 double xmax = std::numeric_limits<double>::min();
1904 //double ymin = std::numeric_limits<double>::max();
1905 //double ymax = std::numeric_limits<double>::min();
1906
2/2
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 2 times.
10 for (const Point3d& faceVertex : subSurfaceFaceVertices) {
1907
1/1
✓ Branch 1 taken 8 times.
8 xmin = std::min(xmin, faceVertex.x());
1908
1/1
✓ Branch 1 taken 8 times.
8 xmax = std::max(xmax, faceVertex.x());
1909 //ymin = std::min(ymin, faceVertex.y());
1910 //ymax = std::max(ymax, faceVertex.y());
1911 }
1912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (xmin > xmax) {
1913 ✗ continue;
1914 }
1915
1916
4/6
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 2 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
12 masks.emplace_back(Point3dVector{Point3d(xmax + expand, ymax + expand, 0), Point3d(xmax + expand, ymin - expand, 0),
1917 10 Point3d(xmin - expand, ymin - expand, 0), Point3d(xmin - expand, ymax + expand, 0)});
1918 2 }
1919
1920 // join masks
1921
1/1
✓ Branch 1 taken 1 time.
1 std::vector<Point3dVector> joinedMasks = joinAll(masks, tol);
1922
1923 // intersect masks with surface
1924 1 std::vector<Point3dVector> newFaces;
1925
1/1
✓ Branch 1 taken 1 time.
1 newFaces.push_back(faceVertices);
1926
2/2
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 1 time.
3 for (const Point3dVector& mask : joinedMasks) {
1927
1928 2 std::vector<Point3dVector> tmpFaces;
1929 2 unsigned numIntersects = 0;
1930
2/2
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 2 times.
6 for (const Point3dVector& newFace : newFaces) {
1931 // each mask should intersect one and only one newFace
1932
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<IntersectionResult> intersection = openstudio::intersect(newFace, mask, tol);
1933
1934
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if (intersection) {
1935 2 numIntersects += 1;
1936
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 tmpFaces.push_back(intersection->polygon1());
1937
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 auto thisTmpFaces = intersection->newPolygons1();
1938
1/1
✓ Branch 5 taken 2 times.
2 tmpFaces.insert(tmpFaces.end(), thisTmpFaces.begin(), thisTmpFaces.end());
1939 2 } else {
1940
1/1
✓ Branch 1 taken 2 times.
2 tmpFaces.push_back(newFace);
1941 }
1942 4 }
1943
1944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (numIntersects != 1) {
1945 ✗ LOG(Warn, "Expected each mask to intersect one and only one face");
1946 }
1947
1948
1/1
✓ Branch 1 taken 2 times.
2 newFaces = tmpFaces;
1949 2 }
1950
1951
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✗ Branch 4 not taken.
1 OS_ASSERT(!newFaces.empty());
1952
1953 // sort new faces in descending order by area
1954
1/1
✓ Branch 3 taken 1 time.
1 std::sort(newFaces.begin(), newFaces.end(), PolygonAreaGreater());
1955
1956 // loop over all new faces to create new Surfaces
1957 1 bool changedThis = false;
1958 1 unsigned numReparented = 0;
1959
1/1
✓ Branch 1 taken 1 time.
1 Model model = this->model();
1960
2/2
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 1 time.
6 for (const Point3dVector& newFace : newFaces) {
1961
1962 5 boost::optional<Surface> surface;
1963
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 4 times.
5 if (!changedThis) {
1964 // Re-use the original surface
1965 1 changedThis = true;
1966
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 surface = getObject<Surface>();
1967 } else {
1968 // Create new surfaces
1969
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
4 boost::optional<ModelObject> object = this->clone(model);
1970
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
4 OS_ASSERT(object);
1971
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 surface = object->optionalCast<Surface>();
1972
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
4 OS_ASSERT(surface);
1973 // remove cloned sub surfaces
1974
4/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 4 times.
11 for (ModelObject& child : surface->children()) {
1975
1/1
✓ Branch 1 taken 7 times.
7 child.remove();
1976 4 }
1977
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 result.push_back(*surface);
1978 4 }
1979
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 4 not taken.
5 OS_ASSERT(surface);
1980
1981
1/1
✓ Branch 1 taken 5 times.
5 Point3dVector vertices = newFace;
1982
1/1
✓ Branch 3 taken 5 times.
5 std::reverse(vertices.begin(), vertices.end());
1983
1/1
✓ Branch 1 taken 5 times.
5 vertices = transformation * vertices;
1984
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 surface->setVertices(vertices);
1985
1986 // loop over all sub surfaces and reparent
1987
2/2
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 5 times.
15 for (const auto& p : handleToFaceVertexMap) {
1988 // if surface includes a single point it will include them all
1989
3/3
✓ Branch 2 taken 10 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 8 times.
10 if (pointInPolygon(p.second[0], newFace, tol)) {
1990
1/1
✓ Branch 1 taken 2 times.
2 boost::optional<SubSurface> subSurface = model.getModelObject<SubSurface>(p.first);
1991
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (subSurface) {
1992 2 numReparented += 1;
1993
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 subSurface->setSurface(*surface);
1994 }
1995 2 continue;
1996 2 }
1997 }
1998 5 }
1999
2000
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
1 if (numReparented != handleToFaceVertexMap.size()) {
2001 ✗ LOG(Warn, "Expected to reparent " << handleToFaceVertexMap.size() << " sub surfaces in splitSurfaceForSubSurfaces, but only reparented "
2002 << numReparented);
2003 }
2004
2005 1 return result;
2006 3 }
2007
2008 49 std::vector<SubSurface> Surface_Impl::createSubSurfaces(const std::vector<std::vector<Point3d>>& faces, double inset,
2009 const boost::optional<ConstructionBase>& construction) {
2010 49 std::vector<SubSurface> result;
2011
2012 49 double tol = 0.0254;
2013
2014
3/3
✓ Branch 1 taken 49 times.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 48 times.
49 if (!this->subSurfaces().empty()) {
2015 1 return result;
2016 }
2017
2018
2/3
✓ Branch 1 taken 48 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 48 times.
96 if (this->adjacentSurface()) {
2019 ✗ return result;
2020 }
2021
2022
2/2
✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
48 boost::optional<Point3d> centroid = this->centroid();
2023
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
48 if (!centroid) {
2024 ✗ return result;
2025 }
2026
2027
1/1
✓ Branch 1 taken 48 times.
48 Point3dVector vertices = this->vertices();
2028
2/2
✓ Branch 1 taken 48 times.
✓ Branch 4 taken 48 times.
48 Point3dVector insetVertices = moveVerticesTowardsPoint(vertices, *centroid, inset);
2029
2030
1/1
✓ Branch 1 taken 48 times.
48 Transformation transformation = Transformation::alignFace(vertices);
2031
1/1
✓ Branch 1 taken 48 times.
48 Transformation inverseTransformation = transformation.inverse();
2032
1/1
✓ Branch 1 taken 48 times.
48 Point3dVector insetFaceVertices = inverseTransformation * insetVertices;
2033
2034 // boost polygon wants vertices in clockwise order, insetFaceVertices must be reversed
2035
1/1
✓ Branch 3 taken 48 times.
48 std::reverse(insetFaceVertices.begin(), insetFaceVertices.end());
2036
2037
1/1
✓ Branch 1 taken 48 times.
48 Model model = this->model();
2038
1/1
✓ Branch 1 taken 48 times.
48 auto surface = getObject<Surface>();
2039
2/2
✓ Branch 5 taken 1560 times.
✓ Branch 6 taken 48 times.
1608 for (const std::vector<Point3d>& face : faces) {
2040
1/1
✓ Branch 1 taken 1560 times.
1560 Point3dVector faceVertices = inverseTransformation * face;
2041
2042 // boost polygon wants vertices in clockwise order, faceVertices must be reversed
2043
1/1
✓ Branch 3 taken 1560 times.
1560 std::reverse(faceVertices.begin(), faceVertices.end());
2044
2045
1/1
✓ Branch 1 taken 1560 times.
1560 boost::optional<IntersectionResult> intersection = openstudio::intersect(faceVertices, insetFaceVertices, tol);
2046
2/2
✓ Branch 0 taken 501 times.
✓ Branch 1 taken 1059 times.
1560 if (intersection) {
2047
2/2
✓ Branch 1 taken 501 times.
✓ Branch 4 taken 501 times.
501 Point3dVector intersectionVertices = intersection->polygon1();
2048
2049 501 std::vector<std::vector<Point3d>> allNewFaceVertices;
2050
2/2
✓ Branch 1 taken 471 times.
✓ Branch 2 taken 30 times.
501 if (intersectionVertices.size() <= 4) {
2051
1/1
✓ Branch 1 taken 471 times.
471 allNewFaceVertices.push_back(intersectionVertices);
2052 } else {
2053 30 std::vector<std::vector<Point3d>> holes;
2054
1/1
✓ Branch 1 taken 30 times.
30 allNewFaceVertices = computeTriangulation(intersectionVertices, holes, tol);
2055 30 }
2056
2057 // TODO: I think the copy makes sense here
2058
3/3
✓ Branch 4 taken 561 times.
✓ Branch 8 taken 561 times.
✓ Branch 9 taken 501 times.
1062 for (Point3dVector newFaceVertices : allNewFaceVertices) {
2059
2060
1/1
✓ Branch 3 taken 561 times.
561 std::reverse(newFaceVertices.begin(), newFaceVertices.end());
2061
2062
1/1
✓ Branch 1 taken 561 times.
561 Point3dVector newVertices = transformation * newFaceVertices;
2063 try {
2064
2065
1/1
✓ Branch 1 taken 561 times.
561 SubSurface subSurface(newVertices, model);
2066
1/1
✓ Branch 1 taken 561 times.
561 subSurface.setSurface(surface);
2067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 561 times.
561 if (construction) {
2068 ✗ subSurface.setConstruction(*construction);
2069 }
2070
1/1
✓ Branch 1 taken 561 times.
561 result.push_back(subSurface);
2071
0/2
✗ Branch 2 not taken.
✗ Branch 3 not taken.
561 } catch (const std::exception&) {
2072 ✗ LOG(Error, "Could not create sub-surface.");
2073 ✗ }
2074 561 }
2075 501 }
2076 1560 }
2077
2078 48 return result;
2079 48 }
2080
2081 9 AirflowNetworkSurface Surface_Impl::getAirflowNetworkSurface(const AirflowNetworkComponent& surfaceAirflowLeakage) {
2082
1/1
✓ Branch 1 taken 9 times.
9 boost::optional<AirflowNetworkSurface> result = airflowNetworkSurface();
2083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (result) {
2084 ✗ boost::optional<AirflowNetworkComponent> leakageComponent = result->leakageComponent();
2085 ✗ if (leakageComponent) {
2086 ✗ if (leakageComponent->handle() == surfaceAirflowLeakage.handle()) {
2087 ✗ return result.get();
2088 } else {
2089 ✗ result->remove();
2090 }
2091 } else {
2092 ✗ result->remove();
2093 }
2094 ✗ }
2095
4/4
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
9 return AirflowNetworkSurface(this->model(), surfaceAirflowLeakage.handle(), this->handle());
2096 9 }
2097
2098 7 bool Surface_Impl::setAdjacentFoundation(const FoundationKiva& kiva) {
2099
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 bool result = this->setPointer(OS_SurfaceFields::OutsideBoundaryConditionObject, kiva.handle());
2100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 OS_ASSERT(result);
2101
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
14 result = this->setString(OS_SurfaceFields::OutsideBoundaryCondition, "Foundation");
2102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 OS_ASSERT(result);
2103 7 return result;
2104 }
2105
2106 24 boost::optional<AirflowNetworkSurface> Surface_Impl::airflowNetworkSurface() const {
2107 std::vector<AirflowNetworkSurface> myAFNSurfs =
2108
3/3
✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
24 getObject<ModelObject>().getModelObjectSources<AirflowNetworkSurface>(AirflowNetworkSurface::iddObjectType());
2109
1/1
✓ Branch 1 taken 24 times.
24 boost::optional<Surface> other = adjacentSurface();
2110
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 if (other) {
2111 std::vector<AirflowNetworkSurface> adjAFNSurfs =
2112
2/2
✓ Branch 1 taken 5 times.
✓ Branch 6 taken 5 times.
10 other.get().getImpl<detail::Surface_Impl>()->getObject<ModelObject>().getModelObjectSources<AirflowNetworkSurface>(
2113
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 AirflowNetworkSurface::iddObjectType());
2114
1/1
✓ Branch 5 taken 5 times.
5 myAFNSurfs.insert(myAFNSurfs.end(), adjAFNSurfs.begin(), adjAFNSurfs.end());
2115 5 }
2116 24 auto count = myAFNSurfs.size();
2117
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 16 times.
24 if (count == 1) {
2118
1/1
✓ Branch 2 taken 8 times.
8 return myAFNSurfs[0];
2119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 } else if (count > 1) {
2120 ✗ LOG(Warn, briefDescription() << " has more than one AirflowNetwork Surface attached, returning first.");
2121 ✗ return myAFNSurfs[0];
2122 }
2123 16 return boost::none;
2124 24 }
2125
2126 59095 boost::optional<FoundationKiva> Surface_Impl::adjacentFoundation() const {
2127
2/2
✓ Branch 1 taken 59095 times.
✓ Branch 4 taken 59095 times.
59095 return getObject<ModelObject>().getModelObjectTarget<FoundationKiva>(OS_SurfaceFields::OutsideBoundaryConditionObject);
2128 }
2129
2130 1 void Surface_Impl::resetAdjacentFoundation() {
2131
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<FoundationKiva> adjacentFoundation = this->adjacentFoundation();
2132
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (adjacentFoundation) {
2133
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool result = setString(OS_SurfaceFields::OutsideBoundaryConditionObject, "");
2134
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
1 OS_ASSERT(result);
2135
1/1
✓ Branch 1 taken 1 time.
1 this->assignDefaultBoundaryCondition();
2136
1/1
✓ Branch 1 taken 1 time.
1 this->assignDefaultSunExposure();
2137
1/1
✓ Branch 1 taken 1 time.
1 this->assignDefaultWindExposure();
2138 }
2139 1 }
2140
2141 boost::optional<SurfacePropertyExposedFoundationPerimeter>
2142 11 Surface_Impl::createSurfacePropertyExposedFoundationPerimeter(const std::string& exposedPerimeterCalculationMethod, double exposedPerimeter) {
2143
1/1
✓ Branch 1 taken 11 times.
11 auto thisSurface = getObject<Surface>();
2144 std::vector<SurfacePropertyExposedFoundationPerimeter> props =
2145
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 thisSurface.getModelObjectSources<SurfacePropertyExposedFoundationPerimeter>(SurfacePropertyExposedFoundationPerimeter::iddObjectType());
2146
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 10 times.
11 if (!props.empty()) {
2147 1 return boost::none;
2148 }
2149
2150
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
10 SurfacePropertyExposedFoundationPerimeter prop(thisSurface, exposedPerimeterCalculationMethod, exposedPerimeter);
2151
1/1
✓ Branch 1 taken 10 times.
10 return prop;
2152 11 }
2153
2154 11078 boost::optional<SurfacePropertyExposedFoundationPerimeter> Surface_Impl::surfacePropertyExposedFoundationPerimeter() const {
2155 std::vector<SurfacePropertyExposedFoundationPerimeter> props =
2156
1/1
✓ Branch 1 taken 11078 times.
22156 getObject<ModelObject>().getModelObjectSources<SurfacePropertyExposedFoundationPerimeter>(
2157
2/2
✓ Branch 1 taken 11078 times.
✓ Branch 4 taken 11078 times.
11078 SurfacePropertyExposedFoundationPerimeter::iddObjectType());
2158
2/2
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 11064 times.
11078 if (props.empty()) {
2159 // no error
2160
1/2
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
14 } else if (props.size() == 1) {
2161
1/1
✓ Branch 2 taken 14 times.
14 return props[0];
2162 } else {
2163 // error
2164 }
2165 11064 return boost::none;
2166 11078 }
2167
2168 1 void Surface_Impl::resetSurfacePropertyExposedFoundationPerimeter() {
2169
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<SurfacePropertyExposedFoundationPerimeter> prop = this->surfacePropertyExposedFoundationPerimeter();
2170
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (prop) {
2171
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 prop->remove();
2172 }
2173 1 }
2174
2175 ✗ std::vector<EMSActuatorNames> Surface_Impl::emsActuatorNames() const {
2176 std::vector<EMSActuatorNames> actuators{{"Surface", "Interior Surface Convection Heat Transfer Coefficient"},
2177 {"Surface", "Exterior Surface Convection Heat Transfer Coefficient"},
2178 {"Surface", "Outdoor Air Drybulb Temperature"},
2179 {"Surface", "Outdoor Air Wetbulb Temperature"},
2180 {"Surface", "Outdoor Air Wind Speed"},
2181 {"Surface", "Outdoor Air Wind Direction"},
2182 {"Surface", "Construction State"},
2183 {"Window Shading Control", "Control Status"},
2184 ✗ {"Window Shading Control", "Slat Angle"}};
2185 ✗ return actuators;
2186 ✗ }
2187
2188 ✗ std::vector<std::string> Surface_Impl::emsInternalVariableNames() const {
2189 ✗ std::vector<std::string> types;
2190 ✗ return types;
2191 }
2192
2193 ✗ double Surface_Impl::exposedPerimeter(const Polygon3d& buildingPerimeter) const {
2194 ✗ Transformation tr = space()->transformation();
2195
2196 ✗ double perimeter = 0;
2197
2198 ✗ if (surfaceType() == "Floor" && outsideBoundaryCondition() == "Ground") {
2199 ✗ auto vertices = this->vertices();
2200 ✗ if (!vertices.empty() && vertices[0].z() == 0.0) {
2201 ✗ vertices = tr * vertices;
2202 ✗ for (size_t i = 0; i < vertices.size(); i++) {
2203 ✗ Point3dVector line;
2204 ✗ line.push_back(vertices[i]);
2205 ✗ line.push_back(vertices[(i + 1) % vertices.size()]);
2206 ✗ Point3dVectorVector overlaps = buildingPerimeter.overlap(line);
2207 ✗ for (const auto& overlap : overlaps) {
2208 ✗ perimeter += openstudio::getDistance(overlap[0], overlap[1]);
2209 }
2210 ✗ }
2211 }
2212 ✗ }
2213
2214 ✗ return perimeter;
2215 ✗ }
2216
2217 } // namespace detail
2218
2219 26053 Surface::Surface(const std::vector<Point3d>& vertices, const Model& model) : PlanarSurface(Surface::iddObjectType(), vertices, model) {
2220
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 26049 times.
✗ Branch 5 not taken.
26049 OS_ASSERT(getImpl<detail::Surface_Impl>());
2221
1/1
✓ Branch 3 taken 26049 times.
26049 getImpl<detail::Surface_Impl>()->assignDefaultSurfaceType(false);
2222
1/1
✓ Branch 3 taken 26049 times.
26049 getImpl<detail::Surface_Impl>()->assignDefaultBoundaryCondition(false);
2223
1/1
✓ Branch 3 taken 26049 times.
26049 getImpl<detail::Surface_Impl>()->assignDefaultSunExposure(false);
2224
1/1
✓ Branch 3 taken 26049 times.
26049 getImpl<detail::Surface_Impl>()->assignDefaultWindExposure(false);
2225
1/1
✓ Branch 3 taken 26049 times.
26049 getImpl<detail::Surface_Impl>()->emitChangeSignals(); // emit signals here
2226 26049 }
2227
2228 275286 IddObjectType Surface::iddObjectType() {
2229
1/1
✓ Branch 1 taken 275286 times.
275286 IddObjectType result(IddObjectType::OS_Surface);
2230 275286 return result;
2231 }
2232
2233 ✗ std::vector<std::string> Surface::validSurfaceTypeValues() {
2234 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_SurfaceFields::SurfaceType);
2235 }
2236
2237 1 std::vector<std::string> Surface::validOutsideBoundaryConditionValues() {
2238
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 return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_SurfaceFields::OutsideBoundaryCondition);
2239 }
2240
2241 ✗ std::vector<std::string> Surface::validSunExposureValues() {
2242 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_SurfaceFields::SunExposure);
2243 }
2244
2245 ✗ std::vector<std::string> Surface::validWindExposureValues() {
2246 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_SurfaceFields::WindExposure);
2247 }
2248
2249 303793 std::string Surface::surfaceType() const {
2250
1/1
✓ Branch 3 taken 303793 times.
303793 return getImpl<detail::Surface_Impl>()->surfaceType();
2251 }
2252
2253 55265 std::string Surface::outsideBoundaryCondition() const {
2254
1/1
✓ Branch 3 taken 55265 times.
55265 return getImpl<detail::Surface_Impl>()->outsideBoundaryCondition();
2255 }
2256
2257 164 bool Surface::isGroundSurface() const {
2258
1/1
✓ Branch 3 taken 164 times.
164 return getImpl<detail::Surface_Impl>()->isGroundSurface();
2259 }
2260
2261 28315 std::string Surface::sunExposure() const {
2262
1/1
✓ Branch 3 taken 28315 times.
28315 return getImpl<detail::Surface_Impl>()->sunExposure();
2263 }
2264
2265 3261 bool Surface::isSunExposureDefaulted() const {
2266
1/1
✓ Branch 3 taken 3261 times.
3261 return getImpl<detail::Surface_Impl>()->isSunExposureDefaulted();
2267 }
2268
2269 27243 std::string Surface::windExposure() const {
2270
1/1
✓ Branch 3 taken 27243 times.
27243 return getImpl<detail::Surface_Impl>()->windExposure();
2271 }
2272
2273 3261 bool Surface::isWindExposureDefaulted() const {
2274
1/1
✓ Branch 3 taken 3261 times.
3261 return getImpl<detail::Surface_Impl>()->isWindExposureDefaulted();
2275 }
2276
2277 3261 boost::optional<double> Surface::viewFactortoGround() const {
2278
1/1
✓ Branch 3 taken 3261 times.
3261 return getImpl<detail::Surface_Impl>()->viewFactortoGround();
2279 }
2280
2281 ✗ bool Surface::isViewFactortoGroundDefaulted() const {
2282 ✗ return getImpl<detail::Surface_Impl>()->isViewFactortoGroundDefaulted();
2283 }
2284
2285 1 bool Surface::isViewFactortoGroundAutocalculated() const {
2286
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::Surface_Impl>()->isViewFactortoGroundAutocalculated();
2287 }
2288
2289 ✗ boost::optional<double> Surface::numberofVertices() const {
2290 ✗ return getImpl<detail::Surface_Impl>()->numberofVertices();
2291 }
2292
2293 ✗ bool Surface::isNumberofVerticesDefaulted() const {
2294 ✗ return getImpl<detail::Surface_Impl>()->isNumberofVerticesDefaulted();
2295 }
2296
2297 1 bool Surface::isNumberofVerticesAutocalculated() const {
2298
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::Surface_Impl>()->isNumberofVerticesAutocalculated();
2299 }
2300
2301 16338 bool Surface::setSurfaceType(const std::string& surfaceType) {
2302
1/1
✓ Branch 3 taken 16338 times.
16338 return getImpl<detail::Surface_Impl>()->setSurfaceType(surfaceType);
2303 }
2304
2305 2064 bool Surface::setOutsideBoundaryCondition(const std::string& outsideBoundaryCondition) {
2306
1/1
✓ Branch 3 taken 2064 times.
2064 return getImpl<detail::Surface_Impl>()->setOutsideBoundaryCondition(outsideBoundaryCondition);
2307 }
2308
2309 2141 bool Surface::setSunExposure(const std::string& sunExposure) {
2310
1/1
✓ Branch 3 taken 2141 times.
2141 return getImpl<detail::Surface_Impl>()->setSunExposure(sunExposure);
2311 }
2312
2313 ✗ void Surface::resetSunExposure() {
2314 ✗ getImpl<detail::Surface_Impl>()->resetSunExposure();
2315 ✗ }
2316
2317 2141 bool Surface::setWindExposure(const std::string& windExposure) {
2318
1/1
✓ Branch 3 taken 2141 times.
2141 return getImpl<detail::Surface_Impl>()->setWindExposure(windExposure);
2319 }
2320
2321 ✗ void Surface::resetWindExposure() {
2322 ✗ getImpl<detail::Surface_Impl>()->resetWindExposure();
2323 ✗ }
2324
2325 ✗ bool Surface::setViewFactortoGround(boost::optional<double> viewFactortoGround) {
2326 ✗ return getImpl<detail::Surface_Impl>()->setViewFactortoGround(viewFactortoGround);
2327 }
2328
2329 30 bool Surface::setViewFactortoGround(double viewFactortoGround) {
2330
1/1
✓ Branch 3 taken 30 times.
30 return getImpl<detail::Surface_Impl>()->setViewFactortoGround(viewFactortoGround);
2331 }
2332
2333 ✗ void Surface::resetViewFactortoGround() {
2334 ✗ getImpl<detail::Surface_Impl>()->resetViewFactortoGround();
2335 ✗ }
2336
2337 1 void Surface::autocalculateViewFactortoGround() {
2338
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::Surface_Impl>()->autocalculateViewFactortoGround();
2339 1 }
2340
2341 ✗ bool Surface::setNumberofVertices(boost::optional<double> numberofVertices) {
2342 ✗ return getImpl<detail::Surface_Impl>()->setNumberofVertices(numberofVertices);
2343 }
2344
2345 ✗ bool Surface::setNumberofVertices(double numberofVertices) {
2346 ✗ return getImpl<detail::Surface_Impl>()->setNumberofVertices(numberofVertices);
2347 }
2348
2349 ✗ void Surface::resetNumberofVertices() {
2350 ✗ getImpl<detail::Surface_Impl>()->resetNumberofVertices();
2351 ✗ }
2352
2353 1 void Surface::autocalculateNumberofVertices() {
2354
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::Surface_Impl>()->autocalculateNumberofVertices();
2355 1 }
2356
2357 768473 SubSurfaceVector Surface::subSurfaces() const {
2358
1/1
✓ Branch 3 taken 768473 times.
768473 return getImpl<detail::Surface_Impl>()->subSurfaces();
2359 }
2360
2361 26393 bool Surface::setSpace(const Space& space) {
2362
1/1
✓ Branch 3 taken 26393 times.
26393 return getImpl<detail::Surface_Impl>()->setSpace(space);
2363 }
2364
2365 1574146 boost::optional<Surface> Surface::adjacentSurface() const {
2366
1/1
✓ Branch 3 taken 1574146 times.
1574146 return getImpl<detail::Surface_Impl>()->adjacentSurface();
2367 }
2368
2369 14586 bool Surface::setAdjacentSurface(Surface& surface) {
2370
1/1
✓ Branch 3 taken 14586 times.
14586 return getImpl<detail::Surface_Impl>()->setAdjacentSurface(surface);
2371 }
2372
2373 6 void Surface::resetAdjacentSurface() {
2374
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::Surface_Impl>()->resetAdjacentSurface();
2375 }
2376
2377 3275 boost::optional<SurfaceControlMovableInsulation> Surface::surfaceControlMovableInsulation() const {
2378
1/1
✓ Branch 3 taken 3275 times.
3275 return getImpl<detail::Surface_Impl>()->surfaceControlMovableInsulation();
2379 }
2380
2381 3273 boost::optional<SurfacePropertyConvectionCoefficients> Surface::surfacePropertyConvectionCoefficients() const {
2382
1/1
✓ Branch 3 taken 3273 times.
3273 return getImpl<detail::Surface_Impl>()->surfacePropertyConvectionCoefficients();
2383 }
2384
2385 3274 boost::optional<SurfacePropertyLocalEnvironment> Surface::surfacePropertyLocalEnvironment() const {
2386
1/1
✓ Branch 3 taken 3274 times.
3274 return getImpl<detail::Surface_Impl>()->surfacePropertyLocalEnvironment();
2387 }
2388
2389 3266 boost::optional<SurfacePropertyOtherSideCoefficients> Surface::surfacePropertyOtherSideCoefficients() const {
2390
1/1
✓ Branch 3 taken 3266 times.
3266 return getImpl<detail::Surface_Impl>()->surfacePropertyOtherSideCoefficients();
2391 }
2392
2393 2 bool Surface::setSurfacePropertyOtherSideCoefficients(const SurfacePropertyOtherSideCoefficients& otherSideCoefficients) {
2394
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::Surface_Impl>()->setSurfacePropertyOtherSideCoefficients(otherSideCoefficients);
2395 }
2396
2397 ✗ void Surface::resetSurfacePropertyOtherSideCoefficients() {
2398 ✗ return getImpl<detail::Surface_Impl>()->resetSurfacePropertyOtherSideCoefficients();
2399 }
2400
2401 3270 boost::optional<SurfacePropertyOtherSideConditionsModel> Surface::surfacePropertyOtherSideConditionsModel() const {
2402
1/1
✓ Branch 3 taken 3270 times.
3270 return getImpl<detail::Surface_Impl>()->surfacePropertyOtherSideConditionsModel();
2403 }
2404
2405 4 bool Surface::setSurfacePropertyOtherSideConditionsModel(const SurfacePropertyOtherSideConditionsModel& otherSideModel) {
2406
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::Surface_Impl>()->setSurfacePropertyOtherSideConditionsModel(otherSideModel);
2407 }
2408
2409 ✗ void Surface::resetSurfacePropertyOtherSideConditionsModel() {
2410 ✗ return getImpl<detail::Surface_Impl>()->resetSurfacePropertyOtherSideConditionsModel();
2411 }
2412
2413 664 bool Surface::intersect(Surface& otherSurface) {
2414
1/1
✓ Branch 3 taken 664 times.
664 return getImpl<detail::Surface_Impl>()->intersect(otherSurface);
2415 }
2416
2417 520661 boost::optional<SurfaceIntersection> Surface::computeIntersection(Surface& otherSurface) {
2418
1/1
✓ Branch 3 taken 520661 times.
520661 return getImpl<detail::Surface_Impl>()->computeIntersection(otherSurface);
2419 }
2420
2421 836 boost::optional<Surface> Surface::createAdjacentSurface(const Space& otherSpace) {
2422
1/1
✓ Branch 3 taken 836 times.
836 return getImpl<detail::Surface_Impl>()->createAdjacentSurface(otherSpace);
2423 }
2424
2425 593 bool Surface::isPartOfEnvelope() const {
2426
1/1
✓ Branch 3 taken 593 times.
593 return getImpl<detail::Surface_Impl>()->isPartOfEnvelope();
2427 }
2428
2429 774 void Surface::assignDefaultSurfaceType() {
2430
1/1
✓ Branch 3 taken 774 times.
774 getImpl<detail::Surface_Impl>()->assignDefaultSurfaceType();
2431 774 }
2432
2433 85 void Surface::assignDefaultBoundaryCondition() {
2434
1/1
✓ Branch 3 taken 85 times.
85 getImpl<detail::Surface_Impl>()->assignDefaultBoundaryCondition();
2435 85 }
2436
2437 15504 void Surface::assignDefaultSunExposure() {
2438
1/1
✓ Branch 3 taken 15504 times.
15504 getImpl<detail::Surface_Impl>()->assignDefaultSunExposure();
2439 15504 }
2440
2441 15504 void Surface::assignDefaultWindExposure() {
2442
1/1
✓ Branch 3 taken 15504 times.
15504 getImpl<detail::Surface_Impl>()->assignDefaultWindExposure();
2443 15504 }
2444
2445 7 double Surface::filmResistance() const {
2446
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::Surface_Impl>()->filmResistance();
2447 }
2448
2449 30 double Surface::windowToWallRatio() const {
2450
1/1
✓ Branch 3 taken 30 times.
30 return getImpl<detail::Surface_Impl>()->windowToWallRatio();
2451 }
2452
2453 130 double Surface::skylightToRoofRatio() const {
2454
1/1
✓ Branch 3 taken 130 times.
130 return getImpl<detail::Surface_Impl>()->skylightToRoofRatio();
2455 }
2456
2457 20 double Surface::skylightToProjectedFloorRatio() const {
2458
1/1
✓ Branch 3 taken 20 times.
20 return getImpl<detail::Surface_Impl>()->skylightToProjectedFloorRatio();
2459 }
2460
2461 74 boost::optional<SubSurface> Surface::setWindowToWallRatio(double wwr) {
2462
1/1
✓ Branch 3 taken 74 times.
74 return getImpl<detail::Surface_Impl>()->setWindowToWallRatio(wwr);
2463 }
2464
2465 6 boost::optional<SubSurface> Surface::setWindowToWallRatio(double wwr, double desiredHeightOffset, bool heightOffsetFromFloor) {
2466
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::Surface_Impl>()->setWindowToWallRatio(wwr, desiredHeightOffset, heightOffsetFromFloor);
2467 }
2468
2469 123 std::vector<SubSurface> Surface::applyViewAndDaylightingGlassRatios(double viewGlassToWallRatio, double daylightingGlassToWallRatio,
2470 double desiredViewGlassSillHeight, double desiredDaylightingGlassHeaderHeight,
2471 double exteriorShadingProjectionFactor, double interiorShelfProjectionFactor,
2472 const boost::optional<ConstructionBase>& viewGlassConstruction,
2473 const boost::optional<ConstructionBase>& daylightingGlassConstruction) {
2474 246 return getImpl<detail::Surface_Impl>()->applyViewAndDaylightingGlassRatios(
2475 viewGlassToWallRatio, daylightingGlassToWallRatio, desiredViewGlassSillHeight, desiredDaylightingGlassHeaderHeight,
2476
1/1
✓ Branch 2 taken 123 times.
246 exteriorShadingProjectionFactor, interiorShelfProjectionFactor, viewGlassConstruction, daylightingGlassConstruction);
2477 }
2478
2479 49 std::vector<SubSurface> Surface::createSubSurfaces(const std::vector<std::vector<Point3d>>& faces, double inset,
2480 const boost::optional<ConstructionBase>& construction) {
2481
1/1
✓ Branch 3 taken 49 times.
49 return getImpl<detail::Surface_Impl>()->createSubSurfaces(faces, inset, construction);
2482 }
2483
2484 ✗ std::vector<ShadingSurfaceGroup> Surface::shadingSurfaceGroups() const {
2485 ✗ return getImpl<detail::Surface_Impl>()->shadingSurfaceGroups();
2486 }
2487
2488 1 std::vector<Surface> Surface::splitSurfaceForSubSurfaces() {
2489
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::Surface_Impl>()->splitSurfaceForSubSurfaces();
2490 }
2491
2492 7 bool Surface::setAdjacentFoundation(const FoundationKiva& kiva) {
2493
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::Surface_Impl>()->setAdjacentFoundation(kiva);
2494 }
2495
2496 3268 boost::optional<FoundationKiva> Surface::adjacentFoundation() const {
2497
1/1
✓ Branch 3 taken 3268 times.
3268 return getImpl<detail::Surface_Impl>()->adjacentFoundation();
2498 }
2499
2500 1 void Surface::resetAdjacentFoundation() {
2501
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::Surface_Impl>()->resetAdjacentFoundation();
2502 }
2503
2504 boost::optional<SurfacePropertyExposedFoundationPerimeter>
2505 11 Surface::createSurfacePropertyExposedFoundationPerimeter(const std::string& exposedPerimeterCalculationMethod, double exposedPerimeter) {
2506
1/1
✓ Branch 3 taken 11 times.
11 return getImpl<detail::Surface_Impl>()->createSurfacePropertyExposedFoundationPerimeter(exposedPerimeterCalculationMethod, exposedPerimeter);
2507 }
2508
2509 3283 boost::optional<SurfacePropertyExposedFoundationPerimeter> Surface::surfacePropertyExposedFoundationPerimeter() const {
2510
1/1
✓ Branch 3 taken 3283 times.
3283 return getImpl<detail::Surface_Impl>()->surfacePropertyExposedFoundationPerimeter();
2511 }
2512
2513 1 void Surface::resetSurfacePropertyExposedFoundationPerimeter() {
2514
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::Surface_Impl>()->resetSurfacePropertyExposedFoundationPerimeter();
2515 1 }
2516
2517 /// @cond
2518
1/1
✓ Branch 3 taken 4766073 times.
4766073 Surface::Surface(std::shared_ptr<detail::Surface_Impl> impl) : PlanarSurface(std::move(impl)) {}
2519 /// @endcond
2520
2521 7021 SurfaceIntersection::SurfaceIntersection(const Surface& surface1, const Surface& surface2, const std::vector<Surface>& newSurfaces1,
2522 7021 const std::vector<Surface>& newSurfaces2)
2523
3/3
✓ Branch 2 taken 7021 times.
✓ Branch 5 taken 7021 times.
✓ Branch 8 taken 7021 times.
7021 : m_surface1(surface1), m_surface2(surface2), m_newSurfaces1(newSurfaces1), m_newSurfaces2(newSurfaces2) {}
2524
2525 7021 Surface SurfaceIntersection::surface1() const {
2526 7021 return m_surface1;
2527 }
2528
2529 7021 Surface SurfaceIntersection::surface2() const {
2530 7021 return m_surface2;
2531 }
2532
2533 13458 std::vector<Surface> SurfaceIntersection::newSurfaces1() const {
2534 13458 return m_newSurfaces1;
2535 }
2536
2537 13458 std::vector<Surface> SurfaceIntersection::newSurfaces2() const {
2538 13458 return m_newSurfaces2;
2539 }
2540
2541 7021 std::ostream& operator<<(std::ostream& os, const SurfaceIntersection& surfaceIntersection) {
2542
6/6
✓ Branch 1 taken 7021 times.
✓ Branch 4 taken 7021 times.
✓ Branch 7 taken 7021 times.
✓ Branch 10 taken 7021 times.
✓ Branch 13 taken 7021 times.
✓ Branch 16 taken 7021 times.
7021 os << "(" << surfaceIntersection.surface1().name().get() << "), ";
2543
2544
6/6
✓ Branch 1 taken 7021 times.
✓ Branch 4 taken 7021 times.
✓ Branch 7 taken 7021 times.
✓ Branch 10 taken 7021 times.
✓ Branch 13 taken 7021 times.
✓ Branch 16 taken 7021 times.
7021 os << "(" << surfaceIntersection.surface2().name().get() << "), ";
2545
2546
1/1
✓ Branch 1 taken 7021 times.
7021 os << "[";
2547
1/1
✓ Branch 1 taken 7021 times.
7021 std::vector<Surface> newSurfaces1 = surfaceIntersection.newSurfaces1();
2548
2/2
✓ Branch 1 taken 1847 times.
✓ Branch 2 taken 7021 times.
8868 for (unsigned i = 0; i < newSurfaces1.size(); ++i) {
2549
3/3
✓ Branch 2 taken 1847 times.
✓ Branch 5 taken 1847 times.
✓ Branch 8 taken 1847 times.
1847 os << newSurfaces1[i].name().get();
2550
2/2
✓ Branch 1 taken 344 times.
✓ Branch 2 taken 1503 times.
1847 if (i != newSurfaces1.size() - 1) {
2551
1/1
✓ Branch 1 taken 344 times.
344 os << ", ";
2552 }
2553 }
2554
2555
1/1
✓ Branch 1 taken 7021 times.
7021 os << "], [";
2556
1/1
✓ Branch 1 taken 7021 times.
7021 std::vector<Surface> newSurfaces2 = surfaceIntersection.newSurfaces2();
2557
2/2
✓ Branch 1 taken 1356 times.
✓ Branch 2 taken 7021 times.
8377 for (unsigned i = 0; i < newSurfaces2.size(); ++i) {
2558
3/3
✓ Branch 2 taken 1356 times.
✓ Branch 5 taken 1356 times.
✓ Branch 8 taken 1356 times.
1356 os << newSurfaces2[i].name().get();
2559
2/2
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 1095 times.
1356 if (i != newSurfaces2.size() - 1) {
2560
1/1
✓ Branch 1 taken 261 times.
261 os << ", ";
2561 }
2562 }
2563
1/1
✓ Branch 1 taken 7021 times.
7021 os << "]";
2564
2565 7021 return os;
2566 7021 }
2567
2568 1 AirflowNetworkSurface Surface::getAirflowNetworkSurface(const AirflowNetworkDetailedOpening& surfaceAirflowLeakage) {
2569
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::Surface_Impl>()->getAirflowNetworkSurface(surfaceAirflowLeakage);
2570 }
2571
2572 1 AirflowNetworkSurface Surface::getAirflowNetworkSurface(const AirflowNetworkSimpleOpening& surfaceAirflowLeakage) {
2573
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::Surface_Impl>()->getAirflowNetworkSurface(surfaceAirflowLeakage);
2574 }
2575
2576 3 AirflowNetworkSurface Surface::getAirflowNetworkSurface(const AirflowNetworkCrack& surfaceAirflowLeakage) {
2577
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::Surface_Impl>()->getAirflowNetworkSurface(surfaceAirflowLeakage);
2578 }
2579
2580 1 AirflowNetworkSurface Surface::getAirflowNetworkSurface(const AirflowNetworkEffectiveLeakageArea& surfaceAirflowLeakage) {
2581
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::Surface_Impl>()->getAirflowNetworkSurface(surfaceAirflowLeakage);
2582 }
2583
2584 1 AirflowNetworkSurface Surface::getAirflowNetworkSurface(const AirflowNetworkHorizontalOpening& surfaceAirflowLeakage) {
2585
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::Surface_Impl>()->getAirflowNetworkSurface(surfaceAirflowLeakage);
2586 }
2587
2588 2 AirflowNetworkSurface Surface::getAirflowNetworkSurface(const AirflowNetworkSpecifiedFlowRate& surfaceAirflowLeakage) {
2589
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::Surface_Impl>()->getAirflowNetworkSurface(surfaceAirflowLeakage);
2590 }
2591
2592 15 boost::optional<AirflowNetworkSurface> Surface::airflowNetworkSurface() const {
2593
1/1
✓ Branch 3 taken 15 times.
15 return getImpl<detail::Surface_Impl>()->airflowNetworkSurface();
2594 }
2595
2596 ✗ double Surface::exposedPerimeter(const Polygon3d& buildingPerimeter) const {
2597 ✗ return getImpl<detail::Surface_Impl>()->exposedPerimeter(buildingPerimeter);
2598 }
2599 } // namespace model
2600 } // namespace openstudio
2601