src/model/AirLoopHVACReturnPlenum.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 "AirLoopHVACReturnPlenum.hpp" | ||
| 7 | #include "AirLoopHVACReturnPlenum_Impl.hpp" | ||
| 8 | #include "AirLoopHVACZoneMixer.hpp" | ||
| 9 | #include "AirLoopHVACZoneMixer_Impl.hpp" | ||
| 10 | #include "AirLoopHVACSupplyPlenum.hpp" | ||
| 11 | #include "AirLoopHVACSupplyPlenum_Impl.hpp" | ||
| 12 | #include "AirLoopHVACZoneSplitter.hpp" | ||
| 13 | #include "AirLoopHVACZoneSplitter_Impl.hpp" | ||
| 14 | #include "ZoneHVACComponent.hpp" | ||
| 15 | #include "ZoneHVACComponent_Impl.hpp" | ||
| 16 | #include "ThermalZone.hpp" | ||
| 17 | #include "ThermalZone_Impl.hpp" | ||
| 18 | #include "Model.hpp" | ||
| 19 | #include "Model_Impl.hpp" | ||
| 20 | #include "AirLoopHVAC.hpp" | ||
| 21 | #include "AirLoopHVAC_Impl.hpp" | ||
| 22 | #include "Node.hpp" | ||
| 23 | #include "Node_Impl.hpp" | ||
| 24 | #include "PortList.hpp" | ||
| 25 | #include "PortList_Impl.hpp" | ||
| 26 | #include "Connection.hpp" | ||
| 27 | #include "Connection_Impl.hpp" | ||
| 28 | #include "ZoneHVACIdealLoadsAirSystem.hpp" | ||
| 29 | #include "ZoneHVACIdealLoadsAirSystem_Impl.hpp" | ||
| 30 | |||
| 31 | #include "../utilities/data/DataEnums.hpp" | ||
| 32 | |||
| 33 | #include <utilities/idd/OS_AirLoopHVAC_ReturnPlenum_FieldEnums.hxx> | ||
| 34 | #include <utilities/idd/IddEnums.hxx> | ||
| 35 | |||
| 36 | namespace openstudio { | ||
| 37 | namespace model { | ||
| 38 | |||
| 39 | namespace detail { | ||
| 40 | |||
| 41 | 10 | AirLoopHVACReturnPlenum_Impl::AirLoopHVACReturnPlenum_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 42 | 10 | : Mixer_Impl(idfObject, model, keepHandle) { | |
| 43 |
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(idfObject.iddObject().type() == AirLoopHVACReturnPlenum::iddObjectType()); |
| 44 | 10 | } | |
| 45 | |||
| 46 | ✗ | AirLoopHVACReturnPlenum_Impl::AirLoopHVACReturnPlenum_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, | |
| 47 | ✗ | bool keepHandle) | |
| 48 | ✗ | : Mixer_Impl(other, model, keepHandle) { | |
| 49 | ✗ | OS_ASSERT(other.iddObject().type() == AirLoopHVACReturnPlenum::iddObjectType()); | |
| 50 | ✗ | } | |
| 51 | |||
| 52 | 3 | AirLoopHVACReturnPlenum_Impl::AirLoopHVACReturnPlenum_Impl(const AirLoopHVACReturnPlenum_Impl& other, Model_Impl* model, bool keepHandle) | |
| 53 | 3 | : Mixer_Impl(other, model, keepHandle) {} | |
| 54 | |||
| 55 | ✗ | const std::vector<std::string>& AirLoopHVACReturnPlenum_Impl::outputVariableNames() const { | |
| 56 | ✗ | static const std::vector<std::string> result; | |
| 57 | ✗ | return result; | |
| 58 | } | ||
| 59 | |||
| 60 | 45 | IddObjectType AirLoopHVACReturnPlenum_Impl::iddObjectType() const { | |
| 61 | 45 | return AirLoopHVACReturnPlenum::iddObjectType(); | |
| 62 | } | ||
| 63 | |||
| 64 | 77 | boost::optional<ThermalZone> AirLoopHVACReturnPlenum_Impl::thermalZone() const { | |
| 65 |
2/2✓ Branch 1 taken 77 times.
✓ Branch 4 taken 77 times.
|
77 | return getObject<ModelObject>().getModelObjectTarget<ThermalZone>(OS_AirLoopHVAC_ReturnPlenumFields::ThermalZone); |
| 66 | } | ||
| 67 | |||
| 68 | 9 | bool AirLoopHVACReturnPlenum_Impl::setThermalZone(const boost::optional<ThermalZone>& thermalZone) { | |
| 69 | 9 | bool result(false); | |
| 70 | |||
| 71 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
|
9 | if (!thermalZone) { |
| 72 | ✗ | resetThermalZone(); | |
| 73 | ✗ | result = true; | |
| 74 |
3/9✓ Branch 3 taken 9 times.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 9 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
18 | } else if ((!thermalZone->getImpl<ThermalZone_Impl>()->airLoopHVACSupplyPlenum()) |
| 75 |
9/20✓ Branch 1 taken 9 times.
✓ Branch 6 taken 9 times.
✓ Branch 9 taken 9 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 9 times.
✓ Branch 15 taken 9 times.
✓ Branch 18 taken 9 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 9 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 9 times.
✗ Branch 25 not taken.
✓ Branch 27 taken 9 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
|
18 | && (!thermalZone->getImpl<ThermalZone_Impl>()->airLoopHVACReturnPlenum()) && (thermalZone->equipment().empty()) |
| 76 |
6/9✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
✓ Branch 12 taken 9 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 9 times.
✗ Branch 15 not taken.
|
27 | && (!thermalZone->useIdealAirLoads())) { |
| 77 |
3/3✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
|
9 | result = setPointer(OS_AirLoopHVAC_ReturnPlenumFields::ThermalZone, thermalZone.get().handle()); |
| 78 | } | ||
| 79 | |||
| 80 | 9 | return result; | |
| 81 | } | ||
| 82 | |||
| 83 | ✗ | void AirLoopHVACReturnPlenum_Impl::resetThermalZone() { | |
| 84 | ✗ | bool result = setString(OS_AirLoopHVAC_ReturnPlenumFields::ThermalZone, ""); | |
| 85 | ✗ | OS_ASSERT(result); | |
| 86 | ✗ | } | |
| 87 | |||
| 88 | 545 | unsigned AirLoopHVACReturnPlenum_Impl::outletPort() const { | |
| 89 | 545 | return OS_AirLoopHVAC_ReturnPlenumFields::OutletNode; | |
| 90 | } | ||
| 91 | |||
| 92 | 4 | PortList AirLoopHVACReturnPlenum_Impl::inducedAirOutletPortList() { | |
| 93 |
1/1✓ Branch 1 taken 4 times.
|
4 | auto plenum = getObject<model::AirLoopHVACReturnPlenum>(); |
| 94 |
1/1✓ Branch 1 taken 4 times.
|
4 | boost::optional<PortList> portList = plenum.getModelObjectTarget<PortList>(OS_AirLoopHVAC_ReturnPlenumFields::InducedAirOutletPortList); |
| 95 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | if (!portList) { |
| 96 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | portList = PortList(plenum); |
| 97 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | setPointer(OS_AirLoopHVAC_ReturnPlenumFields::InducedAirOutletPortList, portList->handle()); |
| 98 | } | ||
| 99 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | return portList.get(); |
| 100 | 4 | } | |
| 101 | |||
| 102 | 246 | unsigned AirLoopHVACReturnPlenum_Impl::inletPort(unsigned branchIndex) const { | |
| 103 | unsigned result; | ||
| 104 | 246 | result = numNonextensibleFields(); | |
| 105 | 246 | result = result + branchIndex; | |
| 106 | 246 | return result; | |
| 107 | } | ||
| 108 | |||
| 109 | 19 | unsigned AirLoopHVACReturnPlenum_Impl::nextInletPort() const { | |
| 110 | 19 | return inletPort(this->nextBranchIndex()); | |
| 111 | } | ||
| 112 | |||
| 113 | 17 | bool AirLoopHVACReturnPlenum_Impl::addToNode(Node& node) { | |
| 114 | 17 | bool result = true; | |
| 115 | |||
| 116 |
1/1✓ Branch 1 taken 17 times.
|
17 | Model _model = model(); |
| 117 | // Is the node in this model | ||
| 118 |
3/4✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 17 times.
|
17 | if (node.model() != _model) { |
| 119 | ✗ | return false; | |
| 120 | } | ||
| 121 | |||
| 122 |
1/1✓ Branch 1 taken 17 times.
|
17 | auto thisObject = getObject<AirLoopHVACReturnPlenum>(); |
| 123 | |||
| 124 |
1/1✓ Branch 1 taken 17 times.
|
17 | auto outletObj = node.outletModelObject(); |
| 125 |
1/1✓ Branch 1 taken 17 times.
|
17 | auto inletObj = node.inletModelObject(); |
| 126 | |||
| 127 | 17 | boost::optional<ZoneHVACComponent> zoneHVAC; | |
| 128 |
1/2✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
|
17 | if (outletObj) { |
| 129 |
2/2✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
|
17 | zoneHVAC = outletObj->optionalCast<ZoneHVACComponent>(); |
| 130 | } | ||
| 131 | |||
| 132 | // Plenum can be attached to ZoneHVAC OR AirLoopHVAC | ||
| 133 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 16 times.
|
17 | if (zoneHVAC) { |
| 134 | // don't let a plenum connect to ZoneHVAC and AirLoopHVAC at the same time | ||
| 135 |
2/3✓ Branch 1 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
|
2 | if (airLoopHVAC()) { |
| 136 | ✗ | result = false; | |
| 137 | } | ||
| 138 | |||
| 139 | 1 | boost::optional<ThermalZone> zone; | |
| 140 | |||
| 141 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (inletObj) { |
| 142 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | auto pl = inletObj->optionalCast<PortList>(); |
| 143 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (pl) { |
| 144 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | zone = pl->thermalZone(); |
| 145 | } | ||
| 146 | 1 | } | |
| 147 | |||
| 148 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!zone) { |
| 149 | ✗ | result = false; | |
| 150 | } | ||
| 151 | |||
| 152 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (result) { |
| 153 |
5/5✓ 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.
|
1 | _model.connect(node, node.outletPort(), thisObject, thisObject.nextInletPort()); |
| 154 | |||
| 155 |
1/1✓ Branch 1 taken 1 time.
|
1 | Node zoneHVACInletNode(_model); |
| 156 |
7/7✓ 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.
|
1 | _model.connect(zoneHVACInletNode, zoneHVACInletNode.outletPort(), zoneHVAC.get(), zoneHVAC->inletPort()); |
| 157 |
1/1✓ Branch 1 taken 1 time.
|
1 | auto pl = inducedAirOutletPortList(); |
| 158 |
5/5✓ 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.
|
1 | _model.connect(pl, pl.nextPort(), zoneHVACInletNode, zoneHVACInletNode.inletPort()); |
| 159 | 1 | } | |
| 160 | 1 | } else { | |
| 161 | // Is the node part of an air loop | ||
| 162 |
1/1✓ Branch 1 taken 16 times.
|
16 | auto nodeAirLoop = node.airLoopHVAC(); |
| 163 | |||
| 164 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
|
16 | if (!nodeAirLoop) { |
| 165 | ✗ | result = false; | |
| 166 | } | ||
| 167 | |||
| 168 | // Is this plenum already connected to a different air loop | ||
| 169 |
1/1✓ Branch 1 taken 16 times.
|
16 | auto currentAirLoopHVAC = airLoopHVAC(); |
| 170 |
6/8✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
✓ Branch 3 taken 8 times.
✓ Branch 6 taken 8 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 8 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 16 times.
|
16 | if (currentAirLoopHVAC && (currentAirLoopHVAC.get() != nodeAirLoop)) { |
| 171 | ✗ | result = false; | |
| 172 | } | ||
| 173 | |||
| 174 | 16 | boost::optional<AirLoopHVACZoneMixer> mixer; | |
| 175 | // Is the immediate downstream object to the node a mixer | ||
| 176 |
1/2✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
|
16 | if (result) { |
| 177 |
3/3✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
|
16 | mixer = nodeAirLoop->zoneMixer(); |
| 178 | |||
| 179 |
7/11✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 8 taken 16 times.
✓ Branch 11 taken 16 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 16 times.
|
32 | if (!(outletObj && mixer && (outletObj.get() == mixer.get()))) { |
| 180 | ✗ | result = false; | |
| 181 | } | ||
| 182 | } | ||
| 183 | |||
| 184 | // Make sure there is not already a return plenum | ||
| 185 |
1/2✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
|
16 | if (result) { |
| 186 |
6/12✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 16 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
48 | if (inletObj && inletObj->optionalCast<AirLoopHVACReturnPlenum>()) { |
| 187 | ✗ | result = false; | |
| 188 | } | ||
| 189 | } | ||
| 190 | |||
| 191 | // Is there a zone on this branch | ||
| 192 |
1/2✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
|
16 | if (result) { |
| 193 |
2/2✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
|
16 | Splitter splitter = nodeAirLoop->zoneSplitter(); |
| 194 |
4/5✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 16 times.
|
16 | if (nodeAirLoop->demandComponents(splitter, node, ThermalZone::iddObjectType()).empty()) { |
| 195 | ✗ | result = false; | |
| 196 | } | ||
| 197 | 16 | } | |
| 198 | |||
| 199 |
1/2✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
|
16 | if (result) { |
| 200 | unsigned inletObjectPort; | ||
| 201 | unsigned outletObjectPort; | ||
| 202 | 16 | boost::optional<ModelObject> inletModelObject; | |
| 203 | 16 | boost::optional<ModelObject> outletModelObject; | |
| 204 | |||
| 205 |
1/1✓ Branch 1 taken 16 times.
|
16 | inletModelObject = node; |
| 206 |
1/1✓ Branch 1 taken 16 times.
|
16 | inletObjectPort = node.outletPort(); |
| 207 |
1/1✓ Branch 1 taken 16 times.
|
16 | outletModelObject = outletObj; |
| 208 |
3/3✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
|
16 | outletObjectPort = node.connectedObjectPort(node.outletPort()).get(); |
| 209 | |||
| 210 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
|
16 | if (currentAirLoopHVAC) { |
| 211 |
5/5✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
✓ Branch 13 taken 8 times.
|
8 | mixer->removePortForBranch(mixer->branchIndexForInletModelObject(inletModelObject.get())); |
| 212 |
5/5✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
✓ Branch 13 taken 8 times.
|
8 | _model.connect(inletModelObject.get(), inletObjectPort, thisObject, thisObject.nextInletPort()); |
| 213 | } else { | ||
| 214 |
1/1✓ Branch 1 taken 8 times.
|
8 | Node plenumOutletNode(_model); |
| 215 |
1/1✓ Branch 1 taken 8 times.
|
8 | plenumOutletNode.createName(); |
| 216 | |||
| 217 |
5/5✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
✓ Branch 13 taken 8 times.
|
8 | _model.connect(inletModelObject.get(), inletObjectPort, thisObject, thisObject.nextInletPort()); |
| 218 |
5/5✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
✓ Branch 13 taken 8 times.
|
8 | _model.connect(thisObject, thisObject.outletPort(), plenumOutletNode, plenumOutletNode.inletPort()); |
| 219 |
5/5✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
✓ Branch 10 taken 8 times.
✓ Branch 13 taken 8 times.
|
8 | _model.connect(plenumOutletNode, plenumOutletNode.outletPort(), outletModelObject.get(), outletObjectPort); |
| 220 | 8 | } | |
| 221 | 16 | } | |
| 222 | 16 | } | |
| 223 | |||
| 224 | 17 | return result; | |
| 225 | 17 | } | |
| 226 | |||
| 227 | ✗ | bool AirLoopHVACReturnPlenum_Impl::addBranchForZone(openstudio::model::ThermalZone& thermalZone) { | |
| 228 | ✗ | boost::optional<HVACComponent> t_terminal; | |
| 229 | |||
| 230 | ✗ | return addBranchForZoneImpl(thermalZone, t_terminal); | |
| 231 | ✗ | } | |
| 232 | |||
| 233 | ✗ | bool AirLoopHVACReturnPlenum_Impl::addBranchForZone(openstudio::model::ThermalZone& thermalZone, HVACComponent& terminal) { | |
| 234 | ✗ | boost::optional<HVACComponent> t_terminal = terminal; | |
| 235 | |||
| 236 | ✗ | return addBranchForZoneImpl(thermalZone, t_terminal); | |
| 237 | ✗ | } | |
| 238 | |||
| 239 | ✗ | bool AirLoopHVACReturnPlenum_Impl::addBranchForZoneImpl(openstudio::model::ThermalZone& thermalZone, boost::optional<HVACComponent>& terminal) { | |
| 240 | ✗ | boost::optional<Splitter> splitter; | |
| 241 | ✗ | boost::optional<Mixer> mixer = getObject<AirLoopHVACReturnPlenum>(); | |
| 242 | |||
| 243 | ✗ | boost::optional<AirLoopHVAC> t_airLoopHVAC = airLoopHVAC(); | |
| 244 | |||
| 245 | ✗ | if (!t_airLoopHVAC) { | |
| 246 | ✗ | return false; | |
| 247 | } | ||
| 248 | |||
| 249 | ✗ | std::vector<ModelObject> supplyPlenums; | |
| 250 | ✗ | supplyPlenums = t_airLoopHVAC->demandComponents(t_airLoopHVAC->demandInletNode(), mixer.get(), AirLoopHVACSupplyPlenum::iddObjectType()); | |
| 251 | |||
| 252 | ✗ | if (supplyPlenums.size() == 1u) { | |
| 253 | ✗ | splitter = supplyPlenums.front().cast<Splitter>(); | |
| 254 | } else { | ||
| 255 | ✗ | splitter = t_airLoopHVAC->zoneSplitter(); | |
| 256 | } | ||
| 257 | |||
| 258 | ✗ | OS_ASSERT(splitter); | |
| 259 | ✗ | OS_ASSERT(mixer); | |
| 260 | |||
| 261 | ✗ | return AirLoopHVAC_Impl::addBranchForZoneImpl(thermalZone, t_airLoopHVAC.get(), splitter.get(), mixer.get(), true, terminal); | |
| 262 | ✗ | } | |
| 263 | |||
| 264 | 4 | std::vector<IdfObject> AirLoopHVACReturnPlenum_Impl::remove() { | |
| 265 |
1/1✓ Branch 1 taken 4 times.
|
4 | Model t_model = model(); |
| 266 | |||
| 267 |
2/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
|
8 | if (boost::optional<AirLoopHVAC> t_airLoopHVAC = airLoopHVAC()) { |
| 268 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | AirLoopHVACZoneMixer zoneMixer = t_airLoopHVAC->zoneMixer(); |
| 269 |
1/1✓ Branch 1 taken 4 times.
|
4 | std::vector<ModelObject> t_inletModelObjects = inletModelObjects(); |
| 270 | |||
| 271 |
2/2✓ Branch 3 taken 10 times.
✓ Branch 4 taken 4 times.
|
14 | for (auto it = t_inletModelObjects.rbegin(); it != t_inletModelObjects.rend(); ++it) { |
| 272 |
1/1✓ Branch 2 taken 10 times.
|
10 | unsigned branchIndex = branchIndexForInletModelObject(*it); |
| 273 |
1/1✓ Branch 1 taken 10 times.
|
10 | unsigned t_inletPort = inletPort(branchIndex); |
| 274 |
2/2✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
|
10 | unsigned connectedObjectOutletPort = connectedObjectPort(t_inletPort).get(); |
| 275 | |||
| 276 |
4/4✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 8 taken 10 times.
✓ Branch 11 taken 10 times.
|
10 | t_model.connect(*it, connectedObjectOutletPort, zoneMixer, zoneMixer.nextInletPort()); |
| 277 | } | ||
| 278 | |||
| 279 |
1/1✓ Branch 1 taken 4 times.
|
4 | boost::optional<ModelObject> mo = outletModelObject(); |
| 280 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
|
4 | OS_ASSERT(mo); |
| 281 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | boost::optional<Node> node = mo->optionalCast<Node>(); |
| 282 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
|
4 | OS_ASSERT(node); |
| 283 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | zoneMixer.removePortForBranch(zoneMixer.branchIndexForInletModelObject(node.get())); |
| 284 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | node->remove(); |
| 285 | 4 | } else { | |
| 286 | ✗ | auto outlet = outletModelObject(); | |
| 287 | ✗ | auto h = handle(); | |
| 288 | |||
| 289 | ✗ | auto zoneHVAC = t_model.getModelObjects<ZoneHVACComponent>(); | |
| 290 | ✗ | for (auto& hvac : zoneHVAC) { | |
| 291 | ✗ | auto plenum = hvac.returnPlenum(); | |
| 292 | ✗ | if (plenum && (plenum->handle() == h)) { | |
| 293 | ✗ | hvac.removeReturnPlenum(); | |
| 294 | } | ||
| 295 | ✗ | } | |
| 296 | |||
| 297 | ✗ | if (outlet) { | |
| 298 | ✗ | outlet->remove(); | |
| 299 | } | ||
| 300 | 4 | } | |
| 301 | |||
| 302 |
1/1✓ Branch 1 taken 4 times.
|
8 | return Mixer_Impl::remove(); |
| 303 | 4 | } | |
| 304 | |||
| 305 | // If every zone on the plenum has exactly one piece of equipment | ||
| 306 | // and that equipment is a ZoneHVACIdealLoadsAirSystem | ||
| 307 | // then return a list of all them, | ||
| 308 | // This is used privatly in the translator to work around an EnergyPlus bug | ||
| 309 | 3 | std::vector<model::ZoneHVACIdealLoadsAirSystem> AirLoopHVACReturnPlenum_Impl::zoneHVACIdealLoadsAirSystems() const { | |
| 310 | 3 | std::vector<model::ZoneHVACIdealLoadsAirSystem> result; | |
| 311 | 3 | bool doworkaround = true; | |
| 312 |
1/1✓ Branch 1 taken 3 times.
|
3 | auto inlets = inletModelObjects(); |
| 313 |
2/2✓ Branch 5 taken 4 times.
✓ Branch 6 taken 3 times.
|
7 | for (const auto& inlet : inlets) { |
| 314 |
1/1✓ Branch 1 taken 4 times.
|
4 | auto node = inlet.optionalCast<Node>(); |
| 315 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (node) { |
| 316 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | auto nodeinlet = node->inletModelObject(); |
| 317 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (nodeinlet) { |
| 318 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | auto pl = nodeinlet->optionalCast<PortList>(); |
| 319 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 time.
|
4 | if (pl) { |
| 320 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | auto zone = pl->thermalZone(); |
| 321 |
1/1✓ Branch 1 taken 3 times.
|
3 | auto equipment = zone.equipment(); |
| 322 |
1/2✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
|
3 | if (equipment.size() < 2) { |
| 323 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (equipment.size() == 1) { |
| 324 | ✗ | auto ideal = equipment.front().optionalCast<ZoneHVACIdealLoadsAirSystem>(); | |
| 325 | ✗ | if (ideal) { | |
| 326 | ✗ | result.push_back(ideal.get()); | |
| 327 | } else { | ||
| 328 | ✗ | doworkaround = false; | |
| 329 | ✗ | break; | |
| 330 | } | ||
| 331 | ✗ | } | |
| 332 | } else { | ||
| 333 | ✗ | doworkaround = false; | |
| 334 | ✗ | break; | |
| 335 | } | ||
| 336 | 3 | } | |
| 337 | 4 | } | |
| 338 | 4 | } | |
| 339 | 4 | } | |
| 340 | |||
| 341 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (!doworkaround) { |
| 342 | ✗ | result.clear(); | |
| 343 | } | ||
| 344 | |||
| 345 | 6 | return result; | |
| 346 | 3 | } | |
| 347 | |||
| 348 | ✗ | ComponentType AirLoopHVACReturnPlenum_Impl::componentType() const { | |
| 349 | ✗ | return ComponentType::None; | |
| 350 | } | ||
| 351 | |||
| 352 | ✗ | std::vector<FuelType> AirLoopHVACReturnPlenum_Impl::coolingFuelTypes() const { | |
| 353 | ✗ | return {}; | |
| 354 | } | ||
| 355 | |||
| 356 | ✗ | std::vector<FuelType> AirLoopHVACReturnPlenum_Impl::heatingFuelTypes() const { | |
| 357 | ✗ | return {}; | |
| 358 | } | ||
| 359 | |||
| 360 | ✗ | std::vector<AppGFuelType> AirLoopHVACReturnPlenum_Impl::appGHeatingFuelTypes() const { | |
| 361 | ✗ | return {}; | |
| 362 | } | ||
| 363 | |||
| 364 | } // namespace detail | ||
| 365 | |||
| 366 | 10 | AirLoopHVACReturnPlenum::AirLoopHVACReturnPlenum(const Model& model) : Mixer(AirLoopHVACReturnPlenum::iddObjectType(), model) { | |
| 367 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
✗ Branch 5 not taken.
|
10 | OS_ASSERT(getImpl<detail::AirLoopHVACReturnPlenum_Impl>()); |
| 368 | 10 | } | |
| 369 | |||
| 370 | 27797 | IddObjectType AirLoopHVACReturnPlenum::iddObjectType() { | |
| 371 |
1/1✓ Branch 1 taken 27797 times.
|
27797 | return {IddObjectType::OS_AirLoopHVAC_ReturnPlenum}; |
| 372 | } | ||
| 373 | |||
| 374 | 77 | boost::optional<ThermalZone> AirLoopHVACReturnPlenum::thermalZone() const { | |
| 375 |
1/1✓ Branch 3 taken 77 times.
|
77 | return getImpl<detail::AirLoopHVACReturnPlenum_Impl>()->thermalZone(); |
| 376 | } | ||
| 377 | |||
| 378 | 9 | bool AirLoopHVACReturnPlenum::setThermalZone(const ThermalZone& thermalZone) { | |
| 379 |
2/2✓ Branch 3 taken 9 times.
✓ Branch 6 taken 9 times.
|
9 | return getImpl<detail::AirLoopHVACReturnPlenum_Impl>()->setThermalZone(thermalZone); |
| 380 | } | ||
| 381 | |||
| 382 | ✗ | void AirLoopHVACReturnPlenum::resetThermalZone() { | |
| 383 | ✗ | getImpl<detail::AirLoopHVACReturnPlenum_Impl>()->resetThermalZone(); | |
| 384 | ✗ | } | |
| 385 | |||
| 386 | 8 | unsigned AirLoopHVACReturnPlenum::outletPort() const { | |
| 387 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::AirLoopHVACReturnPlenum_Impl>()->outletPort(); |
| 388 | } | ||
| 389 | |||
| 390 | 2 | unsigned AirLoopHVACReturnPlenum::inletPort(unsigned branchIndex) const { | |
| 391 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::AirLoopHVACReturnPlenum_Impl>()->inletPort(branchIndex); |
| 392 | } | ||
| 393 | |||
| 394 | 19 | unsigned AirLoopHVACReturnPlenum::nextInletPort() const { | |
| 395 |
1/1✓ Branch 3 taken 19 times.
|
19 | return getImpl<detail::AirLoopHVACReturnPlenum_Impl>()->nextInletPort(); |
| 396 | } | ||
| 397 | |||
| 398 | 17 | bool AirLoopHVACReturnPlenum::addToNode(Node& node) { | |
| 399 |
1/1✓ Branch 3 taken 17 times.
|
17 | return getImpl<detail::AirLoopHVACReturnPlenum_Impl>()->addToNode(node); |
| 400 | } | ||
| 401 | |||
| 402 | ✗ | bool AirLoopHVACReturnPlenum::addBranchForZone(openstudio::model::ThermalZone& thermalZone) { | |
| 403 | ✗ | return getImpl<detail::AirLoopHVACReturnPlenum_Impl>()->addBranchForZone(thermalZone); | |
| 404 | } | ||
| 405 | |||
| 406 | ✗ | bool AirLoopHVACReturnPlenum::addBranchForZone(openstudio::model::ThermalZone& thermalZone, HVACComponent& terminal) { | |
| 407 | ✗ | return getImpl<detail::AirLoopHVACReturnPlenum_Impl>()->addBranchForZone(thermalZone, terminal); | |
| 408 | } | ||
| 409 | |||
| 410 | /// @cond | ||
| 411 |
1/1✓ Branch 3 taken 112 times.
|
112 | AirLoopHVACReturnPlenum::AirLoopHVACReturnPlenum(std::shared_ptr<detail::AirLoopHVACReturnPlenum_Impl> impl) : Mixer(std::move(impl)) {} |
| 412 | /// @endcond | ||
| 413 | |||
| 414 | } // namespace model | ||
| 415 | } // namespace openstudio | ||
| 416 |