GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 51.4% 55 / 0 / 107
Functions: 59.3% 16 / 0 / 27
Branches: 41.3% 45 / 0 / 109

src/model/AirLoopHVACZoneSplitter.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 "AirLoopHVAC.hpp"
7 #include "AirLoopHVACZoneSplitter.hpp"
8 #include "AirLoopHVACZoneSplitter_Impl.hpp"
9 #include "AirflowNetworkDistributionNode.hpp"
10 #include "AirflowNetworkDistributionNode_Impl.hpp"
11 #include "HVACComponent.hpp"
12 #include "HVACComponent_Impl.hpp"
13 #include "Node.hpp"
14 #include "ThermalZone.hpp"
15 #include "ThermalZone_Impl.hpp"
16 #include "Model.hpp"
17 #include "Model_Impl.hpp"
18 #include <utilities/idd/OS_AirLoopHVAC_ZoneSplitter_FieldEnums.hxx>
19 #include <utilities/idd/IddEnums.hxx>
20 #include "../utilities/core/Compare.hpp"
21 #include "../utilities/core/Assert.hpp"
22 #include "../utilities/data/DataEnums.hpp"
23
24 namespace openstudio {
25 namespace model {
26
27 namespace detail {
28
29 776 AirLoopHVACZoneSplitter_Impl::AirLoopHVACZoneSplitter_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
30 776 : Splitter_Impl(idfObject, model, keepHandle) {
31
4/6
✓ Branch 1 taken 776 times.
✓ Branch 4 taken 776 times.
✓ Branch 7 taken 776 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 776 times.
✗ Branch 13 not taken.
776 OS_ASSERT(idfObject.iddObject().type() == AirLoopHVACZoneSplitter::iddObjectType());
32 776 }
33
34 43 AirLoopHVACZoneSplitter_Impl::AirLoopHVACZoneSplitter_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model,
35 43 bool keepHandle)
36 43 : Splitter_Impl(other, model, keepHandle) {
37
4/6
✓ Branch 1 taken 43 times.
✓ Branch 4 taken 43 times.
✓ Branch 7 taken 43 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 43 times.
✗ Branch 13 not taken.
43 OS_ASSERT(other.iddObject().type() == AirLoopHVACZoneSplitter::iddObjectType());
38 43 }
39
40 268 AirLoopHVACZoneSplitter_Impl::AirLoopHVACZoneSplitter_Impl(const AirLoopHVACZoneSplitter_Impl& other, Model_Impl* model, bool keepHandle)
41 268 : Splitter_Impl(other, model, keepHandle) {}
42
43 1 const std::vector<std::string>& AirLoopHVACZoneSplitter_Impl::outputVariableNames() const {
44
2/4
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
1 static const std::vector<std::string> result;
45 // Not Appropriate: No variables available
46 1 return result;
47 }
48
49 2981 IddObjectType AirLoopHVACZoneSplitter_Impl::iddObjectType() const {
50 2981 return AirLoopHVACZoneSplitter::iddObjectType();
51 }
52
53 228 std::vector<ModelObject> AirLoopHVACZoneSplitter_Impl::children() const {
54 228 std::vector<ModelObject> result;
55
56 std::vector<AirflowNetworkDistributionNode> myAFNItems =
57
3/3
✓ Branch 1 taken 228 times.
✓ Branch 4 taken 228 times.
✓ Branch 7 taken 228 times.
228 getObject<ModelObject>().getModelObjectSources<AirflowNetworkDistributionNode>(AirflowNetworkDistributionNode::iddObjectType());
58
1/1
✓ Branch 5 taken 228 times.
228 result.insert(result.end(), myAFNItems.begin(), myAFNItems.end());
59
60 456 return result;
61 228 }
62
63 54 std::vector<openstudio::IdfObject> AirLoopHVACZoneSplitter_Impl::remove() {
64
3/3
✓ Branch 1 taken 54 times.
✓ Branch 4 taken 31 times.
✓ Branch 5 taken 23 times.
108 if (this->airLoopHVAC()) {
65 31 return {};
66 } else {
67
3/3
✓ Branch 1 taken 23 times.
✓ Branch 4 taken 23 times.
✓ Branch 7 taken 23 times.
23 OptionalAirLoopHVACZoneSplitter self = model().getModelObject<AirLoopHVACZoneSplitter>(handle());
68
5/5
✓ Branch 1 taken 23 times.
✓ Branch 4 taken 23 times.
✓ Branch 7 taken 23 times.
✓ Branch 10 taken 23 times.
✓ Branch 13 taken 23 times.
23 model().disconnect(*self, inletPort());
69
2/3
✓ Branch 1 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
23 for (int i = 0; i < int(nextBranchIndex()) - 1; i++) {
70 ✗ model().disconnect(*self, outletPort(i));
71 }
72
1/1
✓ Branch 1 taken 23 times.
23 return HVACComponent_Impl::remove();
73 23 }
74 }
75
76 17 void AirLoopHVACZoneSplitter_Impl::disconnect() {
77
1/1
✓ Branch 1 taken 17 times.
17 auto mo = this->getObject<ModelObject>();
78
4/4
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✓ Branch 7 taken 17 times.
✓ Branch 10 taken 17 times.
17 model().disconnect(mo, inletPort());
79
3/3
✓ Branch 1 taken 34 times.
✓ Branch 3 taken 17 times.
✓ Branch 4 taken 17 times.
34 for (int i = 0; i < int(nextBranchIndex()); i++) {
80
4/4
✓ Branch 1 taken 17 times.
✓ Branch 4 taken 17 times.
✓ Branch 7 taken 17 times.
✓ Branch 10 taken 17 times.
17 model().disconnect(mo, outletPort(i));
81 }
82 17 }
83
84 977 unsigned AirLoopHVACZoneSplitter_Impl::inletPort() const {
85 977 return OS_AirLoopHVAC_ZoneSplitterFields::InletNodeName;
86 }
87
88 37144 unsigned AirLoopHVACZoneSplitter_Impl::outletPort(unsigned branchIndex) const {
89 unsigned result;
90 37144 result = numNonextensibleFields();
91 37144 result = result + branchIndex;
92 37144 return result;
93 }
94
95 860 unsigned AirLoopHVACZoneSplitter_Impl::nextOutletPort() const {
96 860 return outletPort(this->nextBranchIndex());
97 }
98
99 ✗ std::vector<ThermalZone> AirLoopHVACZoneSplitter_Impl::thermalZones() {
100 ✗ std::vector<ThermalZone> zones;
101 ✗ std::vector<ModelObject> modelObjects;
102 //std::vector<ModelObject> _outletModelObjects = outletModelObjects();
103
104 ✗ OptionalAirLoopHVAC _airLoopHVAC = airLoopHVAC();
105 ✗ OptionalNode demandOutletNode;
106 ✗ OptionalNode demandInletNode;
107 ✗ if (_airLoopHVAC) {
108 ✗ demandOutletNode = _airLoopHVAC->demandOutletNode();
109 ✗ demandInletNode = _airLoopHVAC->demandInletNode();
110 } else {
111 ✗ return zones;
112 }
113
114 ✗ modelObjects = _airLoopHVAC->demandComponents(demandInletNode.get(), demandOutletNode.get(), ThermalZone::iddObjectType());
115
116 ✗ for (const auto& modelObject : modelObjects) {
117 ✗ OptionalThermalZone zone;
118 ✗ zone = modelObject.optionalCast<ThermalZone>();
119 ✗ if (zone) {
120 ✗ zones.push_back(*zone);
121 }
122 ✗ }
123
124 ✗ return zones;
125 ✗ }
126
127 ✗ AirflowNetworkDistributionNode AirLoopHVACZoneSplitter_Impl::getAirflowNetworkDistributionNode() {
128 ✗ boost::optional<AirflowNetworkDistributionNode> opt = airflowNetworkDistributionNode();
129 ✗ if (opt) {
130 ✗ return opt.get();
131 }
132 ✗ return AirflowNetworkDistributionNode(model(), handle());
133 ✗ }
134
135 ✗ boost::optional<AirflowNetworkDistributionNode> AirLoopHVACZoneSplitter_Impl::airflowNetworkDistributionNode() const {
136 std::vector<AirflowNetworkDistributionNode> myAFNItems =
137 ✗ getObject<ModelObject>().getModelObjectSources<AirflowNetworkDistributionNode>(AirflowNetworkDistributionNode::iddObjectType());
138 ✗ auto count = myAFNItems.size();
139 ✗ if (count == 1) {
140 ✗ return myAFNItems[0];
141 ✗ } else if (count > 1) {
142 ✗ LOG(Warn, briefDescription() << " has more than one AirflowNetwork DistributionNode attached, returning first.");
143 ✗ return myAFNItems[0];
144 }
145 ✗ return boost::none;
146 ✗ }
147
148 ✗ ComponentType AirLoopHVACZoneSplitter_Impl::componentType() const {
149 ✗ return ComponentType::None;
150 }
151
152 ✗ std::vector<FuelType> AirLoopHVACZoneSplitter_Impl::coolingFuelTypes() const {
153 ✗ return {};
154 }
155
156 ✗ std::vector<FuelType> AirLoopHVACZoneSplitter_Impl::heatingFuelTypes() const {
157 ✗ return {};
158 }
159
160 ✗ std::vector<AppGFuelType> AirLoopHVACZoneSplitter_Impl::appGHeatingFuelTypes() const {
161 ✗ return {};
162 }
163
164 } // namespace detail
165
166 732 AirLoopHVACZoneSplitter::AirLoopHVACZoneSplitter(const Model& model) : Splitter(AirLoopHVACZoneSplitter::iddObjectType(), model) {
167
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 732 times.
✗ Branch 5 not taken.
732 OS_ASSERT(getImpl<detail::AirLoopHVACZoneSplitter_Impl>());
168 732 }
169
170
1/1
✓ Branch 3 taken 1522 times.
1522 AirLoopHVACZoneSplitter::AirLoopHVACZoneSplitter(std::shared_ptr<detail::AirLoopHVACZoneSplitter_Impl> impl) : Splitter(std::move(impl)) {}
171
172 732 unsigned AirLoopHVACZoneSplitter::inletPort() const {
173
1/1
✓ Branch 3 taken 732 times.
732 return getImpl<detail::AirLoopHVACZoneSplitter_Impl>()->inletPort();
174 }
175
176 ✗ unsigned AirLoopHVACZoneSplitter::outletPort(unsigned branchIndex) const {
177 ✗ return getImpl<detail::AirLoopHVACZoneSplitter_Impl>()->outletPort(branchIndex);
178 }
179
180 844 unsigned AirLoopHVACZoneSplitter::nextOutletPort() const {
181
1/1
✓ Branch 3 taken 844 times.
844 return getImpl<detail::AirLoopHVACZoneSplitter_Impl>()->nextOutletPort();
182 }
183
184 12282 IddObjectType AirLoopHVACZoneSplitter::iddObjectType() {
185
1/1
✓ Branch 1 taken 12282 times.
12282 IddObjectType result(IddObjectType::OS_AirLoopHVAC_ZoneSplitter);
186 12282 return result;
187 }
188
189 ✗ std::vector<ThermalZone> AirLoopHVACZoneSplitter::thermalZones() {
190 ✗ return getImpl<detail::AirLoopHVACZoneSplitter_Impl>()->thermalZones();
191 }
192
193 ✗ AirflowNetworkDistributionNode AirLoopHVACZoneSplitter::getAirflowNetworkDistributionNode() {
194 ✗ return getImpl<detail::AirLoopHVACZoneSplitter_Impl>()->getAirflowNetworkDistributionNode();
195 }
196
197 ✗ boost::optional<AirflowNetworkDistributionNode> AirLoopHVACZoneSplitter::airflowNetworkDistributionNode() const {
198 ✗ return getImpl<detail::AirLoopHVACZoneSplitter_Impl>()->airflowNetworkDistributionNode();
199 }
200
201 } // namespace model
202
203 } // namespace openstudio
204