src/model/PipeIndoor.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 "PipeIndoor.hpp" | ||
| 7 | #include "PipeIndoor_Impl.hpp" | ||
| 8 | |||
| 9 | #include "Construction.hpp" | ||
| 10 | #include "Construction_Impl.hpp" | ||
| 11 | #include "Node.hpp" | ||
| 12 | #include "Node_Impl.hpp" | ||
| 13 | #include "Schedule.hpp" | ||
| 14 | #include "Schedule_Impl.hpp" | ||
| 15 | #include "ScheduleTypeLimits.hpp" | ||
| 16 | #include "ScheduleTypeRegistry.hpp" | ||
| 17 | #include "ThermalZone.hpp" | ||
| 18 | #include "ThermalZone_Impl.hpp" | ||
| 19 | |||
| 20 | #include "../utilities/core/Assert.hpp" | ||
| 21 | #include "../utilities/data/DataEnums.hpp" | ||
| 22 | |||
| 23 | #include <utilities/idd/IddEnums.hxx> | ||
| 24 | #include <utilities/idd/IddFactory.hxx> | ||
| 25 | #include <utilities/idd/OS_Pipe_Indoor_FieldEnums.hxx> | ||
| 26 | |||
| 27 | namespace openstudio { | ||
| 28 | namespace model { | ||
| 29 | |||
| 30 | namespace detail { | ||
| 31 | |||
| 32 | 4 | PipeIndoor_Impl::PipeIndoor_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 33 | 4 | : StraightComponent_Impl(idfObject, model, keepHandle) { | |
| 34 |
4/6✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 13 not taken.
|
4 | OS_ASSERT(idfObject.iddObject().type() == PipeIndoor::iddObjectType()); |
| 35 | 4 | } | |
| 36 | |||
| 37 | ✗ | PipeIndoor_Impl::PipeIndoor_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 38 | ✗ | : StraightComponent_Impl(other, model, keepHandle) { | |
| 39 | ✗ | OS_ASSERT(other.iddObject().type() == PipeIndoor::iddObjectType()); | |
| 40 | ✗ | } | |
| 41 | |||
| 42 | 2 | PipeIndoor_Impl::PipeIndoor_Impl(const PipeIndoor_Impl& other, Model_Impl* model, bool keepHandle) | |
| 43 | 2 | : StraightComponent_Impl(other, model, keepHandle) {} | |
| 44 | |||
| 45 | ✗ | const std::vector<std::string>& PipeIndoor_Impl::outputVariableNames() const { | |
| 46 | static const std::vector<std::string> result{ | ||
| 47 | "Pipe Fluid Heat Transfer Rate", "Pipe Ambient Heat Transfer Rate", "Pipe Fluid Heat Transfer Energy", "Pipe Ambient Heat Transfer Energy", | ||
| 48 | ✗ | "Pipe Mass Flow Rate", "Pipe Inlet Temperature", "Pipe Outlet Temperature", "Pipe Volume Flow Rate"}; | |
| 49 | ✗ | return result; | |
| 50 | ✗ | } | |
| 51 | |||
| 52 | ✗ | IddObjectType PipeIndoor_Impl::iddObjectType() const { | |
| 53 | ✗ | return PipeIndoor::iddObjectType(); | |
| 54 | } | ||
| 55 | |||
| 56 | 8 | unsigned PipeIndoor_Impl::inletPort() const { | |
| 57 | 8 | return OS_Pipe_IndoorFields::FluidInletNode; | |
| 58 | } | ||
| 59 | |||
| 60 | 28 | unsigned PipeIndoor_Impl::outletPort() const { | |
| 61 | 28 | return OS_Pipe_IndoorFields::FluidOutletNode; | |
| 62 | } | ||
| 63 | |||
| 64 | ✗ | std::vector<ScheduleTypeKey> PipeIndoor_Impl::getScheduleTypeKeys(const Schedule& schedule) const { | |
| 65 | ✗ | std::vector<ScheduleTypeKey> result; | |
| 66 | ✗ | const UnsignedVector fieldIndices = getSourceIndices(schedule.handle()); | |
| 67 | ✗ | const auto b = fieldIndices.cbegin(); | |
| 68 | ✗ | const auto e = fieldIndices.cend(); | |
| 69 | ✗ | if (std::find(b, e, OS_Pipe_IndoorFields::AmbientTemperatureSchedule) != e) { | |
| 70 | ✗ | result.emplace_back("PipeIndoor", "Ambient Temperature Schedule"); | |
| 71 | } | ||
| 72 | ✗ | if (std::find(b, e, OS_Pipe_IndoorFields::AmbientAirVelocitySchedule) != e) { | |
| 73 | ✗ | result.emplace_back("PipeIndoor", "Ambient Air Velocity Schedule"); | |
| 74 | } | ||
| 75 | ✗ | return result; | |
| 76 | ✗ | } | |
| 77 | |||
| 78 | 2 | boost::optional<Construction> PipeIndoor_Impl::construction() const { | |
| 79 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | return getObject<ModelObject>().getModelObjectTarget<Construction>(OS_Pipe_IndoorFields::Construction); |
| 80 | } | ||
| 81 | |||
| 82 | 2 | std::string PipeIndoor_Impl::environmentType() const { | |
| 83 |
1/1✓ Branch 1 taken 2 times.
|
2 | boost::optional<std::string> value = getString(OS_Pipe_IndoorFields::EnvironmentType, true); |
| 84 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
|
2 | OS_ASSERT(value); |
| 85 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | return value.get(); |
| 86 | 2 | } | |
| 87 | |||
| 88 | 2 | boost::optional<ThermalZone> PipeIndoor_Impl::ambientTemperatureZone() const { | |
| 89 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | return getObject<ModelObject>().getModelObjectTarget<ThermalZone>(OS_Pipe_IndoorFields::AmbientTemperatureZone); |
| 90 | } | ||
| 91 | |||
| 92 | 2 | boost::optional<Schedule> PipeIndoor_Impl::ambientTemperatureSchedule() const { | |
| 93 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_Pipe_IndoorFields::AmbientTemperatureSchedule); |
| 94 | } | ||
| 95 | |||
| 96 | 2 | boost::optional<Schedule> PipeIndoor_Impl::ambientAirVelocitySchedule() const { | |
| 97 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | return getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_Pipe_IndoorFields::AmbientAirVelocitySchedule); |
| 98 | } | ||
| 99 | |||
| 100 | 2 | double PipeIndoor_Impl::pipeInsideDiameter() const { | |
| 101 |
1/1✓ Branch 1 taken 2 times.
|
2 | boost::optional<double> value = getDouble(OS_Pipe_IndoorFields::PipeInsideDiameter, true); |
| 102 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
|
2 | OS_ASSERT(value); |
| 103 |
1/1✓ Branch 1 taken 2 times.
|
4 | return value.get(); |
| 104 | } | ||
| 105 | |||
| 106 | 2 | double PipeIndoor_Impl::pipeLength() const { | |
| 107 |
1/1✓ Branch 1 taken 2 times.
|
2 | boost::optional<double> value = getDouble(OS_Pipe_IndoorFields::PipeLength, true); |
| 108 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 4 not taken.
|
2 | OS_ASSERT(value); |
| 109 |
1/1✓ Branch 1 taken 2 times.
|
4 | return value.get(); |
| 110 | } | ||
| 111 | |||
| 112 | 1 | bool PipeIndoor_Impl::setConstruction(const boost::optional<Construction>& construction) { | |
| 113 | 1 | bool result(false); | |
| 114 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (construction) { |
| 115 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | result = setPointer(OS_Pipe_IndoorFields::Construction, construction.get().handle()); |
| 116 | } else { | ||
| 117 | ✗ | resetConstruction(); | |
| 118 | ✗ | result = true; | |
| 119 | } | ||
| 120 | 1 | return result; | |
| 121 | } | ||
| 122 | |||
| 123 | ✗ | void PipeIndoor_Impl::resetConstruction() { | |
| 124 | ✗ | bool result = setString(OS_Pipe_IndoorFields::Construction, ""); | |
| 125 | ✗ | OS_ASSERT(result); | |
| 126 | ✗ | } | |
| 127 | |||
| 128 | 6 | bool PipeIndoor_Impl::setEnvironmentType(const std::string& environmentType) { | |
| 129 | 6 | bool result = setString(OS_Pipe_IndoorFields::EnvironmentType, environmentType); | |
| 130 | 6 | return result; | |
| 131 | } | ||
| 132 | |||
| 133 | 1 | bool PipeIndoor_Impl::setAmbientTemperatureZone(const boost::optional<ThermalZone>& thermalZone) { | |
| 134 | 1 | bool result(false); | |
| 135 |
1/2✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
|
1 | if (thermalZone) { |
| 136 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | result = setPointer(OS_Pipe_IndoorFields::AmbientTemperatureZone, thermalZone.get().handle()); |
| 137 | } else { | ||
| 138 | ✗ | resetAmbientTemperatureZone(); | |
| 139 | ✗ | result = true; | |
| 140 | } | ||
| 141 | 1 | return result; | |
| 142 | } | ||
| 143 | |||
| 144 | ✗ | void PipeIndoor_Impl::resetAmbientTemperatureZone() { | |
| 145 | ✗ | bool result = setString(OS_Pipe_IndoorFields::AmbientTemperatureZone, ""); | |
| 146 | ✗ | OS_ASSERT(result); | |
| 147 | ✗ | } | |
| 148 | |||
| 149 | 1 | bool PipeIndoor_Impl::setAmbientTemperatureSchedule(Schedule& schedule) { | |
| 150 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
4 | bool result = setSchedule(OS_Pipe_IndoorFields::AmbientTemperatureSchedule, "PipeIndoor", "Ambient Temperature Schedule", schedule); |
| 151 | 1 | return result; | |
| 152 | } | ||
| 153 | |||
| 154 | ✗ | void PipeIndoor_Impl::resetAmbientTemperatureSchedule() { | |
| 155 | ✗ | bool result = setString(OS_Pipe_IndoorFields::AmbientTemperatureSchedule, ""); | |
| 156 | ✗ | OS_ASSERT(result); | |
| 157 | ✗ | } | |
| 158 | |||
| 159 | 1 | bool PipeIndoor_Impl::setAmbientAirVelocitySchedule(Schedule& schedule) { | |
| 160 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
4 | bool result = setSchedule(OS_Pipe_IndoorFields::AmbientAirVelocitySchedule, "PipeIndoor", "Ambient Air Velocity Schedule", schedule); |
| 161 | 1 | return result; | |
| 162 | } | ||
| 163 | |||
| 164 | ✗ | void PipeIndoor_Impl::resetAmbientAirVelocitySchedule() { | |
| 165 | ✗ | bool result = setString(OS_Pipe_IndoorFields::AmbientAirVelocitySchedule, ""); | |
| 166 | ✗ | OS_ASSERT(result); | |
| 167 | ✗ | } | |
| 168 | |||
| 169 | 6 | bool PipeIndoor_Impl::setPipeInsideDiameter(double pipeInsideDiameter) { | |
| 170 | 6 | bool result = setDouble(OS_Pipe_IndoorFields::PipeInsideDiameter, pipeInsideDiameter); | |
| 171 | 6 | return result; | |
| 172 | } | ||
| 173 | |||
| 174 | 6 | bool PipeIndoor_Impl::setPipeLength(double pipeLength) { | |
| 175 | 6 | bool result = setDouble(OS_Pipe_IndoorFields::PipeLength, pipeLength); | |
| 176 | 6 | return result; | |
| 177 | } | ||
| 178 | |||
| 179 | 7 | bool PipeIndoor_Impl::addToNode(Node& node) { | |
| 180 |
3/3✓ Branch 1 taken 7 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 2 times.
|
14 | if (node.plantLoop()) { |
| 181 | 5 | return StraightComponent_Impl::addToNode(node); | |
| 182 | } | ||
| 183 | |||
| 184 | 2 | return false; | |
| 185 | } | ||
| 186 | |||
| 187 | 1 | ComponentType PipeIndoor_Impl::componentType() const { | |
| 188 |
1/1✓ Branch 1 taken 1 time.
|
1 | return ComponentType::None; |
| 189 | } | ||
| 190 | |||
| 191 | 1 | std::vector<FuelType> PipeIndoor_Impl::coolingFuelTypes() const { | |
| 192 | 1 | return {}; | |
| 193 | } | ||
| 194 | |||
| 195 | 1 | std::vector<FuelType> PipeIndoor_Impl::heatingFuelTypes() const { | |
| 196 | 1 | return {}; | |
| 197 | } | ||
| 198 | |||
| 199 | 1 | std::vector<AppGFuelType> PipeIndoor_Impl::appGHeatingFuelTypes() const { | |
| 200 | 1 | return {}; | |
| 201 | } | ||
| 202 | |||
| 203 | } // namespace detail | ||
| 204 | |||
| 205 | 4 | PipeIndoor::PipeIndoor(const Model& model) : StraightComponent(PipeIndoor::iddObjectType(), model) { | |
| 206 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 5 not taken.
|
4 | OS_ASSERT(getImpl<detail::PipeIndoor_Impl>()); |
| 207 | |||
| 208 | 4 | bool ok = true; | |
| 209 | // ok = setHandle(); | ||
| 210 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
|
4 | OS_ASSERT(ok); |
| 211 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | ok = setEnvironmentType("Zone"); // e+ default Zone |
| 212 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
|
4 | OS_ASSERT(ok); |
| 213 |
1/1✓ Branch 1 taken 4 times.
|
4 | ok = setPipeInsideDiameter(0.05); |
| 214 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
|
4 | OS_ASSERT(ok); |
| 215 |
1/1✓ Branch 1 taken 4 times.
|
4 | ok = setPipeLength(100.0); |
| 216 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
|
4 | OS_ASSERT(ok); |
| 217 | 4 | } | |
| 218 | |||
| 219 | 7606 | IddObjectType PipeIndoor::iddObjectType() { | |
| 220 |
1/1✓ Branch 1 taken 7606 times.
|
7606 | return {IddObjectType::OS_Pipe_Indoor}; |
| 221 | } | ||
| 222 | |||
| 223 | ✗ | std::vector<std::string> PipeIndoor::environmentTypeValues() { | |
| 224 | ✗ | return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_Pipe_IndoorFields::EnvironmentType); | |
| 225 | } | ||
| 226 | |||
| 227 | 2 | boost::optional<Construction> PipeIndoor::construction() const { | |
| 228 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::PipeIndoor_Impl>()->construction(); |
| 229 | } | ||
| 230 | |||
| 231 | 2 | std::string PipeIndoor::environmentType() const { | |
| 232 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::PipeIndoor_Impl>()->environmentType(); |
| 233 | } | ||
| 234 | |||
| 235 | 2 | boost::optional<ThermalZone> PipeIndoor::ambientTemperatureZone() const { | |
| 236 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::PipeIndoor_Impl>()->ambientTemperatureZone(); |
| 237 | } | ||
| 238 | |||
| 239 | 2 | boost::optional<Schedule> PipeIndoor::ambientTemperatureSchedule() const { | |
| 240 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::PipeIndoor_Impl>()->ambientTemperatureSchedule(); |
| 241 | } | ||
| 242 | |||
| 243 | 2 | boost::optional<Schedule> PipeIndoor::ambientAirVelocitySchedule() const { | |
| 244 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::PipeIndoor_Impl>()->ambientAirVelocitySchedule(); |
| 245 | } | ||
| 246 | |||
| 247 | 2 | double PipeIndoor::pipeInsideDiameter() const { | |
| 248 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::PipeIndoor_Impl>()->pipeInsideDiameter(); |
| 249 | } | ||
| 250 | |||
| 251 | 2 | double PipeIndoor::pipeLength() const { | |
| 252 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::PipeIndoor_Impl>()->pipeLength(); |
| 253 | } | ||
| 254 | |||
| 255 | 1 | bool PipeIndoor::setConstruction(const Construction& construction) { | |
| 256 |
2/2✓ Branch 3 taken 1 time.
✓ Branch 6 taken 1 time.
|
1 | return getImpl<detail::PipeIndoor_Impl>()->setConstruction(construction); |
| 257 | } | ||
| 258 | |||
| 259 | ✗ | void PipeIndoor::resetConstruction() { | |
| 260 | ✗ | getImpl<detail::PipeIndoor_Impl>()->resetConstruction(); | |
| 261 | ✗ | } | |
| 262 | |||
| 263 | 6 | bool PipeIndoor::setEnvironmentType(const std::string& environmentType) { | |
| 264 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::PipeIndoor_Impl>()->setEnvironmentType(environmentType); |
| 265 | } | ||
| 266 | |||
| 267 | 1 | bool PipeIndoor::setAmbientTemperatureZone(const ThermalZone& thermalZone) { | |
| 268 |
2/2✓ Branch 3 taken 1 time.
✓ Branch 6 taken 1 time.
|
1 | return getImpl<detail::PipeIndoor_Impl>()->setAmbientTemperatureZone(thermalZone); |
| 269 | } | ||
| 270 | |||
| 271 | ✗ | void PipeIndoor::resetAmbientTemperatureZone() { | |
| 272 | ✗ | getImpl<detail::PipeIndoor_Impl>()->resetAmbientTemperatureZone(); | |
| 273 | ✗ | } | |
| 274 | |||
| 275 | 1 | bool PipeIndoor::setAmbientTemperatureSchedule(Schedule& schedule) { | |
| 276 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::PipeIndoor_Impl>()->setAmbientTemperatureSchedule(schedule); |
| 277 | } | ||
| 278 | |||
| 279 | ✗ | void PipeIndoor::resetAmbientTemperatureSchedule() { | |
| 280 | ✗ | getImpl<detail::PipeIndoor_Impl>()->resetAmbientTemperatureSchedule(); | |
| 281 | ✗ | } | |
| 282 | |||
| 283 | 1 | bool PipeIndoor::setAmbientAirVelocitySchedule(Schedule& schedule) { | |
| 284 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::PipeIndoor_Impl>()->setAmbientAirVelocitySchedule(schedule); |
| 285 | } | ||
| 286 | |||
| 287 | ✗ | void PipeIndoor::resetAmbientAirVelocitySchedule() { | |
| 288 | ✗ | getImpl<detail::PipeIndoor_Impl>()->resetAmbientAirVelocitySchedule(); | |
| 289 | ✗ | } | |
| 290 | |||
| 291 | 6 | bool PipeIndoor::setPipeInsideDiameter(double pipeInsideDiameter) { | |
| 292 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::PipeIndoor_Impl>()->setPipeInsideDiameter(pipeInsideDiameter); |
| 293 | } | ||
| 294 | |||
| 295 | 6 | bool PipeIndoor::setPipeLength(double pipeLength) { | |
| 296 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::PipeIndoor_Impl>()->setPipeLength(pipeLength); |
| 297 | } | ||
| 298 | |||
| 299 | /// @cond | ||
| 300 |
1/1✓ Branch 3 taken 1 time.
|
1 | PipeIndoor::PipeIndoor(std::shared_ptr<detail::PipeIndoor_Impl> impl) : StraightComponent(std::move(impl)) {} |
| 301 | /// @endcond | ||
| 302 | |||
| 303 | } // namespace model | ||
| 304 | } // namespace openstudio | ||
| 305 |