GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 84.3% 129 / 0 / 153
Functions: 80.6% 25 / 0 / 31
Branches: 67.1% 153 / 0 / 228

src/model/CoilSystemCoolingWaterHeatExchangerAssisted.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 "CoilSystemCoolingWaterHeatExchangerAssisted.hpp"
7 #include "CoilSystemCoolingWaterHeatExchangerAssisted_Impl.hpp"
8 #include "AirToAirComponent.hpp"
9 #include "AirToAirComponent_Impl.hpp"
10 #include "WaterToAirComponent.hpp"
11 #include "WaterToAirComponent_Impl.hpp"
12 #include "CoilCoolingWater.hpp"
13 #include "CoilCoolingWater_Impl.hpp"
14 #include "CoilSystemCoolingWater.hpp"
15 #include "CoilSystemCoolingWater_Impl.hpp"
16 #include "Model.hpp"
17 #include "Model_Impl.hpp"
18 #include "Node.hpp"
19 #include "Node_Impl.hpp"
20 #include "AirLoopHVAC.hpp"
21 #include "AirLoopHVAC_Impl.hpp"
22 #include "HeatExchangerAirToAirSensibleAndLatent.hpp"
23 #include "HeatExchangerAirToAirSensibleAndLatent_Impl.hpp"
24
25 #include "AirLoopHVACUnitarySystem.hpp"
26 #include "AirLoopHVACUnitarySystem_Impl.hpp"
27 #include "ZoneHVACFourPipeFanCoil.hpp"
28 #include "ZoneHVACFourPipeFanCoil_Impl.hpp"
29 #include "ZoneHVACUnitVentilator.hpp"
30 #include "ZoneHVACUnitVentilator_Impl.hpp"
31
32 #include "AirLoopHVACOutdoorAirSystem.hpp"
33 #include "AirLoopHVACOutdoorAirSystem_Impl.hpp"
34 #include "AirLoopHVACDedicatedOutdoorAirSystem.hpp"
35 #include "AirLoopHVACDedicatedOutdoorAirSystem_Impl.hpp"
36
37 #include <utilities/idd/OS_CoilSystem_Cooling_Water_HeatExchangerAssisted_FieldEnums.hxx>
38 #include <utilities/idd/IddFactory.hxx>
39 #include "../utilities/core/Assert.hpp"
40 #include "../utilities/data/DataEnums.hpp"
41
42 namespace openstudio {
43 namespace model {
44
45 namespace detail {
46
47 17 CoilSystemCoolingWaterHeatExchangerAssisted_Impl::CoilSystemCoolingWaterHeatExchangerAssisted_Impl(const IdfObject& idfObject, Model_Impl* model,
48 17 bool keepHandle)
49 17 : StraightComponent_Impl(idfObject, model, keepHandle) {
50
4/6
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✓ Branch 7 taken 17 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 17 times.
✗ Branch 13 not taken.
17 OS_ASSERT(idfObject.iddObject().type() == CoilSystemCoolingWaterHeatExchangerAssisted::iddObjectType());
51 17 }
52
53 ✗ CoilSystemCoolingWaterHeatExchangerAssisted_Impl::CoilSystemCoolingWaterHeatExchangerAssisted_Impl(
54 ✗ const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
55 ✗ : StraightComponent_Impl(other, model, keepHandle) {
56 ✗ OS_ASSERT(other.iddObject().type() == CoilSystemCoolingWaterHeatExchangerAssisted::iddObjectType());
57 ✗ }
58
59 10 CoilSystemCoolingWaterHeatExchangerAssisted_Impl::CoilSystemCoolingWaterHeatExchangerAssisted_Impl(
60 10 const CoilSystemCoolingWaterHeatExchangerAssisted_Impl& other, Model_Impl* model, bool keepHandle)
61 10 : StraightComponent_Impl(other, model, keepHandle) {}
62
63 ✗ const std::vector<std::string>& CoilSystemCoolingWaterHeatExchangerAssisted_Impl::outputVariableNames() const {
64 ✗ static const std::vector<std::string> result;
65 // Not appropriate: no specific output, there are at the coil and HX level
66 ✗ return result;
67 }
68
69 17 IddObjectType CoilSystemCoolingWaterHeatExchangerAssisted_Impl::iddObjectType() const {
70 17 return CoilSystemCoolingWaterHeatExchangerAssisted::iddObjectType();
71 }
72
73 10 std::vector<ModelObject> CoilSystemCoolingWaterHeatExchangerAssisted_Impl::children() const {
74 10 std::vector<ModelObject> result;
75
76
3/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 1 time.
20 if (auto intermediate = optionalCoolingCoil()) {
77
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 result.push_back(*intermediate);
78 10 }
79
3/3
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 1 time.
20 if (auto intermediate = optionalHeatExchanger()) {
80
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 result.push_back(*intermediate);
81 10 }
82
83 10 return result;
84 ✗ }
85
86 3 ModelObject CoilSystemCoolingWaterHeatExchangerAssisted_Impl::clone(Model model) const {
87
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 auto newCoilSystem = StraightComponent_Impl::clone(model).cast<CoilSystemCoolingWaterHeatExchangerAssisted>();
88
89 {
90
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 auto mo = coolingCoil().clone(model).cast<WaterToAirComponent>();
91
1/1
✓ Branch 1 taken 3 times.
3 newCoilSystem.setCoolingCoil(mo);
92 3 }
93
94 {
95
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 auto mo = heatExchanger().clone(model).cast<AirToAirComponent>();
96
1/1
✓ Branch 1 taken 3 times.
3 newCoilSystem.setHeatExchanger(mo);
97 3 }
98
99 6 return std::move(newCoilSystem);
100 3 }
101
102 3 std::vector<IdfObject> CoilSystemCoolingWaterHeatExchangerAssisted_Impl::remove() {
103
3/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1 time.
6 if (auto cc_ = optionalCoolingCoil()) {
104
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 cc_->removeFromPlantLoop();
105 3 }
106
107 3 return StraightComponent_Impl::remove();
108 }
109
110 13 boost::optional<HVACComponent> CoilSystemCoolingWaterHeatExchangerAssisted_Impl::containingHVACComponent() const {
111 // AirLoopHVACUnitarySystem
112
2/2
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
13 std::vector<AirLoopHVACUnitarySystem> airLoopHVACUnitarySystems = this->model().getConcreteModelObjects<AirLoopHVACUnitarySystem>();
113
114
2/2
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 10 times.
13 for (const auto& airLoopHVACUnitarySystem : airLoopHVACUnitarySystems) {
115
2/3
✓ Branch 1 taken 3 times.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
6 if (boost::optional<HVACComponent> coolingCoil = airLoopHVACUnitarySystem.coolingCoil()) {
116
5/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
3 if (coolingCoil->handle() == this->handle()) {
117
1/1
✓ Branch 1 taken 3 times.
3 return airLoopHVACUnitarySystem;
118 }
119 3 }
120 }
121
122 // CoilSystemCoolingWater
123
4/4
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 7 times.
10 for (const auto& coilSystem : this->model().getConcreteModelObjects<CoilSystemCoolingWater>()) {
124
5/6
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✗ Branch 14 not taken.
3 if (coilSystem.coolingCoil().handle() == this->handle()) {
125
1/1
✓ Branch 1 taken 3 times.
3 return coilSystem;
126 ✗ } else if (boost::optional<HVACComponent> companionCoil_ = coilSystem.companionCoilUsedForHeatRecovery()) {
127 ✗ if (companionCoil_->handle() == this->handle()) {
128 ✗ return coilSystem;
129 }
130 ✗ }
131 10 }
132
133 7 return boost::none;
134 13 }
135
136 5 boost::optional<ZoneHVACComponent> CoilSystemCoolingWaterHeatExchangerAssisted_Impl::containingZoneHVACComponent() const {
137
138 // ZoneHVACFourPipeFanCoil
139 5 std::vector<ZoneHVACFourPipeFanCoil> zoneHVACFourPipeFanCoils;
140
141
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 zoneHVACFourPipeFanCoils = this->model().getConcreteModelObjects<ZoneHVACFourPipeFanCoil>();
142
143
2/2
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 4 times.
5 for (const auto& zoneHVACFourPipeFanCoil : zoneHVACFourPipeFanCoils) {
144
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 8 taken 1 time.
✗ Branch 9 not taken.
2 if (boost::optional<HVACComponent> coil = zoneHVACFourPipeFanCoil.coolingCoil()) {
145
5/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 12 taken 1 time.
✗ Branch 13 not taken.
1 if (coil->handle() == this->handle()) {
146
1/1
✓ Branch 1 taken 1 time.
1 return zoneHVACFourPipeFanCoil;
147 }
148 1 }
149 }
150
151 // ZoneHVACUnitVentilator
152 4 std::vector<ZoneHVACUnitVentilator> zoneHVACUnitVentilators;
153
154
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 zoneHVACUnitVentilators = this->model().getConcreteModelObjects<ZoneHVACUnitVentilator>();
155
156
2/2
✓ Branch 5 taken 1 time.
✓ Branch 6 taken 3 times.
4 for (const auto& zoneHVACUnitVentilator : zoneHVACUnitVentilators) {
157
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 if (boost::optional<HVACComponent> coil = zoneHVACUnitVentilator.coolingCoil()) {
158
5/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 12 taken 1 time.
✗ Branch 13 not taken.
1 if (coil->handle() == this->handle()) {
159
1/1
✓ Branch 1 taken 1 time.
1 return zoneHVACUnitVentilator;
160 }
161 1 }
162 }
163
164 // ZoneHVAC:WindowAirConditioner not wrapped
165
166 3 return boost::none;
167 5 }
168
169 18 AirToAirComponent CoilSystemCoolingWaterHeatExchangerAssisted_Impl::heatExchanger() const {
170
1/1
✓ Branch 1 taken 18 times.
18 boost::optional<AirToAirComponent> value = optionalHeatExchanger();
171
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
18 if (!value) {
172 ✗ LOG_AND_THROW(briefDescription() << " does not have an Heat Exchanger attached.");
173 }
174
2/2
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
36 return value.get();
175 18 }
176
177 51 WaterToAirComponent CoilSystemCoolingWaterHeatExchangerAssisted_Impl::coolingCoil() const {
178
1/1
✓ Branch 1 taken 51 times.
51 auto value = optionalCoolingCoil();
179
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
51 if (!value) {
180 ✗ LOG_AND_THROW(briefDescription() << " does not have an Cooling Coil attached.");
181 }
182
2/2
✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
102 return value.get();
183 51 }
184
185 20 bool CoilSystemCoolingWaterHeatExchangerAssisted_Impl::setHeatExchanger(const AirToAirComponent& heatExchanger) {
186
2/2
✓ Branch 1 taken 20 times.
✓ Branch 4 taken 20 times.
20 bool result = setPointer(OS_CoilSystem_Cooling_Water_HeatExchangerAssistedFields::HeatExchanger, heatExchanger.handle());
187 20 return result;
188 }
189
190 19 bool CoilSystemCoolingWaterHeatExchangerAssisted_Impl::setCoolingCoil(const WaterToAirComponent& coolingCoil) {
191
2/2
✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
19 bool result = setPointer(OS_CoilSystem_Cooling_Water_HeatExchangerAssistedFields::CoolingCoil, coolingCoil.handle());
192 19 return result;
193 }
194
195 28 boost::optional<AirToAirComponent> CoilSystemCoolingWaterHeatExchangerAssisted_Impl::optionalHeatExchanger() const {
196
2/2
✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
28 return getObject<ModelObject>().getModelObjectTarget<AirToAirComponent>(OS_CoilSystem_Cooling_Water_HeatExchangerAssistedFields::HeatExchanger);
197 }
198
199 64 boost::optional<WaterToAirComponent> CoilSystemCoolingWaterHeatExchangerAssisted_Impl::optionalCoolingCoil() const {
200
2/2
✓ Branch 1 taken 64 times.
✓ Branch 4 taken 64 times.
64 return getObject<ModelObject>().getModelObjectTarget<WaterToAirComponent>(OS_CoilSystem_Cooling_Water_HeatExchangerAssistedFields::CoolingCoil);
201 }
202
203 61 unsigned CoilSystemCoolingWaterHeatExchangerAssisted_Impl::inletPort() const {
204 61 return OS_CoilSystem_Cooling_Water_HeatExchangerAssistedFields::AirInletNodeName;
205 }
206
207 53 unsigned CoilSystemCoolingWaterHeatExchangerAssisted_Impl::outletPort() const {
208 53 return OS_CoilSystem_Cooling_Water_HeatExchangerAssistedFields::AirOutletNodeName;
209 }
210
211 5 bool CoilSystemCoolingWaterHeatExchangerAssisted_Impl::addToNode(Node& node) {
212 5 bool result = false;
213
214
3/3
✓ Branch 1 taken 5 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1 time.
10 if (boost::optional<AirLoopHVAC> airLoop = node.airLoopHVAC()) {
215
4/5
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 11 taken 4 times.
✗ Branch 12 not taken.
4 if (!airLoop->demandComponent(node.handle())) {
216
1/1
✓ Branch 1 taken 4 times.
4 return StraightComponent_Impl::addToNode(node);
217 }
218
2/3
✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
2 } else if (boost::optional<AirLoopHVACOutdoorAirSystem> oas = node.airLoopHVACOutdoorAirSystem()) {
219
3/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
2 if (oas->airLoopHVACDedicatedOutdoorAirSystem()) {
220
1/1
✓ Branch 1 taken 1 time.
1 return StraightComponent_Impl::addToNode(node);
221 }
222 6 }
223
224 ✗ return result;
225 }
226
227 ✗ ComponentType CoilSystemCoolingWaterHeatExchangerAssisted_Impl::componentType() const {
228 ✗ return ComponentType::Cooling;
229 }
230
231 ✗ std::vector<FuelType> CoilSystemCoolingWaterHeatExchangerAssisted_Impl::coolingFuelTypes() const {
232 ✗ return coolingCoil().coolingFuelTypes();
233 }
234
235 ✗ std::vector<FuelType> CoilSystemCoolingWaterHeatExchangerAssisted_Impl::heatingFuelTypes() const {
236 ✗ return {};
237 }
238
239 ✗ std::vector<AppGFuelType> CoilSystemCoolingWaterHeatExchangerAssisted_Impl::appGHeatingFuelTypes() const {
240 ✗ return {};
241 }
242
243 } // namespace detail
244
245 15 CoilSystemCoolingWaterHeatExchangerAssisted::CoilSystemCoolingWaterHeatExchangerAssisted(const Model& model)
246 15 : StraightComponent(CoilSystemCoolingWaterHeatExchangerAssisted::iddObjectType(), model) {
247
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 5 not taken.
15 OS_ASSERT(getImpl<detail::CoilSystemCoolingWaterHeatExchangerAssisted_Impl>());
248
249
1/1
✓ Branch 1 taken 15 times.
15 CoilCoolingWater coolingCoil(model);
250
1/1
✓ Branch 1 taken 15 times.
15 setCoolingCoil(coolingCoil);
251
252
1/1
✓ Branch 1 taken 15 times.
15 HeatExchangerAirToAirSensibleAndLatent heatExchanger(model);
253
1/1
✓ Branch 1 taken 15 times.
15 heatExchanger.setSupplyAirOutletTemperatureControl(false);
254
1/1
✓ Branch 1 taken 15 times.
15 setHeatExchanger(heatExchanger);
255 15 }
256
257 2 CoilSystemCoolingWaterHeatExchangerAssisted::CoilSystemCoolingWaterHeatExchangerAssisted(const Model& model, const AirToAirComponent& heatExchanger)
258 2 : StraightComponent(CoilSystemCoolingWaterHeatExchangerAssisted::iddObjectType(), model) {
259
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 5 not taken.
2 OS_ASSERT(getImpl<detail::CoilSystemCoolingWaterHeatExchangerAssisted_Impl>());
260
261
1/1
✓ Branch 1 taken 2 times.
2 bool ok = setHeatExchanger(heatExchanger);
262
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
2 if (!ok) {
263
1/1
✓ Branch 1 taken 1 time.
1 remove();
264
25/25
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 22 taken 1 time.
✓ Branch 27 taken 1 time.
✓ Branch 30 taken 1 time.
✓ Branch 33 taken 1 time.
✓ Branch 39 taken 1 time.
✓ Branch 42 taken 1 time.
✓ Branch 45 taken 1 time.
✓ Branch 48 taken 1 time.
✓ Branch 51 taken 1 time.
✓ Branch 54 taken 1 time.
✓ Branch 57 taken 1 time.
✓ Branch 60 taken 1 time.
✓ Branch 63 taken 1 time.
✓ Branch 66 taken 1 time.
✓ Branch 69 taken 1 time.
✓ Branch 72 taken 1 time.
✓ Branch 78 taken 1 time.
✓ Branch 81 taken 1 time.
1 LOG_AND_THROW("Unable to set " << briefDescription() << "'s Heat Exchanger " << heatExchanger.briefDescription() << ".");
265 }
266
267
1/1
✓ Branch 1 taken 1 time.
1 CoilCoolingWater coolingCoil(model);
268
1/1
✓ Branch 1 taken 1 time.
1 setCoolingCoil(coolingCoil);
269 2 }
270
271 7945 IddObjectType CoilSystemCoolingWaterHeatExchangerAssisted::iddObjectType() {
272
1/1
✓ Branch 1 taken 7945 times.
7945 return {IddObjectType::OS_CoilSystem_Cooling_Water_HeatExchangerAssisted};
273 }
274
275 15 AirToAirComponent CoilSystemCoolingWaterHeatExchangerAssisted::heatExchanger() const {
276
1/1
✓ Branch 3 taken 15 times.
15 return getImpl<detail::CoilSystemCoolingWaterHeatExchangerAssisted_Impl>()->heatExchanger();
277 }
278
279 48 WaterToAirComponent CoilSystemCoolingWaterHeatExchangerAssisted::coolingCoil() const {
280
1/1
✓ Branch 3 taken 48 times.
48 return getImpl<detail::CoilSystemCoolingWaterHeatExchangerAssisted_Impl>()->coolingCoil();
281 }
282
283 20 bool CoilSystemCoolingWaterHeatExchangerAssisted::setHeatExchanger(const AirToAirComponent& heatExchanger) {
284
1/1
✓ Branch 3 taken 20 times.
20 return getImpl<detail::CoilSystemCoolingWaterHeatExchangerAssisted_Impl>()->setHeatExchanger(heatExchanger);
285 }
286
287 19 bool CoilSystemCoolingWaterHeatExchangerAssisted::setCoolingCoil(const WaterToAirComponent& coolingCoil) {
288
1/1
✓ Branch 3 taken 19 times.
19 return getImpl<detail::CoilSystemCoolingWaterHeatExchangerAssisted_Impl>()->setCoolingCoil(coolingCoil);
289 }
290
291 /// @cond
292 51 CoilSystemCoolingWaterHeatExchangerAssisted::CoilSystemCoolingWaterHeatExchangerAssisted(
293 51 std::shared_ptr<detail::CoilSystemCoolingWaterHeatExchangerAssisted_Impl> impl)
294
1/1
✓ Branch 3 taken 51 times.
51 : StraightComponent(std::move(impl)) {}
295 /// @endcond
296
297 } // namespace model
298 } // namespace openstudio
299