GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 60.6% 57 / 0 / 94
Functions: 100.0% 1 / 0 / 1
Branches: 40.7% 68 / 0 / 167

src/energyplus/ReverseTranslator/ReverseTranslateFoundationKiva.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/FoundationKiva.hpp"
9 #include "../../model/FoundationKiva_Impl.hpp"
10 #include "../../model/Material.hpp"
11 #include "../../model/Material_Impl.hpp"
12 #include "../../model/ConstructionBase.hpp"
13 #include "../../model/ConstructionBase_Impl.hpp"
14
15 #include "../../utilities/idf/WorkspaceExtensibleGroup.hpp"
16
17 #include <utilities/idd/Foundation_Kiva_FieldEnums.hxx>
18 #include "../../utilities/idd/IddEnums.hpp"
19 #include <utilities/idd/IddEnums.hxx>
20
21 #include "../../utilities/core/Assert.hpp"
22
23 using namespace openstudio::model;
24
25 namespace openstudio {
26
27 namespace energyplus {
28
29 2 OptionalModelObject ReverseTranslator::translateFoundationKiva(const WorkspaceObject& workspaceObject) {
30
4/5
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
2 if (workspaceObject.iddObject().type() != IddObjectType::Foundation_Kiva) {
31 ✗ LOG(Error, "WorkspaceObject is not IddObjectType: FoundationKiva");
32 ✗ return boost::none;
33 }
34
35
1/1
✓ Branch 1 taken 2 times.
2 openstudio::model::FoundationKiva foundationKiva(m_model);
36
37 2 OptionalString s;
38 2 OptionalDouble d;
39 2 OptionalWorkspaceObject target;
40
41
1/1
✓ Branch 1 taken 2 times.
2 s = workspaceObject.name();
42
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (s) {
43
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 foundationKiva.setName(*s);
44 }
45
46
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Foundation_KivaFields::InitialIndoorAirTemperature);
47
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
48 ✗ foundationKiva.setInitialIndoorAirTemperature(*d);
49 }
50
51
1/1
✓ Branch 1 taken 2 times.
2 target = workspaceObject.getTarget(openstudio::Foundation_KivaFields::InteriorHorizontalInsulationMaterialName);
52
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (target) {
53 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
54 ✗ if (modelObject) {
55 ✗ if (modelObject->optionalCast<Material>()) {
56 ✗ foundationKiva.setInteriorHorizontalInsulationMaterial(modelObject->cast<Material>());
57 }
58 }
59 ✗ }
60
61
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Foundation_KivaFields::InteriorHorizontalInsulationDepth);
62
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (d) {
63
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 foundationKiva.setInteriorHorizontalInsulationDepth(*d);
64 }
65
66
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Foundation_KivaFields::InteriorHorizontalInsulationWidth);
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
68 ✗ foundationKiva.setInteriorHorizontalInsulationWidth(*d);
69 }
70
71
1/1
✓ Branch 1 taken 2 times.
2 target = workspaceObject.getTarget(openstudio::Foundation_KivaFields::InteriorVerticalInsulationMaterialName);
72
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (target) {
73 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
74 ✗ if (modelObject) {
75 ✗ if (modelObject->optionalCast<Material>()) {
76 ✗ foundationKiva.setInteriorVerticalInsulationMaterial(modelObject->cast<Material>());
77 }
78 }
79 ✗ }
80
81
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Foundation_KivaFields::InteriorVerticalInsulationDepth);
82
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
83 ✗ foundationKiva.setInteriorVerticalInsulationDepth(*d);
84 }
85
86
1/1
✓ Branch 1 taken 2 times.
2 target = workspaceObject.getTarget(openstudio::Foundation_KivaFields::ExteriorHorizontalInsulationMaterialName);
87
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (target) {
88 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
89 ✗ if (modelObject) {
90 ✗ if (modelObject->optionalCast<Material>()) {
91 ✗ foundationKiva.setExteriorHorizontalInsulationMaterial(modelObject->cast<Material>());
92 }
93 }
94 ✗ }
95
96
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Foundation_KivaFields::ExteriorHorizontalInsulationDepth);
97
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
98 ✗ foundationKiva.setExteriorHorizontalInsulationDepth(*d);
99 }
100
101
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Foundation_KivaFields::ExteriorHorizontalInsulationWidth);
102
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (d) {
103
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 foundationKiva.setExteriorHorizontalInsulationWidth(*d);
104 }
105
106
1/1
✓ Branch 1 taken 2 times.
2 target = workspaceObject.getTarget(openstudio::Foundation_KivaFields::ExteriorVerticalInsulationMaterialName);
107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (target) {
108 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
109 ✗ if (modelObject) {
110 ✗ if (modelObject->optionalCast<Material>()) {
111 ✗ foundationKiva.setExteriorVerticalInsulationMaterial(modelObject->cast<Material>());
112 }
113 }
114 ✗ }
115
116
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Foundation_KivaFields::ExteriorVerticalInsulationDepth);
117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (d) {
118 ✗ foundationKiva.setExteriorVerticalInsulationDepth(*d);
119 }
120
121
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Foundation_KivaFields::WallHeightAboveGrade);
122
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (d) {
123
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 foundationKiva.setWallHeightAboveGrade(*d);
124 }
125
126
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Foundation_KivaFields::WallDepthBelowSlab);
127
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (d) {
128
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 foundationKiva.setWallDepthBelowSlab(*d);
129 }
130
131
1/1
✓ Branch 1 taken 2 times.
2 target = workspaceObject.getTarget(openstudio::Foundation_KivaFields::FootingWallConstructionName);
132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (target) {
133 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
134 ✗ if (modelObject) {
135 ✗ if (modelObject->optionalCast<ConstructionBase>()) {
136 ✗ foundationKiva.setFootingWallConstruction(modelObject->cast<ConstructionBase>());
137 }
138 }
139 ✗ }
140
141
1/1
✓ Branch 1 taken 2 times.
2 target = workspaceObject.getTarget(openstudio::Foundation_KivaFields::FootingMaterialName);
142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (target) {
143 ✗ OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
144 ✗ if (modelObject) {
145 ✗ if (modelObject->optionalCast<Material>()) {
146 ✗ foundationKiva.setFootingMaterial(modelObject->cast<Material>());
147 }
148 }
149 ✗ }
150
151
1/1
✓ Branch 1 taken 2 times.
2 d = workspaceObject.getDouble(Foundation_KivaFields::FootingDepth);
152
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (d) {
153
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 foundationKiva.setFootingDepth(*d);
154 }
155
156 // get extensible groups for custom blocks
157
3/3
✓ Branch 1 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 2 times.
4 for (const IdfExtensibleGroup& idfGroup : workspaceObject.extensibleGroups()) {
158
1/1
✓ Branch 1 taken 2 times.
2 auto workspaceGroup = idfGroup.cast<WorkspaceExtensibleGroup>();
159
1/1
✓ Branch 1 taken 2 times.
2 OptionalWorkspaceObject target = workspaceGroup.getTarget(Foundation_KivaExtensibleFields::CustomBlockMaterialName);
160
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target);
161
1/1
✓ Branch 1 taken 2 times.
2 OptionalDouble depth = workspaceGroup.getDouble(Foundation_KivaExtensibleFields::CustomBlockDepth);
162
1/1
✓ Branch 1 taken 2 times.
2 OptionalDouble xPosition = workspaceGroup.getDouble(Foundation_KivaExtensibleFields::CustomBlockXPosition);
163
1/1
✓ Branch 1 taken 2 times.
2 OptionalDouble zPosition = workspaceGroup.getDouble(Foundation_KivaExtensibleFields::CustomBlockZPosition);
164
165 // add the custom block
166
6/6
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
2 foundationKiva.addCustomBlock(modelObject->cast<Material>(), *depth, *xPosition, *zPosition);
167 4 }
168
169
1/1
✓ Branch 1 taken 2 times.
2 return foundationKiva;
170 2 }
171
172 } // namespace energyplus
173
174 } // namespace openstudio
175