GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 39.2% 38 / 0 / 97
Functions: 36.1% 13 / 0 / 36
Branches: 22.4% 24 / 0 / 107

src/model/AirGap.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 "AirGap.hpp"
7 #include "AirGap_Impl.hpp"
8
9 #include <utilities/idd/OS_Material_AirGap_FieldEnums.hxx>
10 #include <utilities/idd/IddEnums.hxx>
11
12 #include "../utilities/units/Unit.hpp"
13
14 #include "../utilities/core/Assert.hpp"
15
16 namespace openstudio {
17 namespace model {
18
19 namespace detail {
20
21 458 AirGap_Impl::AirGap_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) : OpaqueMaterial_Impl(idfObject, model, keepHandle) {
22
4/6
✓ Branch 1 taken 458 times.
✓ Branch 4 taken 458 times.
✓ Branch 7 taken 458 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 458 times.
✗ Branch 13 not taken.
458 OS_ASSERT(idfObject.iddObject().type() == AirGap::iddObjectType());
23 458 }
24
25 72 AirGap_Impl::AirGap_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
26 72 : OpaqueMaterial_Impl(other, model, keepHandle) {
27
4/6
✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 72 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 72 times.
✗ Branch 13 not taken.
72 OS_ASSERT(other.iddObject().type() == AirGap::iddObjectType());
28 72 }
29
30 153 AirGap_Impl::AirGap_Impl(const AirGap_Impl& other, Model_Impl* model, bool keepHandle) : OpaqueMaterial_Impl(other, model, keepHandle) {}
31
32 ✗ double AirGap_Impl::thickness() const {
33 ✗ return 0.0;
34 }
35
36 ✗ double AirGap_Impl::thermalConductivity() const {
37 ✗ LOG_AND_THROW("Unable to convert thermal resistance to thermal conductivity for AirGap " << briefDescription() << ".");
38 return 0.0;
39 }
40
41 ✗ double AirGap_Impl::thermalConductance() const {
42 ✗ OS_ASSERT(thermalResistance());
43 ✗ return 1.0 / thermalResistance();
44 }
45
46 ✗ double AirGap_Impl::thermalResistivity() const {
47 ✗ LOG_AND_THROW("Unable to convert thermal resistance to thermal resistivity for AirGap " << briefDescription() << ".");
48 return 0.0;
49 }
50
51 113 double AirGap_Impl::thermalResistance() const {
52
1/1
✓ Branch 1 taken 113 times.
113 OptionalDouble od = getDouble(OS_Material_AirGapFields::ThermalResistance, true);
53
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
113 if (!od) {
54 ✗ LOG_AND_THROW("Thermal resistance is not set for AirGap " << briefDescription() << ".");
55 }
56
1/1
✓ Branch 1 taken 113 times.
226 return *od;
57 }
58
59 ✗ double AirGap_Impl::thermalAbsorptance() const {
60 ✗ OptionalDouble od(0.0);
61 ✗ return *od;
62 }
63
64 ✗ OptionalDouble AirGap_Impl::thermalReflectance() const {
65 ✗ OptionalDouble od(0.0);
66 ✗ return od;
67 }
68
69 ✗ double AirGap_Impl::solarAbsorptance() const {
70 ✗ OptionalDouble od(0.0);
71 ✗ return *od;
72 }
73
74 ✗ OptionalDouble AirGap_Impl::solarReflectance() const {
75 ✗ OptionalDouble od(0.0);
76 ✗ return od;
77 }
78
79 ✗ double AirGap_Impl::visibleTransmittance() const {
80 ✗ return 1.0;
81 }
82
83 ✗ double AirGap_Impl::visibleAbsorptance() const {
84 ✗ OptionalDouble od(0.0);
85 ✗ return *od;
86 }
87
88 ✗ OptionalDouble AirGap_Impl::visibleReflectance() const {
89 ✗ OptionalDouble od(0.0);
90 ✗ return od;
91 }
92
93 2 const std::vector<std::string>& AirGap_Impl::outputVariableNames() const {
94
3/4
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 static const std::vector<std::string> result;
95 2 return result;
96 }
97
98 ✗ IddObjectType AirGap_Impl::iddObjectType() const {
99 ✗ return AirGap::iddObjectType();
100 }
101
102 ✗ bool AirGap_Impl::setThickness(double /*value*/) {
103 ✗ return false;
104 }
105
106 ✗ bool AirGap_Impl::setThermalConductivity(double /*value*/) {
107 ✗ return false;
108 }
109
110 ✗ bool AirGap_Impl::setThermalConductance(double value) {
111 ✗ return setThermalResistance(1.0 / value);
112 }
113
114 ✗ bool AirGap_Impl::setThermalResistivity(double /*value*/) {
115 ✗ return false;
116 }
117
118 720 bool AirGap_Impl::setThermalResistance(double value) {
119 720 return setDouble(OS_Material_AirGapFields::ThermalResistance, value);
120 }
121
122 ✗ bool AirGap_Impl::setThermalAbsorptance(double /*value*/) {
123 ✗ return false;
124 }
125
126 ✗ bool AirGap_Impl::setThermalReflectance(OptionalDouble /*value*/) {
127 ✗ return false;
128 }
129
130 ✗ bool AirGap_Impl::setSolarAbsorptance(OptionalDouble /*value*/) {
131 ✗ return false;
132 }
133
134 ✗ bool AirGap_Impl::setSolarReflectance(OptionalDouble /*value*/) {
135 ✗ return false;
136 }
137
138 ✗ bool AirGap_Impl::setVisibleAbsorptance(OptionalDouble /*value*/) {
139 ✗ return false;
140 }
141
142 ✗ bool AirGap_Impl::setVisibleReflectance(OptionalDouble /*value*/) {
143 ✗ return false;
144 }
145
146 ✗ bool AirGap_Impl::setThermalResistance(boost::optional<double> thermalResistance) {
147 ✗ bool result(false);
148 ✗ if (thermalResistance) {
149 ✗ result = setDouble(OS_Material_AirGapFields::ThermalResistance, thermalResistance.get());
150 } else {
151 ✗ resetThermalResistance();
152 ✗ result = true;
153 }
154 ✗ return result;
155 }
156
157 1 void AirGap_Impl::resetThermalResistance() {
158 // Note JM 2018-12-04: Reset to the Ctor default of 0.1
159 // thermalResistance returns a double, so we CANNOT leave this field empty since it has no IDD default!
160 1 bool result = setDouble(OS_Material_AirGapFields::ThermalResistance, 0.1);
161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(result);
162 1 }
163
164 } // namespace detail
165
166 383 AirGap::AirGap(const Model& model, double thermalResistance) : OpaqueMaterial(AirGap::iddObjectType(), model) {
167
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 383 times.
✗ Branch 5 not taken.
383 OS_ASSERT(getImpl<detail::AirGap_Impl>());
168
169 // TODO: Appropriately handle the following required object-list fields.
170 383 bool ok = true;
171 // ok = setHandle();
172
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 383 times.
✗ Branch 3 not taken.
383 OS_ASSERT(ok);
173
1/1
✓ Branch 1 taken 383 times.
383 ok = setThermalResistance(thermalResistance);
174
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 383 times.
✗ Branch 3 not taken.
383 OS_ASSERT(ok);
175 383 }
176
177 8513 IddObjectType AirGap::iddObjectType() {
178
1/1
✓ Branch 1 taken 8513 times.
8513 return {IddObjectType::OS_Material_AirGap};
179 }
180
181 // cppcheck-suppress [duplInheritedMember] for documentation purposes
182 102 double AirGap::thermalResistance() const {
183
1/1
✓ Branch 3 taken 102 times.
102 return getImpl<detail::AirGap_Impl>()->thermalResistance();
184 }
185
186 // cppcheck-suppress [duplInheritedMember] for documentation purposes
187 720 bool AirGap::setThermalResistance(double thermalResistance) {
188
1/1
✓ Branch 3 taken 720 times.
720 return getImpl<detail::AirGap_Impl>()->setThermalResistance(thermalResistance);
189 }
190
191 1 void AirGap::resetThermalResistance() {
192
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::AirGap_Impl>()->resetThermalResistance();
193 1 }
194
195 /// @cond
196
1/1
✓ Branch 3 taken 125 times.
125 AirGap::AirGap(std::shared_ptr<detail::AirGap_Impl> impl) : OpaqueMaterial(std::move(impl)) {}
197 /// @endcond
198
199 } // namespace model
200 } // namespace openstudio
201