GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 67.5% 318 / 0 / 471
Functions: 71.1% 54 / 0 / 76
Branches: 55.1% 367 / 0 / 666

src/model/PlanarSurface.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 "PlanarSurface.hpp"
7 #include "PlanarSurface_Impl.hpp"
8 #include "Model.hpp"
9
10 #include "PlanarSurfaceGroup.hpp"
11 #include "Space.hpp"
12 #include "ModelExtensibleGroup.hpp"
13 #include "ConstructionBase.hpp"
14 #include "ConstructionBase_Impl.hpp"
15 #include "ConstructionAirBoundary.hpp"
16 #include "ConstructionAirBoundary_Impl.hpp"
17 #include "LayeredConstruction.hpp"
18 #include "LayeredConstruction_Impl.hpp"
19 #include "Material.hpp"
20 #include "SubSurface.hpp"
21 #include "SubSurface_Impl.hpp"
22 #include "GeneratorPhotovoltaic.hpp"
23 #include "GeneratorPhotovoltaic_Impl.hpp"
24 #include "SurfacePropertyConvectionCoefficients.hpp"
25 #include "SurfacePropertyConvectionCoefficients_Impl.hpp"
26
27 #include "../utilities/sql/SqlFile.hpp"
28
29 #include "../utilities/geometry/Geometry.hpp"
30 #include "../utilities/geometry/Transformation.hpp"
31 #include "../utilities/geometry/Polyhedron.hpp"
32
33 #include "../utilities/core/Assert.hpp"
34
35 #include <utilities/idd/IddEnums.hxx>
36
37 #include <boost/math/constants/constants.hpp>
38 #include <boost/lexical_cast.hpp>
39
40 using openstudio::Handle;
41 using openstudio::OptionalHandle;
42 using openstudio::HandleVector;
43 using openstudio::IdfObject;
44 using openstudio::WorkspaceObject;
45 using openstudio::OptionalWorkspaceObject;
46 using openstudio::WorkspaceObjectVector;
47 using openstudio::Workspace;
48
49 using boost::to_upper_copy;
50
51 namespace openstudio {
52 namespace model {
53
54 namespace detail {
55
56 // constructor
57 ✗ PlanarSurface_Impl::PlanarSurface_Impl(IddObjectType type, Model_Impl* model) : ParentObject_Impl(type, model) {
58 // connect signals
59 ✗ this->PlanarSurface_Impl::onChange.connect<PlanarSurface_Impl, &PlanarSurface_Impl::clearCachedVariables>(this);
60 ✗ }
61
62 // constructor
63 58155 PlanarSurface_Impl::PlanarSurface_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
64 58155 : ParentObject_Impl(idfObject, model, keepHandle) {
65 // connect signals
66
1/1
✓ Branch 1 taken 58155 times.
58155 this->PlanarSurface_Impl::onChange.connect<PlanarSurface_Impl, &PlanarSurface_Impl::clearCachedVariables>(this);
67 58155 }
68
69 25944 PlanarSurface_Impl::PlanarSurface_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
70 25944 : ParentObject_Impl(other, model, keepHandle) {
71 // connect signals
72
1/1
✓ Branch 1 taken 25944 times.
25944 this->PlanarSurface_Impl::onChange.connect<PlanarSurface_Impl, &PlanarSurface_Impl::clearCachedVariables>(this);
73 25944 }
74
75 15757 PlanarSurface_Impl::PlanarSurface_Impl(const PlanarSurface_Impl& other, Model_Impl* model, bool keepHandle)
76 15757 : ParentObject_Impl(other, model, keepHandle) {
77 // connect signals
78
1/1
✓ Branch 1 taken 15757 times.
15757 this->PlanarSurface_Impl::onChange.connect<PlanarSurface_Impl, &PlanarSurface_Impl::clearCachedVariables>(this);
79 15757 }
80
81 1255 boost::optional<ConstructionBase> PlanarSurface_Impl::construction() const {
82
1/1
✓ Branch 1 taken 1255 times.
1255 boost::optional<std::pair<ConstructionBase, int>> result = this->constructionWithSearchDistance();
83
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 1157 times.
1255 if (result) {
84
2/2
✓ Branch 1 taken 98 times.
✓ Branch 4 taken 98 times.
98 return result->first;
85 }
86 1157 return boost::none;
87 1255 }
88
89 /// get the vertices
90 2720517 Point3dVector PlanarSurface_Impl::vertices() const {
91
2/2
✓ Branch 1 taken 154686 times.
✓ Branch 2 taken 2565831 times.
2720517 if (!m_cachedVertices) {
92 154686 Point3dVector result;
93
94
3/3
✓ Branch 1 taken 154686 times.
✓ Branch 8 taken 679962 times.
✓ Branch 9 taken 154686 times.
834648 for (const auto& group : extensibleGroups()) {
95
1/1
✓ Branch 1 taken 679962 times.
679962 OptionalDouble x = group.getDouble(0);
96
1/1
✓ Branch 1 taken 679962 times.
679962 OptionalDouble y = group.getDouble(1);
97
1/1
✓ Branch 1 taken 679962 times.
679962 OptionalDouble z = group.getDouble(2);
98
99
4/8
✓ Branch 0 taken 679962 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 679962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 679962 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 679962 times.
✗ Branch 7 not taken.
2039886 if (x && y && z) {
100
5/5
✓ Branch 1 taken 679962 times.
✓ Branch 4 taken 679962 times.
✓ Branch 7 taken 679962 times.
✓ Branch 10 taken 679962 times.
✓ Branch 13 taken 679962 times.
679962 result.push_back(Point3d(*x, *y, *z));
101 } else {
102 ✗ LOG(Error, "Could not read vertex " << group.groupIndex() << " in " << briefDescription() << ".");
103 }
104 154686 }
105
106
1/1
✓ Branch 1 taken 154686 times.
154686 m_cachedVertices = result;
107 154686 }
108
109 2720517 return m_cachedVertices.get();
110 }
111
112 /// set the vertices
113 53232 bool PlanarSurface_Impl::setVertices(const std::vector<Point3d>& vertices) {
114 53232 unsigned n = vertices.size();
115
116
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 53225 times.
53232 if (n < 3) {
117
7/7
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 8 taken 7 times.
✓ Branch 11 taken 7 times.
✓ Branch 14 taken 7 times.
✓ Branch 17 taken 7 times.
✓ Branch 20 taken 7 times.
7 LOG(Error, "Cannot set vertices because size of vertices is " << vertices.size() << ", which is less than 3.");
118 7 return false;
119 }
120
121 // compute plane
122 // DLM: still ok to make sure we can compute a plane at least
123 53225 boost::optional<Plane> plane;
124 try {
125
2/2
✓ Branch 1 taken 53225 times.
✓ Branch 4 taken 53225 times.
53225 plane = Plane(vertices);
126 ✗ } catch (const std::exception&) {
127 ✗ LOG(Error, "Could not compute plane for vertices for '" << this->name().get() << "'.");
128 ✗ return false;
129 ✗ }
130
131 53225 bool result = true;
132
133 // DA - Removed these because they are of little value for debugging and just create noise in the log file
134 // LOG(Debug, "Before setVertices have " << numFields() << " fields.");
135
136
1/1
✓ Branch 1 taken 53225 times.
53225 clearExtensibleGroups(false);
137
138 // DA - Removed these because they are of little value for debugging and just create noise in the log file
139 // LOG(Debug, "After clearExtensibleGroups in setVertices have " << numFields() << " fields.");
140
141 // set the vertices
142 // bool nonPlanarPointFound = false;
143
2/2
✓ Branch 0 taken 235105 times.
✓ Branch 1 taken 53225 times.
288330 for (unsigned vertexIndex = 0; vertexIndex < n; ++vertexIndex) {
144
145 // DLM: fitting points to plane here as well as in SketchUp was resulting in unacceptable rounding errors
146 // just use point directly
147
1/1
✓ Branch 2 taken 235105 times.
235105 Point3d vertex = vertices[vertexIndex];
148
149 // project point to plane
150 //Point3d vertex = plane->project(vertices[vertexIndex]);
151 //LOG(Debug, "Original vertex = " << vertices[vertexIndex] << ", new vertex = " << vertex);
152
153 // see how far off we were
154 //if (!nonPlanarPointFound){
155 // Vector3d diff = vertex - vertices[vertexIndex];
156 // // see if more than 1 inch off of plane
157 // if (diff.length() > 0.0254){
158 // LOG(Warn, "PlanarSurface '" << this->name().get() << "' given non-planar vertices, these have been corrected.");
159 // nonPlanarPointFound = true;
160 // }
161 //}
162
163
3/5
✓ Branch 1 taken 235105 times.
✓ Branch 3 taken 705315 times.
✓ Branch 4 taken 235105 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1175525 std::vector<std::string> values{toString(vertex.x()), toString(vertex.y()), toString(vertex.z())};
164
165
1/1
✓ Branch 1 taken 235105 times.
235105 auto group = pushExtensibleGroup(values, false);
166
2/4
✓ Branch 1 taken 235105 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 235105 times.
✗ Branch 6 not taken.
235105 OS_ASSERT(!group.empty());
167 235105 }
168
169 // DA - Removed these because they are of little value for debugging and just create noise in the log file
170 // LOG(Debug, "After setVertices have " << numFields() << " fields. Size of vertices is " << vertices.size() << ".");
171
172
1/1
✓ Branch 1 taken 53225 times.
53225 this->emitChangeSignals();
173
174 53225 return result;
175 288330 }
176
177 ✗ bool PlanarSurface_Impl::setUFactor(boost::optional<double> value) {
178 // DLM: change interface to take a double?
179 ✗ OS_ASSERT(value);
180 ✗ return setUFactor(*value);
181 }
182
183 ✗ bool PlanarSurface_Impl::setThermalConductance(boost::optional<double> value) {
184 // DLM: change interface to take a double?
185 ✗ OS_ASSERT(value);
186 ✗ return setThermalConductance(*value);
187 }
188
189 /// is this surface an air wall
190 21549 bool PlanarSurface_Impl::isAirWall() const {
191
1/1
✓ Branch 1 taken 21549 times.
21549 OptionalConstructionBase oConstruction = this->construction();
192
8/10
✓ Branch 1 taken 5349 times.
✓ Branch 2 taken 16200 times.
✓ Branch 4 taken 5349 times.
✓ Branch 7 taken 5349 times.
✓ Branch 10 taken 758 times.
✓ Branch 11 taken 4591 times.
✓ Branch 12 taken 5349 times.
✓ Branch 13 taken 16200 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
69996 return oConstruction && oConstruction->optionalCast<ConstructionAirBoundary>();
193 21549 }
194
195 // compute gross area (m^2)
196 1375716 double PlanarSurface_Impl::grossArea() const {
197 1375716 double result = 0.0;
198
2/2
✓ Branch 1 taken 1375716 times.
✓ Branch 4 taken 1375716 times.
1375716 OptionalDouble area = getArea(vertices());
199
1/2
✓ Branch 0 taken 1375716 times.
✗ Branch 1 not taken.
1375716 if (area) {
200
1/1
✓ Branch 1 taken 1375716 times.
1375716 result = *area;
201 }
202 1375716 return result;
203 }
204
205 // compute net area (m^2)
206 1523 double PlanarSurface_Impl::netArea() const {
207 1523 double result = this->grossArea();
208
209 // subtract net area of child planar surfaces
210
3/3
✓ Branch 1 taken 1523 times.
✓ Branch 8 taken 722 times.
✓ Branch 9 taken 1523 times.
2245 for (const ModelObject& child : this->children()) {
211
1/1
✓ Branch 1 taken 722 times.
722 OptionalPlanarSurface surface = child.optionalCast<PlanarSurface>();
212
2/2
✓ Branch 0 taken 721 times.
✓ Branch 1 taken 1 time.
722 if (surface) {
213
3/4
✓ Branch 1 taken 721 times.
✓ Branch 4 taken 721 times.
✓ Branch 6 taken 721 times.
✗ Branch 7 not taken.
721 if (surface->subtractFromGrossArea()) {
214 721 double multiplier = 1.0;
215
1/1
✓ Branch 1 taken 721 times.
721 OptionalSubSurface subSurface = child.optionalCast<SubSurface>();
216
1/2
✓ Branch 0 taken 721 times.
✗ Branch 1 not taken.
721 if (subSurface) {
217
2/2
✓ Branch 1 taken 721 times.
✓ Branch 4 taken 721 times.
721 multiplier = subSurface->multiplier();
218 }
219
2/2
✓ Branch 1 taken 721 times.
✓ Branch 4 taken 721 times.
721 result -= multiplier * subSurface->roughOpeningArea();
220 721 }
221 }
222 2245 }
223
224 1523 return result;
225 }
226
227 /// get the outward normal
228 68796 Vector3d PlanarSurface_Impl::outwardNormal() const {
229
2/2
✓ Branch 1 taken 68705 times.
✓ Branch 2 taken 91 times.
68796 if (!m_cachedOutwardNormal) {
230
1/1
✓ Branch 1 taken 68705 times.
68705 Point3dVector vertices = this->vertices();
231
1/1
✓ Branch 1 taken 68705 times.
68705 m_cachedOutwardNormal = getOutwardNormal(vertices);
232
2/2
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 68704 times.
68705 if (!m_cachedOutwardNormal) {
233 1 std::string surfaceNameMsg;
234
1/1
✓ Branch 1 taken 1 time.
1 boost::optional<std::string> name = this->name();
235
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 if (name) {
236
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 surfaceNameMsg = ", surface name = '" + *name + "'";
237 }
238
17/17
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 25 taken 1 time.
✓ Branch 28 taken 1 time.
✓ Branch 31 taken 1 time.
✓ Branch 34 taken 1 time.
✓ Branch 37 taken 1 time.
✓ Branch 40 taken 1 time.
✓ Branch 43 taken 1 time.
✓ Branch 46 taken 1 time.
✓ Branch 50 taken 1 time.
✓ Branch 53 taken 1 time.
1 LOG_AND_THROW("Cannot compute outward normal for vertices " << vertices << surfaceNameMsg);
239 2 }
240 68705 }
241 68795 return m_cachedOutwardNormal.get();
242 }
243
244 56715 double PlanarSurface_Impl::tilt() const {
245
2/2
✓ Branch 1 taken 56714 times.
✓ Branch 4 taken 56714 times.
56715 OptionalVector3d on = outwardNormal();
246
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 56714 times.
56714 if (!on) {
247 ✗ LOG_AND_THROW("Cannot calculate PlanarSurface tilt because there is no outwardNormal.");
248 }
249
2/2
✓ Branch 1 taken 56714 times.
✓ Branch 4 taken 56714 times.
56714 Vector3d n = *on;
250
1/1
✓ Branch 1 taken 56714 times.
56714 Vector3d up(0.0, 0.0, 1.0);
251
1/1
✓ Branch 1 taken 56714 times.
113428 return getAngle(n, up);
252 56714 }
253
254 60 double PlanarSurface_Impl::azimuth() const {
255
2/2
✓ Branch 1 taken 60 times.
✓ Branch 4 taken 60 times.
60 OptionalVector3d on = outwardNormal();
256
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
60 if (!on) {
257 ✗ LOG_AND_THROW("Cannot calculate PlanarSurface azimuth because there is no outwardNormal.");
258 }
259
2/2
✓ Branch 1 taken 60 times.
✓ Branch 4 taken 60 times.
60 Vector3d n = *on;
260
1/1
✓ Branch 1 taken 60 times.
60 Vector3d north(0.0, 1.0, 0.0);
261
1/1
✓ Branch 1 taken 60 times.
60 double rawAngle = getAngle(n, north);
262
4/4
✓ Branch 1 taken 60 times.
✓ Branch 4 taken 60 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 52 times.
60 if (on->x() < 0.0) {
263 8 return -rawAngle + 2.0 * boost::math::constants::pi<double>();
264 }
265 52 return rawAngle;
266 60 }
267
268 ✗ boost::optional<double> PlanarSurface_Impl::uFactor() const {
269 ✗ return boost::none;
270 }
271
272 ✗ boost::optional<double> PlanarSurface_Impl::thermalConductance() const {
273 ✗ return boost::none;
274 }
275
276 ✗ bool PlanarSurface_Impl::setUFactor(double /*value*/) {
277 ✗ return false;
278 }
279
280 ✗ bool PlanarSurface_Impl::setThermalConductance(double /*value*/) {
281 ✗ return false;
282 }
283
284 ✗ boost::optional<double> PlanarSurface_Impl::heatCapacity() const {
285 ✗ OptionalDouble result;
286 ✗ OptionalConstructionBase oConstruction = this->construction();
287
288 ✗ if (oConstruction) {
289 ✗ result = oConstruction->heatCapacity();
290 }
291
292 ✗ return result;
293 ✗ }
294
295 114 boost::optional<double> PlanarSurface_Impl::interiorVisibleAbsorptance() const {
296 114 OptionalDouble result;
297
2/2
✓ Branch 1 taken 114 times.
✓ Branch 4 taken 114 times.
114 OptionalSqlFile sqlFile = model().sqlFile();
298
1/1
✓ Branch 1 taken 114 times.
114 OptionalConstructionBase oConstruction = this->construction();
299
300
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if (oConstruction) {
301 // from input
302
2/2
✓ Branch 1 taken 105 times.
✓ Branch 4 taken 105 times.
105 OptionalDouble inputResult = oConstruction->interiorVisibleAbsorptance();
303
304 // from output
305 105 OptionalDouble outputResult;
306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (sqlFile) {
307 ✗ OptionalString constructionName = oConstruction->name();
308 ✗ if (constructionName) {
309 ✗ std::string query = "SELECT InsideAbsorpVis FROM constructions WHERE Name=?;";
310 ✗ outputResult = sqlFile->execAndReturnFirstDouble(query,
311 // bindArgs
312 ✗ to_upper_copy(*constructionName));
313 ✗ }
314 ✗ }
315
316
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if (inputResult) {
317 105 result = inputResult;
318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (outputResult) {
319 ✗ compareInputAndOutput(*oConstruction, "interior visible absorptance", *inputResult, *outputResult, 1.0E-5);
320 }
321 } else {
322 ✗ result = outputResult;
323 }
324 }
325
326 114 return result;
327 114 }
328
329 /// get exterior visible absorptance (unitless)
330 114 boost::optional<double> PlanarSurface_Impl::exteriorVisibleAbsorptance() const {
331 114 OptionalDouble result;
332
2/2
✓ Branch 1 taken 114 times.
✓ Branch 4 taken 114 times.
114 OptionalSqlFile sqlFile = model().sqlFile();
333
1/1
✓ Branch 1 taken 114 times.
114 OptionalConstructionBase oConstruction = this->construction();
334
335
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 9 times.
114 if (oConstruction) {
336 // from input
337
2/2
✓ Branch 1 taken 105 times.
✓ Branch 4 taken 105 times.
105 OptionalDouble inputResult = oConstruction->exteriorVisibleAbsorptance();
338
339 // from output
340 105 OptionalDouble outputResult;
341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (sqlFile) {
342 ✗ OptionalString constructionName = oConstruction->name();
343 ✗ if (constructionName) {
344 ✗ std::string query = "SELECT OutsideAbsorpVis FROM constructions WHERE Name=?;";
345 ✗ outputResult = sqlFile->execAndReturnFirstDouble(query, to_upper_copy(*constructionName));
346 ✗ }
347 ✗ }
348
349
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if (inputResult) {
350 105 result = inputResult;
351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (outputResult) {
352 ✗ compareInputAndOutput(*oConstruction, "exterior visible absorptance", *inputResult, *outputResult, 1.0E-5);
353 }
354 } else {
355 ✗ result = outputResult;
356 }
357 }
358
359 114 return result;
360 114 }
361
362 /// get visible transmittance (unitless)
363 /// requires 'EnvelopeSummary' summary table
364 6 boost::optional<double> PlanarSurface_Impl::visibleTransmittance() const {
365 6 OptionalDouble result;
366
1/1
✓ Branch 1 taken 6 times.
6 boost::optional<std::string> surfaceName = this->name();
367
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 OptionalSqlFile sqlFile = model().sqlFile();
368
1/1
✓ Branch 1 taken 6 times.
6 OptionalConstructionBase oConstruction = this->construction();
369
370
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (oConstruction) {
371 // from input
372
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 OptionalDouble inputResult = oConstruction->visibleTransmittance();
373
374 // from output
375 6 OptionalDouble outputResult;
376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (sqlFile) {
377 ✗ OptionalString surfaceName = this->name();
378 //OptionalString constructionName = oConstruction->name();
379 ✗ std::string query;
380 ✗ if (surfaceName) {
381
382 ✗ if (!outputResult) {
383 ✗ std::string query = R"(SELECT Value from TabularDataWithStrings
384 WHERE ReportName = 'EnvelopeSummary'
385 AND ReportForString = 'Entire Facility'
386 AND TableName = 'Exterior Fenestration'
387 AND ColumnName = 'Glass Visible Transmittance'
388 AND RowName = ?;)";
389 ✗ outputResult = sqlFile->execAndReturnFirstDouble(query, to_upper_copy(*surfaceName));
390 ✗ }
391
392 ✗ if (!outputResult) {
393 ✗ std::string query = R"(SELECT Value from TabularDataWithStrings
394 WHERE ReportName = 'EnvelopeSummary'
395 AND ReportForString = 'Entire Facility'
396 AND TableName = 'Interior Fenestration'
397 AND ColumnName = 'Glass Visible Transmittance'
398 AND RowName = ?;)";
399 ✗ outputResult = sqlFile->execAndReturnFirstDouble(query, to_upper_copy(*surfaceName));
400 ✗ }
401 }
402 ✗ }
403
404
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (inputResult) {
405 6 result = inputResult;
406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (outputResult) {
407 ✗ compareInputAndOutput(*oConstruction, "visible transmittance", *inputResult, *outputResult, 1.0E-5);
408 }
409 } else {
410 ✗ result = outputResult;
411 }
412 }
413
414 6 return result;
415 6 }
416
417 ✗ bool PlanarSurface_Impl::equalVertices(const PlanarSurface& other) const {
418 ✗ std::vector<Point3d> vertices1 = this->vertices();
419 ✗ std::vector<Point3d> vertices2 = other.vertices();
420
421 ✗ boost::optional<PlanarSurfaceGroup> group;
422
423 ✗ Transformation t1;
424 ✗ group = this->planarSurfaceGroup();
425 ✗ if (group) {
426 ✗ t1 = group->buildingTransformation();
427 }
428
429 ✗ Transformation t2;
430 ✗ group = other.planarSurfaceGroup();
431 ✗ if (group) {
432 ✗ t2 = group->buildingTransformation();
433 }
434
435 ✗ return circularEqual(t1 * vertices1, t2 * vertices2);
436 ✗ }
437
438 ✗ bool PlanarSurface_Impl::reverseEqualVertices(const PlanarSurface& other) const {
439 ✗ std::vector<Point3d> vertices1 = this->vertices();
440 ✗ std::vector<Point3d> vertices2 = other.vertices();
441 ✗ std::reverse(vertices2.begin(), vertices2.end());
442
443 ✗ boost::optional<PlanarSurfaceGroup> group;
444
445 ✗ Transformation t1;
446 ✗ group = this->planarSurfaceGroup();
447 ✗ if (group) {
448 ✗ t1 = group->buildingTransformation();
449 }
450
451 ✗ Transformation t2;
452 ✗ group = other.planarSurfaceGroup();
453 ✗ if (group) {
454 ✗ t2 = group->buildingTransformation();
455 }
456
457 ✗ return circularEqual(t1 * vertices1, t2 * vertices2);
458 ✗ }
459
460 1043143 Plane PlanarSurface_Impl::plane() const {
461
2/2
✓ Branch 1 taken 27187 times.
✓ Branch 2 taken 1015956 times.
1043143 if (!m_cachedPlane) {
462
3/3
✓ Branch 1 taken 27187 times.
✓ Branch 4 taken 27187 times.
✓ Branch 7 taken 27187 times.
27187 m_cachedPlane = Plane(this->vertices());
463 }
464 1043143 return m_cachedPlane.get();
465 }
466
467 5017 Surface3d PlanarSurface_Impl::surface3d() const {
468
3/3
✓ Branch 1 taken 5017 times.
✓ Branch 4 taken 5017 times.
✓ Branch 7 taken 5017 times.
5017 return {this->vertices(), this->nameString(), 0};
469 }
470
471 5017 bool PlanarSurface_Impl::isConvex() const {
472
2/2
✓ Branch 1 taken 5017 times.
✓ Branch 4 taken 5017 times.
5017 return surface3d().isConvex();
473 }
474
475 19 std::vector<std::vector<Point3d>> PlanarSurface_Impl::triangulation() const {
476
2/2
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 8 times.
19 if (m_cachedTriangulation.empty()) {
477
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 Transformation faceTransformation = Transformation::alignFace(this->vertices());
478
1/1
✓ Branch 1 taken 11 times.
11 Transformation faceTransformationInverse = faceTransformation.inverse();
479
480
2/2
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
11 std::vector<Point3d> faceVertices = faceTransformationInverse * this->vertices();
481
1/1
✓ Branch 3 taken 11 times.
11 std::reverse(faceVertices.begin(), faceVertices.end());
482
483 11 std::vector<std::vector<Point3d>> faceHoles;
484
3/3
✓ Branch 1 taken 11 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 11 times.
15 for (const ModelObject& child : this->children()) {
485
1/1
✓ Branch 1 taken 4 times.
4 OptionalPlanarSurface surface = child.optionalCast<PlanarSurface>();
486
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (surface) {
487
3/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if (surface->subtractFromGrossArea()) {
488
3/3
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
4 std::vector<Point3d> holeVertices = faceTransformationInverse * surface->vertices();
489
1/1
✓ Branch 3 taken 4 times.
4 std::reverse(holeVertices.begin(), holeVertices.end());
490
1/1
✓ Branch 1 taken 4 times.
4 faceHoles.push_back(holeVertices);
491 4 }
492 }
493 15 }
494
495
1/1
✓ Branch 1 taken 11 times.
11 std::vector<std::vector<Point3d>> faceTriangulation = computeTriangulation(faceVertices, faceHoles);
496
497
2/2
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 11 times.
60 for (std::vector<Point3d>& faceTriangle : faceTriangulation) {
498
1/1
✓ Branch 3 taken 49 times.
49 std::reverse(faceTriangle.begin(), faceTriangle.end());
499
2/2
✓ Branch 1 taken 49 times.
✓ Branch 4 taken 49 times.
49 m_cachedTriangulation.push_back(faceTransformation * faceTriangle);
500 }
501 11 }
502 19 return m_cachedTriangulation;
503 }
504
505 64 Point3d PlanarSurface_Impl::centroid() const {
506
2/2
✓ Branch 1 taken 64 times.
✓ Branch 4 taken 64 times.
64 boost::optional<Point3d> result = getCentroid(this->vertices());
507
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 4 not taken.
64 OS_ASSERT(result);
508
2/2
✓ Branch 1 taken 64 times.
✓ Branch 4 taken 64 times.
128 return *result;
509 64 }
510
511 9 std::vector<ModelObject> PlanarSurface_Impl::solarCollectors() const {
512 9 std::vector<ModelObject> result;
513
4/4
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 9 times.
15 for (const ModelObject& modelObject : getObject<ModelObject>().getModelObjectSources<ModelObject>()) {
514
4/5
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
6 switch (modelObject.iddObject().type().value()) {
515 6 case IddObjectType::OS_SolarCollector_FlatPlate_PhotovoltaicThermal: // fall through
516 case IddObjectType::OS_SolarCollector_FlatPlate_Water: // fall through
517 case IddObjectType::OS_SolarCollector_IntegralCollectorStorage: // fall through
518
1/1
✓ Branch 1 taken 6 times.
6 result.push_back(modelObject);
519 6 break;
520 ✗ default:
521 ✗ break;
522 }
523 9 }
524 9 return result;
525 ✗ }
526
527 2 std::vector<GeneratorPhotovoltaic> PlanarSurface_Impl::generatorPhotovoltaics() const {
528
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return getObject<ModelObject>().getModelObjectSources<GeneratorPhotovoltaic>();
529 }
530
531 ✗ std::vector<SurfacePropertyConvectionCoefficients> PlanarSurface_Impl::surfacePropertyConvectionCoefficients() const {
532 ✗ return getObject<ModelObject>().getModelObjectSources<SurfacePropertyConvectionCoefficients>();
533 }
534
535 ✗ boost::optional<ModelObject> PlanarSurface_Impl::constructionAsModelObject() const {
536 ✗ return static_cast<boost::optional<ModelObject>>(this->construction());
537 }
538
539 ✗ boost::optional<ModelObject> PlanarSurface_Impl::planarSurfaceGroupAsModelObject() const {
540 ✗ OptionalModelObject result;
541 ✗ OptionalPlanarSurfaceGroup intermediate = planarSurfaceGroup();
542 ✗ if (intermediate) {
543 ✗ result = *intermediate;
544 }
545 ✗ return result;
546 ✗ }
547
548 ✗ boost::optional<ModelObject> PlanarSurface_Impl::spaceAsModelObject() const {
549 ✗ OptionalModelObject result;
550 ✗ OptionalSpace intermediate = space();
551 ✗ if (intermediate) {
552 ✗ result = *intermediate;
553 }
554 ✗ return result;
555 ✗ }
556
557 348639 void PlanarSurface_Impl::clearCachedVariables() {
558 348639 m_cachedVertices.reset();
559 348639 m_cachedPlane.reset();
560 348639 m_cachedOutwardNormal.reset();
561 348639 m_cachedTriangulation.clear();
562 348639 }
563
564 ✗ bool PlanarSurface_Impl::setConstructionAsModelObject(boost::optional<ModelObject> modelObject) {
565 ✗ bool result = false;
566 ✗ if (!modelObject) {
567 // reset construction not currently implemented
568 ✗ result = false;
569 } else {
570 ✗ boost::optional<ConstructionBase> construction = modelObject->optionalCast<ConstructionBase>();
571 ✗ if (construction) {
572 ✗ result = this->setConstruction(*construction);
573 }
574 ✗ }
575 ✗ return result;
576 }
577
578 } // namespace detail
579
580 32178 PlanarSurface::PlanarSurface(IddObjectType type, const std::vector<Point3d>& vertices, const Model& model) : ParentObject(type, model) {
581
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 32178 times.
✗ Branch 5 not taken.
32178 OS_ASSERT(getImpl<detail::PlanarSurface_Impl>());
582
1/1
✓ Branch 1 taken 32177 times.
32178 bool ok = this->setVertices(vertices);
583
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 32171 times.
32177 if (!ok) {
584
1/1
✓ Branch 1 taken 6 times.
6 this->remove();
585
15/15
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✓ Branch 10 taken 6 times.
✓ Branch 13 taken 6 times.
✓ Branch 16 taken 6 times.
✓ Branch 22 taken 6 times.
✓ Branch 25 taken 6 times.
✓ Branch 28 taken 6 times.
✓ Branch 31 taken 6 times.
✓ Branch 34 taken 6 times.
✓ Branch 37 taken 6 times.
✓ Branch 40 taken 6 times.
✓ Branch 44 taken 6 times.
✓ Branch 47 taken 6 times.
6 LOG_AND_THROW("Cannot create a surface with vertices " << vertices);
586 }
587 32178 }
588
589
1/1
✓ Branch 3 taken 4908826 times.
4908826 PlanarSurface::PlanarSurface(std::shared_ptr<detail::PlanarSurface_Impl> p) : ParentObject(std::move(p)) {}
590
591 33636 boost::optional<ConstructionBase> PlanarSurface::construction() const {
592
1/1
✓ Branch 3 taken 33636 times.
33636 return getImpl<detail::PlanarSurface_Impl>()->construction();
593 }
594
595 14237 boost::optional<std::pair<ConstructionBase, int>> PlanarSurface::constructionWithSearchDistance() const {
596
1/1
✓ Branch 3 taken 14237 times.
14237 return getImpl<detail::PlanarSurface_Impl>()->constructionWithSearchDistance();
597 }
598
599 193 bool PlanarSurface::isConstructionDefaulted() const {
600
1/1
✓ Branch 3 taken 193 times.
193 return getImpl<detail::PlanarSurface_Impl>()->isConstructionDefaulted();
601 }
602
603 /// get the vertices
604 1214257 Point3dVector PlanarSurface::vertices() const {
605
1/1
✓ Branch 3 taken 1214257 times.
1214257 return getImpl<detail::PlanarSurface_Impl>()->vertices();
606 }
607
608 /// set the vertices
609 46211 bool PlanarSurface::setVertices(const std::vector<Point3d>& vertices) {
610
1/1
✓ Branch 3 taken 46210 times.
46211 return getImpl<detail::PlanarSurface_Impl>()->setVertices(vertices);
611 }
612
613 /// set the construction object
614 3978 bool PlanarSurface::setConstruction(const ConstructionBase& construction) {
615
1/1
✓ Branch 3 taken 3978 times.
3978 return getImpl<detail::PlanarSurface_Impl>()->setConstruction(construction);
616 }
617
618 1005 void PlanarSurface::resetConstruction() {
619
1/1
✓ Branch 3 taken 1005 times.
1005 getImpl<detail::PlanarSurface_Impl>()->resetConstruction();
620 1005 }
621
622 ✗ bool PlanarSurface::setUFactor(double value) {
623 ✗ return getImpl<detail::PlanarSurface_Impl>()->setUFactor(value);
624 }
625
626 ✗ bool PlanarSurface::setThermalConductance(double value) {
627 ✗ return getImpl<detail::PlanarSurface_Impl>()->setThermalConductance(value);
628 }
629
630 /// is this surface an air wall
631 21549 bool PlanarSurface::isAirWall() const {
632
1/1
✓ Branch 3 taken 21549 times.
21549 return getImpl<detail::PlanarSurface_Impl>()->isAirWall();
633 }
634
635 // compute gross area (m^2)
636 1374033 double PlanarSurface::grossArea() const {
637
1/1
✓ Branch 3 taken 1374033 times.
1374033 return getImpl<detail::PlanarSurface_Impl>()->grossArea();
638 }
639
640 /// should subtract this surface from parent's gross area for net area
641 725 bool PlanarSurface::subtractFromGrossArea() const {
642
1/1
✓ Branch 3 taken 725 times.
725 return getImpl<detail::PlanarSurface_Impl>()->subtractFromGrossArea();
643 }
644
645 // compute net area (m^2)
646 1523 double PlanarSurface::netArea() const {
647
1/1
✓ Branch 3 taken 1523 times.
1523 return getImpl<detail::PlanarSurface_Impl>()->netArea();
648 }
649
650 /// get the outward normal
651 12021 Vector3d PlanarSurface::outwardNormal() const {
652
1/1
✓ Branch 3 taken 12021 times.
12021 return getImpl<detail::PlanarSurface_Impl>()->outwardNormal();
653 }
654
655 ✗ double PlanarSurface::tilt() const {
656 ✗ return getImpl<detail::PlanarSurface_Impl>()->tilt();
657 }
658
659 60 double PlanarSurface::azimuth() const {
660
1/1
✓ Branch 3 taken 60 times.
60 return getImpl<detail::PlanarSurface_Impl>()->azimuth();
661 }
662
663 4 boost::optional<double> PlanarSurface::uFactor() const {
664
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::PlanarSurface_Impl>()->uFactor();
665 }
666
667 4 boost::optional<double> PlanarSurface::thermalConductance() const {
668
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::PlanarSurface_Impl>()->thermalConductance();
669 }
670
671 ✗ boost::optional<double> PlanarSurface::heatCapacity() const {
672 ✗ return getImpl<detail::PlanarSurface_Impl>()->heatCapacity();
673 }
674
675 /// get interior visible absorptance (unitless)
676 114 OptionalDouble PlanarSurface::interiorVisibleAbsorptance() const {
677
1/1
✓ Branch 3 taken 114 times.
114 return getImpl<detail::PlanarSurface_Impl>()->interiorVisibleAbsorptance();
678 }
679
680 /// get exterior visible absorptance (unitless)
681 114 OptionalDouble PlanarSurface::exteriorVisibleAbsorptance() const {
682
1/1
✓ Branch 3 taken 114 times.
114 return getImpl<detail::PlanarSurface_Impl>()->exteriorVisibleAbsorptance();
683 }
684
685 63332 boost::optional<PlanarSurfaceGroup> PlanarSurface::planarSurfaceGroup() const {
686
1/1
✓ Branch 3 taken 63332 times.
63332 return getImpl<detail::PlanarSurface_Impl>()->planarSurfaceGroup();
687 }
688
689 564469 boost::optional<Space> PlanarSurface::space() const {
690
1/1
✓ Branch 3 taken 564469 times.
564469 return getImpl<detail::PlanarSurface_Impl>()->space();
691 }
692
693 /// get visible transmittance (unitless)
694 /// requires 'EnvelopeSummary' summary table
695 6 boost::optional<double> PlanarSurface::visibleTransmittance() const {
696
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::PlanarSurface_Impl>()->visibleTransmittance();
697 }
698
699 ✗ bool PlanarSurface::equalVertices(const PlanarSurface& other) const {
700 ✗ return getImpl<detail::PlanarSurface_Impl>()->equalVertices(other);
701 }
702
703 ✗ bool PlanarSurface::reverseEqualVertices(const PlanarSurface& other) const {
704 ✗ return getImpl<detail::PlanarSurface_Impl>()->reverseEqualVertices(other);
705 }
706
707 521821 Plane PlanarSurface::plane() const {
708
1/1
✓ Branch 3 taken 521821 times.
521821 return getImpl<detail::PlanarSurface_Impl>()->plane();
709 }
710
711 5017 bool PlanarSurface::isConvex() const {
712
1/1
✓ Branch 3 taken 5017 times.
5017 return getImpl<detail::PlanarSurface_Impl>()->isConvex();
713 }
714
715 19 std::vector<std::vector<Point3d>> PlanarSurface::triangulation() const {
716
1/1
✓ Branch 3 taken 19 times.
19 return getImpl<detail::PlanarSurface_Impl>()->triangulation();
717 }
718
719 16 Point3d PlanarSurface::centroid() const {
720
1/1
✓ Branch 3 taken 16 times.
16 return getImpl<detail::PlanarSurface_Impl>()->centroid();
721 }
722
723 9 std::vector<ModelObject> PlanarSurface::solarCollectors() const {
724
1/1
✓ Branch 3 taken 9 times.
9 return getImpl<detail::PlanarSurface_Impl>()->solarCollectors();
725 }
726
727 2 std::vector<GeneratorPhotovoltaic> PlanarSurface::generatorPhotovoltaics() const {
728
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::PlanarSurface_Impl>()->generatorPhotovoltaics();
729 }
730
731 ✗ std::vector<SurfacePropertyConvectionCoefficients> PlanarSurface::surfacePropertyConvectionCoefficients() const {
732 ✗ return getImpl<detail::PlanarSurface_Impl>()->surfacePropertyConvectionCoefficients();
733 }
734
735 422 std::vector<PlanarSurface> PlanarSurface::findPlanarSurfaces(const std::vector<PlanarSurface>& planarSurfaces,
736 boost::optional<double> minDegreesFromNorth,
737 boost::optional<double> maxDegreesFromNorth, boost::optional<double> minDegreesTilt,
738 boost::optional<double> maxDegreesTilt, double tol) {
739 422 std::vector<PlanarSurface> result;
740
741 // check inputs
742 422 bool error = false;
743
744
7/10
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 6 times.
✓ Branch 3 taken 416 times.
✓ Branch 5 taken 416 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 416 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 416 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 422 times.
422 if (minDegreesFromNorth && ((*minDegreesFromNorth < 0) || (*minDegreesFromNorth > 360))) {
745 ✗ error = true;
746 ✗ LOG(Error, "minDegreesFromNorth out of range [0-360], " << *minDegreesFromNorth);
747 }
748
749
7/10
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 6 times.
✓ Branch 3 taken 416 times.
✓ Branch 5 taken 416 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 416 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 416 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 422 times.
422 if (maxDegreesFromNorth && ((*maxDegreesFromNorth < 0) || (*maxDegreesFromNorth > 360))) {
750 ✗ error = true;
751 ✗ LOG(Error, "maxDegreesFromNorth out of range [0-360], " << *maxDegreesFromNorth);
752 }
753
754
6/10
✓ Branch 0 taken 422 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 422 times.
✓ Branch 5 taken 422 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 422 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 422 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 422 times.
422 if (minDegreesTilt && ((*minDegreesTilt < 0) || (*minDegreesTilt > 180))) {
755 ✗ error = true;
756 ✗ LOG(Error, "minDegreesTilt out of range [0-180], " << *minDegreesTilt);
757 }
758
759
6/10
✓ Branch 0 taken 422 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 422 times.
✓ Branch 5 taken 422 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 422 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 422 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 422 times.
422 if (maxDegreesTilt && ((*maxDegreesTilt < 0) || (*maxDegreesTilt > 180))) {
760 ✗ error = true;
761 ✗ LOG(Error, "maxDegreesTilt out of range [0-180], " << *maxDegreesTilt);
762 }
763
764
6/10
✓ Branch 0 taken 422 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 422 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 422 times.
✓ Branch 8 taken 422 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 422 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 422 times.
844 if (minDegreesTilt && maxDegreesTilt && (*minDegreesTilt > *maxDegreesTilt)) {
765 ✗ error = true;
766 ✗ LOG(Error, "minDegreesTilt (" << *minDegreesTilt << ") > maxDegreesTilt (" << *maxDegreesTilt << ")");
767 }
768
769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 422 times.
422 if (error) {
770 ✗ return result;
771 }
772
773 422 std::map<PlanarSurfaceGroup, Transformation> siteTransformationMap;
774
1/1
✓ Branch 1 taken 422 times.
422 Vector3d up(0.0, 0.0, 1.0);
775
1/1
✓ Branch 1 taken 422 times.
422 Vector3d north(0.0, 1.0, 0.0);
776
777 // inputs ok, loop over surfaces
778
2/2
✓ Branch 5 taken 2546 times.
✓ Branch 6 taken 422 times.
2968 for (const auto& planarSurface : planarSurfaces) {
779
780 // find the transformation to site coordinates
781
1/1
✓ Branch 1 taken 2546 times.
2546 Transformation siteTransformation;
782
783
1/1
✓ Branch 1 taken 2546 times.
2546 OptionalPlanarSurfaceGroup group = planarSurface.planarSurfaceGroup();
784
1/2
✓ Branch 0 taken 2546 times.
✗ Branch 1 not taken.
2546 if (group) {
785
2/2
✓ Branch 1 taken 2546 times.
✓ Branch 4 taken 2546 times.
2546 auto it = siteTransformationMap.find(*group);
786
787
2/2
✓ Branch 2 taken 2124 times.
✓ Branch 3 taken 422 times.
2546 if (it != siteTransformationMap.end()) {
788
1/1
✓ Branch 2 taken 2124 times.
2124 siteTransformation = it->second;
789 } else {
790
2/2
✓ Branch 1 taken 422 times.
✓ Branch 4 taken 422 times.
422 siteTransformation = group->buildingTransformation();
791
3/3
✓ Branch 1 taken 422 times.
✓ Branch 4 taken 422 times.
✓ Branch 7 taken 422 times.
422 siteTransformationMap.insert(std::make_pair(*group, siteTransformation));
792 }
793 }
794
795 // vertices and outward normal in site coordinates
796
2/2
✓ Branch 1 taken 2546 times.
✓ Branch 4 taken 2546 times.
2546 Point3dVector siteVertices = siteTransformation * planarSurface.vertices();
797
1/1
✓ Branch 1 taken 2546 times.
2546 OptionalVector3d siteOutwardNormal = getOutwardNormal(siteVertices);
798
799
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2546 times.
2546 if (!siteOutwardNormal) {
800 ✗ LOG(Error, "Could not compute outward normal for planarSurface " << planarSurface);
801 ✗ continue;
802 ✗ }
803
804
3/3
✓ Branch 1 taken 2546 times.
✓ Branch 4 taken 2546 times.
✓ Branch 7 taken 2546 times.
2546 double degreesTilt = radToDeg(getAngle(*siteOutwardNormal, up));
805
806
6/7
✓ Branch 0 taken 2546 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 2546 times.
✓ Branch 5 taken 431 times.
✓ Branch 6 taken 2115 times.
✓ Branch 7 taken 431 times.
✓ Branch 8 taken 2115 times.
2546 if (minDegreesTilt && (*minDegreesTilt - tol > degreesTilt)) {
807 431 continue;
808 }
809
810
6/7
✓ Branch 0 taken 2115 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 2115 times.
✓ Branch 5 taken 431 times.
✓ Branch 6 taken 1684 times.
✓ Branch 7 taken 431 times.
✓ Branch 8 taken 1684 times.
2115 if (maxDegreesTilt && (*maxDegreesTilt + tol < degreesTilt)) {
811 431 continue;
812 }
813
814 double degreesFromNorth;
815
4/4
✓ Branch 1 taken 1684 times.
✓ Branch 4 taken 1684 times.
✓ Branch 6 taken 420 times.
✓ Branch 7 taken 1264 times.
1684 if (siteOutwardNormal->x() < 0.0) {
816
3/3
✓ Branch 1 taken 420 times.
✓ Branch 4 taken 420 times.
✓ Branch 7 taken 420 times.
420 degreesFromNorth = 360 - radToDeg(getAngle(*siteOutwardNormal, north));
817 } else {
818
3/3
✓ Branch 1 taken 1264 times.
✓ Branch 4 taken 1264 times.
✓ Branch 7 taken 1264 times.
1264 degreesFromNorth = radToDeg(getAngle(*siteOutwardNormal, north));
819 }
820
821
5/6
✓ Branch 0 taken 1678 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1678 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1678 times.
✓ Branch 5 taken 6 times.
3362 if (minDegreesFromNorth && maxDegreesFromNorth) {
822
4/4
✓ Branch 1 taken 1678 times.
✓ Branch 4 taken 1678 times.
✓ Branch 6 taken 1670 times.
✓ Branch 7 taken 8 times.
1678 if (*maxDegreesFromNorth >= *minDegreesFromNorth) {
823
8/8
✓ Branch 1 taken 1670 times.
✓ Branch 3 taken 1046 times.
✓ Branch 4 taken 624 times.
✓ Branch 6 taken 1046 times.
✓ Branch 8 taken 628 times.
✓ Branch 9 taken 418 times.
✓ Branch 10 taken 1252 times.
✓ Branch 11 taken 418 times.
1670 if ((*minDegreesFromNorth - tol > degreesFromNorth) || (*maxDegreesFromNorth + tol < degreesFromNorth)) {
824 1252 continue;
825 }
826 } else {
827
7/8
✓ Branch 1 taken 8 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 8 times.
✓ Branch 8 taken 6 times.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 2 times.
8 if ((*minDegreesFromNorth - tol > degreesFromNorth) && (*maxDegreesFromNorth + tol < degreesFromNorth)) {
828 6 continue;
829 }
830 }
831
2/7
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
6 } else if (minDegreesFromNorth && (*minDegreesFromNorth - tol > degreesFromNorth)) {
832 ✗ continue;
833
2/7
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
6 } else if (maxDegreesFromNorth && (*maxDegreesFromNorth + tol < degreesFromNorth)) {
834 ✗ continue;
835 }
836
837
1/1
✓ Branch 1 taken 426 times.
426 result.push_back(planarSurface);
838 8906 }
839
840 422 return result;
841 422 }
842
843 18 double PlanarSurface::filmResistance(const FilmResistanceType& type) {
844 // assumes suface emmittance of 0.90
845
7/8
✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
18 switch (type.value()) {
846 1 case FilmResistanceType::StillAir_HorizontalSurface_HeatFlowsUpward:
847 1 return 0.107427212046;
848 1 case FilmResistanceType::StillAir_45DegreeSurface_HeatFlowsUpward:
849 1 return 0.109188313883;
850 1 case FilmResistanceType::StillAir_VerticalSurface:
851 1 return 0.119754924904;
852 1 case FilmResistanceType::StillAir_45DegreeSurface_HeatFlowsDownward:
853 1 return 0.133843739599;
854 1 case FilmResistanceType::StillAir_HorizontalSurface_HeatFlowsDownward:
855 1 return 0.162021368988;
856 12 case FilmResistanceType::MovingAir_15mph:
857 12 return 0.029938731226;
858 1 case FilmResistanceType::MovingAir_7p5mph:
859 1 return 0.044027545921;
860 ✗ default:
861 ✗ LOG_AND_THROW("Unknown FilmResistanceType.");
862 };
863 OS_ASSERT(false);
864 return 0.0;
865 }
866
867 11 double PlanarSurface::stillAirFilmResistance(double tilt) {
868 // filmResistance = a + b*tilt^2
869 // approximately 1% relative accuracy on five interpolated points, which is about all you can
870 // expect given that the original data (IP units) was in just two significant figures.
871 11 return 0.106042621636483 + 0.005513085609325 * std::pow(tilt, 2);
872 }
873
874 } // namespace model
875 } // namespace openstudio
876