src/model/Loop.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 "Loop.hpp" | ||
| 7 | #include "Loop_Impl.hpp" | ||
| 8 | #include "Node.hpp" | ||
| 9 | #include "Node_Impl.hpp" | ||
| 10 | #include "ThermalZone.hpp" | ||
| 11 | #include "ThermalZone_Impl.hpp" | ||
| 12 | #include "PortList.hpp" | ||
| 13 | #include "PortList_Impl.hpp" | ||
| 14 | #include "Splitter.hpp" | ||
| 15 | #include "Splitter_Impl.hpp" | ||
| 16 | #include "Mixer.hpp" | ||
| 17 | #include "Mixer_Impl.hpp" | ||
| 18 | #include "HVACComponent.hpp" | ||
| 19 | #include "HVACComponent_Impl.hpp" | ||
| 20 | #include "StraightComponent.hpp" | ||
| 21 | #include "StraightComponent_Impl.hpp" | ||
| 22 | #include "WaterToAirComponent.hpp" | ||
| 23 | #include "WaterToAirComponent_Impl.hpp" | ||
| 24 | #include "WaterToWaterComponent.hpp" | ||
| 25 | #include "WaterToWaterComponent_Impl.hpp" | ||
| 26 | #include "AirLoopHVACOutdoorAirSystem.hpp" | ||
| 27 | #include "AirLoopHVACOutdoorAirSystem_Impl.hpp" | ||
| 28 | #include "ConnectorSplitter.hpp" | ||
| 29 | #include "ConnectorSplitter_Impl.hpp" | ||
| 30 | #include "Model.hpp" | ||
| 31 | |||
| 32 | #include "../utilities/core/Assert.hpp" | ||
| 33 | #include "../utilities/core/ContainersMove.hpp" | ||
| 34 | #include "../utilities/data/DataEnums.hpp" | ||
| 35 | |||
| 36 | #include <utilities/idd/IddEnums.hxx> | ||
| 37 | |||
| 38 | #include <algorithm> | ||
| 39 | #include <functional> | ||
| 40 | |||
| 41 | namespace openstudio { | ||
| 42 | |||
| 43 | namespace model { | ||
| 44 | |||
| 45 | namespace detail { | ||
| 46 | ✗ | Loop_Impl::Loop_Impl(IddObjectType type, Model_Impl* model) : ParentObject_Impl(type, model) {} | |
| 47 | |||
| 48 | 1277 | Loop_Impl::Loop_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) : ParentObject_Impl(idfObject, model, keepHandle) {} | |
| 49 | |||
| 50 | 57 | Loop_Impl::Loop_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 51 | 57 | : ParentObject_Impl(other, model, keepHandle) {} | |
| 52 | |||
| 53 | 562 | Loop_Impl::Loop_Impl(const Loop_Impl& other, Model_Impl* model, bool keepHandles) : ParentObject_Impl(other, model, keepHandles) {} | |
| 54 | |||
| 55 | ✗ | const std::vector<std::string>& Loop_Impl::outputVariableNames() const { | |
| 56 | ✗ | static const std::vector<std::string> result; | |
| 57 | ✗ | return result; | |
| 58 | } | ||
| 59 | |||
| 60 | ✗ | std::vector<openstudio::IdfObject> Loop_Impl::remove() { | |
| 61 | //ModelObjectVector modelObjects; | ||
| 62 | //ModelObjectVector::iterator it; | ||
| 63 | //modelObjects = this->supplyComponents(); | ||
| 64 | //for(it = modelObjects.begin(); | ||
| 65 | // it != modelObjects.end(); | ||
| 66 | // it++) | ||
| 67 | //{ | ||
| 68 | // if( it->optionalCast<Node>() ) continue; | ||
| 69 | // it->remove(); | ||
| 70 | //} | ||
| 71 | //modelObjects = this->demandComponents(); | ||
| 72 | //for(it = modelObjects.begin(); | ||
| 73 | // it != modelObjects.end(); | ||
| 74 | // it++) | ||
| 75 | //{ | ||
| 76 | // it->remove(); | ||
| 77 | //} | ||
| 78 | ✗ | return ParentObject_Impl::remove(); | |
| 79 | } | ||
| 80 | |||
| 81 | // Recursive depth first search | ||
| 82 | // start algorithm with one source node in the visited vector | ||
| 83 | // searches all paths of nodes between the source and sink until a handle match is found | ||
| 84 | ✗ | boost::optional<ModelObject> findModelObject(const openstudio::Handle& handle, const HVACComponent& sink, std::vector<HVACComponent>& visited, | |
| 85 | bool isDemandComponents) { | ||
| 86 | ✗ | HVACComponent hvacComponent = visited.back(); | |
| 87 | ✗ | if (handle == hvacComponent.handle()) { | |
| 88 | ✗ | return hvacComponent; | |
| 89 | } | ||
| 90 | |||
| 91 | ✗ | boost::optional<HVACComponent> prev; | |
| 92 | ✗ | if (visited.size() >= 2u) { | |
| 93 | ✗ | prev = visited.rbegin()[1]; | |
| 94 | } | ||
| 95 | |||
| 96 | ✗ | std::vector<HVACComponent> nodes = hvacComponent.getImpl<HVACComponent_Impl>()->edges(prev); | |
| 97 | |||
| 98 | ✗ | for (auto& node : nodes) { | |
| 99 | // if it node has already been visited or node is sink then continue | ||
| 100 | ✗ | if (std::find(visited.begin(), visited.end(), node) != visited.end() || node == sink) { | |
| 101 | ✗ | continue; | |
| 102 | } | ||
| 103 | ✗ | visited.push_back(node); | |
| 104 | ✗ | boost::optional<ModelObject> foundHandle = findModelObject(handle, sink, visited, isDemandComponents); | |
| 105 | ✗ | if (foundHandle) { | |
| 106 | ✗ | return *foundHandle; | |
| 107 | } | ||
| 108 | ✗ | visited.pop_back(); | |
| 109 | ✗ | } | |
| 110 | ✗ | return boost::none; | |
| 111 | ✗ | } | |
| 112 | |||
| 113 | 8633 | OptionalModelObject Loop_Impl::component(openstudio::Handle handle) const { | |
| 114 |
1/1✓ Branch 1 taken 8633 times.
|
8633 | boost::optional<ModelObject> supplyComp = this->supplyComponent(handle); |
| 115 |
2/2✓ Branch 0 taken 2406 times.
✓ Branch 1 taken 6227 times.
|
8633 | if (supplyComp) { |
| 116 | 2406 | return supplyComp; | |
| 117 | } | ||
| 118 |
1/1✓ Branch 1 taken 6227 times.
|
6227 | return this->demandComponent(handle); |
| 119 | 8633 | } | |
| 120 | |||
| 121 | 9275 | boost::optional<ModelObject> Loop_Impl::demandComponent(openstudio::Handle handle) const { | |
| 122 |
3/3✓ Branch 1 taken 9275 times.
✓ Branch 4 taken 9275 times.
✓ Branch 7 taken 9275 times.
|
18550 | auto comps = demandComponents(); |
| 123 | |||
| 124 |
3/3✓ Branch 3 taken 9275 times.
✓ Branch 6 taken 70184 times.
✓ Branch 9 taken 70184 times.
|
79459 | auto it = std::find_if(comps.begin(), comps.end(), [&](const ModelObject& comp) { return (comp.handle() == handle); }); |
| 125 |
2/2✓ Branch 2 taken 2997 times.
✓ Branch 3 taken 6278 times.
|
9275 | if (it != comps.end()) { |
| 126 |
1/1✓ Branch 2 taken 2997 times.
|
2997 | return *it; |
| 127 | } | ||
| 128 | |||
| 129 | 6278 | return boost::none; | |
| 130 | 9275 | } | |
| 131 | |||
| 132 | 12225 | boost::optional<ModelObject> Loop_Impl::supplyComponent(openstudio::Handle handle) const { | |
| 133 |
3/3✓ Branch 1 taken 12225 times.
✓ Branch 4 taken 12225 times.
✓ Branch 7 taken 12225 times.
|
24450 | auto comps = supplyComponents(); |
| 134 | |||
| 135 |
3/3✓ Branch 3 taken 12225 times.
✓ Branch 6 taken 59461 times.
✓ Branch 9 taken 59461 times.
|
71686 | auto it = std::find_if(comps.begin(), comps.end(), [&](const ModelObject& comp) { return (comp.handle() == handle); }); |
| 136 |
2/2✓ Branch 2 taken 5176 times.
✓ Branch 3 taken 7049 times.
|
12225 | if (it != comps.end()) { |
| 137 |
1/1✓ Branch 2 taken 5176 times.
|
5176 | return *it; |
| 138 | } | ||
| 139 | |||
| 140 | 7049 | return boost::none; | |
| 141 | 12225 | } | |
| 142 | |||
| 143 | 12 | ModelObject Loop_Impl::clone(Model model) const { | |
| 144 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | return ParentObject_Impl::clone(model); |
| 145 | } | ||
| 146 | |||
| 147 | ✗ | std::vector<ModelObject> Loop_Impl::children() const { | |
| 148 | ✗ | return {}; | |
| 149 | } | ||
| 150 | |||
| 151 | // std::vector<ModelObject> Loop_Impl::supplyComponents(std::vector<HVACComponent> /*inletComps*/, std::vector<HVACComponent> /*outletComps*/, | ||
| 152 | // openstudio::IddObjectType /*type*/) const { | ||
| 153 | // LOG(Warn, "supplyComponents method for " << briefDescription() << " is not implemented to take multiple inlet and outlet components"); | ||
| 154 | // return {}; | ||
| 155 | // } | ||
| 156 | |||
| 157 | // std::vector<ModelObject> Loop_Impl::demandComponents(std::vector<HVACComponent> /*inletComps*/, std::vector<HVACComponent> /*outletComps*/, | ||
| 158 | // openstudio::IddObjectType /*type*/) const { | ||
| 159 | // return {}; | ||
| 160 | // } | ||
| 161 | |||
| 162 | ✗ | boost::optional<ModelObject> Loop_Impl::supplyInletNodeAsModelObject() const { | |
| 163 | ✗ | OptionalModelObject result = supplyInletNode(); | |
| 164 | ✗ | return result; | |
| 165 | } | ||
| 166 | |||
| 167 | ✗ | boost::optional<ModelObject> Loop_Impl::supplyOutletNodeAsModelObject() const { | |
| 168 | ✗ | OptionalModelObject result = supplyOutletNode(); | |
| 169 | ✗ | return result; | |
| 170 | } | ||
| 171 | |||
| 172 | ✗ | boost::optional<ModelObject> Loop_Impl::demandInletNodeAsModelObject() const { | |
| 173 | ✗ | OptionalModelObject result = demandInletNode(); | |
| 174 | ✗ | return result; | |
| 175 | } | ||
| 176 | |||
| 177 | ✗ | boost::optional<ModelObject> Loop_Impl::demandOutletNodeAsModelObject() const { | |
| 178 | ✗ | OptionalModelObject result = demandOutletNode(); | |
| 179 | ✗ | return result; | |
| 180 | } | ||
| 181 | |||
| 182 | // Recursive depth first search | ||
| 183 | // start algorithm with one source node in the visited vector | ||
| 184 | // when complete, paths will be populated with all nodes between the source node and sink | ||
| 185 | 205023 | void findModelObjects(const HVACComponent& sink, std::vector<HVACComponent>& visited, std::vector<HVACComponent>& paths, | |
| 186 | bool isDemandComponents) { | ||
| 187 | 205023 | boost::optional<HVACComponent> prev; | |
| 188 |
2/2✓ Branch 1 taken 167729 times.
✓ Branch 2 taken 37294 times.
|
205023 | if (visited.size() >= 2u) { |
| 189 |
2/2✓ Branch 2 taken 167729 times.
✓ Branch 5 taken 167729 times.
|
167729 | prev = visited.rbegin()[1]; |
| 190 | } | ||
| 191 | |||
| 192 |
1/1✓ Branch 4 taken 205023 times.
|
205023 | std::vector<HVACComponent> nodes = visited.back().getImpl<HVACComponent_Impl>()->edges(prev); |
| 193 | |||
| 194 |
2/2✓ Branch 5 taken 211758 times.
✓ Branch 6 taken 205023 times.
|
416781 | for (const auto& node : nodes) { |
| 195 | // if it node has already been visited then continue | ||
| 196 |
2/3✓ Branch 4 taken 211758 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 211758 times.
|
211758 | if (std::find(visited.begin(), visited.end(), node) != visited.end()) { |
| 197 | ✗ | continue; | |
| 198 | } | ||
| 199 |
3/3✓ Branch 1 taken 211758 times.
✓ Branch 3 taken 44029 times.
✓ Branch 4 taken 167729 times.
|
211758 | if (node == sink) { |
| 200 |
1/1✓ Branch 1 taken 44029 times.
|
44029 | visited.push_back(node); |
| 201 | // Avoid pushing duplicate nodes into paths | ||
| 202 |
2/2✓ Branch 1 taken 36893 times.
✓ Branch 2 taken 7136 times.
|
44029 | if (paths.empty()) { |
| 203 |
1/1✓ Branch 5 taken 36893 times.
|
36893 | paths.insert(paths.end(), visited.begin(), visited.end()); |
| 204 | } else { | ||
| 205 |
2/2✓ Branch 5 taken 55077 times.
✓ Branch 6 taken 7136 times.
|
62213 | for (const auto& visitedit : visited) { |
| 206 |
3/3✓ Branch 4 taken 55077 times.
✓ Branch 7 taken 23220 times.
✓ Branch 8 taken 31857 times.
|
55077 | if (std::find(paths.begin(), paths.end(), visitedit) == paths.end()) { |
| 207 |
1/1✓ Branch 1 taken 23220 times.
|
23220 | paths.push_back(visitedit); |
| 208 | } | ||
| 209 | } | ||
| 210 | } | ||
| 211 | 44029 | visited.pop_back(); | |
| 212 | } | ||
| 213 | } | ||
| 214 | |||
| 215 |
2/2✓ Branch 5 taken 211758 times.
✓ Branch 6 taken 205023 times.
|
416781 | for (const auto& node : nodes) { |
| 216 | // if it node has already been visited or node is sink then continue | ||
| 217 |
7/8✓ Branch 4 taken 211758 times.
✓ Branch 7 taken 211758 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 211758 times.
✓ Branch 12 taken 44029 times.
✓ Branch 13 taken 167729 times.
✓ Branch 14 taken 44029 times.
✓ Branch 15 taken 167729 times.
|
211758 | if (std::find(visited.begin(), visited.end(), node) != visited.end() || node == sink) { |
| 218 | 44029 | continue; | |
| 219 | } | ||
| 220 |
1/1✓ Branch 1 taken 167729 times.
|
167729 | visited.push_back(node); |
| 221 |
1/1✓ Branch 1 taken 167729 times.
|
167729 | findModelObjects(sink, visited, paths, isDemandComponents); |
| 222 | 167729 | visited.pop_back(); | |
| 223 | } | ||
| 224 | 205023 | } | |
| 225 | |||
| 226 | 15110 | std::vector<ModelObject> Loop_Impl::demandComponents(const HVACComponent& inletComp, const HVACComponent& outletComp, | |
| 227 | openstudio::IddObjectType type) const { | ||
| 228 | 15110 | std::vector<HVACComponent> visited; | |
| 229 |
1/1✓ Branch 1 taken 15110 times.
|
15110 | visited.push_back(inletComp); |
| 230 | 15110 | std::vector<HVACComponent> allPaths; | |
| 231 | |||
| 232 |
3/3✓ Branch 1 taken 15110 times.
✓ Branch 3 taken 160 times.
✓ Branch 4 taken 14950 times.
|
15110 | if (inletComp == outletComp) { |
| 233 |
1/1✓ Branch 1 taken 160 times.
|
160 | allPaths.push_back(inletComp); |
| 234 | } else { | ||
| 235 |
1/1✓ Branch 1 taken 14950 times.
|
14950 | findModelObjects(outletComp, visited, allPaths, true); |
| 236 | } | ||
| 237 |
1/1✓ Branch 3 taken 15110 times.
|
15110 | std::vector<ModelObject> modelObjects = std::vector<ModelObject>(allPaths.begin(), allPaths.end()); |
| 238 | |||
| 239 | // Filter modelObjects for type | ||
| 240 |
3/3✓ Branch 1 taken 15110 times.
✓ Branch 4 taken 2804 times.
✓ Branch 5 taken 12306 times.
|
15110 | if (type != IddObjectType::Catchall) { |
| 241 |
1/1✓ Branch 3 taken 2804 times.
|
5608 | modelObjects.erase( |
| 242 |
2/2✓ Branch 1 taken 15710 times.
✓ Branch 7 taken 2804 times.
|
18514 | std::remove_if(modelObjects.begin(), modelObjects.end(), [&](const auto& mo) -> bool { return mo.iddObjectType() != type; }), |
| 243 | 5608 | modelObjects.end()); | |
| 244 | } | ||
| 245 | 30220 | return modelObjects; | |
| 246 | 15110 | } | |
| 247 | |||
| 248 | template <typename T> | ||
| 249 | struct Duplicate | ||
| 250 | { | ||
| 251 | 3692 | bool operator()(const T& element) { | |
| 252 | 3692 | return !s_.insert(element).second; // true if element already in set | |
| 253 | } | ||
| 254 | |||
| 255 | private: | ||
| 256 | std::set<T> s_; | ||
| 257 | }; | ||
| 258 | |||
| 259 | 20113 | std::vector<ModelObject> Loop_Impl::supplyComponents(openstudio::IddObjectType type) const { | |
| 260 | 20113 | std::vector<ModelObject> result; | |
| 261 | |||
| 262 |
1/1✓ Branch 1 taken 20113 times.
|
20113 | auto t_supplyInletNode = supplyInletNode(); |
| 263 |
1/1✓ Branch 1 taken 20113 times.
|
20113 | auto t_supplyOutletNodes = supplyOutletNodes(); |
| 264 | |||
| 265 |
2/2✓ Branch 5 taken 20520 times.
✓ Branch 6 taken 20113 times.
|
40633 | for (auto const& t_supplyOutletNode : t_supplyOutletNodes) { |
| 266 |
1/1✓ Branch 1 taken 20520 times.
|
20520 | auto components = supplyComponents(t_supplyInletNode, t_supplyOutletNode, type); |
| 267 |
1/1✓ Branch 5 taken 20520 times.
|
20520 | result.insert(result.end(), components.begin(), components.end()); |
| 268 | 20520 | } | |
| 269 | |||
| 270 | // If there is more than one outlet node (dual duct) we might have duplicates | ||
| 271 |
2/2✓ Branch 1 taken 407 times.
✓ Branch 2 taken 19706 times.
|
20113 | if (t_supplyOutletNodes.size() > 1u) { |
| 272 | 407 | Duplicate<ModelObject> pred; | |
| 273 |
1/1✓ Branch 4 taken 407 times.
|
407 | auto it = std::remove_if(result.begin(), result.end(), std::ref(pred)); |
| 274 |
1/1✓ Branch 2 taken 407 times.
|
814 | return {result.begin(), it}; |
| 275 | 407 | } else { | |
| 276 | 19706 | return result; | |
| 277 | } | ||
| 278 | 20113 | } | |
| 279 | |||
| 280 | 12351 | std::vector<ModelObject> Loop_Impl::demandComponents(openstudio::IddObjectType type) const { | |
| 281 | 12351 | std::vector<ModelObject> result; | |
| 282 | |||
| 283 |
1/1✓ Branch 1 taken 12351 times.
|
12351 | auto t_demandOutletNode = demandOutletNode(); |
| 284 |
1/1✓ Branch 1 taken 12351 times.
|
12351 | auto t_demandInletNodes = demandInletNodes(); |
| 285 | |||
| 286 |
2/2✓ Branch 5 taken 12445 times.
✓ Branch 6 taken 12351 times.
|
24796 | for (auto const& t_demandInletNode : t_demandInletNodes) { |
| 287 |
1/1✓ Branch 1 taken 12445 times.
|
12445 | auto components = demandComponents(t_demandInletNode, t_demandOutletNode, type); |
| 288 |
1/1✓ Branch 5 taken 12445 times.
|
12445 | result.insert(result.end(), components.begin(), components.end()); |
| 289 | 12445 | } | |
| 290 | |||
| 291 | // If there is more than one inlet node (dual duct) we might have duplicates | ||
| 292 |
2/2✓ Branch 1 taken 94 times.
✓ Branch 2 taken 12257 times.
|
12351 | if (t_demandInletNodes.size() > 1u) { |
| 293 | 94 | Duplicate<ModelObject> pred; | |
| 294 |
1/1✓ Branch 4 taken 94 times.
|
94 | auto it = std::remove_if(result.begin(), result.end(), std::ref(pred)); |
| 295 |
1/1✓ Branch 2 taken 94 times.
|
188 | return {result.begin(), it}; |
| 296 | 94 | } else { | |
| 297 | 12257 | return result; | |
| 298 | } | ||
| 299 | 12351 | } | |
| 300 | |||
| 301 | 119 | std::vector<ModelObject> Loop_Impl::components(openstudio::IddObjectType type) const { | |
| 302 |
3/3✓ Branch 1 taken 119 times.
✓ Branch 4 taken 119 times.
✓ Branch 7 taken 119 times.
|
119 | return openstudio::concat<ModelObject>(this->supplyComponents(type), this->demandComponents(type)); |
| 303 | } | ||
| 304 | |||
| 305 | 22507 | std::vector<ModelObject> Loop_Impl::supplyComponents(const HVACComponent& inletComp, const HVACComponent& outletComp, | |
| 306 | openstudio::IddObjectType type) const { | ||
| 307 | 22507 | std::vector<HVACComponent> visited; | |
| 308 |
1/1✓ Branch 1 taken 22507 times.
|
22507 | visited.push_back(inletComp); |
| 309 | 22507 | std::vector<HVACComponent> allPaths; | |
| 310 | |||
| 311 |
3/3✓ Branch 1 taken 22507 times.
✓ Branch 3 taken 163 times.
✓ Branch 4 taken 22344 times.
|
22507 | if (inletComp == outletComp) { |
| 312 |
1/1✓ Branch 1 taken 163 times.
|
163 | allPaths.push_back(inletComp); |
| 313 | } else { | ||
| 314 |
1/1✓ Branch 1 taken 22344 times.
|
22344 | findModelObjects(outletComp, visited, allPaths, false); |
| 315 | } | ||
| 316 |
1/1✓ Branch 3 taken 22507 times.
|
22507 | std::vector<ModelObject> modelObjects = std::vector<ModelObject>(allPaths.begin(), allPaths.end()); |
| 317 | |||
| 318 | // Filter modelObjects for type | ||
| 319 |
3/3✓ Branch 1 taken 22507 times.
✓ Branch 4 taken 4343 times.
✓ Branch 5 taken 18164 times.
|
22507 | if (type != IddObjectType::Catchall) { |
| 320 |
1/1✓ Branch 3 taken 4343 times.
|
8686 | modelObjects.erase( |
| 321 |
2/2✓ Branch 1 taken 21785 times.
✓ Branch 7 taken 4343 times.
|
26128 | std::remove_if(modelObjects.begin(), modelObjects.end(), [&](const auto& mo) -> bool { return mo.iddObjectType() != type; }), |
| 322 | 8686 | modelObjects.end()); | |
| 323 | } | ||
| 324 | 45014 | return modelObjects; | |
| 325 | 22507 | } | |
| 326 | |||
| 327 | 66 | std::vector<ModelObject> Loop_Impl::components(const HVACComponent& inletComp, const HVACComponent& outletComp, | |
| 328 | openstudio::IddObjectType type) const { | ||
| 329 |
12/18✓ Branch 1 taken 66 times.
✓ Branch 4 taken 66 times.
✓ Branch 7 taken 14 times.
✓ Branch 8 taken 52 times.
✓ Branch 10 taken 14 times.
✓ Branch 13 taken 14 times.
✓ Branch 16 taken 14 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 14 times.
✓ Branch 19 taken 52 times.
✓ Branch 21 taken 66 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 14 times.
✓ Branch 25 taken 52 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
146 | if ((supplyComponent(inletComp.handle()) && supplyComponent(outletComp.handle()))) { |
| 330 | 14 | return supplyComponents(inletComp, outletComp, type); | |
| 331 |
9/18✓ Branch 1 taken 52 times.
✓ Branch 4 taken 52 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 52 times.
✓ Branch 13 taken 52 times.
✓ Branch 16 taken 52 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 52 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 52 times.
✗ Branch 22 not taken.
✓ Branch 24 taken 52 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
|
156 | } else if ((demandComponent(inletComp.handle()) && demandComponent(outletComp.handle()))) { |
| 332 | 52 | return demandComponents(inletComp, outletComp, type); | |
| 333 | } | ||
| 334 | |||
| 335 | ✗ | return {}; | |
| 336 | } | ||
| 337 | |||
| 338 | // default implementation does nothing. | ||
| 339 | // should only be used by objects that have | ||
| 340 | // no autosized fields | ||
| 341 | ✗ | void Loop_Impl::autosize() {} | |
| 342 | |||
| 343 | // default implementation does nothing. | ||
| 344 | // should only be used by objects that have | ||
| 345 | // no autosized fields | ||
| 346 | ✗ | void Loop_Impl::applySizingValues() {} | |
| 347 | |||
| 348 | 27 | ComponentType Loop_Impl::componentType() const { | |
| 349 | 27 | bool has_cooling = false; | |
| 350 | 27 | bool has_heating = false; | |
| 351 |
6/6✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
✓ Branch 7 taken 27 times.
✓ Branch 10 taken 27 times.
✓ Branch 19 taken 196 times.
✓ Branch 20 taken 27 times.
|
277 | for (const auto& comp : subsetCastVector<HVACComponent>(supplyComponents())) { |
| 352 |
1/1✓ Branch 1 taken 196 times.
|
196 | auto compType = comp.componentType(); |
| 353 |
3/3✓ Branch 1 taken 196 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 192 times.
|
196 | if (compType == ComponentType::Cooling) { |
| 354 | 4 | has_cooling = true; | |
| 355 |
3/3✓ Branch 1 taken 192 times.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 169 times.
|
192 | } else if (compType == ComponentType::Heating) { |
| 356 | 23 | has_heating = true; | |
| 357 |
3/3✓ Branch 1 taken 169 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 167 times.
|
169 | } else if (compType == ComponentType::Both) { |
| 358 | 2 | has_cooling = true; | |
| 359 | 2 | has_heating = true; | |
| 360 | } | ||
| 361 | 27 | } | |
| 362 | |||
| 363 |
4/4✓ Branch 0 taken 6 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 1 time.
|
27 | if (has_cooling && has_heating) { |
| 364 |
1/1✓ Branch 1 taken 5 times.
|
5 | return ComponentType::Both; |
| 365 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 21 times.
|
22 | } else if (has_cooling) { |
| 366 |
1/1✓ Branch 1 taken 1 time.
|
1 | return ComponentType::Cooling; |
| 367 |
2/2✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1 time.
|
21 | } else if (has_heating) { |
| 368 |
1/1✓ Branch 1 taken 20 times.
|
20 | return ComponentType::Heating; |
| 369 | } | ||
| 370 |
1/1✓ Branch 1 taken 1 time.
|
1 | return ComponentType::None; |
| 371 | } | ||
| 372 | |||
| 373 | 27 | std::vector<FuelType> Loop_Impl::coolingFuelTypes() const { | |
| 374 | 27 | std::set<FuelType> result; | |
| 375 |
6/6✓ Branch 1 taken 27 times.
✓ Branch 4 taken 27 times.
✓ Branch 7 taken 27 times.
✓ Branch 10 taken 27 times.
✓ Branch 19 taken 183 times.
✓ Branch 20 taken 27 times.
|
264 | for (const auto& comp : subsetCastVector<HVACComponent>(supplyComponents())) { |
| 376 |
3/3✓ Branch 1 taken 183 times.
✓ Branch 8 taken 10 times.
✓ Branch 9 taken 183 times.
|
193 | for (auto& ft : comp.coolingFuelTypes()) { |
| 377 |
1/1✓ Branch 1 taken 10 times.
|
10 | result.insert(ft); |
| 378 | 183 | } | |
| 379 | 27 | } | |
| 380 |
1/1✓ Branch 3 taken 27 times.
|
81 | return {result.begin(), result.end()}; |
| 381 | 27 | } | |
| 382 | |||
| 383 | 43 | std::vector<FuelType> Loop_Impl::heatingFuelTypes() const { | |
| 384 | 43 | std::set<FuelType> result; | |
| 385 |
6/6✓ Branch 1 taken 43 times.
✓ Branch 4 taken 43 times.
✓ Branch 7 taken 43 times.
✓ Branch 10 taken 43 times.
✓ Branch 19 taken 297 times.
✓ Branch 20 taken 43 times.
|
426 | for (const auto& comp : subsetCastVector<HVACComponent>(supplyComponents())) { |
| 386 |
3/3✓ Branch 1 taken 297 times.
✓ Branch 8 taken 38 times.
✓ Branch 9 taken 297 times.
|
335 | for (auto& ft : comp.heatingFuelTypes()) { |
| 387 |
1/1✓ Branch 1 taken 38 times.
|
38 | result.insert(ft); |
| 388 | 297 | } | |
| 389 | 43 | } | |
| 390 |
1/1✓ Branch 3 taken 43 times.
|
129 | return {result.begin(), result.end()}; |
| 391 | 43 | } | |
| 392 | |||
| 393 | 41 | std::vector<AppGFuelType> Loop_Impl::appGHeatingFuelTypes() const { | |
| 394 | 41 | std::set<AppGFuelType> result; | |
| 395 |
6/6✓ Branch 1 taken 41 times.
✓ Branch 4 taken 41 times.
✓ Branch 7 taken 41 times.
✓ Branch 10 taken 41 times.
✓ Branch 19 taken 285 times.
✓ Branch 20 taken 41 times.
|
408 | for (const auto& comp : subsetCastVector<HVACComponent>(supplyComponents())) { |
| 396 |
3/3✓ Branch 1 taken 285 times.
✓ Branch 8 taken 37 times.
✓ Branch 9 taken 285 times.
|
322 | for (auto& ft : comp.appGHeatingFuelTypes()) { |
| 397 |
1/1✓ Branch 1 taken 37 times.
|
37 | result.insert(ft); |
| 398 | 285 | } | |
| 399 | 41 | } | |
| 400 |
1/1✓ Branch 3 taken 41 times.
|
123 | return {result.begin(), result.end()}; |
| 401 | 41 | } | |
| 402 | |||
| 403 | } // namespace detail | ||
| 404 | |||
| 405 | 1219 | Loop::Loop(IddObjectType type, const Model& model) : ParentObject(type, model) { | |
| 406 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 1219 times.
✗ Branch 5 not taken.
|
1219 | OS_ASSERT(getImpl<detail::Loop_Impl>()); |
| 407 | 1219 | } | |
| 408 | |||
| 409 |
1/1✓ Branch 3 taken 19367 times.
|
19367 | Loop::Loop(std::shared_ptr<detail::Loop_Impl> impl) : ParentObject(std::move(impl)) {} |
| 410 | |||
| 411 | 1 | std::vector<IdfObject> Loop::remove() { | |
| 412 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::Loop_Impl>()->remove(); |
| 413 | } | ||
| 414 | |||
| 415 | 101 | std::vector<ModelObject> Loop::components(openstudio::IddObjectType type) const { | |
| 416 |
1/1✓ Branch 3 taken 101 times.
|
101 | return getImpl<detail::Loop_Impl>()->components(type); |
| 417 | } | ||
| 418 | |||
| 419 | 18 | std::vector<ModelObject> Loop::components(const HVACComponent& inletComp, const HVACComponent& outletComp, openstudio::IddObjectType type) { | |
| 420 |
1/1✓ Branch 3 taken 18 times.
|
18 | return getImpl<detail::Loop_Impl>()->components(inletComp, outletComp, type); |
| 421 | } | ||
| 422 | |||
| 423 | 8633 | boost::optional<ModelObject> Loop::component(openstudio::Handle handle) const { | |
| 424 |
1/1✓ Branch 3 taken 8633 times.
|
8633 | return getImpl<detail::Loop_Impl>()->component(handle); |
| 425 | } | ||
| 426 | |||
| 427 | // std::vector<ModelObject> Loop::supplyComponents(std::vector<HVACComponent> inletComps, std::vector<HVACComponent> outletComps, | ||
| 428 | // openstudio::IddObjectType type) const { | ||
| 429 | // return getImpl<detail::Loop_Impl>()->supplyComponents(inletComps, outletComps, type); | ||
| 430 | // } | ||
| 431 | |||
| 432 | // std::vector<ModelObject> Loop::demandComponents(std::vector<HVACComponent> inletComps, std::vector<HVACComponent> outletComps, | ||
| 433 | // openstudio::IddObjectType type) const { | ||
| 434 | // return getImpl<detail::Loop_Impl>()->demandComponents(inletComps, outletComps, type); | ||
| 435 | // } | ||
| 436 | |||
| 437 | 1889 | std::vector<ModelObject> Loop::supplyComponents(const HVACComponent& inletComp, const HVACComponent& outletComp, | |
| 438 | openstudio::IddObjectType type) const { | ||
| 439 |
1/1✓ Branch 3 taken 1889 times.
|
1889 | return getImpl<detail::Loop_Impl>()->supplyComponents(inletComp, outletComp, type); |
| 440 | } | ||
| 441 | |||
| 442 | 3650 | std::vector<ModelObject> Loop::supplyComponents(openstudio::IddObjectType type) const { | |
| 443 |
1/1✓ Branch 3 taken 3650 times.
|
3650 | return getImpl<detail::Loop_Impl>()->supplyComponents(type); |
| 444 | } | ||
| 445 | |||
| 446 | 2485 | std::vector<ModelObject> Loop::demandComponents(const HVACComponent& inletComp, const HVACComponent& outletComp, | |
| 447 | openstudio::IddObjectType type) const { | ||
| 448 |
1/1✓ Branch 3 taken 2485 times.
|
2485 | return getImpl<detail::Loop_Impl>()->demandComponents(inletComp, outletComp, type); |
| 449 | } | ||
| 450 | |||
| 451 | 1353 | std::vector<ModelObject> Loop::demandComponents(openstudio::IddObjectType type) const { | |
| 452 |
1/1✓ Branch 3 taken 1353 times.
|
1353 | return getImpl<detail::Loop_Impl>()->demandComponents(type); |
| 453 | } | ||
| 454 | |||
| 455 | ✗ | ModelObject Loop::clone(Model model) const { | |
| 456 | ✗ | return getImpl<detail::Loop_Impl>()->clone(model); | |
| 457 | } | ||
| 458 | |||
| 459 | ✗ | std::vector<ModelObject> Loop::children() const { | |
| 460 | ✗ | return getImpl<detail::Loop_Impl>()->children(); | |
| 461 | } | ||
| 462 | |||
| 463 | 2923 | boost::optional<ModelObject> Loop::demandComponent(openstudio::Handle handle) const { | |
| 464 |
1/1✓ Branch 3 taken 2923 times.
|
2923 | return getImpl<detail::Loop_Impl>()->demandComponent(handle); |
| 465 | } | ||
| 466 | |||
| 467 | 3509 | boost::optional<ModelObject> Loop::supplyComponent(openstudio::Handle handle) const { | |
| 468 |
1/1✓ Branch 3 taken 3509 times.
|
3509 | return getImpl<detail::Loop_Impl>()->supplyComponent(handle); |
| 469 | } | ||
| 470 | |||
| 471 | 864 | Node Loop::supplyInletNode() const { | |
| 472 |
1/1✓ Branch 3 taken 864 times.
|
864 | return getImpl<detail::Loop_Impl>()->supplyInletNode(); |
| 473 | } | ||
| 474 | |||
| 475 | 45 | Node Loop::supplyOutletNode() const { | |
| 476 |
1/1✓ Branch 3 taken 45 times.
|
45 | return getImpl<detail::Loop_Impl>()->supplyOutletNode(); |
| 477 | } | ||
| 478 | |||
| 479 | 819 | std::vector<Node> Loop::supplyOutletNodes() const { | |
| 480 |
1/1✓ Branch 3 taken 819 times.
|
819 | return getImpl<detail::Loop_Impl>()->supplyOutletNodes(); |
| 481 | } | ||
| 482 | |||
| 483 | 116 | Node Loop::demandInletNode() const { | |
| 484 |
1/1✓ Branch 3 taken 116 times.
|
116 | return getImpl<detail::Loop_Impl>()->demandInletNode(); |
| 485 | } | ||
| 486 | |||
| 487 | ✗ | std::vector<Node> Loop::demandInletNodes() const { | |
| 488 | ✗ | return getImpl<detail::Loop_Impl>()->demandInletNodes(); | |
| 489 | } | ||
| 490 | |||
| 491 | 116 | Node Loop::demandOutletNode() const { | |
| 492 |
1/1✓ Branch 3 taken 116 times.
|
116 | return getImpl<detail::Loop_Impl>()->demandOutletNode(); |
| 493 | } | ||
| 494 | |||
| 495 | 378 | Splitter Loop::demandSplitter() const { | |
| 496 |
1/1✓ Branch 3 taken 378 times.
|
378 | return getImpl<detail::Loop_Impl>()->demandSplitter(); |
| 497 | } | ||
| 498 | |||
| 499 | 7 | Mixer Loop::demandMixer() const { | |
| 500 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::Loop_Impl>()->demandMixer(); |
| 501 | } | ||
| 502 | |||
| 503 | ✗ | void Loop::autosize() { | |
| 504 | ✗ | return getImpl<detail::Loop_Impl>()->autosize(); | |
| 505 | } | ||
| 506 | |||
| 507 | ✗ | void Loop::applySizingValues() { | |
| 508 | ✗ | return getImpl<detail::Loop_Impl>()->applySizingValues(); | |
| 509 | } | ||
| 510 | |||
| 511 | 27 | ComponentType Loop::componentType() const { | |
| 512 |
1/1✓ Branch 3 taken 27 times.
|
27 | return getImpl<detail::Loop_Impl>()->componentType(); |
| 513 | } | ||
| 514 | |||
| 515 | 27 | std::vector<FuelType> Loop::coolingFuelTypes() const { | |
| 516 |
1/1✓ Branch 3 taken 27 times.
|
27 | return getImpl<detail::Loop_Impl>()->coolingFuelTypes(); |
| 517 | } | ||
| 518 | |||
| 519 | 43 | std::vector<FuelType> Loop::heatingFuelTypes() const { | |
| 520 |
1/1✓ Branch 3 taken 43 times.
|
43 | return getImpl<detail::Loop_Impl>()->heatingFuelTypes(); |
| 521 | } | ||
| 522 | |||
| 523 | 41 | std::vector<AppGFuelType> Loop::appGHeatingFuelTypes() const { | |
| 524 |
1/1✓ Branch 3 taken 41 times.
|
41 | return getImpl<detail::Loop_Impl>()->appGHeatingFuelTypes(); |
| 525 | } | ||
| 526 | |||
| 527 | } // namespace model | ||
| 528 | |||
| 529 | } // namespace openstudio | ||
| 530 |