src/model/ConstructionBase.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 "ConstructionBase.hpp" | ||
| 7 | #include "ConstructionBase_Impl.hpp" | ||
| 8 | |||
| 9 | #include "Model.hpp" | ||
| 10 | #include "StandardsInformationConstruction.hpp" | ||
| 11 | #include "StandardsInformationConstruction_Impl.hpp" | ||
| 12 | #include "PlanarSurface.hpp" | ||
| 13 | #include "PlanarSurface_Impl.hpp" | ||
| 14 | #include "Surface.hpp" | ||
| 15 | #include "Surface_Impl.hpp" | ||
| 16 | #include "SubSurface.hpp" | ||
| 17 | #include "SubSurface_Impl.hpp" | ||
| 18 | #include "InteriorPartitionSurface.hpp" | ||
| 19 | #include "InteriorPartitionSurface_Impl.hpp" | ||
| 20 | #include "InteriorPartitionSurfaceGroup.hpp" | ||
| 21 | #include "InteriorPartitionSurfaceGroup_Impl.hpp" | ||
| 22 | #include "RenderingColor.hpp" | ||
| 23 | #include "RenderingColor_Impl.hpp" | ||
| 24 | #include "Space.hpp" | ||
| 25 | |||
| 26 | #include "../utilities/core/Assert.hpp" | ||
| 27 | |||
| 28 | using std::vector; | ||
| 29 | |||
| 30 | namespace openstudio { | ||
| 31 | namespace model { | ||
| 32 | |||
| 33 | namespace detail { | ||
| 34 | |||
| 35 | 3463 | ConstructionBase_Impl::ConstructionBase_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 36 | 3463 | : ResourceObject_Impl(idfObject, model, keepHandle) {} | |
| 37 | |||
| 38 | 733 | ConstructionBase_Impl::ConstructionBase_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 39 | 733 | : ResourceObject_Impl(other, model, keepHandle) {} | |
| 40 | |||
| 41 | 1590 | ConstructionBase_Impl::ConstructionBase_Impl(const ConstructionBase_Impl& other, Model_Impl* model, bool keepHandle) | |
| 42 | 1590 | : ResourceObject_Impl(other, model, keepHandle) {} | |
| 43 | |||
| 44 | 358 | StandardsInformationConstruction ConstructionBase_Impl::standardsInformation() const { | |
| 45 |
2/2✓ Branch 1 taken 358 times.
✓ Branch 4 taken 358 times.
|
358 | StandardsInformationConstructionVector candidates = getObject<ConstructionBase>().getModelObjectSources<StandardsInformationConstruction>(); |
| 46 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 358 times.
|
358 | if (candidates.size() > 1) { |
| 47 | ✗ | for (unsigned i = 1, n = candidates.size(); i < n; ++i) { | |
| 48 | ✗ | candidates[i].remove(); | |
| 49 | } | ||
| 50 | ✗ | LOG(Warn, "Removed extraneous ConstructionBaseStandardsInformation objects pointing to " << briefDescription() << "."); | |
| 51 | } | ||
| 52 |
2/2✓ Branch 1 taken 14 times.
✓ Branch 2 taken 344 times.
|
358 | if (candidates.size() == 1) { |
| 53 |
1/1✓ Branch 2 taken 14 times.
|
14 | return candidates[0]; |
| 54 | } | ||
| 55 |
2/2✓ Branch 1 taken 344 times.
✓ Branch 4 taken 344 times.
|
344 | return StandardsInformationConstruction(getObject<ConstructionBase>()); |
| 56 | 358 | } | |
| 57 | |||
| 58 | // not in the public api | ||
| 59 | 259 | double getNetAreaHelper(const PlanarSurface& planarSurface) { | |
| 60 |
1/1✓ Branch 1 taken 259 times.
|
259 | boost::optional<Space> space = planarSurface.space(); |
| 61 | |||
| 62 | 259 | double multiplier = 1.0; | |
| 63 |
2/2✓ Branch 0 taken 258 times.
✓ Branch 1 taken 1 time.
|
259 | if (space) { |
| 64 |
2/2✓ Branch 1 taken 258 times.
✓ Branch 4 taken 258 times.
|
258 | multiplier = space->multiplier(); |
| 65 | } | ||
| 66 | |||
| 67 |
3/3✓ Branch 1 taken 259 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 244 times.
|
518 | if (planarSurface.optionalCast<SubSurface>()) { |
| 68 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | multiplier = multiplier * planarSurface.cast<SubSurface>().multiplier(); |
| 69 | } | ||
| 70 | |||
| 71 |
2/3✓ Branch 1 taken 259 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259 times.
|
518 | if (planarSurface.optionalCast<InteriorPartitionSurface>()) { |
| 72 | boost::optional<InteriorPartitionSurfaceGroup> interiorPartitionSurfaceGroup = | ||
| 73 | ✗ | planarSurface.cast<InteriorPartitionSurface>().interiorPartitionSurfaceGroup(); | |
| 74 | ✗ | if (interiorPartitionSurfaceGroup) { | |
| 75 | ✗ | multiplier = multiplier * interiorPartitionSurfaceGroup->multiplier(); | |
| 76 | } | ||
| 77 | ✗ | } | |
| 78 | |||
| 79 |
1/1✓ Branch 1 taken 259 times.
|
518 | return multiplier * planarSurface.netArea(); |
| 80 | 259 | } | |
| 81 | |||
| 82 | 106 | double ConstructionBase_Impl::getNetArea() const { | |
| 83 |
1/1✓ Branch 1 taken 106 times.
|
106 | Handle handle = this->handle(); |
| 84 | 106 | std::set<Handle> adjacentPlanarSurfacesToSkip; | |
| 85 | |||
| 86 | 106 | double result = 0.0; | |
| 87 |
4/4✓ Branch 1 taken 106 times.
✓ Branch 4 taken 106 times.
✓ Branch 12 taken 1255 times.
✓ Branch 13 taken 106 times.
|
1361 | for (const PlanarSurface& planarSurface : model().getModelObjects<PlanarSurface>()) { |
| 88 | |||
| 89 | // if we have already processed this surface as an adjacent surface | ||
| 90 |
2/2✓ Branch 1 taken 1255 times.
✓ Branch 6 taken 1255 times.
|
1255 | if (std::find(adjacentPlanarSurfacesToSkip.begin(), adjacentPlanarSurfacesToSkip.end(), planarSurface.handle()) |
| 91 |
2/2✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1231 times.
|
2510 | != adjacentPlanarSurfacesToSkip.end()) { |
| 92 | 161 | continue; | |
| 93 | } | ||
| 94 | |||
| 95 | // PlanarSurface::construction now attempts to resolve surface matching mismatches | ||
| 96 |
1/1✓ Branch 1 taken 1231 times.
|
1231 | boost::optional<ConstructionBase> constructionBase = planarSurface.construction(); |
| 97 |
2/2✓ Branch 1 taken 137 times.
✓ Branch 2 taken 1094 times.
|
1231 | if (!constructionBase) { |
| 98 | 137 | continue; | |
| 99 | } | ||
| 100 | |||
| 101 |
5/5✓ Branch 1 taken 1094 times.
✓ Branch 4 taken 1094 times.
✓ Branch 7 taken 1094 times.
✓ Branch 9 taken 235 times.
✓ Branch 10 taken 859 times.
|
1094 | if (constructionBase->handle() == handle) { |
| 102 |
1/1✓ Branch 1 taken 235 times.
|
235 | double netArea = getNetAreaHelper(planarSurface); |
| 103 | |||
| 104 | // avoid double counting construction for adjacent surface | ||
| 105 |
3/3✓ Branch 1 taken 235 times.
✓ Branch 4 taken 226 times.
✓ Branch 5 taken 9 times.
|
470 | if (planarSurface.optionalCast<Surface>()) { |
| 106 |
2/2✓ Branch 1 taken 226 times.
✓ Branch 4 taken 226 times.
|
226 | boost::optional<Surface> adjacentSurface = planarSurface.cast<Surface>().adjacentSurface(); |
| 107 |
2/2✓ Branch 0 taken 22 times.
✓ Branch 1 taken 204 times.
|
226 | if (adjacentSurface) { |
| 108 |
2/2✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
|
22 | boost::optional<ConstructionBase> adjacentConstructionBase = adjacentSurface->construction(); |
| 109 |
10/11✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 22 times.
✓ Branch 6 taken 22 times.
✓ Branch 9 taken 22 times.
✓ Branch 12 taken 22 times.
✓ Branch 15 taken 22 times.
✓ Branch 17 taken 18 times.
✓ Branch 18 taken 4 times.
✓ Branch 19 taken 18 times.
✓ Branch 20 taken 4 times.
|
22 | if (adjacentConstructionBase && (constructionBase->handle() == adjacentConstructionBase->handle())) { |
| 110 |
3/3✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
✓ Branch 7 taken 18 times.
|
18 | adjacentPlanarSurfacesToSkip.insert(adjacentSurface->handle()); |
| 111 |
2/2✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
|
18 | netArea = std::max(netArea, getNetAreaHelper(*adjacentSurface)); |
| 112 | } | ||
| 113 | 22 | } | |
| 114 | 226 | } | |
| 115 | |||
| 116 |
3/3✓ Branch 1 taken 235 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 226 times.
|
470 | if (planarSurface.optionalCast<SubSurface>()) { |
| 117 |
2/2✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
|
9 | boost::optional<SubSurface> adjacentSubSurface = planarSurface.cast<SubSurface>().adjacentSubSurface(); |
| 118 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
|
9 | if (adjacentSubSurface) { |
| 119 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | boost::optional<ConstructionBase> adjacentConstructionBase = adjacentSubSurface->construction(); |
| 120 |
8/11✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 6 taken 6 times.
✓ Branch 9 taken 6 times.
✓ Branch 12 taken 6 times.
✓ Branch 15 taken 6 times.
✓ Branch 17 taken 6 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 6 times.
✗ Branch 20 not taken.
|
6 | if (adjacentConstructionBase && (constructionBase->handle() == adjacentConstructionBase->handle())) { |
| 121 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
|
6 | adjacentPlanarSurfacesToSkip.insert(adjacentSubSurface->handle()); |
| 122 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | netArea = std::max(netArea, getNetAreaHelper(*adjacentSubSurface)); |
| 123 | } | ||
| 124 | 6 | } | |
| 125 | 9 | } | |
| 126 | |||
| 127 | 235 | result += netArea; | |
| 128 | } | ||
| 129 | 1337 | } | |
| 130 | 106 | return result; | |
| 131 | 106 | } | |
| 132 | |||
| 133 | 999 | std::vector<ModelObject> ConstructionBase_Impl::children() const { | |
| 134 | |||
| 135 |
3/3✓ Branch 1 taken 999 times.
✓ Branch 4 taken 999 times.
✓ Branch 7 taken 999 times.
|
999 | vector<ModelObject> results(castVector<ModelObject>(getObject<ConstructionBase>().getModelObjectSources<StandardsInformationConstruction>())); |
| 136 | |||
| 137 | 999 | return results; | |
| 138 | } | ||
| 139 | |||
| 140 | ✗ | std::vector<IddObjectType> ConstructionBase_Impl::allowableChildTypes() const { | |
| 141 | ✗ | IddObjectTypeVector result; | |
| 142 | ✗ | result.push_back(StandardsInformationConstruction::iddObjectType()); | |
| 143 | ✗ | return result; | |
| 144 | ✗ | } | |
| 145 | |||
| 146 | 1 | bool ConstructionBase_Impl::setUFactor(double /*value*/) { | |
| 147 | 1 | return false; | |
| 148 | } | ||
| 149 | |||
| 150 | ✗ | bool ConstructionBase_Impl::setUFactor(double /*value*/, double /*filmResistance*/) { | |
| 151 | ✗ | return false; | |
| 152 | } | ||
| 153 | |||
| 154 | 1 | bool ConstructionBase_Impl::setConductance(double /*value*/) { | |
| 155 | 1 | return false; | |
| 156 | } | ||
| 157 | |||
| 158 | ✗ | bool ConstructionBase_Impl::setConductance(double /*value*/, double /*filmResistance*/) { | |
| 159 | ✗ | return false; | |
| 160 | } | ||
| 161 | |||
| 162 | 1 | bool ConstructionBase_Impl::isGreenRoof() const { | |
| 163 | 1 | return false; | |
| 164 | } | ||
| 165 | |||
| 166 | 15 | boost::optional<double> ConstructionBase_Impl::uFactor() const { | |
| 167 | 15 | return boost::none; | |
| 168 | } | ||
| 169 | |||
| 170 | ✗ | boost::optional<double> ConstructionBase_Impl::uFactor(double /*filmResistance*/) const { | |
| 171 | ✗ | return boost::none; | |
| 172 | } | ||
| 173 | |||
| 174 | 1 | boost::optional<double> ConstructionBase_Impl::thermalConductance() const { | |
| 175 | 1 | return boost::none; | |
| 176 | } | ||
| 177 | |||
| 178 | ✗ | boost::optional<double> ConstructionBase_Impl::thermalConductance(double /*filmResistance*/) const { | |
| 179 | ✗ | return boost::none; | |
| 180 | } | ||
| 181 | |||
| 182 | 2 | boost::optional<double> ConstructionBase_Impl::heatCapacity() const { | |
| 183 | 2 | return boost::none; | |
| 184 | } | ||
| 185 | |||
| 186 | 1 | boost::optional<double> ConstructionBase_Impl::interiorVisibleAbsorptance() const { | |
| 187 | 1 | return boost::none; | |
| 188 | } | ||
| 189 | |||
| 190 | 1 | boost::optional<double> ConstructionBase_Impl::exteriorVisibleAbsorptance() const { | |
| 191 | 1 | return boost::none; | |
| 192 | } | ||
| 193 | |||
| 194 | 15 | boost::optional<double> ConstructionBase_Impl::visibleTransmittance() const { | |
| 195 | 15 | return boost::none; | |
| 196 | } | ||
| 197 | |||
| 198 | 330 | boost::optional<RenderingColor> ConstructionBase_Impl::renderingColor() const { | |
| 199 |
3/3✓ Branch 1 taken 330 times.
✓ Branch 4 taken 330 times.
✓ Branch 7 taken 330 times.
|
330 | return getObject<ModelObject>().getModelObjectTarget<RenderingColor>(this->renderingColorIndex()); |
| 200 | } | ||
| 201 | |||
| 202 | 72 | bool ConstructionBase_Impl::setRenderingColor(const RenderingColor& renderingColor) { | |
| 203 |
3/3✓ Branch 1 taken 72 times.
✓ Branch 4 taken 72 times.
✓ Branch 7 taken 72 times.
|
72 | return setPointer(this->renderingColorIndex(), renderingColor.handle()); |
| 204 | } | ||
| 205 | |||
| 206 | ✗ | void ConstructionBase_Impl::resetRenderingColor() { | |
| 207 | ✗ | bool test = setString(this->renderingColorIndex(), ""); | |
| 208 | ✗ | OS_ASSERT(test); | |
| 209 | ✗ | } | |
| 210 | |||
| 211 | } // namespace detail | ||
| 212 | |||
| 213 | 16 | StandardsInformationConstruction ConstructionBase::standardsInformation() const { | |
| 214 |
1/1✓ Branch 3 taken 16 times.
|
16 | return getImpl<detail::ConstructionBase_Impl>()->standardsInformation(); |
| 215 | } | ||
| 216 | |||
| 217 | 106 | double ConstructionBase::getNetArea() const { | |
| 218 |
1/1✓ Branch 3 taken 106 times.
|
106 | return getImpl<detail::ConstructionBase_Impl>()->getNetArea(); |
| 219 | } | ||
| 220 | 1 | bool ConstructionBase::setUFactor(double value) { | |
| 221 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::ConstructionBase_Impl>()->setUFactor(value); |
| 222 | } | ||
| 223 | |||
| 224 | ✗ | bool ConstructionBase::setUFactor(double value, double filmResistance) { | |
| 225 | ✗ | return getImpl<detail::ConstructionBase_Impl>()->setUFactor(value, filmResistance); | |
| 226 | } | ||
| 227 | |||
| 228 | 4 | bool ConstructionBase::setConductance(double value) { | |
| 229 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::ConstructionBase_Impl>()->setConductance(value); |
| 230 | } | ||
| 231 | |||
| 232 | ✗ | bool ConstructionBase::setConductance(double value, double filmResistance) { | |
| 233 | ✗ | return getImpl<detail::ConstructionBase_Impl>()->setConductance(value, filmResistance); | |
| 234 | } | ||
| 235 | |||
| 236 | 2202 | bool ConstructionBase::isOpaque() const { | |
| 237 |
1/1✓ Branch 3 taken 2202 times.
|
2202 | return getImpl<detail::ConstructionBase_Impl>()->isOpaque(); |
| 238 | } | ||
| 239 | |||
| 240 | 134 | bool ConstructionBase::isFenestration() const { | |
| 241 |
1/1✓ Branch 3 taken 134 times.
|
134 | return getImpl<detail::ConstructionBase_Impl>()->isFenestration(); |
| 242 | } | ||
| 243 | |||
| 244 | 4 | bool ConstructionBase::isSolarDiffusing() const { | |
| 245 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::ConstructionBase_Impl>()->isSolarDiffusing(); |
| 246 | } | ||
| 247 | |||
| 248 | 1 | bool ConstructionBase::isModelPartition() const { | |
| 249 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::ConstructionBase_Impl>()->isModelPartition(); |
| 250 | } | ||
| 251 | |||
| 252 | 1 | bool ConstructionBase::isGreenRoof() const { | |
| 253 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::ConstructionBase_Impl>()->isGreenRoof(); |
| 254 | } | ||
| 255 | |||
| 256 | 15 | boost::optional<double> ConstructionBase::uFactor() const { | |
| 257 |
1/1✓ Branch 3 taken 15 times.
|
15 | return getImpl<detail::ConstructionBase_Impl>()->uFactor(); |
| 258 | } | ||
| 259 | |||
| 260 | 4 | boost::optional<double> ConstructionBase::uFactor(double filmResistance) const { | |
| 261 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::ConstructionBase_Impl>()->uFactor(filmResistance); |
| 262 | } | ||
| 263 | |||
| 264 | 228 | boost::optional<double> ConstructionBase::thermalConductance() const { | |
| 265 |
1/1✓ Branch 3 taken 228 times.
|
228 | return getImpl<detail::ConstructionBase_Impl>()->thermalConductance(); |
| 266 | } | ||
| 267 | |||
| 268 | 4 | boost::optional<double> ConstructionBase::thermalConductance(double filmResistance) const { | |
| 269 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::ConstructionBase_Impl>()->thermalConductance(filmResistance); |
| 270 | } | ||
| 271 | |||
| 272 | 2 | boost::optional<double> ConstructionBase::heatCapacity() const { | |
| 273 |
1/1✓ Branch 3 taken 2 times.
|
2 | return getImpl<detail::ConstructionBase_Impl>()->heatCapacity(); |
| 274 | } | ||
| 275 | |||
| 276 | 106 | boost::optional<double> ConstructionBase::interiorVisibleAbsorptance() const { | |
| 277 |
1/1✓ Branch 3 taken 106 times.
|
106 | return getImpl<detail::ConstructionBase_Impl>()->interiorVisibleAbsorptance(); |
| 278 | } | ||
| 279 | |||
| 280 | 106 | boost::optional<double> ConstructionBase::exteriorVisibleAbsorptance() const { | |
| 281 |
1/1✓ Branch 3 taken 106 times.
|
106 | return getImpl<detail::ConstructionBase_Impl>()->exteriorVisibleAbsorptance(); |
| 282 | } | ||
| 283 | |||
| 284 | 21 | boost::optional<double> ConstructionBase::visibleTransmittance() const { | |
| 285 |
1/1✓ Branch 3 taken 21 times.
|
21 | return getImpl<detail::ConstructionBase_Impl>()->visibleTransmittance(); |
| 286 | } | ||
| 287 | |||
| 288 | 330 | boost::optional<RenderingColor> ConstructionBase::renderingColor() const { | |
| 289 |
1/1✓ Branch 3 taken 330 times.
|
330 | return getImpl<detail::ConstructionBase_Impl>()->renderingColor(); |
| 290 | } | ||
| 291 | |||
| 292 | 72 | bool ConstructionBase::setRenderingColor(const RenderingColor& renderingColor) { | |
| 293 |
1/1✓ Branch 3 taken 72 times.
|
72 | return getImpl<detail::ConstructionBase_Impl>()->setRenderingColor(renderingColor); |
| 294 | } | ||
| 295 | |||
| 296 | ✗ | void ConstructionBase::resetRenderingColor() { | |
| 297 | ✗ | getImpl<detail::ConstructionBase_Impl>()->resetRenderingColor(); | |
| 298 | ✗ | } | |
| 299 | |||
| 300 | /// @cond | ||
| 301 | 2718 | ConstructionBase::ConstructionBase(IddObjectType type, const Model& model) : ResourceObject(type, model) { | |
| 302 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 2718 times.
✗ Branch 5 not taken.
|
2718 | OS_ASSERT(getImpl<detail::ConstructionBase_Impl>()); |
| 303 | 2718 | } | |
| 304 | |||
| 305 |
1/1✓ Branch 3 taken 63516 times.
|
63516 | ConstructionBase::ConstructionBase(std::shared_ptr<detail::ConstructionBase_Impl> impl) : ResourceObject(std::move(impl)) {} |
| 306 | /// @endcond | ||
| 307 | |||
| 308 | } // namespace model | ||
| 309 | } // namespace openstudio | ||
| 310 |