GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 83.7% 1208 / 0 / 1443
Functions: 78.4% 156 / 0 / 199
Branches: 68.3% 1699 / 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 48737 Surface_Impl::Surface_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) : PlanarSurface_Impl(idfObject, model, keepHandle) {
81
4/6
✓ Branch 1 taken 48737 times.
✓ Branch 4 taken 48737 times.
✓ Branch 7 taken 48737 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 48737 times.
✗ Branch 13 not taken.
48737 OS_ASSERT(idfObject.iddObject().type() == Surface::iddObjectType());
82 48737 }
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 13426 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 7821 std::vector<ModelObject> Surface_Impl::children() const {
106 7821 std::vector<ModelObject> result;
107
108 // subSurfaces
109
1/1
✓ Branch 1 taken 7821 times.
7821 SubSurfaceVector subSurfaces = this->subSurfaces();
110
1/1
✓ Branch 5 taken 7821 times.
7821 result.insert(result.end(), subSurfaces.begin(), subSurfaces.end());
111
112 std::vector<AirflowNetworkSurface> myAFNItems =
113
3/3
✓ Branch 1 taken 7821 times.
✓ Branch 4 taken 7821 times.
✓ Branch 7 taken 7821 times.
7821 getObject<ModelObject>().getModelObjectSources<AirflowNetworkSurface>(AirflowNetworkSurface::iddObjectType());
114
1/1
✓ Branch 5 taken 7821 times.
7821 result.insert(result.end(), myAFNItems.begin(), myAFNItems.end());
115
116
3/3
✓ Branch 1 taken 7821 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 7817 times.
15642 if (boost::optional<SurfacePropertyExposedFoundationPerimeter> prop = this->surfacePropertyExposedFoundationPerimeter()) {
117
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 result.push_back(prop.get());
118 7821 }
119
120 15642 return result;
121 7821 }
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 48181 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 48181 times.
48181 boost::optional<std::pair<ConstructionBase, int>> constructionWithSearchDistance = this->constructionWithSearchDistance();
300
301
1/1
✓ Branch 1 taken 48181 times.
48181 model::OptionalSurface adjacentSurface = this->adjacentSurface();
302
2/2
✓ Branch 1 taken 35523 times.
✓ Branch 2 taken 12658 times.
48181 if (!adjacentSurface) {
303
2/2
✓ Branch 0 taken 18517 times.
✓ Branch 1 taken 17006 times.
35523 if (constructionWithSearchDistance) {
304
2/2
✓ Branch 1 taken 18517 times.
✓ Branch 4 taken 18517 times.
18517 return constructionWithSearchDistance->first;
305 }
306 17006 return boost::none;
307 }
308
309 boost::optional<std::pair<model::ConstructionBase, int>> adjacentConstructionWithSearchDistance =
310
2/2
✓ Branch 1 taken 12658 times.
✓ Branch 4 taken 12658 times.
12658 adjacentSurface->constructionWithSearchDistance();
311
312
6/6
✓ Branch 0 taken 10818 times.
✓ Branch 1 taken 1840 times.
✓ Branch 3 taken 860 times.
✓ Branch 4 taken 9958 times.
✓ Branch 5 taken 860 times.
✓ Branch 6 taken 11798 times.
12658 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 1840 times.
✓ Branch 2 taken 9958 times.
✓ Branch 3 taken 640 times.
✓ Branch 4 taken 1200 times.
✓ Branch 5 taken 640 times.
✓ Branch 6 taken 11158 times.
13638 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 1200 times.
✓ Branch 2 taken 9958 times.
✓ Branch 4 taken 1200 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1200 times.
✓ Branch 7 taken 9958 times.
11158 if (!constructionWithSearchDistance && !adjacentConstructionWithSearchDistance) {
323 // no constructions, nothing to be done
324 1200 return boost::none;
325 }
326
327 // both surfaces return a construction
328
329
7/7
✓ Branch 1 taken 9958 times.
✓ Branch 4 taken 9958 times.
✓ Branch 7 taken 9958 times.
✓ Branch 10 taken 9958 times.
✓ Branch 13 taken 9958 times.
✓ Branch 15 taken 7990 times.
✓ Branch 16 taken 1968 times.
9958 if (constructionWithSearchDistance->first.handle() == adjacentConstructionWithSearchDistance->first.handle()) {
330 // both surfaces have same construction
331
2/2
✓ Branch 1 taken 7990 times.
✓ Branch 4 taken 7990 times.
7990 return constructionWithSearchDistance->first;
332 }
333
334 // both surfaces return a construction and they are not the same
335
336
4/4
✓ Branch 1 taken 1968 times.
✓ Branch 4 taken 1968 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 1961 times.
1968 if (constructionWithSearchDistance->second < adjacentConstructionWithSearchDistance->second) {
337 // lower search distance to construction
338
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 return constructionWithSearchDistance->first;
339 }
340
341
4/4
✓ Branch 1 taken 1961 times.
✓ Branch 4 taken 1961 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 1954 times.
1961 if (constructionWithSearchDistance->second > adjacentConstructionWithSearchDistance->second) {
342 // lower search distance to adjacent construction
343
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 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 1954 times.
✓ Branch 4 taken 1954 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3908 if (constructionWithSearchDistance->first.optionalCast<model::LayeredConstruction>()
349
7/13
✓ Branch 1 taken 1954 times.
✓ Branch 4 taken 1954 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1954 times.
✓ Branch 10 taken 1954 times.
✓ Branch 13 taken 1954 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 1954 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 1954 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
7816 && adjacentConstructionWithSearchDistance->first.optionalCast<model::LayeredConstruction>()) {
350
4/5
✓ Branch 1 taken 1954 times.
✓ Branch 4 taken 1954 times.
✓ Branch 7 taken 1954 times.
✓ Branch 9 taken 1954 times.
✗ Branch 10 not taken.
5862 if (constructionWithSearchDistance->first.cast<model::LayeredConstruction>().reverseEqualLayers(
351
2/2
✓ Branch 1 taken 1954 times.
✓ Branch 4 taken 1954 times.
3908 adjacentConstructionWithSearchDistance->first.cast<model::LayeredConstruction>())) {
352 // these constructions are reverse equal
353
2/2
✓ Branch 1 taken 1954 times.
✓ Branch 4 taken 1954 times.
1954 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 48181 }
361
362 62039 boost::optional<std::pair<ConstructionBase, int>> Surface_Impl::constructionWithSearchDistance() const {
363 62039 boost::optional<std::pair<ConstructionBase, int>> result;
364
365 boost::optional<ConstructionBase> construction =
366
2/2
✓ Branch 1 taken 62039 times.
✓ Branch 4 taken 62039 times.
62039 getObject<ModelObject>().getModelObjectTarget<ConstructionBase>(OS_SurfaceFields::ConstructionName);
367
2/2
✓ Branch 0 taken 20662 times.
✓ Branch 1 taken 41377 times.
62039 if (construction) {
368
3/3
✓ Branch 1 taken 20662 times.
✓ Branch 4 taken 20662 times.
✓ Branch 7 taken 20662 times.
20662 return std::make_pair(*construction, 0);
369 }
370
371
1/1
✓ Branch 1 taken 41377 times.
41377 boost::optional<Space> space = this->space();
372
2/2
✓ Branch 0 taken 41372 times.
✓ Branch 1 taken 5 times.
41377 if (space) {
373
3/3
✓ Branch 1 taken 41372 times.
✓ Branch 4 taken 41372 times.
✓ Branch 7 taken 41372 times.
41372 result = space->getDefaultConstructionWithSearchDistance(this->getObject<Surface>());
374 }
375 41377 return result;
376 62039 }
377
378 3951 bool Surface_Impl::isConstructionDefaulted() const {
379 3951 return isEmpty(OS_SurfaceFields::ConstructionName);
380 }
381
382 46213 bool Surface_Impl::setVertices(const std::vector<Point3d>& vertices) {
383 46213 bool result = PlanarSurface_Impl::setVertices(vertices);
384
385
2/2
✓ Branch 1 taken 26187 times.
✓ Branch 2 taken 20026 times.
46213 if (isEmpty(OS_SurfaceFields::SurfaceType)) {
386
2/2
✓ Branch 0 taken 26184 times.
✓ Branch 1 taken 3 times.
26187 if (result) {
387 26184 this->assignDefaultSurfaceType(false);
388 26183 this->assignDefaultBoundaryCondition(false);
389 26183 this->assignDefaultSunExposure(false);
390 26183 this->assignDefaultWindExposure(false);
391 26183 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 46212 return result;
398 }
399
400 3194 bool Surface_Impl::setConstruction(const ConstructionBase& construction) {
401
2/2
✓ Branch 1 taken 3194 times.
✓ Branch 4 taken 3194 times.
3194 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 359297 std::string Surface_Impl::surfaceType() const {
409
1/1
✓ Branch 1 taken 359297 times.
359297 boost::optional<std::string> value = getString(OS_SurfaceFields::SurfaceType, true, true);
410
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 359297 times.
✗ Branch 4 not taken.
359297 OS_ASSERT(value);
411
2/2
✓ Branch 1 taken 359297 times.
✓ Branch 4 taken 359297 times.
718594 return value.get();
412 359297 }
413
414 ✗ std::vector<std::string> Surface_Impl::surfaceTypeValues() const {
415 ✗ return Surface::validSurfaceTypeValues();
416 }
417
418 333719 std::string Surface_Impl::outsideBoundaryCondition() const {
419
1/1
✓ Branch 1 taken 333719 times.
333719 boost::optional<std::string> value = getString(OS_SurfaceFields::OutsideBoundaryCondition, true);
420
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 333719 times.
✗ Branch 4 not taken.
333719 OS_ASSERT(value);
421
2/2
✓ Branch 1 taken 333719 times.
✓ Branch 4 taken 333719 times.
667438 return value.get();
422 333719 }
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 28342 std::string Surface_Impl::sunExposure() const {
446
1/1
✓ Branch 1 taken 28342 times.
28342 boost::optional<std::string> value = getString(OS_SurfaceFields::SunExposure, true);
447
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 28342 times.
✗ Branch 4 not taken.
28342 OS_ASSERT(value);
448
2/2
✓ Branch 1 taken 28342 times.
✓ Branch 4 taken 28342 times.
56684 return value.get();
449 28342 }
450
451 ✗ std::vector<std::string> Surface_Impl::sunExposureValues() const {
452 ✗ return Surface::validSunExposureValues();
453 }
454
455 3288 bool Surface_Impl::isSunExposureDefaulted() const {
456 3288 return isEmpty(OS_SurfaceFields::SunExposure);
457 }
458
459 27270 std::string Surface_Impl::windExposure() const {
460
1/1
✓ Branch 1 taken 27270 times.
27270 boost::optional<std::string> value = getString(OS_SurfaceFields::WindExposure, true);
461
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 27270 times.
✗ Branch 4 not taken.
27270 OS_ASSERT(value);
462
2/2
✓ Branch 1 taken 27270 times.
✓ Branch 4 taken 27270 times.
54540 return value.get();
463 27270 }
464
465 ✗ std::vector<std::string> Surface_Impl::windExposureValues() const {
466 ✗ return Surface::validWindExposureValues();
467 }
468
469 3288 bool Surface_Impl::isWindExposureDefaulted() const {
470 3288 return isEmpty(OS_SurfaceFields::WindExposure);
471 }
472
473 3288 boost::optional<double> Surface_Impl::viewFactortoGround() const {
474 3288 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 69477 bool Surface_Impl::setSurfaceType(const std::string& surfaceType, bool driverMethod) {
512 69477 bool result = setString(OS_SurfaceFields::SurfaceType, surfaceType, true);
513
2/2
✓ Branch 0 taken 17112 times.
✓ Branch 1 taken 52365 times.
69477 if (driverMethod) {
514 17112 this->emitChangeSignals(); // emit signals here
515 }
516 69477 return result;
517 }
518
519 2069 bool Surface_Impl::setOutsideBoundaryCondition(const std::string& outsideBoundaryCondition) {
520 2069 return setOutsideBoundaryCondition(outsideBoundaryCondition, true);
521 }
522
523 54598 bool Surface_Impl::setOutsideBoundaryCondition(const std::string& outsideBoundaryCondition, bool driverMethod) {
524 54598 bool result = false;
525
526
1/1
✓ Branch 1 taken 54598 times.
54598 boost::optional<Surface> adjacentSurface = this->adjacentSurface();
527
1/1
✓ Branch 1 taken 54598 times.
54598 boost::optional<SurfacePropertyOtherSideCoefficients> surfacePropertyOtherSideCoefficients = this->surfacePropertyOtherSideCoefficients();
528 boost::optional<SurfacePropertyOtherSideConditionsModel> surfacePropertyOtherSideConditionsModel =
529
1/1
✓ Branch 1 taken 54598 times.
54598 this->surfacePropertyOtherSideConditionsModel();
530
531
4/4
✓ Branch 1 taken 54598 times.
✓ Branch 4 taken 54598 times.
✓ Branch 7 taken 95 times.
✓ Branch 8 taken 54503 times.
109196 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 54503 times.
✓ Branch 4 taken 54503 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54503 times.
109006 } else if (istringEqual("OtherSideCoefficients", outsideBoundaryCondition)) {
536 ✗ if (surfacePropertyOtherSideCoefficients) {
537 ✗ result = setString(OS_SurfaceFields::OutsideBoundaryCondition, outsideBoundaryCondition, true);
538 }
539
3/4
✓ Branch 1 taken 54503 times.
✓ Branch 4 taken 54503 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54503 times.
109006 } 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 54503 times.
54503 this->resetAdjacentSurface();
545
1/1
✓ Branch 1 taken 54503 times.
54503 this->resetSurfacePropertyOtherSideCoefficients();
546
1/1
✓ Branch 1 taken 54503 times.
54503 this->resetSurfacePropertyOtherSideConditionsModel();
547
1/1
✓ Branch 1 taken 54503 times.
54503 result = setString(OS_SurfaceFields::OutsideBoundaryCondition, outsideBoundaryCondition, true);
548
2/2
✓ Branch 0 taken 54497 times.
✓ Branch 1 taken 6 times.
54503 if (result) {
549
1/1
✓ Branch 1 taken 54497 times.
54497 this->assignDefaultSunExposure(false);
550
1/1
✓ Branch 1 taken 54497 times.
54497 this->assignDefaultWindExposure(false);
551
552
4/4
✓ Branch 1 taken 54497 times.
✓ Branch 4 taken 54497 times.
✓ Branch 7 taken 838 times.
✓ Branch 8 taken 53659 times.
108994 if (istringEqual("Adiabatic", outsideBoundaryCondition)) {
553 // remove all subsurfaces
554 838 int n_subsurfaces = 0;
555
2/3
✓ Branch 1 taken 838 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 838 times.
838 for (auto& subSurface : subSurfaces()) {
556 ✗ subSurface.remove();
557 ✗ ++n_subsurfaces;
558 838 }
559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 838 times.
838 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 2233 times.
✓ Branch 1 taken 52365 times.
54598 if (driverMethod) {
582
1/1
✓ Branch 1 taken 2233 times.
2233 this->emitChangeSignals(); // emit signals here
583 }
584
585 54598 return result;
586 54598 }
587
588 2141 bool Surface_Impl::setSunExposure(const std::string& sunExposure) {
589 2141 return setSunExposure(sunExposure, true);
590 }
591
592 140042 bool Surface_Impl::setSunExposure(const std::string& sunExposure, bool driverMethod) {
593 140042 bool result = setString(OS_SurfaceFields::SunExposure, sunExposure, true);
594
2/2
✓ Branch 0 taken 33180 times.
✓ Branch 1 taken 106862 times.
140042 if (driverMethod) {
595 33180 this->emitChangeSignals(); // emit signals here
596 }
597 140042 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 140042 bool Surface_Impl::setWindExposure(const std::string& windExposure, bool driverMethod) {
610 140042 bool result = setString(OS_SurfaceFields::WindExposure, windExposure, true);
611
2/2
✓ Branch 0 taken 33180 times.
✓ Branch 1 taken 106862 times.
140042 if (driverMethod) {
612 33180 this->emitChangeSignals(); // emit signals here
613 }
614 140042 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 1472303 SubSurfaceVector Surface_Impl::subSurfaces() const {
673 1472303 SubSurfaceVector result;
674
1/1
✓ Branch 1 taken 1472303 times.
1472303 auto object = getObject<ModelObject>();
675
2/2
✓ Branch 1 taken 1472303 times.
✓ Branch 4 taken 1472303 times.
1472303 WorkspaceObjectVector idfSubSurfaces = object.getSources(IddObjectType(IddObjectType::OS_SubSurface));
676
2/2
✓ Branch 5 taken 25077 times.
✓ Branch 6 taken 1472303 times.
1497380 for (const WorkspaceObject& idfSubSurface : idfSubSurfaces) {
677
3/3
✓ Branch 1 taken 25077 times.
✓ Branch 4 taken 25077 times.
✓ Branch 7 taken 25077 times.
25077 OptionalSubSurface subSurface = this->model().getModelObject<SubSurface>(idfSubSurface.handle());
678
1/2
✓ Branch 0 taken 25077 times.
✗ Branch 1 not taken.
25077 if (subSurface) {
679
2/2
✓ Branch 1 taken 25077 times.
✓ Branch 4 taken 25077 times.
25077 result.push_back(*subSurface);
680 }
681 25077 }
682 2944606 return result;
683 1472303 }
684
685 57828 boost::optional<PlanarSurfaceGroup> Surface_Impl::planarSurfaceGroup() const {
686
2/2
✓ Branch 1 taken 57828 times.
✓ Branch 4 taken 57828 times.
57828 return boost::optional<PlanarSurfaceGroup>(this->space());
687 }
688
689 1185985 boost::optional<Space> Surface_Impl::space() const {
690 1185985 boost::optional<Space> result;
691
1/1
✓ Branch 1 taken 1185985 times.
1185985 OptionalWorkspaceObject space = getTarget(OS_SurfaceFields::SpaceName);
692
2/2
✓ Branch 0 taken 1185230 times.
✓ Branch 1 taken 755 times.
1185985 if (space) {
693
2/2
✓ Branch 1 taken 1185230 times.
✓ Branch 4 taken 1185230 times.
1185230 result = space->optionalCast<Space>();
694 }
695 2371970 return result;
696 1185985 }
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 30215 bool Surface_Impl::setSpace(const Space& space) {
823
2/2
✓ Branch 1 taken 30215 times.
✓ Branch 4 taken 30215 times.
30215 return setPointer(OS_SurfaceFields::SpaceName, space.handle());
824 }
825
826 2321454 boost::optional<Surface> Surface_Impl::adjacentSurface() const {
827
2/2
✓ Branch 1 taken 2321454 times.
✓ Branch 4 taken 2321454 times.
2321454 return getObject<Surface>().getModelObjectTarget<Surface>(OS_SurfaceFields::OutsideBoundaryConditionObject);
828 }
829
830 15434 bool Surface_Impl::setAdjacentSurface(Surface& surface) {
831
832 // matching surface with self is ok for stories with multipliers
833 15434 bool isSameSurface = false;
834
5/5
✓ Branch 1 taken 15434 times.
✓ Branch 4 taken 15434 times.
✓ Branch 7 taken 15434 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 15431 times.
15434 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 15434 times.
15434 boost::optional<Surface> adjacentSurface = this->adjacentSurface();
846
1/1
✓ Branch 1 taken 15434 times.
15434 boost::optional<Surface> otherAdjacentSurface = surface.adjacentSurface();
847
848 // if other surface is pointing to this
849 15434 bool isNewMatch = true;
850
10/10
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 8240 times.
✓ Branch 3 taken 7194 times.
✓ Branch 6 taken 7194 times.
✓ Branch 9 taken 7194 times.
✓ Branch 12 taken 7194 times.
✓ Branch 14 taken 7191 times.
✓ Branch 15 taken 3 times.
✓ Branch 16 taken 7191 times.
✓ Branch 17 taken 8243 times.
15434 if (otherAdjacentSurface && (otherAdjacentSurface->handle() == this->handle())) {
851 // if this is pointing to other surface
852
7/10
✓ Branch 0 taken 7191 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 7191 times.
✓ Branch 6 taken 7191 times.
✓ Branch 9 taken 7191 times.
✓ Branch 12 taken 7191 times.
✓ Branch 14 taken 7191 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 7191 times.
✗ Branch 17 not taken.
7191 if (adjacentSurface && (adjacentSurface->handle() == surface.handle())) {
853 7191 isNewMatch = false;
854 }
855 }
856
857 // this is basically testing if surface is in same model as this
858
2/2
✓ Branch 1 taken 15434 times.
✓ Branch 4 taken 15434 times.
15434 bool test = this->setPointer(OS_SurfaceFields::OutsideBoundaryConditionObject, surface.handle());
859
1/2
✓ Branch 0 taken 15434 times.
✗ Branch 1 not taken.
15434 if (test) {
860
861 // clean all other surfaces pointing to this (unless it is surface)
862
4/4
✓ Branch 1 taken 15434 times.
✓ Branch 4 taken 15434 times.
✓ Branch 11 taken 7199 times.
✓ Branch 12 taken 15434 times.
22633 for (const WorkspaceObject& wo : this->getSources(IddObjectType::OS_Surface)) {
863
5/5
✓ Branch 1 taken 7199 times.
✓ Branch 4 taken 7199 times.
✓ Branch 7 taken 7199 times.
✓ Branch 9 taken 7194 times.
✓ Branch 10 taken 5 times.
7199 if (wo.handle() == surface.handle()) {
864 7194 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 15439 }
878
879
2/2
✓ Branch 0 taken 15431 times.
✓ Branch 1 taken 3 times.
15434 if (!isSameSurface) {
880 // clean all other surfaces pointing to surface (unless it is this)
881
4/4
✓ Branch 1 taken 15431 times.
✓ Branch 4 taken 15431 times.
✓ Branch 11 taken 15433 times.
✓ Branch 12 taken 15431 times.
30864 for (const WorkspaceObject& wo : surface.getSources(IddObjectType::OS_Surface)) {
882
5/5
✓ Branch 1 taken 15433 times.
✓ Branch 4 taken 15433 times.
✓ Branch 7 taken 15433 times.
✓ Branch 9 taken 15431 times.
✓ Branch 10 taken 2 times.
15433 if (wo.handle() == this->handle()) {
883 15431 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 15433 }
897 }
898
899 // this and surface are newly pointing to each other, clean sub surfaces on both
900
2/2
✓ Branch 0 taken 8243 times.
✓ Branch 1 taken 7191 times.
15434 if (isNewMatch) {
901
3/3
✓ Branch 1 taken 8243 times.
✓ Branch 8 taken 158 times.
✓ Branch 9 taken 8243 times.
8401 for (SubSurface& subSurface : this->subSurfaces()) {
902
1/1
✓ Branch 1 taken 158 times.
158 subSurface.resetAdjacentSubSurface();
903 8243 }
904
2/2
✓ Branch 0 taken 8240 times.
✓ Branch 1 taken 3 times.
8243 if (!isSameSurface) {
905
3/3
✓ Branch 1 taken 8240 times.
✓ Branch 8 taken 50 times.
✓ Branch 9 taken 8240 times.
8290 for (SubSurface& subSurface : surface.subSurfaces()) {
906
1/1
✓ Branch 1 taken 50 times.
50 subSurface.resetAdjacentSubSurface();
907 8240 }
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 15434 times.
✓ Branch 4 taken 15434 times.
15434 bool test = this->setPointer(OS_SurfaceFields::OutsideBoundaryConditionObject, surface.handle());
913
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15434 times.
✗ Branch 3 not taken.
15434 OS_ASSERT(test);
914
2/2
✓ Branch 1 taken 15434 times.
✓ Branch 4 taken 15434 times.
30868 test = this->setString(OS_SurfaceFields::OutsideBoundaryCondition, "Surface");
915
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15434 times.
✗ Branch 3 not taken.
15434 OS_ASSERT(test);
916
1/1
✓ Branch 1 taken 15434 times.
15434 this->assignDefaultSunExposure();
917
1/1
✓ Branch 1 taken 15434 times.
15434 this->assignDefaultWindExposure();
918
919
2/2
✓ Branch 0 taken 15431 times.
✓ Branch 1 taken 3 times.
15434 if (!isSameSurface) {
920
2/2
✓ Branch 1 taken 15431 times.
✓ Branch 4 taken 15431 times.
15431 test = surface.setPointer(OS_SurfaceFields::OutsideBoundaryConditionObject, this->handle());
921
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15431 times.
✗ Branch 3 not taken.
15431 OS_ASSERT(test);
922
2/2
✓ Branch 1 taken 15431 times.
✓ Branch 4 taken 15431 times.
30862 test = surface.setString(OS_SurfaceFields::OutsideBoundaryCondition, "Surface");
923
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15431 times.
✗ Branch 3 not taken.
15431 OS_ASSERT(test);
924
1/1
✓ Branch 1 taken 15431 times.
15431 surface.assignDefaultSunExposure();
925
1/1
✓ Branch 1 taken 15431 times.
15431 surface.assignDefaultWindExposure();
926 }
927 }
928 15434 return test;
929 15434 }
930
931 54578 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 54578 times.
54578 boost::optional<Surface> adjacentSurface = this->adjacentSurface();
938
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 54504 times.
54578 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 54578 times.
✓ Branch 8 taken 48 times.
✓ Branch 9 taken 54578 times.
54626 for (SubSurface& subSurface : this->subSurfaces()) {
948
1/1
✓ Branch 1 taken 48 times.
48 subSurface.resetAdjacentSubSurface();
949 54578 }
950
951 // clean all other surfaces pointing to this
952
4/4
✓ Branch 1 taken 54578 times.
✓ Branch 4 taken 54578 times.
✓ Branch 11 taken 78 times.
✓ Branch 12 taken 54578 times.
54656 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 54656 }
965 54578 }
966
967 3302 boost::optional<SurfaceControlMovableInsulation> Surface_Impl::surfaceControlMovableInsulation() const {
968
1/1
✓ Branch 1 taken 3302 times.
3302 auto thisSurface = getObject<Surface>();
969 std::vector<SurfaceControlMovableInsulation> movableInsulations =
970
2/2
✓ Branch 1 taken 3302 times.
✓ Branch 4 taken 3302 times.
3302 thisSurface.getModelObjectSources<SurfaceControlMovableInsulation>(SurfaceControlMovableInsulation::iddObjectType());
971
2/2
✓ Branch 1 taken 3296 times.
✓ Branch 2 taken 6 times.
3302 if (movableInsulations.empty()) {
972 3296 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 3302 }
980
981 6863 boost::optional<SurfacePropertyConvectionCoefficients> Surface_Impl::surfacePropertyConvectionCoefficients() const {
982
2/2
✓ Branch 1 taken 6863 times.
✓ Branch 4 taken 6863 times.
6863 std::vector<SurfacePropertyConvectionCoefficients> spccs(model().getConcreteModelObjects<SurfacePropertyConvectionCoefficients>());
983
1/1
✓ Branch 1 taken 6863 times.
6863 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 6863 times.
✓ Branch 9 taken 6863 times.
6863 spccs.erase(std::remove_if(spccs.begin(), spccs.end(), isNotPointingToMe), spccs.end());
990
991
2/2
✓ Branch 1 taken 6854 times.
✓ Branch 2 taken 9 times.
6863 if (spccs.empty()) {
992 6854 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 6863 }
1000
1001 3301 boost::optional<SurfacePropertyLocalEnvironment> Surface_Impl::surfacePropertyLocalEnvironment() const {
1002
1003 3301 std::vector<SurfacePropertyLocalEnvironment> result;
1004
4/4
✓ Branch 1 taken 3301 times.
✓ Branch 4 taken 3301 times.
✓ Branch 12 taken 18 times.
✓ Branch 13 taken 3301 times.
3319 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 3301 }
1011
2/2
✓ Branch 1 taken 3292 times.
✓ Branch 2 taken 9 times.
3301 if (result.empty()) {
1012 3292 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 3301 }
1020
1021 164923 boost::optional<SurfacePropertyOtherSideCoefficients> Surface_Impl::surfacePropertyOtherSideCoefficients() const {
1022
2/2
✓ Branch 1 taken 164923 times.
✓ Branch 4 taken 164923 times.
164923 return getObject<Surface>().getModelObjectTarget<SurfacePropertyOtherSideCoefficients>(OS_SurfaceFields::OutsideBoundaryConditionObject);
1023 }
1024
1025 4 bool Surface_Impl::setSurfacePropertyOtherSideCoefficients(const SurfacePropertyOtherSideCoefficients& otherSideCoefficients) {
1026
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<Surface> adjacentSurface = this->adjacentSurface();
1027
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 3 times.
4 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 4 times.
✓ Branch 4 taken 4 times.
4 bool test = this->setPointer(OS_SurfaceFields::OutsideBoundaryConditionObject, otherSideCoefficients.handle());
1033
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (test) {
1034
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
8 test = this->setString(OS_SurfaceFields::OutsideBoundaryCondition, "OtherSideCoefficients");
1035
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(test);
1036
1/1
✓ Branch 1 taken 4 times.
4 this->assignDefaultSunExposure();
1037
1/1
✓ Branch 1 taken 4 times.
4 this->assignDefaultWindExposure();
1038 }
1039 4 return test;
1040 4 }
1041
1042 54503 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 54503 times.
54503 boost::optional<SurfacePropertyOtherSideCoefficients> surfacePropertyOtherSideCoefficients = this->surfacePropertyOtherSideCoefficients();
1048
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 54501 times.
54503 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 54503 times.
✓ Branch 8 taken 34 times.
✓ Branch 9 taken 54503 times.
54537 for (SubSurface& subSurface : this->subSurfaces()) {
1058
1/1
✓ Branch 1 taken 34 times.
34 subSurface.resetSurfacePropertyOtherSideCoefficients();
1059 54503 }
1060 54503 }
1061
1062 164927 boost::optional<SurfacePropertyOtherSideConditionsModel> Surface_Impl::surfacePropertyOtherSideConditionsModel() const {
1063
2/2
✓ Branch 1 taken 164927 times.
✓ Branch 4 taken 164927 times.
164927 return getObject<Surface>().getModelObjectTarget<SurfacePropertyOtherSideConditionsModel>(OS_SurfaceFields::OutsideBoundaryConditionObject);
1064 }
1065
1066 6 bool Surface_Impl::setSurfacePropertyOtherSideConditionsModel(const SurfacePropertyOtherSideConditionsModel& otherSideModel) {
1067
1/1
✓ Branch 1 taken 6 times.
6 boost::optional<Surface> adjacentSurface = this->adjacentSurface();
1068
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 5 times.
6 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 6 times.
✓ Branch 4 taken 6 times.
6 bool test = this->setPointer(OS_SurfaceFields::OutsideBoundaryConditionObject, otherSideModel.handle());
1074
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (test) {
1075
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
12 test = this->setString(OS_SurfaceFields::OutsideBoundaryCondition, "OtherSideConditionsModel");
1076
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 3 not taken.
6 OS_ASSERT(test);
1077
1/1
✓ Branch 1 taken 6 times.
6 this->assignDefaultSunExposure();
1078
1/1
✓ Branch 1 taken 6 times.
6 this->assignDefaultWindExposure();
1079 }
1080 6 return test;
1081 6 }
1082
1083 54503 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 54503 times.
54503 this->surfacePropertyOtherSideConditionsModel();
1090
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 54501 times.
54503 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 54503 times.
✓ Branch 8 taken 34 times.
✓ Branch 9 taken 54503 times.
54537 for (SubSurface& subSurface : this->subSurfaces()) {
1100
1/1
✓ Branch 1 taken 34 times.
34 subSurface.resetSurfacePropertyOtherSideConditionsModel();
1101 54503 }
1102 54503 }
1103
1104 659 bool Surface_Impl::intersect(Surface& otherSurface) {
1105
1/1
✓ Branch 1 taken 659 times.
659 boost::optional<SurfaceIntersection> intersection = computeIntersection(otherSurface);
1106 1318 return intersection.has_value();
1107 659 }
1108
1109 521320 boost::optional<SurfaceIntersection> Surface_Impl::computeIntersection(Surface& otherSurface) {
1110 521320 double tol = 0.01; // 1 cm tolerance
1111 521320 double areaTol = 0.001; // 10 cm2 tolerance
1112
1113 521320 constexpr bool extraLogging = false;
1114
1115
1/1
✓ Branch 1 taken 521320 times.
521320 boost::optional<Space> space = this->space();
1116
1/1
✓ Branch 1 taken 521320 times.
521320 boost::optional<Space> otherSpace = otherSurface.space();
1117
1118
11/13
✓ Branch 1 taken 521320 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 521320 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 521320 times.
✓ Branch 10 taken 521320 times.
✓ Branch 13 taken 521320 times.
✓ Branch 16 taken 521320 times.
✓ Branch 19 taken 521320 times.
✓ Branch 21 taken 3 times.
✓ Branch 22 taken 521317 times.
✓ Branch 23 taken 3 times.
✓ Branch 24 taken 521317 times.
521320 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 521317 times.
✓ Branch 4 taken 521317 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 521317 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 521317 times.
✓ Branch 12 taken 521317 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 521317 times.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 521317 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
521317 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 521317 times.
✓ Branch 4 taken 521317 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 521317 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 521317 times.
✓ Branch 12 taken 521317 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 521317 times.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 521317 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
1563951 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 521317 times.
✓ Branch 4 taken 521317 times.
521317 Transformation spaceTransformation = space->transformation();
1135
2/2
✓ Branch 1 taken 521317 times.
✓ Branch 4 taken 521317 times.
521317 Transformation otherSpaceTransformation = otherSpace->transformation();
1136
1137 // do the intersection in building coordinates
1138
1139
2/2
✓ Branch 1 taken 521317 times.
✓ Branch 4 taken 521317 times.
521317 Plane plane = spaceTransformation * this->plane();
1140
2/2
✓ Branch 1 taken 521317 times.
✓ Branch 4 taken 521317 times.
521317 Plane otherPlane = otherSpaceTransformation * otherSurface.plane();
1141
1142
3/3
✓ Branch 1 taken 521317 times.
✓ Branch 3 taken 496181 times.
✓ Branch 4 taken 25136 times.
521317 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 25136 times.
✓ Branch 4 taken 25136 times.
25136 std::vector<Point3d> buildingVertices = spaceTransformation * this->vertices();
1149
2/2
✓ Branch 1 taken 25136 times.
✓ Branch 4 taken 25136 times.
25136 std::vector<Point3d> otherBuildingVertices = otherSpaceTransformation * otherSurface.vertices();
1150
1151
3/6
✓ Branch 1 taken 25136 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25136 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 25136 times.
25136 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 25136 times.
25136 Transformation faceTransformation;
1158
1/1
✓ Branch 1 taken 25136 times.
25136 Transformation faceTransformationInverse;
1159 try {
1160
1/1
✓ Branch 1 taken 25136 times.
25136 faceTransformation = Transformation::alignFace(buildingVertices);
1161
1/1
✓ Branch 1 taken 25136 times.
25136 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 25136 times.
25136 std::vector<Point3d> faceVertices = faceTransformationInverse * buildingVertices;
1169
1/1
✓ Branch 1 taken 25136 times.
25136 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 25136 times.
25136 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 25136 times.
25136 boost::optional<IntersectionResult> intersection = openstudio::intersect(faceVertices, otherFaceVertices, tol);
1181
2/2
✓ Branch 1 taken 18115 times.
✓ Branch 2 taken 7021 times.
25136 if (!intersection) {
1182 //LOG(Info, "No intersection");
1183 18115 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 5529 times.
✓ Branch 2 taken 1492 times.
✓ Branch 4 taken 4908 times.
✓ Branch 5 taken 621 times.
✓ Branch 6 taken 2113 times.
✓ Branch 7 taken 4908 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 2113 times.
3960 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 2113 times.
3469 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 521320 }
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 600 bool Surface_Impl::isPartOfEnvelope() const {
1359
1/1
✓ Branch 1 taken 600 times.
600 std::string bc = this->outsideBoundaryCondition();
1360
9/15
✓ Branch 1 taken 600 times.
✓ Branch 4 taken 600 times.
✓ Branch 6 taken 147 times.
✓ Branch 7 taken 453 times.
✓ Branch 9 taken 147 times.
✓ Branch 11 taken 33 times.
✓ Branch 12 taken 114 times.
✓ Branch 13 taken 600 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 600 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
1200 bool result = (istringEqual("Outdoors", bc) || this->isGroundSurface());
1361 600 return result;
1362 600 }
1363
1364 774 void Surface_Impl::assignDefaultSurfaceType() {
1365 774 assignDefaultSurfaceType(true);
1366 774 }
1367
1368 53140 void Surface_Impl::assignDefaultSurfaceType(bool driverMethod) {
1369 53140 double degTilt = radToDeg(this->tilt());
1370 53139 bool ok = true;
1371
2/2
✓ Branch 0 taken 7588 times.
✓ Branch 1 taken 45551 times.
53139 if (degTilt < 60) {
1372
2/2
✓ Branch 1 taken 7588 times.
✓ Branch 4 taken 7588 times.
15176 ok = setSurfaceType("RoofCeiling", driverMethod);
1373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7588 times.
7588 OS_ASSERT(ok);
1374
2/2
✓ Branch 0 taken 38061 times.
✓ Branch 1 taken 7490 times.
45551 } else if (degTilt < 179) {
1375
2/2
✓ Branch 1 taken 38061 times.
✓ Branch 4 taken 38061 times.
76122 ok = setSurfaceType("Wall", driverMethod);
1376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38061 times.
38061 OS_ASSERT(ok);
1377 } else {
1378
2/2
✓ Branch 1 taken 7490 times.
✓ Branch 4 taken 7490 times.
14980 ok = setSurfaceType("Floor", driverMethod);
1379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7490 times.
7490 OS_ASSERT(ok);
1380 }
1381 53139 }
1382
1383 164 void Surface_Impl::assignDefaultBoundaryCondition() {
1384 164 assignDefaultBoundaryCondition(true);
1385 164 }
1386
1387 52529 void Surface_Impl::assignDefaultBoundaryCondition(bool driverMethod) {
1388
2/3
✓ Branch 1 taken 52529 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52529 times.
105058 if (this->adjacentSurface()) {
1389 ✗ bool test = this->setOutsideBoundaryCondition("Surface", driverMethod);
1390 ✗ OS_ASSERT(test);
1391
2/3
✓ Branch 1 taken 52529 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52529 times.
105058 } else if (this->surfacePropertyOtherSideCoefficients()) {
1392 ✗ bool test = this->setOutsideBoundaryCondition("OtherSideCoefficients", driverMethod);
1393 ✗ OS_ASSERT(test);
1394
2/3
✓ Branch 1 taken 52529 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52529 times.
105058 } else if (this->surfacePropertyOtherSideConditionsModel()) {
1395 ✗ bool test = this->setOutsideBoundaryCondition("OtherSideConditionsModel", driverMethod);
1396 ✗ OS_ASSERT(test);
1397
2/3
✓ Branch 1 taken 52529 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52529 times.
105058 } else if (this->adjacentFoundation()) {
1398 ✗ bool test = this->setOutsideBoundaryCondition("Foundation", driverMethod);
1399 ✗ OS_ASSERT(test);
1400
5/5
✓ Branch 1 taken 52529 times.
✓ Branch 4 taken 52529 times.
✓ Branch 7 taken 52529 times.
✓ Branch 11 taken 7356 times.
✓ Branch 12 taken 45173 times.
157587 } else if (istringEqual("Floor", this->surfaceType())) {
1401
2/2
✓ Branch 1 taken 7356 times.
✓ Branch 4 taken 7356 times.
14712 bool test = this->setOutsideBoundaryCondition("Ground", driverMethod);
1402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7356 times.
7356 OS_ASSERT(test);
1403 } else {
1404
2/2
✓ Branch 1 taken 45173 times.
✓ Branch 4 taken 45173 times.
90346 bool test = this->setOutsideBoundaryCondition("Outdoors", driverMethod);
1405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45173 times.
45173 OS_ASSERT(test);
1406 }
1407 52529 }
1408
1409 31039 void Surface_Impl::assignDefaultSunExposure() {
1410 31039 assignDefaultSunExposure(true);
1411 31039 }
1412
1413 137901 void Surface_Impl::assignDefaultSunExposure(bool driverMethod) {
1414
1/1
✓ Branch 1 taken 137901 times.
137901 std::string outsideBoundaryCondition = this->outsideBoundaryCondition();
1415
4/4
✓ Branch 1 taken 137901 times.
✓ Branch 4 taken 137901 times.
✓ Branch 7 taken 91274 times.
✓ Branch 8 taken 46627 times.
275802 if (istringEqual("Outdoors", outsideBoundaryCondition)) {
1416
2/2
✓ Branch 1 taken 91274 times.
✓ Branch 4 taken 91274 times.
182548 bool test = this->setSunExposure("SunExposed", driverMethod);
1417
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 91274 times.
✗ Branch 3 not taken.
91274 OS_ASSERT(test);
1418
11/21
✓ Branch 1 taken 46627 times.
✓ Branch 4 taken 15762 times.
✓ Branch 7 taken 15762 times.
✓ Branch 9 taken 15758 times.
✓ Branch 10 taken 4 times.
✓ Branch 12 taken 15762 times.
✓ Branch 13 taken 30865 times.
✓ Branch 14 taken 46627 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 46627 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 46621 times.
✓ Branch 20 taken 6 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.
171405 } else if (istringEqual("Surface", outsideBoundaryCondition) || istringEqual("OtherSideCoefficients", outsideBoundaryCondition)
1419
16/24
✓ Branch 1 taken 15758 times.
✓ Branch 4 taken 15758 times.
✓ Branch 6 taken 14920 times.
✓ Branch 7 taken 838 times.
✓ Branch 9 taken 14920 times.
✓ Branch 12 taken 14920 times.
✓ Branch 14 taken 15 times.
✓ Branch 15 taken 14905 times.
✓ Branch 17 taken 14920 times.
✓ Branch 18 taken 31707 times.
✓ Branch 19 taken 15758 times.
✓ Branch 20 taken 30869 times.
✓ Branch 22 taken 15758 times.
✓ Branch 23 taken 30869 times.
✓ Branch 24 taken 15762 times.
✓ Branch 25 taken 30865 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.
107983 || istringEqual("Adiabatic", outsideBoundaryCondition) || istringEqual("Ground", outsideBoundaryCondition)
1420
8/12
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 7 times.
✓ Branch 9 taken 15 times.
✓ Branch 10 taken 46612 times.
✓ Branch 11 taken 14920 times.
✓ Branch 12 taken 31707 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46657 || istringEqual("GroundFCfactorMethod", outsideBoundaryCondition)
1421
7/12
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 46619 times.
✓ Branch 11 taken 15 times.
✓ Branch 12 taken 46612 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46643 || istringEqual("GroundSlabPreprocessorAverage", outsideBoundaryCondition)
1422
7/12
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 46619 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 46619 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46643 || istringEqual("GroundSlabPreprocessorCore", outsideBoundaryCondition)
1423
7/12
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 46619 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 46619 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46643 || istringEqual("GroundSlabPreprocessorPerimeter", outsideBoundaryCondition)
1424
7/12
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 46619 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 46619 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46643 || istringEqual("GroundBasementPreprocessorAverageWall", outsideBoundaryCondition)
1425
7/12
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 46619 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 46619 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46643 || istringEqual("GroundBasementPreprocessorAverageFloor", outsideBoundaryCondition)
1426
7/12
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 46619 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 46619 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46643 || istringEqual("GroundBasementPreprocessorUpperWall", outsideBoundaryCondition)
1427
7/12
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 46619 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 46619 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46643 || istringEqual("GroundBasementPreprocessorLowerWall", outsideBoundaryCondition)
1428
13/17
✓ Branch 1 taken 46627 times.
✓ Branch 3 taken 15762 times.
✓ Branch 4 taken 30865 times.
✓ Branch 6 taken 8 times.
✓ Branch 9 taken 8 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 8 times.
✓ Branch 14 taken 46619 times.
✓ Branch 16 taken 8 times.
✓ Branch 17 taken 46619 times.
✓ Branch 18 taken 8 times.
✓ Branch 19 taken 46619 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
109024 || istringEqual("Foundation", outsideBoundaryCondition)) {
1429
2/2
✓ Branch 1 taken 46621 times.
✓ Branch 4 taken 46621 times.
93242 bool test = this->setSunExposure("NoSun", driverMethod);
1430
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 46621 times.
✗ Branch 3 not taken.
46621 OS_ASSERT(test);
1431 } else {
1432
1/1
✓ Branch 1 taken 6 times.
6 std::string surfaceType = this->surfaceType();
1433
4/4
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 5 times.
12 if (istringEqual("Floor", surfaceType)) {
1434
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool test = this->setSunExposure("NoSun", driverMethod);
1435
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
1 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 6 }
1441 137901 }
1442
1443 31039 void Surface_Impl::assignDefaultWindExposure() {
1444 31039 assignDefaultWindExposure(true);
1445 31039 }
1446
1447 137901 void Surface_Impl::assignDefaultWindExposure(bool driverMethod) {
1448
1/1
✓ Branch 1 taken 137901 times.
137901 std::string outsideBoundaryCondition = this->outsideBoundaryCondition();
1449
4/4
✓ Branch 1 taken 137901 times.
✓ Branch 4 taken 137901 times.
✓ Branch 7 taken 91274 times.
✓ Branch 8 taken 46627 times.
275802 if (istringEqual("Outdoors", outsideBoundaryCondition)) {
1450
2/2
✓ Branch 1 taken 91274 times.
✓ Branch 4 taken 91274 times.
182548 bool test = this->setWindExposure("WindExposed", driverMethod);
1451
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 91274 times.
✗ Branch 3 not taken.
91274 OS_ASSERT(test);
1452
11/21
✓ Branch 1 taken 46627 times.
✓ Branch 4 taken 15762 times.
✓ Branch 7 taken 15762 times.
✓ Branch 9 taken 15758 times.
✓ Branch 10 taken 4 times.
✓ Branch 12 taken 15762 times.
✓ Branch 13 taken 30865 times.
✓ Branch 14 taken 46627 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 46627 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 46621 times.
✓ Branch 20 taken 6 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.
171405 } else if (istringEqual("Surface", outsideBoundaryCondition) || istringEqual("OtherSideCoefficients", outsideBoundaryCondition)
1453
16/24
✓ Branch 1 taken 15758 times.
✓ Branch 4 taken 15758 times.
✓ Branch 6 taken 14920 times.
✓ Branch 7 taken 838 times.
✓ Branch 9 taken 14920 times.
✓ Branch 12 taken 14920 times.
✓ Branch 14 taken 15 times.
✓ Branch 15 taken 14905 times.
✓ Branch 17 taken 14920 times.
✓ Branch 18 taken 31707 times.
✓ Branch 19 taken 15758 times.
✓ Branch 20 taken 30869 times.
✓ Branch 22 taken 15758 times.
✓ Branch 23 taken 30869 times.
✓ Branch 24 taken 15762 times.
✓ Branch 25 taken 30865 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.
107983 || istringEqual("Adiabatic", outsideBoundaryCondition) || istringEqual("Ground", outsideBoundaryCondition)
1454
8/12
✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 7 times.
✓ Branch 9 taken 15 times.
✓ Branch 10 taken 46612 times.
✓ Branch 11 taken 14920 times.
✓ Branch 12 taken 31707 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46657 || istringEqual("GroundFCfactorMethod", outsideBoundaryCondition)
1455
7/12
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 46619 times.
✓ Branch 11 taken 15 times.
✓ Branch 12 taken 46612 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46643 || istringEqual("GroundSlabPreprocessorAverage", outsideBoundaryCondition)
1456
7/12
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 46619 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 46619 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46643 || istringEqual("GroundSlabPreprocessorCore", outsideBoundaryCondition)
1457
7/12
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 46619 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 46619 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46643 || istringEqual("GroundSlabPreprocessorPerimeter", outsideBoundaryCondition)
1458
7/12
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 46619 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 46619 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46643 || istringEqual("GroundBasementPreprocessorAverageWall", outsideBoundaryCondition)
1459
7/12
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 46619 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 46619 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46643 || istringEqual("GroundBasementPreprocessorAverageFloor", outsideBoundaryCondition)
1460
7/12
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 46619 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 46619 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46643 || istringEqual("GroundBasementPreprocessorUpperWall", outsideBoundaryCondition)
1461
7/12
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 8 times.
✓ Branch 10 taken 46619 times.
✓ Branch 11 taken 8 times.
✓ Branch 12 taken 46619 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
46643 || istringEqual("GroundBasementPreprocessorLowerWall", outsideBoundaryCondition)
1462
13/17
✓ Branch 1 taken 46627 times.
✓ Branch 3 taken 15762 times.
✓ Branch 4 taken 30865 times.
✓ Branch 6 taken 8 times.
✓ Branch 9 taken 8 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 8 times.
✓ Branch 14 taken 46619 times.
✓ Branch 16 taken 8 times.
✓ Branch 17 taken 46619 times.
✓ Branch 18 taken 8 times.
✓ Branch 19 taken 46619 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
109024 || istringEqual("Foundation", outsideBoundaryCondition)) {
1463
2/2
✓ Branch 1 taken 46621 times.
✓ Branch 4 taken 46621 times.
93242 bool test = this->setWindExposure("NoWind", driverMethod);
1464
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 46621 times.
✗ Branch 3 not taken.
46621 OS_ASSERT(test);
1465 } else {
1466
1/1
✓ Branch 1 taken 6 times.
6 std::string surfaceType = this->surfaceType();
1467
4/4
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 5 times.
12 if (istringEqual("Floor", surfaceType)) {
1468
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool test = this->setWindExposure("NoWind", driverMethod);
1469
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 3 not taken.
1 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 6 }
1475 137901 }
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 82 boost::optional<SubSurface> Surface_Impl::setWindowToWallRatio(double wwr) {
1680 82 return setWindowToWallRatio(wwr, 0.762, true);
1681 }
1682
1683 88 boost::optional<SubSurface> Surface_Impl::setWindowToWallRatio(double wwr, double desiredHeightOffset, bool heightOffsetFromFloor) {
1684 88 boost::optional<SubSurface> result;
1685 88 std::vector<SubSurface> tmp;
1686
1687 88 double viewGlassToWallRatio = 0;
1688 88 double daylightingGlassToWallRatio = 0;
1689 88 double desiredViewGlassSillHeight = 0;
1690 88 double desiredDaylightingGlassHeaderHeight = 0;
1691 88 double exteriorShadingProjectionFactor = 0;
1692 88 double interiorShelfProjectionFactor = 0;
1693 88 boost::optional<ConstructionBase> viewGlassConstruction;
1694 88 boost::optional<ConstructionBase> daylightingGlassConstruction;
1695
1696
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 1 time.
88 if (heightOffsetFromFloor) {
1697 87 viewGlassToWallRatio = wwr;
1698 87 desiredViewGlassSillHeight = desiredHeightOffset;
1699 } else {
1700 1 daylightingGlassToWallRatio = wwr;
1701 1 desiredDaylightingGlassHeaderHeight = desiredHeightOffset;
1702 }
1703
1704
1/1
✓ Branch 1 taken 88 times.
176 tmp = applyViewAndDaylightingGlassRatios(viewGlassToWallRatio, daylightingGlassToWallRatio, desiredViewGlassSillHeight,
1705 desiredDaylightingGlassHeaderHeight, exteriorShadingProjectionFactor, interiorShelfProjectionFactor,
1706 88 viewGlassConstruction, daylightingGlassConstruction);
1707
1708
2/2
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 10 times.
88 if (!tmp.empty()) {
1709
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 78 times.
✗ Branch 4 not taken.
78 OS_ASSERT(tmp.size() == 1);
1710
1/1
✓ Branch 2 taken 78 times.
78 result = tmp[0];
1711 }
1712
1713 176 return result;
1714 88 }
1715
1716 211 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 211 std::vector<SubSurface> result;
1721
1722 // has to be a wall
1723
5/5
✓ Branch 1 taken 211 times.
✓ Branch 4 taken 211 times.
✓ Branch 7 taken 211 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 209 times.
422 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 209 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 208 times.
210 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 209 }
1734
1735
1/1
✓ Branch 1 taken 208 times.
208 Point3dVector vertices = this->vertices();
1736 208 Point3dVector viewVertices;
1737 208 Point3dVector daylightingVertices;
1738 208 Point3dVector exteriorShadingVertices;
1739 208 Point3dVector interiorShelfVertices;
1740
1/1
✓ Branch 1 taken 208 times.
208 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 200 times.
208 if (!test) {
1746 8 return result;
1747 }
1748
1749 // everything ok, remove all windows
1750
3/3
✓ Branch 1 taken 200 times.
✓ Branch 8 taken 1 time.
✓ Branch 9 taken 200 times.
201 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 200 }
1755
1756 // add a new window
1757
1/1
✓ Branch 1 taken 200 times.
200 Model model = this->model();
1758
1/1
✓ Branch 1 taken 200 times.
200 auto thisSurface = this->getObject<Surface>();
1759
1/1
✓ Branch 1 taken 200 times.
200 boost::optional<Space> space = this->space();
1760
1761 200 boost::optional<SubSurface> viewWindow;
1762
2/2
✓ Branch 1 taken 188 times.
✓ Branch 2 taken 12 times.
200 if (!viewVertices.empty()) {
1763
2/2
✓ Branch 1 taken 188 times.
✓ Branch 4 taken 188 times.
188 viewWindow = SubSurface(viewVertices, model);
1764
2/2
✓ Branch 1 taken 188 times.
✓ Branch 4 taken 188 times.
188 result.push_back(*viewWindow);
1765
2/2
✓ Branch 1 taken 188 times.
✓ Branch 4 taken 188 times.
188 viewWindow->setSurface(thisSurface);
1766
1767
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 77 times.
188 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 200 boost::optional<SubSurface> daylightingWindow;
1773
2/2
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 87 times.
200 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 200 boost::optional<DaylightingDeviceShelf> interiorShelf;
1784
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 198 times.
200 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 199 times.
200 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 200 return result;
1817 208 }
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 8 bool Surface_Impl::setAdjacentFoundation(const FoundationKiva& kiva) {
2099
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 bool result = this->setPointer(OS_SurfaceFields::OutsideBoundaryConditionObject, kiva.handle());
2100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 OS_ASSERT(result);
2101
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
16 result = this->setString(OS_SurfaceFields::OutsideBoundaryCondition, "Foundation");
2102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 OS_ASSERT(result);
2103 8 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 59388 boost::optional<FoundationKiva> Surface_Impl::adjacentFoundation() const {
2127
2/2
✓ Branch 1 taken 59388 times.
✓ Branch 4 taken 59388 times.
59388 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 12 Surface_Impl::createSurfacePropertyExposedFoundationPerimeter(const std::string& exposedPerimeterCalculationMethod, double exposedPerimeter) {
2143
1/1
✓ Branch 1 taken 12 times.
12 auto thisSurface = getObject<Surface>();
2144 std::vector<SurfacePropertyExposedFoundationPerimeter> props =
2145
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 thisSurface.getModelObjectSources<SurfacePropertyExposedFoundationPerimeter>(SurfacePropertyExposedFoundationPerimeter::iddObjectType());
2146
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 11 times.
12 if (!props.empty()) {
2147 1 return boost::none;
2148 }
2149
2150
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 SurfacePropertyExposedFoundationPerimeter prop(thisSurface, exposedPerimeterCalculationMethod, exposedPerimeter);
2151
1/1
✓ Branch 1 taken 11 times.
11 return prop;
2152 12 }
2153
2154 11133 boost::optional<SurfacePropertyExposedFoundationPerimeter> Surface_Impl::surfacePropertyExposedFoundationPerimeter() const {
2155 std::vector<SurfacePropertyExposedFoundationPerimeter> props =
2156
1/1
✓ Branch 1 taken 11133 times.
22266 getObject<ModelObject>().getModelObjectSources<SurfacePropertyExposedFoundationPerimeter>(
2157
2/2
✓ Branch 1 taken 11133 times.
✓ Branch 4 taken 11133 times.
11133 SurfacePropertyExposedFoundationPerimeter::iddObjectType());
2158
2/2
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 11118 times.
11133 if (props.empty()) {
2159 // no error
2160
1/2
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
15 } else if (props.size() == 1) {
2161
1/1
✓ Branch 2 taken 15 times.
15 return props[0];
2162 } else {
2163 // error
2164 }
2165 11118 return boost::none;
2166 11133 }
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 26186 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 26182 times.
✗ Branch 5 not taken.
26182 OS_ASSERT(getImpl<detail::Surface_Impl>());
2221
1/1
✓ Branch 3 taken 26182 times.
26182 getImpl<detail::Surface_Impl>()->assignDefaultSurfaceType(false);
2222
1/1
✓ Branch 3 taken 26182 times.
26182 getImpl<detail::Surface_Impl>()->assignDefaultBoundaryCondition(false);
2223
1/1
✓ Branch 3 taken 26182 times.
26182 getImpl<detail::Surface_Impl>()->assignDefaultSunExposure(false);
2224
1/1
✓ Branch 3 taken 26182 times.
26182 getImpl<detail::Surface_Impl>()->assignDefaultWindExposure(false);
2225
1/1
✓ Branch 3 taken 26182 times.
26182 getImpl<detail::Surface_Impl>()->emitChangeSignals(); // emit signals here
2226 26182 }
2227
2228 276108 IddObjectType Surface::iddObjectType() {
2229
1/1
✓ Branch 1 taken 276108 times.
276108 IddObjectType result(IddObjectType::OS_Surface);
2230 276108 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 305528 std::string Surface::surfaceType() const {
2250
1/1
✓ Branch 3 taken 305528 times.
305528 return getImpl<detail::Surface_Impl>()->surfaceType();
2251 }
2252
2253 56995 std::string Surface::outsideBoundaryCondition() const {
2254
1/1
✓ Branch 3 taken 56995 times.
56995 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 28342 std::string Surface::sunExposure() const {
2262
1/1
✓ Branch 3 taken 28342 times.
28342 return getImpl<detail::Surface_Impl>()->sunExposure();
2263 }
2264
2265 3288 bool Surface::isSunExposureDefaulted() const {
2266
1/1
✓ Branch 3 taken 3288 times.
3288 return getImpl<detail::Surface_Impl>()->isSunExposureDefaulted();
2267 }
2268
2269 27270 std::string Surface::windExposure() const {
2270
1/1
✓ Branch 3 taken 27270 times.
27270 return getImpl<detail::Surface_Impl>()->windExposure();
2271 }
2272
2273 3288 bool Surface::isWindExposureDefaulted() const {
2274
1/1
✓ Branch 3 taken 3288 times.
3288 return getImpl<detail::Surface_Impl>()->isWindExposureDefaulted();
2275 }
2276
2277 3288 boost::optional<double> Surface::viewFactortoGround() const {
2278
1/1
✓ Branch 3 taken 3288 times.
3288 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 2069 bool Surface::setOutsideBoundaryCondition(const std::string& outsideBoundaryCondition) {
2306
1/1
✓ Branch 3 taken 2069 times.
2069 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 768988 SubSurfaceVector Surface::subSurfaces() const {
2358
1/1
✓ Branch 3 taken 768988 times.
768988 return getImpl<detail::Surface_Impl>()->subSurfaces();
2359 }
2360
2361 26526 bool Surface::setSpace(const Space& space) {
2362
1/1
✓ Branch 3 taken 26526 times.
26526 return getImpl<detail::Surface_Impl>()->setSpace(space);
2363 }
2364
2365 1574494 boost::optional<Surface> Surface::adjacentSurface() const {
2366
1/1
✓ Branch 3 taken 1574494 times.
1574494 return getImpl<detail::Surface_Impl>()->adjacentSurface();
2367 }
2368
2369 14598 bool Surface::setAdjacentSurface(Surface& surface) {
2370
1/1
✓ Branch 3 taken 14598 times.
14598 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 3302 boost::optional<SurfaceControlMovableInsulation> Surface::surfaceControlMovableInsulation() const {
2378
1/1
✓ Branch 3 taken 3302 times.
3302 return getImpl<detail::Surface_Impl>()->surfaceControlMovableInsulation();
2379 }
2380
2381 3300 boost::optional<SurfacePropertyConvectionCoefficients> Surface::surfacePropertyConvectionCoefficients() const {
2382
1/1
✓ Branch 3 taken 3300 times.
3300 return getImpl<detail::Surface_Impl>()->surfacePropertyConvectionCoefficients();
2383 }
2384
2385 3301 boost::optional<SurfacePropertyLocalEnvironment> Surface::surfacePropertyLocalEnvironment() const {
2386
1/1
✓ Branch 3 taken 3301 times.
3301 return getImpl<detail::Surface_Impl>()->surfacePropertyLocalEnvironment();
2387 }
2388
2389 3293 boost::optional<SurfacePropertyOtherSideCoefficients> Surface::surfacePropertyOtherSideCoefficients() const {
2390
1/1
✓ Branch 3 taken 3293 times.
3293 return getImpl<detail::Surface_Impl>()->surfacePropertyOtherSideCoefficients();
2391 }
2392
2393 3 bool Surface::setSurfacePropertyOtherSideCoefficients(const SurfacePropertyOtherSideCoefficients& otherSideCoefficients) {
2394
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::Surface_Impl>()->setSurfacePropertyOtherSideCoefficients(otherSideCoefficients);
2395 }
2396
2397 ✗ void Surface::resetSurfacePropertyOtherSideCoefficients() {
2398 ✗ return getImpl<detail::Surface_Impl>()->resetSurfacePropertyOtherSideCoefficients();
2399 }
2400
2401 3297 boost::optional<SurfacePropertyOtherSideConditionsModel> Surface::surfacePropertyOtherSideConditionsModel() const {
2402
1/1
✓ Branch 3 taken 3297 times.
3297 return getImpl<detail::Surface_Impl>()->surfacePropertyOtherSideConditionsModel();
2403 }
2404
2405 5 bool Surface::setSurfacePropertyOtherSideConditionsModel(const SurfacePropertyOtherSideConditionsModel& otherSideModel) {
2406
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::Surface_Impl>()->setSurfacePropertyOtherSideConditionsModel(otherSideModel);
2407 }
2408
2409 ✗ void Surface::resetSurfacePropertyOtherSideConditionsModel() {
2410 ✗ return getImpl<detail::Surface_Impl>()->resetSurfacePropertyOtherSideConditionsModel();
2411 }
2412
2413 659 bool Surface::intersect(Surface& otherSurface) {
2414
1/1
✓ Branch 3 taken 659 times.
659 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 600 bool Surface::isPartOfEnvelope() const {
2426
1/1
✓ Branch 3 taken 600 times.
600 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 15516 void Surface::assignDefaultSunExposure() {
2438
1/1
✓ Branch 3 taken 15516 times.
15516 getImpl<detail::Surface_Impl>()->assignDefaultSunExposure();
2439 15516 }
2440
2441 15516 void Surface::assignDefaultWindExposure() {
2442
1/1
✓ Branch 3 taken 15516 times.
15516 getImpl<detail::Surface_Impl>()->assignDefaultWindExposure();
2443 15516 }
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 82 boost::optional<SubSurface> Surface::setWindowToWallRatio(double wwr) {
2462
1/1
✓ Branch 3 taken 82 times.
82 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 8 bool Surface::setAdjacentFoundation(const FoundationKiva& kiva) {
2493
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::Surface_Impl>()->setAdjacentFoundation(kiva);
2494 }
2495
2496 3295 boost::optional<FoundationKiva> Surface::adjacentFoundation() const {
2497
1/1
✓ Branch 3 taken 3295 times.
3295 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 12 Surface::createSurfacePropertyExposedFoundationPerimeter(const std::string& exposedPerimeterCalculationMethod, double exposedPerimeter) {
2506
1/1
✓ Branch 3 taken 12 times.
12 return getImpl<detail::Surface_Impl>()->createSurfacePropertyExposedFoundationPerimeter(exposedPerimeterCalculationMethod, exposedPerimeter);
2507 }
2508
2509 3311 boost::optional<SurfacePropertyExposedFoundationPerimeter> Surface::surfacePropertyExposedFoundationPerimeter() const {
2510
1/1
✓ Branch 3 taken 3311 times.
3311 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 4768021 times.
4768021 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 355 times.
✓ Branch 2 taken 1492 times.
1847 if (i != newSurfaces1.size() - 1) {
2551
1/1
✓ Branch 1 taken 355 times.
355 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 254 times.
✓ Branch 2 taken 1102 times.
1356 if (i != newSurfaces2.size() - 1) {
2560
1/1
✓ Branch 1 taken 254 times.
254 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