GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 77.3% 58 / 0 / 75
Functions: 100.0% 1 / 0 / 1
Branches: 57.3% 133 / 0 / 232

src/energyplus/ForwardTranslator/ForwardTranslateSubSurface.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 "../ForwardTranslator.hpp"
7
8 #include "../../model/Model.hpp"
9 #include "../../model/SubSurface.hpp"
10 #include "../../model/SubSurface_Impl.hpp"
11 #include "../../model/Surface.hpp"
12 #include "../../model/Surface_Impl.hpp"
13 #include "../../model/ConstructionBase.hpp"
14 #include "../../model/ConstructionBase_Impl.hpp"
15 #include "../../model/WindowPropertyFrameAndDivider.hpp"
16 #include "../../model/WindowPropertyFrameAndDivider_Impl.hpp"
17 #include "../../model/SurfacePropertyOtherSideCoefficients.hpp"
18 #include "../../model/SurfacePropertyOtherSideConditionsModel.hpp"
19 #include "../../model/SurfacePropertyConvectionCoefficients.hpp"
20 #include "../../model/SurfacePropertyLocalEnvironment.hpp"
21 #include "../../model/SurfacePropertyIncidentSolarMultiplier.hpp"
22
23 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
24
25 #include <utilities/idd/FenestrationSurface_Detailed_FieldEnums.hxx>
26
27 #include "../../utilities/idd/IddEnums.hpp"
28 #include <utilities/idd/IddEnums.hxx>
29 #include <utilities/idd/IddFactory.hxx>
30
31 #include "../../utilities/geometry/Vector3d.hpp"
32
33 using namespace openstudio::model;
34
35 using namespace std;
36
37 namespace openstudio {
38
39 namespace energyplus {
40
41 403 boost::optional<IdfObject> ForwardTranslator::translateSubSurface(model::SubSurface& modelObject) {
42
2/2
✓ Branch 1 taken 403 times.
✓ Branch 4 taken 403 times.
403 IdfObject idfObject(openstudio::IddObjectType::FenestrationSurface_Detailed);
43
44
3/3
✓ Branch 1 taken 403 times.
✓ Branch 4 taken 403 times.
✓ Branch 7 taken 403 times.
403 idfObject.setString(FenestrationSurface_DetailedFields::Name, modelObject.name().get());
45
46
1/1
✓ Branch 1 taken 403 times.
403 idfObject.clearExtensibleGroups();
47
48
1/1
✓ Branch 1 taken 403 times.
403 openstudio::Vector3d offset(0, 0, 0);
49
1/1
✓ Branch 1 taken 403 times.
403 boost::optional<WindowPropertyFrameAndDivider> frameAndDivider = modelObject.windowPropertyFrameAndDivider();
50
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 401 times.
403 if (frameAndDivider) {
51
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 1 time.
2 if (!frameAndDivider->isOutsideRevealDepthDefaulted()) {
52
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
1 offset = -frameAndDivider->outsideRevealDepth() * modelObject.outwardNormal();
53 }
54
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 idfObject.setString(FenestrationSurface_DetailedFields::FrameandDividerName, frameAndDivider->name().get());
55 }
56
57
3/3
✓ Branch 1 taken 403 times.
✓ Branch 8 taken 1619 times.
✓ Branch 9 taken 394 times.
2013 for (const Point3d& point : modelObject.vertices()) {
58
1/1
✓ Branch 1 taken 1619 times.
1619 IdfExtensibleGroup group = idfObject.pushExtensibleGroup();
59
3/3
✓ Branch 1 taken 1619 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 1610 times.
1619 if (group.empty()) {
60
8/8
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
✓ Branch 13 taken 9 times.
✓ Branch 17 taken 9 times.
✓ Branch 20 taken 9 times.
✓ Branch 23 taken 9 times.
9 LOG(Error,
61 "Currently unable to translate " << modelObject.briefDescription() << ", because it has more vertices than allowed by EnergyPlus.");
62 9 return boost::none;
63 }
64
65
1/1
✓ Branch 1 taken 1610 times.
1610 const Point3d newPoint = point + offset;
66
67
2/2
✓ Branch 1 taken 1610 times.
✓ Branch 4 taken 1610 times.
1610 group.setDouble(0, newPoint.x());
68
2/2
✓ Branch 1 taken 1610 times.
✓ Branch 4 taken 1610 times.
1610 group.setDouble(1, newPoint.y());
69
2/2
✓ Branch 1 taken 1610 times.
✓ Branch 4 taken 1610 times.
1610 group.setDouble(2, newPoint.z());
70 2022 }
71
72 // Register and emplace into m_map, so that any child object such as translateSurfacePropertyIncidentSolarMultiplier
73 // can retrieve the subsurface namestring and we don't risk duplicating the subsurface when that child also calls
74 // translateAndMapModelObject(subSurface)
75
1/1
✓ Branch 1 taken 394 times.
394 m_idfObjects.push_back(idfObject);
76
3/3
✓ Branch 1 taken 394 times.
✓ Branch 4 taken 394 times.
✓ Branch 7 taken 394 times.
394 m_map.insert(std::make_pair(modelObject.handle(), idfObject));
77
78
1/1
✓ Branch 1 taken 394 times.
394 std::string subSurfaceType = modelObject.subSurfaceType();
79
16/26
✓ Branch 1 taken 394 times.
✓ Branch 4 taken 394 times.
✓ Branch 6 taken 224 times.
✓ Branch 7 taken 170 times.
✓ Branch 9 taken 224 times.
✓ Branch 12 taken 224 times.
✓ Branch 14 taken 70 times.
✓ Branch 15 taken 154 times.
✓ Branch 16 taken 224 times.
✓ Branch 17 taken 170 times.
✓ Branch 19 taken 224 times.
✓ Branch 20 taken 170 times.
✓ Branch 21 taken 394 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 394 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 240 times.
✓ Branch 27 taken 154 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
1630 if (istringEqual("FixedWindow", subSurfaceType) || istringEqual("OperableWindow", subSurfaceType)) {
80
1/1
✓ Branch 1 taken 240 times.
240 subSurfaceType = "Window";
81
3/4
✓ Branch 1 taken 154 times.
✓ Branch 4 taken 154 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 154 times.
308 } else if (istringEqual("OverheadDoor", subSurfaceType)) {
82 ✗ subSurfaceType = "Door";
83
4/4
✓ Branch 1 taken 154 times.
✓ Branch 4 taken 154 times.
✓ Branch 7 taken 18 times.
✓ Branch 8 taken 136 times.
308 } else if (istringEqual("Skylight", subSurfaceType)) {
84
1/1
✓ Branch 1 taken 18 times.
18 subSurfaceType = "Window";
85 }
86
87
1/1
✓ Branch 1 taken 394 times.
394 boost::optional<ConstructionBase> construction = modelObject.construction();
88
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 64 times.
394 if (construction) {
89
4/4
✓ Branch 1 taken 330 times.
✓ Branch 4 taken 330 times.
✓ Branch 7 taken 330 times.
✓ Branch 10 taken 330 times.
330 idfObject.setString(FenestrationSurface_DetailedFields::ConstructionName, construction->name().get());
90
91
7/9
✓ Branch 1 taken 330 times.
✓ Branch 3 taken 111 times.
✓ Branch 4 taken 219 times.
✓ Branch 6 taken 111 times.
✓ Branch 9 taken 111 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 111 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 330 times.
330 if (subSurfaceType == "Door" && construction->isFenestration()) {
92 ✗ LOG(Warn, "SubSurface '" << modelObject.name().get() << "' uses fenestration construction, changing SubSurfaceType to GlassDoor");
93 ✗ subSurfaceType = "GlassDoor";
94
7/9
✓ Branch 1 taken 330 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 329 times.
✓ Branch 6 taken 1 time.
✓ Branch 9 taken 1 time.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 time.
✗ Branch 13 not taken.
✓ Branch 14 taken 330 times.
330 } else if (subSurfaceType == "GlassDoor" && !construction->isFenestration()) {
95 ✗ LOG(Warn, "SubSurface '" << modelObject.name().get() << "' uses non-fenestration construction, changing SubSurfaceType to Door");
96 ✗ subSurfaceType = "Door";
97 }
98 }
99
100
1/1
✓ Branch 1 taken 394 times.
394 idfObject.setString(FenestrationSurface_DetailedFields::SurfaceType, subSurfaceType);
101
102
1/1
✓ Branch 1 taken 394 times.
394 boost::optional<Surface> surface = modelObject.surface();
103
1/2
✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
394 if (surface) {
104
4/4
✓ Branch 1 taken 394 times.
✓ Branch 4 taken 394 times.
✓ Branch 7 taken 394 times.
✓ Branch 10 taken 394 times.
394 idfObject.setString(FenestrationSurface_DetailedFields::BuildingSurfaceName, surface->name().get());
105 }
106
107
1/1
✓ Branch 1 taken 394 times.
394 boost::optional<SubSurface> adjacentSubSurface = modelObject.adjacentSubSurface();
108
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 306 times.
394 if (adjacentSubSurface) {
109
4/4
✓ Branch 1 taken 88 times.
✓ Branch 4 taken 88 times.
✓ Branch 7 taken 88 times.
✓ Branch 10 taken 88 times.
88 idfObject.setString(FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject, adjacentSubSurface->name().get());
110 }
111
112
1/1
✓ Branch 1 taken 394 times.
394 boost::optional<SurfacePropertyOtherSideCoefficients> surfacePropertyOtherSideCoefficients = modelObject.surfacePropertyOtherSideCoefficients();
113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if (surfacePropertyOtherSideCoefficients) {
114 ✗ boost::optional<IdfObject> osc = translateAndMapModelObject(*surfacePropertyOtherSideCoefficients);
115 ✗ if (osc && osc->name()) {
116 ✗ idfObject.setString(FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject, osc->name().get());
117 } else {
118 ✗ LOG(Error, "SubSurface '" << modelObject.name().get() << "', could not translate OutsideBoundaryConditionObject");
119 }
120 ✗ }
121
122 boost::optional<SurfacePropertyOtherSideConditionsModel> surfacePropertyOtherSideConditionsModel =
123
1/1
✓ Branch 1 taken 394 times.
394 modelObject.surfacePropertyOtherSideConditionsModel();
124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if (surfacePropertyOtherSideConditionsModel) {
125 ✗ boost::optional<IdfObject> oscm = translateAndMapModelObject(*surfacePropertyOtherSideConditionsModel);
126 ✗ if (oscm && oscm->name()) {
127 ✗ idfObject.setString(FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject, oscm->name().get());
128 } else {
129 ✗ LOG(Error, "SubSurface '" << modelObject.name().get() << "', could not translate OutsideBoundaryConditionObject");
130 }
131 ✗ }
132
133 // Call the translation of the SurfacePropertyConvectionCoefficients, which has two advantages:
134 // * will not translate them if they are orphaned (=not referencing a surface or subsurface), and,
135 // * makes the order of these objects in the IDF deterministic
136
2/3
✓ Branch 1 taken 394 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 394 times.
788 if (boost::optional<SurfacePropertyConvectionCoefficients> _sCoefs = modelObject.surfacePropertyConvectionCoefficients()) {
137 ✗ translateAndMapModelObject(_sCoefs.get());
138 394 }
139
140
3/3
✓ Branch 1 taken 394 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 393 times.
788 if (boost::optional<SurfacePropertyLocalEnvironment> localEnv_ = modelObject.surfacePropertyLocalEnvironment()) {
141
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 translateAndMapModelObject(localEnv_.get());
142 394 }
143
144
1/1
✓ Branch 1 taken 394 times.
394 boost::optional<double> viewFactortoGround = modelObject.viewFactortoGround();
145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 394 times.
394 if (viewFactortoGround) {
146 ✗ idfObject.setDouble(FenestrationSurface_DetailedFields::ViewFactortoGround, *viewFactortoGround);
147 }
148
149
3/3
✓ Branch 1 taken 394 times.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 350 times.
394 if (!modelObject.isMultiplierDefaulted()) {
150
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
44 idfObject.setDouble(FenestrationSurface_DetailedFields::Multiplier, modelObject.multiplier());
151 }
152
153
3/3
✓ Branch 1 taken 394 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 393 times.
788 if (boost::optional<SurfacePropertyIncidentSolarMultiplier> spMult_ = modelObject.surfacePropertyIncidentSolarMultiplier()) {
154
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 translateAndMapModelObject(spMult_.get());
155 394 }
156
157
1/1
✓ Branch 1 taken 394 times.
394 return idfObject;
158 403 }
159
160 } // namespace energyplus
161
162 } // namespace openstudio
163