GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 99.0% 98 / 0 / 99
Functions: 100.0% 1 / 0 / 1
Branches: 92.1% 163 / 0 / 177

src/energyplus/ForwardTranslator/ForwardTranslateAirLoopHVACOutdoorAirSystem.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/AirToAirComponent.hpp"
8 #include "../../model/AirToAirComponent_Impl.hpp"
9 #include "../../model/AirLoopHVACOutdoorAirSystem.hpp"
10 #include "../../model/AirLoopHVACOutdoorAirSystem_Impl.hpp"
11 #include "../../model/AirLoopHVACDedicatedOutdoorAirSystem.hpp"
12 #include "../../model/AirLoopHVACDedicatedOutdoorAirSystem_Impl.hpp"
13 #include "../../model/ControllerOutdoorAir.hpp"
14 #include "../../model/ControllerOutdoorAir_Impl.hpp"
15 #include "../../model/ControllerWaterCoil.hpp"
16 #include "../../model/ControllerWaterCoil_Impl.hpp"
17 #include "../../model/CoilCoolingWater.hpp"
18 #include "../../model/CoilCoolingWater_Impl.hpp"
19 #include "../../model/CoilHeatingWater.hpp"
20 #include "../../model/CoilHeatingWater_Impl.hpp"
21 #include "../../model/Node.hpp"
22 #include "../../model/Node_Impl.hpp"
23 #include "../../model/Schedule.hpp"
24 #include "../../model/Schedule_Impl.hpp"
25
26 #include "../../utilities/idf/IdfExtensibleGroup.hpp"
27
28 #include <utilities/idd/AirLoopHVAC_ControllerList_FieldEnums.hxx>
29 #include <utilities/idd/AirLoopHVAC_OutdoorAirSystem_FieldEnums.hxx>
30 #include <utilities/idd/AirLoopHVAC_SupplyPath_FieldEnums.hxx>
31 #include <utilities/idd/AvailabilityManagerAssignmentList_FieldEnums.hxx>
32 #include <utilities/idd/AvailabilityManager_Scheduled_FieldEnums.hxx>
33 #include <utilities/idd/Controller_OutdoorAir_FieldEnums.hxx>
34 #include <utilities/idd/OutdoorAir_Mixer_FieldEnums.hxx>
35 #include "../../utilities/idd/IddEnums.hpp"
36 #include <utilities/idd/IddEnums.hxx>
37 #include <utilities/idd/IddFactory.hxx>
38
39 #include "../../utilities/core/Assert.hpp"
40
41 using namespace openstudio::model;
42
43 namespace openstudio {
44
45 namespace energyplus {
46
47 58 boost::optional<IdfObject> ForwardTranslator::translateAirLoopHVACOutdoorAirSystem(AirLoopHVACOutdoorAirSystem& modelObject) {
48 58 OptionalString s;
49
2/2
✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
58 IdfObject idfObject(IddObjectType::AirLoopHVAC_OutdoorAirSystem);
50
51
1/1
✓ Branch 1 taken 58 times.
58 m_idfObjects.push_back(idfObject);
52
53
1/1
✓ Branch 1 taken 58 times.
58 boost::optional<ModelObject> mixedAirModelObject = modelObject.mixedAirModelObject();
54
1/1
✓ Branch 1 taken 58 times.
58 boost::optional<ModelObject> outdoorAirModelObject = modelObject.outdoorAirModelObject();
55
1/1
✓ Branch 1 taken 58 times.
58 boost::optional<ModelObject> reliefAirModelObject = modelObject.reliefAirModelObject();
56
1/1
✓ Branch 1 taken 58 times.
58 boost::optional<ModelObject> returnAirModelObject = modelObject.returnAirModelObject();
57
58 // Name
59
3/3
✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
✓ Branch 7 taken 58 times.
58 std::string name = modelObject.name().get();
60
1/1
✓ Branch 1 taken 58 times.
58 idfObject.setString(openstudio::AirLoopHVAC_OutdoorAirSystemFields::Name, name);
61
62 // Controller List
63 58 std::vector<ModelObject> controllers;
64
3/3
✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
✓ Branch 7 taken 58 times.
58 auto components = modelObject.components();
65
2/2
✓ Branch 5 taken 206 times.
✓ Branch 6 taken 58 times.
264 for (const auto& component : components) {
66 206 boost::optional<ControllerWaterCoil> controller;
67
68
3/3
✓ Branch 1 taken 206 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 202 times.
412 if (auto coil = component.optionalCast<CoilCoolingWater>()) {
69
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 controller = coil->controllerWaterCoil();
70
2/3
✓ Branch 1 taken 202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 202 times.
404 } else if (auto coil = component.optionalCast<CoilHeatingWater>()) {
71 ✗ controller = coil->controllerWaterCoil();
72 408 }
73
74
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 204 times.
206 if (controller) {
75
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 controllers.push_back(controller.get());
76 }
77 206 }
78
79 // If it's not empty: then we have work to do.
80 // If it's empty, there's at least the controller Outdoor Air UNLESS it's on a AirLoopHVACDOAS in which case do nothing
81
9/11
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 2 times.
✓ Branch 4 taken 56 times.
✓ Branch 7 taken 53 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 56 times.
✓ Branch 10 taken 2 times.
✓ Branch 12 taken 55 times.
✓ Branch 13 taken 3 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
58 if (!controllers.empty() || !modelObject.airLoopHVACDedicatedOutdoorAirSystem()) {
82
83
2/2
✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
55 IdfObject _controllerList(IddObjectType::AirLoopHVAC_ControllerList);
84
2/2
✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
55 _controllerList.setName(name + " Controller List");
85
1/1
✓ Branch 1 taken 55 times.
55 _controllerList.clearExtensibleGroups();
86
1/1
✓ Branch 1 taken 55 times.
55 m_idfObjects.push_back(_controllerList);
87
3/3
✓ Branch 1 taken 55 times.
✓ Branch 4 taken 55 times.
✓ Branch 7 taken 55 times.
55 idfObject.setString(openstudio::AirLoopHVAC_OutdoorAirSystemFields::ControllerListName, _controllerList.name().get());
88
89
1/1
✓ Branch 1 taken 55 times.
55 ControllerOutdoorAir controllerOutdoorAir = modelObject.getControllerOutdoorAir();
90
91
3/3
✓ Branch 1 taken 55 times.
✓ Branch 5 taken 53 times.
✓ Branch 6 taken 2 times.
55 if (!modelObject.airLoopHVACDedicatedOutdoorAirSystem()) {
92
1/1
✓ Branch 1 taken 53 times.
53 boost::optional<IdfObject> _controllerOutdoorAir = translateAndMapModelObject(controllerOutdoorAir);
93
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 4 not taken.
53 OS_ASSERT(_controllerOutdoorAir);
94
95
1/1
✓ Branch 1 taken 53 times.
53 IdfExtensibleGroup eg = _controllerList.pushExtensibleGroup();
96
4/4
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
✓ Branch 7 taken 53 times.
✓ Branch 10 taken 53 times.
53 eg.setString(AirLoopHVAC_ControllerListExtensibleFields::ControllerObjectType, _controllerOutdoorAir->iddObject().name());
97
4/4
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
✓ Branch 7 taken 53 times.
✓ Branch 10 taken 53 times.
53 eg.setString(AirLoopHVAC_ControllerListExtensibleFields::ControllerName, _controllerOutdoorAir->name().get());
98 53 }
99
100
2/2
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 55 times.
57 for (auto& controller : controllers) {
101
1/1
✓ Branch 1 taken 2 times.
2 auto _controller = translateAndMapModelObject(controller);
102
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (_controller) {
103
1/1
✓ Branch 1 taken 2 times.
2 IdfExtensibleGroup eg = _controllerList.pushExtensibleGroup();
104
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 eg.setString(AirLoopHVAC_ControllerListExtensibleFields::ControllerObjectType, _controller->iddObject().name());
105
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 eg.setString(AirLoopHVAC_ControllerListExtensibleFields::ControllerName, _controller->name().get());
106 2 }
107 2 }
108 55 }
109
110 // OA Node List
111
3/3
✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
✓ Branch 7 taken 58 times.
58 s = modelObject.outboardOANode()->name();
112
2/2
✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
58 IdfObject oaNodeListIdf(openstudio::IddObjectType::OutdoorAir_NodeList);
113
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if (s) {
114
2/2
✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
58 oaNodeListIdf.setString(0, *s);
115 }
116
1/1
✓ Branch 1 taken 58 times.
58 m_idfObjects.push_back(oaNodeListIdf);
117
118 ///////////////////////////////////////////////////////////////////////////
119 // Field: Outdoor Air Equipment List Name /////////////////////////////////
120
2/2
✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
58 IdfObject equipmentListIdf(IddObjectType::AirLoopHVAC_OutdoorAirSystem_EquipmentList);
121
2/2
✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
58 equipmentListIdf.setName(name + " Equipment List");
122
123
1/1
✓ Branch 1 taken 58 times.
58 m_idfObjects.push_back(equipmentListIdf);
124
125 58 unsigned i = 1;
126
127 // Components are simulated in the order they are listed, and that order must match the
128 // actual air flow direction: outside air side first, OutdoorAir:Mixer last (it sits between
129 // the OA/relief branches), then any relief-side equipment downstream of the mixer.
130
3/3
✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
✓ Branch 7 taken 58 times.
58 ModelObjectVector oaModelObjects = modelObject.oaComponents();
131
2/2
✓ Branch 4 taken 132 times.
✓ Branch 5 taken 58 times.
190 for (auto oaIt = oaModelObjects.begin(); oaIt != oaModelObjects.end(); ++oaIt) {
132
3/3
✓ Branch 2 taken 132 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 95 times.
264 if (boost::optional<IdfObject> idfObject = translateAndMapModelObject(*oaIt)) {
133
4/4
✓ Branch 1 taken 37 times.
✓ Branch 4 taken 37 times.
✓ Branch 7 taken 37 times.
✓ Branch 10 taken 37 times.
37 equipmentListIdf.setString(i, idfObject->iddObject().name());
134 37 i++;
135
4/4
✓ Branch 1 taken 37 times.
✓ Branch 4 taken 37 times.
✓ Branch 7 taken 37 times.
✓ Branch 10 taken 37 times.
37 equipmentListIdf.setString(i, idfObject->name().get());
136 37 i++;
137 132 }
138 }
139
140
3/3
✓ Branch 1 taken 58 times.
✓ Branch 5 taken 53 times.
✓ Branch 6 taken 5 times.
58 if (!modelObject.airLoopHVACDedicatedOutdoorAirSystem()) {
141
2/2
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
53 IdfObject outdoorAirMixerIdf(IddObjectType::OutdoorAir_Mixer);
142
2/2
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
53 outdoorAirMixerIdf.setName(name + " Outdoor Air Mixer");
143
1/1
✓ Branch 1 taken 53 times.
53 m_idfObjects.push_back(outdoorAirMixerIdf);
144
145
2/2
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
53 s = mixedAirModelObject->name();
146
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (s) {
147
2/2
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
53 outdoorAirMixerIdf.setString(OutdoorAir_MixerFields::MixedAirNodeName, *s);
148 }
149
2/2
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
53 s = outdoorAirModelObject->name();
150
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (s) {
151
2/2
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
53 outdoorAirMixerIdf.setString(OutdoorAir_MixerFields::OutdoorAirStreamNodeName, *s);
152 }
153
154
2/2
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
53 s = reliefAirModelObject->name();
155
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (s) {
156
2/2
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
53 outdoorAirMixerIdf.setString(OutdoorAir_MixerFields::ReliefAirStreamNodeName, *s);
157 }
158
159
2/2
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
53 s = returnAirModelObject->name();
160
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (s) {
161
2/2
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
53 outdoorAirMixerIdf.setString(OutdoorAir_MixerFields::ReturnAirStreamNodeName, *s);
162 }
163
164
3/3
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
✓ Branch 7 taken 53 times.
53 s = outdoorAirMixerIdf.iddObject().name();
165
2/2
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
53 equipmentListIdf.setString(i, *s);
166 53 ++i;
167
1/1
✓ Branch 1 taken 53 times.
53 s = outdoorAirMixerIdf.name();
168
2/2
✓ Branch 1 taken 53 times.
✓ Branch 4 taken 53 times.
53 equipmentListIdf.setString(i, *s);
169 53 ++i;
170 53 }
171
172
3/3
✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
✓ Branch 7 taken 58 times.
58 ModelObjectVector reliefModelObjects = modelObject.reliefComponents();
173
2/2
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 58 times.
132 for (auto reliefIt = reliefModelObjects.begin(); reliefIt != reliefModelObjects.end(); ++reliefIt) {
174 // Make sure this is not an AirToAirComponent,
175 // because those will be added to the equipment list
176 // from the oaComponents() side.
177
3/3
✓ Branch 2 taken 74 times.
✓ Branch 6 taken 70 times.
✓ Branch 7 taken 4 times.
74 if (!reliefIt->optionalCast<AirToAirComponent>()) {
178
3/3
✓ Branch 2 taken 70 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 66 times.
140 if (boost::optional<IdfObject> idfObject = translateAndMapModelObject(*reliefIt)) {
179
4/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
4 equipmentListIdf.setString(i, idfObject->iddObject().name());
180 4 i++;
181
4/4
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
4 equipmentListIdf.setString(i, idfObject->name().get());
182 4 i++;
183 70 }
184 }
185 }
186
187
1/1
✓ Branch 1 taken 58 times.
58 s = equipmentListIdf.name();
188
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if (s) {
189
2/2
✓ Branch 1 taken 58 times.
✓ Branch 4 taken 58 times.
58 idfObject.setString(openstudio::AirLoopHVAC_OutdoorAirSystemFields::OutdoorAirEquipmentListName, *s);
190 }
191
192
1/1
✓ Branch 1 taken 58 times.
116 return boost::optional<IdfObject>(idfObject);
193 58 }
194
195 } // namespace energyplus
196
197 } // namespace openstudio
198