GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 91 / 0 / 91
Functions: 100.0% 2 / 0 / 2
Branches: 93.8% 150 / 0 / 160

src/energyplus/ForwardTranslator/ForwardTranslateDefaultConstructionSet.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 #include "../../model/Model.hpp"
8
9 #include "../../model/DefaultConstructionSet.hpp"
10
11 #include "../../model/DefaultSurfaceConstructions.hpp"
12 #include "../../model/DefaultSubSurfaceConstructions.hpp"
13 #include "../../model/ConstructionBase.hpp"
14 #include "../../model/BuildingStory.hpp"
15 #include "../../model/Space.hpp"
16 #include "../../model/Space_Impl.hpp"
17 #include "../../model/SpaceType.hpp"
18 #include "../../model/PlanarSurface.hpp"
19 #include "../../model/Surface.hpp"
20 #include "../../model/SubSurface.hpp"
21 #include "../../model/InteriorPartitionSurfaceGroup.hpp"
22 #include "../../model/InteriorPartitionSurface.hpp"
23
24 #include <utilities/idd/ConstructionAssignmentSet_FieldEnums.hxx>
25 #include <utilities/idd/IddEnums.hxx>
26
27 using namespace openstudio::model;
28
29 namespace openstudio {
30
31 namespace energyplus {
32
33 // When Space translation is excluded there is no E+ Space, so defaulted constructions would end up unresolved. This function hard-assigns
34 // constructions to all surfaces, subsurfaces and interior partitions in the model that have defaulted constructions, using the
35 // DefaultConstructionSet at the Space, SpaceType and BuildingStory level.
36 63 void ForwardTranslator::hardApplyConstructionsWhenSpaceTranslationOff(model::Model& model) {
37
3/3
✓ Branch 1 taken 63 times.
✓ Branch 8 taken 124 times.
✓ Branch 9 taken 63 times.
187 for (auto& space : model.getConcreteModelObjects<model::Space>()) {
38
39 // Step 1: Collect PlanarSurfaces with defaulted constructions (Surface, SubSurface, InteriorPartitionSurface)
40 124 std::vector<PlanarSurface> planarSurfaces;
41
1/1
✓ Branch 1 taken 124 times.
124 auto surfaces = space.surfaces();
42
1/1
✓ Branch 2 taken 124 times.
124 planarSurfaces.reserve(2 * surfaces.size()); // Initial guess
43
2/2
✓ Branch 5 taken 460 times.
✓ Branch 6 taken 124 times.
584 for (Surface& surface : surfaces) {
44
2/3
✓ Branch 1 taken 460 times.
✓ Branch 3 taken 460 times.
✗ Branch 4 not taken.
460 if (surface.isConstructionDefaulted()) {
45
1/1
✓ Branch 1 taken 460 times.
460 planarSurfaces.push_back(surface);
46 }
47
3/3
✓ Branch 1 taken 460 times.
✓ Branch 8 taken 10 times.
✓ Branch 9 taken 460 times.
470 for (SubSurface& subSurface : surface.subSurfaces()) {
48
2/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 10 times.
✗ Branch 4 not taken.
10 if (subSurface.isConstructionDefaulted()) {
49
1/1
✓ Branch 1 taken 10 times.
10 planarSurfaces.push_back(subSurface);
50 }
51 460 }
52 }
53
54
3/3
✓ Branch 1 taken 124 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 124 times.
128 for (const InteriorPartitionSurfaceGroup& interiorPartitionSurfaceGroup : space.interiorPartitionSurfaceGroups()) {
55
3/3
✓ Branch 1 taken 4 times.
✓ Branch 8 taken 4 times.
✓ Branch 9 taken 4 times.
8 for (InteriorPartitionSurface& interiorPartitionSurface : interiorPartitionSurfaceGroup.interiorPartitionSurfaces()) {
56
2/3
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
4 if (interiorPartitionSurface.isConstructionDefaulted()) {
57
1/1
✓ Branch 1 taken 4 times.
4 planarSurfaces.push_back(interiorPartitionSurface);
58 }
59 4 }
60 124 }
61
62
2/2
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 102 times.
124 if (planarSurfaces.empty()) {
63
8/8
✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 7 taken 22 times.
✓ Branch 10 taken 22 times.
✓ Branch 13 taken 22 times.
✓ Branch 17 taken 22 times.
✓ Branch 20 taken 22 times.
✓ Branch 23 taken 22 times.
22 LOG(Trace, "Space '" << space.nameString() << "' has no surfaces, subsurfaces or interior partitions with defaulted constructions, skipping");
64 22 continue;
65 22 }
66
67 // Gather candidates DCS from Space, SpaceType and BuildingStory, instead of doing it for each planar surface to limit waste.
68 // I also don't call Space::getDefaultConstructionWithSearchDistance to avoid looking at the Building/Building SpaceType Level, which would be
69 // another waste
70 102 std::vector<DefaultConstructionSet> candidateDCSs;
71
3/3
✓ Branch 1 taken 102 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 98 times.
204 if (auto dcs_ = space.defaultConstructionSet()) {
72
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 candidateDCSs.push_back(*dcs_);
73 102 }
74
8/8
✓ Branch 1 taken 102 times.
✓ Branch 3 taken 89 times.
✓ Branch 4 taken 13 times.
✓ Branch 6 taken 89 times.
✓ Branch 8 taken 51 times.
✓ Branch 9 taken 38 times.
✓ Branch 10 taken 51 times.
✓ Branch 11 taken 51 times.
204 if (auto spaceType_ = space.spaceType(); spaceType_ && !space.isSpaceTypeDefaulted()) {
75
4/4
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 50 times.
102 if (auto dcs_ = spaceType_->defaultConstructionSet()) {
76
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 candidateDCSs.push_back(*dcs_);
77 51 }
78 102 }
79
3/3
✓ Branch 1 taken 102 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 84 times.
204 if (auto buildingStory_ = space.buildingStory()) {
80
4/4
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 16 times.
36 if (auto dcs_ = buildingStory_->defaultConstructionSet()) {
81
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 candidateDCSs.push_back(*dcs_);
82 18 }
83 102 }
84
85
2/2
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 5 times.
102 if (candidateDCSs.empty()) {
86
8/8
✓ Branch 1 taken 97 times.
✓ Branch 4 taken 97 times.
✓ Branch 7 taken 97 times.
✓ Branch 10 taken 97 times.
✓ Branch 13 taken 97 times.
✓ Branch 17 taken 97 times.
✓ Branch 20 taken 97 times.
✓ Branch 23 taken 97 times.
97 LOG(Trace, "Space '" << space.nameString() << "' has no DefaultConstructionSet at the Space, SpaceType or BuildingStory level, skipping");
87 97 continue;
88 97 }
89
2/2
✓ Branch 5 taken 20 times.
✓ Branch 6 taken 5 times.
25 for (PlanarSurface& planarSurface : planarSurfaces) {
90
2/2
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 13 times.
40 for (const auto& dcs_ : candidateDCSs) {
91
3/3
✓ Branch 1 taken 27 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 20 times.
54 if (auto construction_ = dcs_.getDefaultConstruction(planarSurface)) {
92
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 planarSurface.setConstruction(*construction_);
93 7 break; // Stop at the first DCS that provides a construction for this planar surface
94 27 }
95 }
96 }
97 403 }
98 63 }
99
100 89 boost::optional<IdfObject> ForwardTranslator::translateDefaultConstructionSet(model::DefaultConstructionSet& modelObject) {
101
102 // Instantiate an IdfObject of the class to store the values
103
2/2
✓ Branch 1 taken 89 times.
✓ Branch 4 taken 89 times.
89 IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::ConstructionAssignmentSet, modelObject);
104 // Name
105
2/2
✓ Branch 1 taken 89 times.
✓ Branch 4 taken 89 times.
89 idfObject.setName(modelObject.nameString());
106
107 // Exterior Surface Construction Assignments Name: Optional Object
108
3/3
✓ Branch 1 taken 89 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 7 times.
178 if (boost::optional<DefaultSurfaceConstructions> exteriorSurfaceConstructionAssignments_ = modelObject.defaultExteriorSurfaceConstructions()) {
109
3/4
✓ Branch 1 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 6 taken 82 times.
✗ Branch 7 not taken.
164 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(*exteriorSurfaceConstructionAssignments_)) {
110
3/3
✓ Branch 1 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 7 taken 82 times.
82 idfObject.setString(ConstructionAssignmentSetFields::ExteriorSurfaceConstructionAssignmentsName, wo_->nameString());
111 82 }
112 89 }
113
114 // Interior Surface Construction Assignments Name: Optional Object
115
3/3
✓ Branch 1 taken 89 times.
✓ Branch 3 taken 63 times.
✓ Branch 4 taken 26 times.
178 if (boost::optional<DefaultSurfaceConstructions> interiorSurfaceConstructionAssignments_ = modelObject.defaultInteriorSurfaceConstructions()) {
116
3/4
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 6 taken 63 times.
✗ Branch 7 not taken.
126 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(*interiorSurfaceConstructionAssignments_)) {
117
3/3
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
63 idfObject.setString(ConstructionAssignmentSetFields::InteriorSurfaceConstructionAssignmentsName, wo_->nameString());
118 63 }
119 89 }
120
121 // Ground Contact Surface Construction Assignments Name: Optional Object
122 89 if (boost::optional<DefaultSurfaceConstructions> groundContactSurfaceConstructionAssignments_ =
123
3/3
✓ Branch 1 taken 89 times.
✓ Branch 3 taken 63 times.
✓ Branch 4 taken 26 times.
178 modelObject.defaultGroundContactSurfaceConstructions()) {
124
3/4
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 6 taken 63 times.
✗ Branch 7 not taken.
126 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(*groundContactSurfaceConstructionAssignments_)) {
125
3/3
✓ Branch 1 taken 63 times.
✓ Branch 4 taken 63 times.
✓ Branch 7 taken 63 times.
63 idfObject.setString(ConstructionAssignmentSetFields::GroundContactSurfaceConstructionAssignmentsName, wo_->nameString());
126 63 }
127 89 }
128
129 // Exterior SubSurface Construction Assignments Name: Optional Object
130 89 if (boost::optional<DefaultSubSurfaceConstructions> exteriorSubSurfaceConstructionAssignments_ =
131
3/3
✓ Branch 1 taken 89 times.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 24 times.
178 modelObject.defaultExteriorSubSurfaceConstructions()) {
132
3/4
✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
✓ Branch 6 taken 65 times.
✗ Branch 7 not taken.
130 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(*exteriorSubSurfaceConstructionAssignments_)) {
133
3/3
✓ Branch 1 taken 65 times.
✓ Branch 4 taken 65 times.
✓ Branch 7 taken 65 times.
65 idfObject.setString(ConstructionAssignmentSetFields::ExteriorSubSurfaceConstructionAssignmentsName, wo_->nameString());
134 65 }
135 89 }
136
137 // Interior SubSurface Construction Assignments Name: Optional Object
138 89 if (boost::optional<DefaultSubSurfaceConstructions> interiorSubSurfaceConstructionAssignments_ =
139
3/3
✓ Branch 1 taken 89 times.
✓ Branch 3 taken 60 times.
✓ Branch 4 taken 29 times.
178 modelObject.defaultInteriorSubSurfaceConstructions()) {
140
3/4
✓ Branch 1 taken 60 times.
✓ Branch 4 taken 60 times.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
120 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(*interiorSubSurfaceConstructionAssignments_)) {
141
3/3
✓ Branch 1 taken 60 times.
✓ Branch 4 taken 60 times.
✓ Branch 7 taken 60 times.
60 idfObject.setString(ConstructionAssignmentSetFields::InteriorSubSurfaceConstructionAssignmentsName, wo_->nameString());
142 60 }
143 89 }
144
145 // Interior Partition Construction Name: Optional Object
146
3/3
✓ Branch 1 taken 89 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 54 times.
178 if (boost::optional<ConstructionBase> interiorPartitionConstruction_ = modelObject.interiorPartitionConstruction()) {
147
3/4
✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
✓ Branch 6 taken 35 times.
✗ Branch 7 not taken.
70 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(*interiorPartitionConstruction_)) {
148
3/3
✓ Branch 1 taken 35 times.
✓ Branch 4 taken 35 times.
✓ Branch 7 taken 35 times.
35 idfObject.setString(ConstructionAssignmentSetFields::InteriorPartitionConstructionName, wo_->nameString());
149 35 }
150 89 }
151
152 // Adiabatic Surface Construction Name: Optional Object
153
3/3
✓ Branch 1 taken 89 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 88 times.
178 if (boost::optional<ConstructionBase> adiabaticSurfaceConstruction_ = modelObject.adiabaticSurfaceConstruction()) {
154
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 1 time.
✗ Branch 7 not taken.
2 if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(*adiabaticSurfaceConstruction_)) {
155
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
1 idfObject.setString(ConstructionAssignmentSetFields::AdiabaticSurfaceConstructionName, wo_->nameString());
156 1 }
157 89 }
158
159 // NOTE: spaceShadingConstruction, buildingShadingConstruction, and siteShadingConstruction are not in the E+ object
160
161
1/1
✓ Branch 1 taken 89 times.
178 return idfObject;
162 89 } // End of translate function
163
164 } // end namespace energyplus
165 } // end namespace openstudio
166