GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 95.4% 62 / 0 / 65
Functions: 100.0% 1 / 0 / 1
Branches: 82.7% 148 / 0 / 179

src/energyplus/ReverseTranslator/ReverseTranslateShadowCalculation.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 "../ReverseTranslator.hpp"
7
8 #include "../../model/ShadowCalculation.hpp"
9 #include "../../model/ShadowCalculation_Impl.hpp"
10
11 #include "../../model/ThermalZone.hpp"
12 #include "../../model/Space.hpp"
13 #include "../../model/Space_Impl.hpp"
14
15 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
16 #include "../../utilities/idf/WorkspaceExtensibleGroup.hpp"
17 #include <utilities/idd/ShadowCalculation_FieldEnums.hxx>
18 #include <utilities/idd/ZoneList_FieldEnums.hxx>
19 #include <utilities/idd/IddEnums.hxx>
20
21 #include "../../utilities/core/Assert.hpp"
22 #include "../../utilities/core/Optional.hpp"
23
24 using namespace openstudio::model;
25
26 namespace openstudio {
27 namespace energyplus {
28
29 10 boost::optional<model::ModelObject> ReverseTranslator::translateShadowCalculation(const WorkspaceObject& workspaceObject) {
30
4/6
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 10 times.
✗ Branch 13 not taken.
10 OS_ASSERT(workspaceObject.iddObject().type() == IddObjectType::ShadowCalculation);
31
32
1/1
✓ Branch 1 taken 10 times.
10 auto sc = m_model.getUniqueModelObject<ShadowCalculation>();
33
34 10 OptionalString _s;
35 10 OptionalInt _i;
36
37 // Shading Calculation Method
38
8/12
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 6 times.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
20 if ((_s = workspaceObject.getString(ShadowCalculationFields::ShadingCalculationMethod)) && !_s->empty()) {
39
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 sc.setShadingCalculationMethod(_s.get());
40 }
41
42 // Shading Calculation Update Frequency Method
43
8/12
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 10 times.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 4 times.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 6 times.
✓ Branch 16 taken 4 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
20 if ((_s = workspaceObject.getString(ShadowCalculationFields::ShadingCalculationUpdateFrequencyMethod)) && !_s->empty()) {
44
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 sc.setShadingCalculationUpdateFrequencyMethod(_s.get());
45 }
46
47 // Shading Calculation Update Frequency
48
3/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 4 times.
20 if ((_i = workspaceObject.getInt(ShadowCalculationFields::ShadingCalculationUpdateFrequency))) {
49
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 sc.setShadingCalculationUpdateFrequency(_i.get());
50 }
51
52 // Maximum Figures in Shadow Overlap Calculations
53
3/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
20 if ((_i = workspaceObject.getInt(ShadowCalculationFields::MaximumFiguresinShadowOverlapCalculations))) {
54
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 sc.setMaximumFiguresInShadowOverlapCalculations(_i.get());
55 }
56
57 // Polygon Clipping Algorithm
58
9/12
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 2 times.
✓ Branch 16 taken 8 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
20 if ((_s = workspaceObject.getString(ShadowCalculationFields::PolygonClippingAlgorithm)) && !_s->empty()) {
59
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 sc.setPolygonClippingAlgorithm(_s.get());
60 }
61
62 // Sky Diffuse Modeling Algorithm
63
9/12
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 3 times.
✓ Branch 12 taken 10 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 2 times.
✓ Branch 16 taken 8 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
20 if ((_s = workspaceObject.getString(ShadowCalculationFields::SkyDiffuseModelingAlgorithm)) && !_s->empty()) {
64
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 sc.setSkyDiffuseModelingAlgorithm(_s.get());
65 }
66
67 // Pixel Counting Resolution
68
3/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 8 times.
20 if ((_i = workspaceObject.getInt(ShadowCalculationFields::PixelCountingResolution))) {
69
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 sc.setPixelCountingResolution(_i.get());
70 }
71
72 // Output External Shading Calculation Results
73
3/3
✓ Branch 1 taken 10 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
20 if ((_s = workspaceObject.getString(ShadowCalculationFields::OutputExternalShadingCalculationResults))) {
74
5/5
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 2 times.
15 if (istringEqual("Yes", _s.get())) {
75
1/1
✓ Branch 1 taken 3 times.
3 sc.setOutputExternalShadingCalculationResults(true);
76
4/5
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
6 } else if (istringEqual("No", _s.get())) {
77
1/1
✓ Branch 1 taken 2 times.
2 sc.setOutputExternalShadingCalculationResults(false);
78 }
79 }
80
81 // Disable Self-Shading Within Shading Zone Groups
82
3/3
✓ Branch 1 taken 10 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
20 if ((_s = workspaceObject.getString(ShadowCalculationFields::DisableSelfShadingWithinShadingZoneGroups))) {
83
5/5
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 1 time.
✓ Branch 11 taken 4 times.
15 if (istringEqual("Yes", _s.get())) {
84
1/1
✓ Branch 1 taken 1 time.
1 sc.setDisableSelfShadingWithinShadingZoneGroups(true);
85
4/5
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
12 } else if (istringEqual("No", _s.get())) {
86
1/1
✓ Branch 1 taken 4 times.
4 sc.setDisableSelfShadingWithinShadingZoneGroups(false);
87 }
88 }
89
90 // Disable Self-Shading From Shading Zone Groups to Other Zones
91
3/3
✓ Branch 1 taken 10 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
20 if ((_s = workspaceObject.getString(ShadowCalculationFields::DisableSelfShadingFromShadingZoneGroupstoOtherZones))) {
92
5/5
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 2 times.
15 if (istringEqual("Yes", _s.get())) {
93
1/1
✓ Branch 1 taken 3 times.
3 sc.setDisableSelfShadingFromShadingZoneGroupstoOtherZones(true);
94
4/5
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
6 } else if (istringEqual("No", _s.get())) {
95
1/1
✓ Branch 1 taken 2 times.
2 sc.setDisableSelfShadingFromShadingZoneGroupstoOtherZones(false);
96 }
97 }
98
99 // Shading Zone Group (E+: Shading Zone Group 1 ZoneList Name)
100 // **Extensible** for ZoneLists
101
3/3
✓ Branch 1 taken 10 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 10 times.
12 for (const IdfExtensibleGroup& eg : workspaceObject.extensibleGroups()) {
102
103
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalWorkspaceObject target = eg.cast<WorkspaceExtensibleGroup>().getTarget(ShadowCalculationExtensibleFields::ShadingZoneGroupZoneListName);
104
105
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (target) {
106
107 // We populate a vector of WorkspaceObject (which are 'Zone'),
108 // so we handle the case when it's a Zone and the case when it's a ZoneList in the same way later down
109 2 std::vector<WorkspaceObject> i_zones;
110
6/6
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 14 taken 1 time.
✓ Branch 15 taken 1 time.
2 if (target->iddObject().type() == IddObjectType::Zone) {
111
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 i_zones.push_back(target.get());
112
113
5/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 14 taken 1 time.
✗ Branch 15 not taken.
1 } else if (target->iddObject().type() == IddObjectType::ZoneList) {
114 // ZoneLists are translated back to a space type, which isn't even something we do want to do here, except it'll still be default RT'ed.
115 // Anyways, using the returned spacetype is useless since if a zone is referenced by multiple ZoneLists, then the sapcetype assigned for that
116 // zone is the last ZoneList found...
117
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 1 time.
3 for (const IdfExtensibleGroup& zeg : target->extensibleGroups()) {
118
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalWorkspaceObject target_zone = zeg.cast<WorkspaceExtensibleGroup>().getTarget(ZoneListExtensibleFields::ZoneName);
119
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (target_zone) {
120
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 i_zones.push_back(target_zone.get());
121 }
122 3 }
123
124 } else {
125 ✗ LOG(Error, "For ShadowCalculation, an extensible group entry is neither a Zone or ZoneList, skipping.");
126 ✗ continue;
127 ✗ }
128
129 // Now we translate all of these WorkspaceObjects, and get corresponding (Model) ThermalZones in a vector
130 2 std::vector<ThermalZone> thermalZones;
131
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 2 times.
5 for (const WorkspaceObject& i_zone : i_zones) {
132 // Zone is translated, and a Space is returned instead
133
1/1
✓ Branch 1 taken 3 times.
3 OptionalModelObject _mo = translateAndMapWorkspaceObject(i_zone);
134
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (_mo) {
135
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 if (boost::optional<Space> _space = _mo->optionalCast<Space>()) {
136
3/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
6 if (auto _zone = _space->thermalZone()) {
137
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 thermalZones.push_back(_zone.get());
138 3 }
139 3 }
140 }
141 3 }
142
143 // And now we add that as a Shading Zone Group
144
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 if (!thermalZones.empty()) {
145
1/1
✓ Branch 1 taken 2 times.
2 sc.addShadingZoneGroup(thermalZones);
146 }
147 2 }
148 12 }
149
150
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
20 return sc.cast<ModelObject>();
151 10 }
152
153 } // namespace energyplus
154 } // namespace openstudio
155