GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 5 / 0 / 5
Functions: 100.0% 5 / 0 / 5
Branches: -% 0 / 0 / 0

src/model/Surface.hpp
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 #ifndef MODEL_SURFACE_HPP
7 #define MODEL_SURFACE_HPP
8
9 #include "ModelAPI.hpp"
10 #include "PlanarSurface.hpp"
11
12 #include "SurfacePropertyExposedFoundationPerimeter.hpp"
13 #include "SurfacePropertyExposedFoundationPerimeter_Impl.hpp"
14
15 namespace openstudio {
16 class Polygon3d;
17
18 namespace model {
19
20 class Space;
21 class SubSurface;
22 class ShadingSurfaceGroup;
23 class ConstructionBase;
24 class SurfaceControlMovableInsulation;
25 class SurfacePropertyOtherSideCoefficients;
26 class SurfacePropertyOtherSideConditionsModel;
27 class SurfacePropertyConvectionCoefficients;
28 class SurfacePropertyLocalEnvironment;
29 class AirflowNetworkSurface;
30 class AirflowNetworkDetailedOpening;
31 class AirflowNetworkSimpleOpening;
32 class AirflowNetworkCrack;
33 class AirflowNetworkEffectiveLeakageArea;
34 class AirflowNetworkHorizontalOpening;
35 class AirflowNetworkSpecifiedFlowRate;
36 class FoundationKiva;
37 class SurfacePropertyExposedFoundationPerimeter;
38
39 namespace detail {
40
41 class Surface_Impl;
42
43 } // namespace detail
44
45 class SurfaceIntersection;
46
47 /** Surface is a PlanarSurface that wraps the OpenStudio IDD object 'OS_Surface'. */
48 class MODEL_API Surface : public PlanarSurface
49 {
50 public:
51 /** @name Constructors and Destructors */
52 //@{
53
54 explicit Surface(const std::vector<Point3d>& vertices, const Model& model);
55
56 7508955 virtual ~Surface() override = default;
57 // Default the copy and move operators because the virtual dtor is explicit
58 83121 Surface(const Surface& other) = default;
59 2631659 Surface(Surface&& other) = default;
60 299 Surface& operator=(const Surface&) = default;
61 799976 Surface& operator=(Surface&&) = default;
62
63 //@}
64 /** @name Static Methods */
65 //@{
66
67 static IddObjectType iddObjectType();
68
69 static std::vector<std::string> validSurfaceTypeValues();
70
71 static std::vector<std::string> validOutsideBoundaryConditionValues();
72
73 static std::vector<std::string> validSunExposureValues();
74
75 static std::vector<std::string> validWindExposureValues();
76
77 //@}
78 /** @name Getters */
79 //@{
80
81 std::string surfaceType() const;
82
83 std::string outsideBoundaryCondition() const;
84
85 /** Returns true if the surface has outsideBoundaryCondition of Ground, GroundFCfactorMethod
86 * GroundSlabPreprocessorAverage, GroundSlabPreprocessorCore, GroundSlabPreprocessorPerimeter,
87 * GroundBasementPreprocessorAverageWall, GroundBasementPreprocessorAverageFloor,
88 * GroundBasementPreprocessorUpperWall, GroundBasementPreprocessorLowerWall, or
89 * Foundation */
90 bool isGroundSurface() const;
91
92 std::string sunExposure() const;
93
94 bool isSunExposureDefaulted() const;
95
96 std::string windExposure() const;
97
98 bool isWindExposureDefaulted() const;
99
100 boost::optional<double> viewFactortoGround() const;
101
102 bool isViewFactortoGroundDefaulted() const;
103
104 bool isViewFactortoGroundAutocalculated() const;
105
106 boost::optional<double> numberofVertices() const;
107
108 bool isNumberofVerticesDefaulted() const;
109
110 bool isNumberofVerticesAutocalculated() const;
111
112 //@}
113 /** @name Setters */
114 //@{
115
116 bool setSurfaceType(const std::string& surfaceType);
117
118 bool setOutsideBoundaryCondition(const std::string& outsideBoundaryCondition);
119
120 bool setSunExposure(const std::string& sunExposure);
121
122 void resetSunExposure();
123
124 bool setWindExposure(const std::string& windExposure);
125
126 void resetWindExposure();
127
128 bool setViewFactortoGround(boost::optional<double> viewFactortoGround);
129
130 bool setViewFactortoGround(double viewFactortoGround);
131
132 void resetViewFactortoGround();
133
134 void autocalculateViewFactortoGround();
135
136 bool setNumberofVertices(boost::optional<double> numberofVertices);
137
138 bool setNumberofVertices(double numberofVertices);
139
140 void resetNumberofVertices();
141
142 void autocalculateNumberofVertices();
143
144 //@}
145
146 /// Returns all child \link SubSurface SubSurfaces \endlink.
147 std::vector<SubSurface> subSurfaces() const;
148
149 /// Sets the parent Space.
150 bool setSpace(const Space& space);
151
152 /** Returns the adjacent Surface, if it exists. */
153 boost::optional<Surface> adjacentSurface() const;
154
155 /** Sets the adjacent Surface, will clear adjacent surface on other surface. */
156 bool setAdjacentSurface(Surface& surface);
157
158 /** Resets the adjacent Surface. */
159 void resetAdjacentSurface();
160
161 /** Returns the SurfaceControlMovableInsulation, if it exists. */
162 boost::optional<SurfaceControlMovableInsulation> surfaceControlMovableInsulation() const;
163
164 /** Returns the SurfacePropertyConvectionCoefficients, if it exists. */
165 // cppcheck-suppress [duplInheritedMember] because PlanarSurface is dumb and returns a vector
166 boost::optional<SurfacePropertyConvectionCoefficients> surfacePropertyConvectionCoefficients() const;
167
168 /** Returns the SurfacePropertyLocalEnvironment, if it exists. */
169 boost::optional<SurfacePropertyLocalEnvironment> surfacePropertyLocalEnvironment() const;
170
171 /** Returns the adjacent SurfaceSurfacePropertyOtherSideCoefficients, if it exists. */
172 boost::optional<SurfacePropertyOtherSideCoefficients> surfacePropertyOtherSideCoefficients() const;
173
174 /** Sets the SurfacePropertyOtherSideCoefficients. */
175 bool setSurfacePropertyOtherSideCoefficients(const SurfacePropertyOtherSideCoefficients& otherSideCoefficients);
176
177 /** Resets the SurfacePropertyOtherSideCoefficients. */
178 void resetSurfacePropertyOtherSideCoefficients();
179
180 /** Returns the adjacent SurfacePropertyOtherSideConditionsModel, if it exists. */
181 boost::optional<SurfacePropertyOtherSideConditionsModel> surfacePropertyOtherSideConditionsModel() const;
182
183 /** Sets the SurfacePropertyOtherSideConditionsModel. */
184 bool setSurfacePropertyOtherSideConditionsModel(const SurfacePropertyOtherSideConditionsModel& otherSideModel);
185
186 /** Resets the SurfacePropertyOtherSideConditionsModel. */
187 void resetSurfacePropertyOtherSideConditionsModel();
188
189 /** Intersect with other Surface in other Space.
190 * Returns false if either surface has child windows.
191 * Returns false if either surface has an adjacent surface.
192 * Returns false if surfaces are not on the same plane with opposing outward normals.
193 * If the surfaces are the same, returns true but no new geometry is created.
194 * Returns true if an intersection occurred. Does not set surface adjacency. */
195 bool intersect(Surface& otherSurface);
196 boost::optional<SurfaceIntersection> computeIntersection(Surface& otherSurface);
197
198 /** Creates an adjacent Surface in another Space, also create adjacent SubSurface objects if needed.
199 Returns the new Surface if created. */
200 boost::optional<Surface> createAdjacentSurface(const Space& otherSpace);
201
202 /** Returns true if the Surface is part of the building envelope. */
203 bool isPartOfEnvelope() const;
204
205 /** Assign default surface type based on vertices. */
206 void assignDefaultSurfaceType();
207
208 /** Assign default boundary condition. */
209 void assignDefaultBoundaryCondition();
210
211 /** Assign default sun exposure. */
212 void assignDefaultSunExposure();
213
214 /** Assign default wind exposure. */
215 void assignDefaultWindExposure();
216
217 /** Returns the default film thermal resistance (m^2*K/W) for this surface. Assumes still indoor
218 * air, and 15 mph wind outside. Does not consider any custom SurfacePropertyConvectionCoefficients. */
219 double filmResistance() const;
220
221 /** Get the window to wall ratio for this surface. Calculated as
222 sum(surface.windows.netArea)/surface.grossArea if this surface is a wall, returns
223 0 if this surface is not a wall. */
224 double windowToWallRatio() const;
225
226 /** Get the skylight to roof ratio for this surface. Calculated as
227 sum(surface.skylights.netArea)/surface.grossArea if this surface is a roof, returns
228 0 if this surface is not a roof. */
229 double skylightToRoofRatio() const;
230
231 /** Get the skylight to projected floor ratio for this surface. Calculated as
232 sum(surface.skylights.netArea)/project(surface to z=0 plane).grossArea if this surface is a roof, returns
233 0 if this surface is not a roof. */
234 double skylightToProjectedFloorRatio() const;
235
236 /** Sets the window to wall ratio for this surface using a single banded window.
237 * Uses applyViewAndDaylightingGlassRatios for implementation. */
238 boost::optional<SubSurface> setWindowToWallRatio(double wwr);
239
240 /** Same as setWindowToWallRatio but with extra parameters desiredHeightOffset and heightOffsetFromFloor.
241 * If heightOffsetFromFloor is true then desiredHeightOffset is the desired sill height, otherwise it is the
242 * offset from the ceiling. Uses applyViewAndDaylightingGlassRatios for implementation. */
243 boost::optional<SubSurface> setWindowToWallRatio(double wwr, double desiredHeightOffset, bool heightOffsetFromFloor);
244
245 /** Applies banded view and daylighting windows to the surface with optional exterior shading and interior light shelf.
246 *
247 * Assumes that this surface spans the entire height of the space, this method should not be used if the wall is broken
248 * into multiple vertical pieces.
249 *
250 * Returns false if the surface is not a wall, if the surface is not rectangular in face coordinates,
251 * if requested ratio is too large (window area ~= surface area), or if surface has any doors.
252 *
253 * Otherwise, removes all existing windows and adds new windows to meet requested ratio.
254 *
255 * viewGlassToWallRatio - the ratio of view glass to wall area, if 0 no view glass will be created
256 * daylightingGlassToWallRatio - the ratio of daylighting glass to wall area, if 0 no daylighting glass will be created
257 * desiredViewGlassSillHeight - the desired distance from the floor to the bottom of the view glass, this may be reduced if the requested window area is too high
258 * desiredDaylightingGlassHeaderHeight - the distance from the ceiling to the top of the daylighting glass, this may be reduced if the requested window area is too high
259 * exteriorShadingProjectionFactor - projection factor of exterior shading applied to the view window, if 0 no exterior shading will be created
260 * interiorShelfProjectionFactor - projection factor of interior light shelf applied to the daylighting window, if 0 no interior light shelf will be created
261 * viewGlassConstruction - optional construction to use for the view glass
262 * daylightingGlassConstruction - optional construction to use for the daylighting glass
263 *
264 * If successful returns a vector of sub surfaces created, view window will be the first in the vector if viewGlassToWallRatio > 0
265 */
266 std::vector<SubSurface> applyViewAndDaylightingGlassRatios(double viewGlassToWallRatio, double daylightingGlassToWallRatio,
267 double desiredViewGlassSillHeight, double desiredDaylightingGlassHeaderHeight,
268 double exteriorShadingProjectionFactor, double interiorShelfProjectionFactor,
269 const boost::optional<ConstructionBase>& viewGlassConstruction,
270 const boost::optional<ConstructionBase>& daylightingGlassConstruction);
271
272 /** Returns any shading surface groups associated with this surface. */
273 std::vector<ShadingSurfaceGroup> shadingSurfaceGroups() const;
274
275 /** Splits this surface vertically surrounding any sub surfaces.
276 * This surface must be a wall and must not have an adjacent surface.
277 * Returns any new surfaces created in this routine.
278 * Typically this is called on a surface that has doors but no windows before applying banded windows. */
279 std::vector<Surface> splitSurfaceForSubSurfaces();
280
281 /** Moves all of the surfaces vertices towards the centroid by inset then intersects each face with the inset polygon.
282 * Faces are in space coordinates, it is expected that not all faces will intersect the surface.
283 * Returns all new sub surfaces created, sub surface types are defaulted. Optional construction is applied.
284 * Returns false is this surface has any current sub surfaces or if there is an adjacent surface.*/
285 std::vector<SubSurface> createSubSurfaces(const std::vector<std::vector<Point3d>>& faces, double inset,
286 const boost::optional<ConstructionBase>& construction);
287
288 AirflowNetworkSurface getAirflowNetworkSurface(const AirflowNetworkDetailedOpening& surfaceAirflowLeakage);
289 AirflowNetworkSurface getAirflowNetworkSurface(const AirflowNetworkSimpleOpening& surfaceAirflowLeakage);
290 AirflowNetworkSurface getAirflowNetworkSurface(const AirflowNetworkCrack& surfaceAirflowLeakage);
291 AirflowNetworkSurface getAirflowNetworkSurface(const AirflowNetworkEffectiveLeakageArea& surfaceAirflowLeakage);
292 AirflowNetworkSurface getAirflowNetworkSurface(const AirflowNetworkHorizontalOpening& surfaceAirflowLeakage);
293 AirflowNetworkSurface getAirflowNetworkSurface(const AirflowNetworkSpecifiedFlowRate& surfaceAirflowLeakage);
294
295 boost::optional<AirflowNetworkSurface> airflowNetworkSurface() const;
296
297 bool setAdjacentFoundation(const FoundationKiva& kiva);
298
299 boost::optional<FoundationKiva> adjacentFoundation() const;
300
301 void resetAdjacentFoundation();
302
303 // if surface property exposed foundation perimeter already exists, do nothing and return nil; creates the surface property exposed foundation perimeter if it does not already exist and return it;
304 boost::optional<SurfacePropertyExposedFoundationPerimeter>
305 createSurfacePropertyExposedFoundationPerimeter(const std::string& exposedPerimeterCalculationMethod, double exposedPerimeter);
306
307 // returns the surface property exposed foundation perimeter if set
308 boost::optional<SurfacePropertyExposedFoundationPerimeter> surfacePropertyExposedFoundationPerimeter() const;
309
310 // resets the surface property exposed foundation perimeter
311 void resetSurfacePropertyExposedFoundationPerimeter();
312
313 // calculates the exposed perimeter of the surface
314 double exposedPerimeter(const Polygon3d& buildingPerimeter) const;
315
316 protected:
317 /// @cond
318 using ImplType = detail::Surface_Impl;
319
320 friend class Model;
321 friend class openstudio::detail::IdfObject_Impl;
322 friend class openstudio::IdfObject;
323 friend class openstudio::model::detail::Surface_Impl;
324
325 explicit Surface(std::shared_ptr<detail::Surface_Impl> impl);
326
327 /// @endcond
328 private:
329 REGISTER_LOGGER("openstudio.model.Surface");
330 };
331
332 /** \relates Surface*/
333 using OptionalSurface = boost::optional<Surface>;
334
335 /** \relates Surface*/
336 using SurfaceVector = std::vector<Surface>;
337
338 /** SurfaceIntersection contains detailed information about a surface intersection. */
339 class MODEL_API SurfaceIntersection
340 {
341 public:
342 SurfaceIntersection(const Surface& surface1, const Surface& surface2, const std::vector<Surface>& newSurfaces1,
343 const std::vector<Surface>& newSurfaces2);
344
345 // first surface post intersection
346 Surface surface1() const;
347
348 // second surface post intersection
349 Surface surface2() const;
350
351 // new surfaces generated in the first surface's space
352 std::vector<Surface> newSurfaces1() const;
353
354 // new surfaces generated in the second surface's space
355 std::vector<Surface> newSurfaces2() const;
356
357 private:
358 model::Surface m_surface1;
359 model::Surface m_surface2;
360 std::vector<Surface> m_newSurfaces1;
361 std::vector<Surface> m_newSurfaces2;
362 };
363
364 /** \relates SurfaceIntersection */
365 MODEL_API std::ostream& operator<<(std::ostream& os, const SurfaceIntersection& surfaceIntersection);
366
367 } // namespace model
368 } // namespace openstudio
369
370 #endif // MODEL_SURFACE_HPP
371