src/model/SpaceInfiltrationFlowCoefficient.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 "SpaceInfiltrationFlowCoefficient.hpp" | ||
| 7 | #include "SpaceInfiltrationFlowCoefficient_Impl.hpp" | ||
| 8 | |||
| 9 | #include "Schedule.hpp" | ||
| 10 | #include "Schedule_Impl.hpp" | ||
| 11 | #include "Space.hpp" | ||
| 12 | #include "Space_Impl.hpp" | ||
| 13 | #include "SpaceType.hpp" | ||
| 14 | #include "SpaceType_Impl.hpp" | ||
| 15 | #include "DefaultScheduleSet.hpp" | ||
| 16 | #include "DefaultScheduleSet_Impl.hpp" | ||
| 17 | #include "LifeCycleCost.hpp" | ||
| 18 | |||
| 19 | #include <utilities/idd/IddFactory.hxx> | ||
| 20 | |||
| 21 | #include <utilities/idd/OS_SpaceInfiltration_FlowCoefficient_FieldEnums.hxx> | ||
| 22 | #include <utilities/idd/IddEnums.hxx> | ||
| 23 | |||
| 24 | #include "../utilities/core/Assert.hpp" | ||
| 25 | |||
| 26 | namespace openstudio { | ||
| 27 | namespace model { | ||
| 28 | |||
| 29 | namespace detail { | ||
| 30 | |||
| 31 | 11 | SpaceInfiltrationFlowCoefficient_Impl::SpaceInfiltrationFlowCoefficient_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 32 | 11 | : SpaceLoad_Impl(idfObject, model, keepHandle) { | |
| 33 |
4/6✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 11 times.
✗ Branch 13 not taken.
|
11 | OS_ASSERT(idfObject.iddObject().type() == SpaceInfiltrationFlowCoefficient::iddObjectType()); |
| 34 | 11 | } | |
| 35 | |||
| 36 | ✗ | SpaceInfiltrationFlowCoefficient_Impl::SpaceInfiltrationFlowCoefficient_Impl(const openstudio::detail::WorkspaceObject_Impl& other, | |
| 37 | ✗ | Model_Impl* model, bool keepHandle) | |
| 38 | ✗ | : SpaceLoad_Impl(other, model, keepHandle) { | |
| 39 | ✗ | OS_ASSERT(other.iddObject().type() == SpaceInfiltrationFlowCoefficient::iddObjectType()); | |
| 40 | ✗ | } | |
| 41 | |||
| 42 | 32 | SpaceInfiltrationFlowCoefficient_Impl::SpaceInfiltrationFlowCoefficient_Impl(const SpaceInfiltrationFlowCoefficient_Impl& other, | |
| 43 | 32 | Model_Impl* model, bool keepHandle) | |
| 44 | 32 | : SpaceLoad_Impl(other, model, keepHandle) {} | |
| 45 | |||
| 46 | ✗ | const std::vector<std::string>& SpaceInfiltrationFlowCoefficient_Impl::outputVariableNames() const { | |
| 47 | ✗ | static const std::vector<std::string> result; | |
| 48 | ✗ | return result; | |
| 49 | } | ||
| 50 | |||
| 51 | ✗ | IddObjectType SpaceInfiltrationFlowCoefficient_Impl::iddObjectType() const { | |
| 52 | ✗ | return SpaceInfiltrationFlowCoefficient::iddObjectType(); | |
| 53 | } | ||
| 54 | |||
| 55 | ✗ | std::vector<ScheduleTypeKey> SpaceInfiltrationFlowCoefficient_Impl::getScheduleTypeKeys(const Schedule& schedule) const { | |
| 56 | ✗ | std::vector<ScheduleTypeKey> result; | |
| 57 | ✗ | UnsignedVector fieldIndices = getSourceIndices(schedule.handle()); | |
| 58 | ✗ | UnsignedVector::const_iterator b(fieldIndices.begin()); | |
| 59 | ✗ | UnsignedVector::const_iterator e(fieldIndices.end()); | |
| 60 | ✗ | if (std::find(b, e, OS_SpaceInfiltration_FlowCoefficientFields::ScheduleName) != e) { | |
| 61 | ✗ | result.push_back(ScheduleTypeKey("SpaceInfiltrationFlowCoefficient", "Infiltration")); | |
| 62 | } | ||
| 63 | ✗ | return result; | |
| 64 | ✗ | } | |
| 65 | |||
| 66 | 12 | bool SpaceInfiltrationFlowCoefficient_Impl::hardSize() { | |
| 67 |
1/1✓ Branch 1 taken 12 times.
|
12 | boost::optional<Space> space = this->space(); |
| 68 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
|
12 | if (!space) { |
| 69 | ✗ | return false; | |
| 70 | } | ||
| 71 | 12 | return false; | |
| 72 | 12 | } | |
| 73 | |||
| 74 | 16 | bool SpaceInfiltrationFlowCoefficient_Impl::hardApplySchedules() { | |
| 75 | 16 | bool result = false; | |
| 76 |
1/1✓ Branch 1 taken 16 times.
|
16 | boost::optional<Schedule> schedule = this->schedule(); |
| 77 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
|
16 | if (schedule) { |
| 78 | ✗ | result = this->setSchedule(*schedule); | |
| 79 | } | ||
| 80 | 16 | return result; | |
| 81 | 16 | } | |
| 82 | |||
| 83 | ✗ | bool SpaceInfiltrationFlowCoefficient_Impl::isAbsolute() const { | |
| 84 | ✗ | return true; | |
| 85 | } | ||
| 86 | |||
| 87 | 34 | double SpaceInfiltrationFlowCoefficient_Impl::flowCoefficient() const { | |
| 88 |
1/1✓ Branch 1 taken 34 times.
|
34 | boost::optional<double> value = getDouble(OS_SpaceInfiltration_FlowCoefficientFields::FlowCoefficient, true); |
| 89 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 4 not taken.
|
34 | OS_ASSERT(value); |
| 90 |
1/1✓ Branch 1 taken 34 times.
|
68 | return value.get(); |
| 91 | } | ||
| 92 | |||
| 93 | 20 | bool SpaceInfiltrationFlowCoefficient_Impl::setFlowCoefficient(double flowCoefficient) { | |
| 94 | 20 | bool result = setDouble(OS_SpaceInfiltration_FlowCoefficientFields::FlowCoefficient, flowCoefficient); | |
| 95 | 20 | return result; | |
| 96 | } | ||
| 97 | |||
| 98 | 30 | double SpaceInfiltrationFlowCoefficient_Impl::stackCoefficient() const { | |
| 99 |
1/1✓ Branch 1 taken 30 times.
|
30 | boost::optional<double> value = getDouble(OS_SpaceInfiltration_FlowCoefficientFields::StackCoefficient, true); |
| 100 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 4 not taken.
|
30 | OS_ASSERT(value); |
| 101 |
1/1✓ Branch 1 taken 30 times.
|
60 | return value.get(); |
| 102 | } | ||
| 103 | |||
| 104 | 20 | bool SpaceInfiltrationFlowCoefficient_Impl::setStackCoefficient(double stackCoefficient) { | |
| 105 | 20 | bool result = setDouble(OS_SpaceInfiltration_FlowCoefficientFields::StackCoefficient, stackCoefficient); | |
| 106 | 20 | return result; | |
| 107 | } | ||
| 108 | |||
| 109 | 30 | double SpaceInfiltrationFlowCoefficient_Impl::pressureExponent() const { | |
| 110 |
1/1✓ Branch 1 taken 30 times.
|
30 | boost::optional<double> value = getDouble(OS_SpaceInfiltration_FlowCoefficientFields::PressureExponent, true); |
| 111 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 4 not taken.
|
30 | OS_ASSERT(value); |
| 112 |
1/1✓ Branch 1 taken 30 times.
|
60 | return value.get(); |
| 113 | } | ||
| 114 | |||
| 115 | 20 | bool SpaceInfiltrationFlowCoefficient_Impl::setPressureExponent(double pressureExponent) { | |
| 116 | 20 | bool result = setDouble(OS_SpaceInfiltration_FlowCoefficientFields::PressureExponent, pressureExponent); | |
| 117 | 20 | return result; | |
| 118 | } | ||
| 119 | |||
| 120 | 30 | double SpaceInfiltrationFlowCoefficient_Impl::windCoefficient() const { | |
| 121 |
1/1✓ Branch 1 taken 30 times.
|
30 | boost::optional<double> value = getDouble(OS_SpaceInfiltration_FlowCoefficientFields::WindCoefficient, true); |
| 122 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 4 not taken.
|
30 | OS_ASSERT(value); |
| 123 |
1/1✓ Branch 1 taken 30 times.
|
60 | return value.get(); |
| 124 | } | ||
| 125 | |||
| 126 | 20 | bool SpaceInfiltrationFlowCoefficient_Impl::setWindCoefficient(double windCoefficient) { | |
| 127 | 20 | bool result = setDouble(OS_SpaceInfiltration_FlowCoefficientFields::WindCoefficient, windCoefficient); | |
| 128 | 20 | return result; | |
| 129 | } | ||
| 130 | |||
| 131 | 30 | double SpaceInfiltrationFlowCoefficient_Impl::shelterFactor() const { | |
| 132 |
1/1✓ Branch 1 taken 30 times.
|
30 | boost::optional<double> value = getDouble(OS_SpaceInfiltration_FlowCoefficientFields::ShelterFactor, true); |
| 133 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 4 not taken.
|
30 | OS_ASSERT(value); |
| 134 |
1/1✓ Branch 1 taken 30 times.
|
60 | return value.get(); |
| 135 | } | ||
| 136 | |||
| 137 | 20 | bool SpaceInfiltrationFlowCoefficient_Impl::setShelterFactor(double shelterFactor) { | |
| 138 | 20 | bool result = setDouble(OS_SpaceInfiltration_FlowCoefficientFields::ShelterFactor, shelterFactor); | |
| 139 | 20 | return result; | |
| 140 | } | ||
| 141 | |||
| 142 | 201 | int SpaceInfiltrationFlowCoefficient_Impl::spaceIndex() const { | |
| 143 | 201 | return OS_SpaceInfiltration_FlowCoefficientFields::SpaceorSpaceTypeName; | |
| 144 | } | ||
| 145 | |||
| 146 | 57 | boost::optional<Schedule> SpaceInfiltrationFlowCoefficient_Impl::schedule() const { | |
| 147 | boost::optional<Schedule> result = | ||
| 148 |
2/2✓ Branch 1 taken 57 times.
✓ Branch 4 taken 57 times.
|
57 | getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_SpaceInfiltration_FlowCoefficientFields::ScheduleName); |
| 149 |
2/2✓ Branch 1 taken 47 times.
✓ Branch 2 taken 10 times.
|
57 | if (!result) { |
| 150 | // search upwards | ||
| 151 |
1/1✓ Branch 1 taken 47 times.
|
47 | OptionalSpace space = this->space(); |
| 152 |
1/1✓ Branch 1 taken 47 times.
|
47 | OptionalSpaceType spaceType = this->spaceType(); |
| 153 |
2/2✓ Branch 0 taken 33 times.
✓ Branch 1 taken 14 times.
|
47 | if (space) { |
| 154 |
3/3✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
✓ Branch 7 taken 33 times.
|
33 | result = space->getDefaultSchedule(DefaultScheduleType::InfiltrationSchedule); |
| 155 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5 times.
|
14 | } else if (spaceType) { |
| 156 |
3/3✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
|
9 | result = spaceType->getDefaultSchedule(DefaultScheduleType::InfiltrationSchedule); |
| 157 | } | ||
| 158 | 47 | } | |
| 159 | 57 | return result; | |
| 160 | ✗ | } | |
| 161 | |||
| 162 | 6 | bool SpaceInfiltrationFlowCoefficient_Impl::isScheduleDefaulted() const { | |
| 163 | 6 | return isEmpty(OS_SpaceInfiltration_FlowCoefficientFields::ScheduleName); | |
| 164 | } | ||
| 165 | |||
| 166 | 6 | bool SpaceInfiltrationFlowCoefficient_Impl::setSchedule(Schedule& schedule) { | |
| 167 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
|
24 | bool result = ModelObject_Impl::setSchedule(OS_SpaceInfiltration_FlowCoefficientFields::ScheduleName, "SpaceInfiltrationFlowCoefficient", |
| 168 | "Infiltration", schedule); | ||
| 169 | 6 | return result; | |
| 170 | } | ||
| 171 | |||
| 172 | 4 | void SpaceInfiltrationFlowCoefficient_Impl::resetSchedule() { | |
| 173 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
8 | bool result = setString(OS_SpaceInfiltration_FlowCoefficientFields::ScheduleName, ""); |
| 174 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | OS_ASSERT(result); |
| 175 | 4 | } | |
| 176 | |||
| 177 | ✗ | boost::optional<ModelObject> SpaceInfiltrationFlowCoefficient_Impl::scheduleAsModelObject() const { | |
| 178 | ✗ | OptionalModelObject result; | |
| 179 | ✗ | OptionalSchedule intermediate = schedule(); | |
| 180 | ✗ | if (intermediate) { | |
| 181 | ✗ | result = *intermediate; | |
| 182 | } | ||
| 183 | ✗ | return result; | |
| 184 | ✗ | } | |
| 185 | |||
| 186 | ✗ | bool SpaceInfiltrationFlowCoefficient_Impl::setScheduleAsModelObject(const boost::optional<ModelObject>& modelObject) { | |
| 187 | ✗ | if (modelObject) { | |
| 188 | ✗ | OptionalSchedule intermediate = modelObject->optionalCast<Schedule>(); | |
| 189 | ✗ | if (intermediate) { | |
| 190 | ✗ | Schedule schedule(*intermediate); | |
| 191 | ✗ | return setSchedule(schedule); | |
| 192 | ✗ | } else { | |
| 193 | ✗ | return false; | |
| 194 | } | ||
| 195 | ✗ | } else { | |
| 196 | ✗ | resetSchedule(); | |
| 197 | } | ||
| 198 | ✗ | return true; | |
| 199 | } | ||
| 200 | |||
| 201 | } // namespace detail | ||
| 202 | |||
| 203 | 11 | SpaceInfiltrationFlowCoefficient::SpaceInfiltrationFlowCoefficient(const Model& model) | |
| 204 | 11 | : SpaceLoad(SpaceInfiltrationFlowCoefficient::iddObjectType(), model) { | |
| 205 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✗ Branch 5 not taken.
|
11 | OS_ASSERT(getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()); |
| 206 | |||
| 207 | // IDD default | ||
| 208 |
1/1✓ Branch 1 taken 11 times.
|
11 | bool test = setPressureExponent(0.67); |
| 209 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 3 not taken.
|
11 | OS_ASSERT(test); |
| 210 | |||
| 211 | // Rest from DirectIndirectEvapCoolers.idf | ||
| 212 |
1/1✓ Branch 1 taken 11 times.
|
11 | test = setFlowCoefficient(0.02); |
| 213 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 3 not taken.
|
11 | OS_ASSERT(test); |
| 214 |
1/1✓ Branch 1 taken 11 times.
|
11 | test = setStackCoefficient(0.05); |
| 215 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 3 not taken.
|
11 | OS_ASSERT(test); |
| 216 |
1/1✓ Branch 1 taken 11 times.
|
11 | test = setWindCoefficient(0.12); |
| 217 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 3 not taken.
|
11 | OS_ASSERT(test); |
| 218 |
1/1✓ Branch 1 taken 11 times.
|
11 | test = setShelterFactor(0.5); |
| 219 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 3 not taken.
|
11 | OS_ASSERT(test); |
| 220 | 11 | } | |
| 221 | |||
| 222 | 10801 | IddObjectType SpaceInfiltrationFlowCoefficient::iddObjectType() { | |
| 223 |
1/1✓ Branch 1 taken 10801 times.
|
10801 | IddObjectType result(IddObjectType::OS_SpaceInfiltration_FlowCoefficient); |
| 224 | 10801 | return result; | |
| 225 | } | ||
| 226 | |||
| 227 | 41 | boost::optional<Schedule> SpaceInfiltrationFlowCoefficient::schedule() const { | |
| 228 |
1/1✓ Branch 3 taken 41 times.
|
41 | return getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()->schedule(); |
| 229 | } | ||
| 230 | |||
| 231 | 6 | bool SpaceInfiltrationFlowCoefficient::isScheduleDefaulted() const { | |
| 232 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()->isScheduleDefaulted(); |
| 233 | } | ||
| 234 | |||
| 235 | 34 | double SpaceInfiltrationFlowCoefficient::flowCoefficient() const { | |
| 236 |
1/1✓ Branch 3 taken 34 times.
|
34 | return getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()->flowCoefficient(); |
| 237 | } | ||
| 238 | |||
| 239 | 30 | double SpaceInfiltrationFlowCoefficient::stackCoefficient() const { | |
| 240 |
1/1✓ Branch 3 taken 30 times.
|
30 | return getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()->stackCoefficient(); |
| 241 | } | ||
| 242 | |||
| 243 | 30 | double SpaceInfiltrationFlowCoefficient::pressureExponent() const { | |
| 244 |
1/1✓ Branch 3 taken 30 times.
|
30 | return getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()->pressureExponent(); |
| 245 | } | ||
| 246 | |||
| 247 | 30 | double SpaceInfiltrationFlowCoefficient::windCoefficient() const { | |
| 248 |
1/1✓ Branch 3 taken 30 times.
|
30 | return getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()->windCoefficient(); |
| 249 | } | ||
| 250 | |||
| 251 | 30 | double SpaceInfiltrationFlowCoefficient::shelterFactor() const { | |
| 252 |
1/1✓ Branch 3 taken 30 times.
|
30 | return getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()->shelterFactor(); |
| 253 | } | ||
| 254 | |||
| 255 | 6 | bool SpaceInfiltrationFlowCoefficient::setSchedule(Schedule& schedule) { | |
| 256 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()->setSchedule(schedule); |
| 257 | } | ||
| 258 | |||
| 259 | 4 | void SpaceInfiltrationFlowCoefficient::resetSchedule() { | |
| 260 |
1/1✓ Branch 3 taken 4 times.
|
4 | getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()->resetSchedule(); |
| 261 | 4 | } | |
| 262 | |||
| 263 | 20 | bool SpaceInfiltrationFlowCoefficient::setFlowCoefficient(double flowCoefficient) { | |
| 264 |
1/1✓ Branch 3 taken 20 times.
|
20 | return getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()->setFlowCoefficient(flowCoefficient); |
| 265 | } | ||
| 266 | |||
| 267 | 20 | bool SpaceInfiltrationFlowCoefficient::setStackCoefficient(double stackCoefficient) { | |
| 268 |
1/1✓ Branch 3 taken 20 times.
|
20 | return getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()->setStackCoefficient(stackCoefficient); |
| 269 | } | ||
| 270 | |||
| 271 | 20 | bool SpaceInfiltrationFlowCoefficient::setPressureExponent(double pressureExponent) { | |
| 272 |
1/1✓ Branch 3 taken 20 times.
|
20 | return getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()->setPressureExponent(pressureExponent); |
| 273 | } | ||
| 274 | |||
| 275 | 20 | bool SpaceInfiltrationFlowCoefficient::setWindCoefficient(double windCoefficient) { | |
| 276 |
1/1✓ Branch 3 taken 20 times.
|
20 | return getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()->setWindCoefficient(windCoefficient); |
| 277 | } | ||
| 278 | |||
| 279 | 20 | bool SpaceInfiltrationFlowCoefficient::setShelterFactor(double shelterFactor) { | |
| 280 |
1/1✓ Branch 3 taken 20 times.
|
20 | return getImpl<detail::SpaceInfiltrationFlowCoefficient_Impl>()->setShelterFactor(shelterFactor); |
| 281 | } | ||
| 282 | |||
| 283 | /// @cond | ||
| 284 | 93 | SpaceInfiltrationFlowCoefficient::SpaceInfiltrationFlowCoefficient(std::shared_ptr<detail::SpaceInfiltrationFlowCoefficient_Impl> impl) | |
| 285 |
1/1✓ Branch 3 taken 93 times.
|
93 | : SpaceLoad(std::move(impl)) {} |
| 286 | /// @endcond | ||
| 287 | |||
| 288 | } // namespace model | ||
| 289 | } // namespace openstudio | ||
| 290 |