src/model/LayeredConstruction.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 "LayeredConstruction.hpp" | ||
| 7 | #include "LayeredConstruction_Impl.hpp" | ||
| 8 | #include "Model.hpp" | ||
| 9 | |||
| 10 | #include "StandardsInformationConstruction.hpp" | ||
| 11 | #include "Material.hpp" | ||
| 12 | #include "OpaqueMaterial.hpp" | ||
| 13 | #include "OpaqueMaterial_Impl.hpp" | ||
| 14 | #include "AirGap.hpp" | ||
| 15 | #include "AirGap_Impl.hpp" | ||
| 16 | #include "RoofVegetation.hpp" | ||
| 17 | #include "RoofVegetation_Impl.hpp" | ||
| 18 | #include "FenestrationMaterial.hpp" | ||
| 19 | #include "FenestrationMaterial_Impl.hpp" | ||
| 20 | #include "SimpleGlazing.hpp" | ||
| 21 | #include "SimpleGlazing_Impl.hpp" | ||
| 22 | #include "StandardGlazing.hpp" | ||
| 23 | #include "StandardGlazing_Impl.hpp" | ||
| 24 | #include "RefractionExtinctionGlazing.hpp" | ||
| 25 | #include "RefractionExtinctionGlazing_Impl.hpp" | ||
| 26 | #include "GasLayer.hpp" | ||
| 27 | #include "GasLayer_Impl.hpp" | ||
| 28 | #include "ShadingMaterial.hpp" | ||
| 29 | #include "ShadingMaterial_Impl.hpp" | ||
| 30 | #include "ModelPartitionMaterial.hpp" | ||
| 31 | #include "ModelPartitionMaterial_Impl.hpp" | ||
| 32 | |||
| 33 | #include "ModelExtensibleGroup.hpp" | ||
| 34 | |||
| 35 | #include "../utilities/idf/ValidityReport.hpp" | ||
| 36 | #include "../utilities/sql/SqlFile.hpp" | ||
| 37 | #include "../utilities/core/Assert.hpp" | ||
| 38 | |||
| 39 | namespace openstudio { | ||
| 40 | namespace model { | ||
| 41 | |||
| 42 | namespace detail { | ||
| 43 | |||
| 44 | 3343 | LayeredConstruction_Impl::LayeredConstruction_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 45 | 3343 | : ConstructionBase_Impl(idfObject, model, keepHandle) {} | |
| 46 | |||
| 47 | 686 | LayeredConstruction_Impl::LayeredConstruction_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 48 | 686 | : ConstructionBase_Impl(other, model, keepHandle) {} | |
| 49 | |||
| 50 | 1514 | LayeredConstruction_Impl::LayeredConstruction_Impl(const LayeredConstruction_Impl& other, Model_Impl* model, bool keepHandle) | |
| 51 | 1514 | : ConstructionBase_Impl(other, model, keepHandle) {} | |
| 52 | |||
| 53 | 11574 | std::vector<Material> LayeredConstruction_Impl::layers() const { | |
| 54 | 11574 | MaterialVector result; | |
| 55 | |||
| 56 | // loop through extensible groups | ||
| 57 |
3/3✓ Branch 1 taken 11574 times.
✓ Branch 8 taken 24898 times.
✓ Branch 9 taken 11574 times.
|
36472 | for (const IdfExtensibleGroup& idfGroup : extensibleGroups()) { |
| 58 |
1/1✓ Branch 1 taken 24898 times.
|
24898 | auto group = idfGroup.cast<ModelExtensibleGroup>(); |
| 59 | // get object pointed to by extensible group | ||
| 60 | // unit test checks that both layered constructions have extensible groups of size 1 | ||
| 61 | // implementation must change if that test starts failing | ||
| 62 |
1/1✓ Branch 1 taken 24898 times.
|
24898 | OptionalMaterial oMaterial = group.getModelObjectTarget<Material>(0); |
| 63 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 24898 times.
|
24898 | if (!oMaterial) { |
| 64 | ✗ | LOG(Warn, "Skipping layer " << group.groupIndex() << " in " << briefDescription() | |
| 65 | << ", as there is no Material object referenced by the corresponding field."); | ||
| 66 | ✗ | continue; | |
| 67 | ✗ | } | |
| 68 |
2/2✓ Branch 1 taken 24898 times.
✓ Branch 4 taken 24898 times.
|
24898 | result.push_back(*oMaterial); |
| 69 | 36472 | } | |
| 70 | |||
| 71 | 11574 | return result; | |
| 72 | ✗ | } | |
| 73 | |||
| 74 | 8 | Material LayeredConstruction_Impl::getLayer(unsigned layerIndex) const { | |
| 75 |
2/3✓ Branch 1 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
|
8 | if (layerIndex >= numLayers()) { |
| 76 | ✗ | LOG_AND_THROW("Asked to get material layer indexed " << layerIndex << ", but " << briefDescription() << " has just " << numLayers() | |
| 77 | << " layers."); | ||
| 78 | } | ||
| 79 | |||
| 80 |
1/1✓ Branch 1 taken 8 times.
|
8 | IdfExtensibleGroup idfGroup = getExtensibleGroup(layerIndex); |
| 81 |
2/4✓ Branch 1 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 6 not taken.
|
8 | OS_ASSERT(!idfGroup.empty()); |
| 82 |
1/1✓ Branch 1 taken 8 times.
|
8 | auto group = idfGroup.cast<ModelExtensibleGroup>(); |
| 83 |
1/1✓ Branch 1 taken 8 times.
|
8 | OptionalMaterial oMaterial = group.getModelObjectTarget<Material>(0); |
| 84 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
|
8 | if (!oMaterial) { |
| 85 | ✗ | LOG_AND_THROW("There is no material at layerIndex " << layerIndex << " in " << briefDescription() << "."); | |
| 86 | } | ||
| 87 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
16 | return *oMaterial; |
| 88 | 8 | } | |
| 89 | |||
| 90 | 16 | bool LayeredConstruction_Impl::eraseLayer(unsigned layerIndex) { | |
| 91 | |||
| 92 |
1/1✓ Branch 1 taken 16 times.
|
16 | layerIndex = mf_clearNullLayers(layerIndex); |
| 93 | |||
| 94 |
1/1✓ Branch 1 taken 16 times.
|
16 | MaterialVector layers = this->layers(); |
| 95 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
|
16 | if (!(layerIndex < layers.size())) { |
| 96 | ✗ | return false; | |
| 97 | } | ||
| 98 | 16 | auto layersBegin = layers.begin(); | |
| 99 | 16 | auto toEraseIt = layersBegin; | |
| 100 |
2/2✓ Branch 1 taken 31 times.
✓ Branch 2 taken 16 times.
|
47 | while (static_cast<unsigned>(toEraseIt - layersBegin) < layerIndex) { |
| 101 | 31 | ++toEraseIt; | |
| 102 | } | ||
| 103 |
1/1✓ Branch 2 taken 16 times.
|
16 | layers.erase(toEraseIt); |
| 104 | |||
| 105 |
6/14✓ Branch 1 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 7 taken 16 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 16 times.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 16 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 16 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
16 | if ((model().strictnessLevel() < StrictnessLevel::Final) || LayeredConstruction::layersAreValid(layers)) { |
| 106 |
1/1✓ Branch 1 taken 16 times.
|
16 | return !eraseExtensibleGroup(layerIndex).empty(); |
| 107 | } | ||
| 108 | |||
| 109 | ✗ | return false; | |
| 110 | 16 | } | |
| 111 | |||
| 112 | 1009 | bool LayeredConstruction_Impl::insertLayer(unsigned layerIndex, const Material& material) { | |
| 113 |
4/5✓ Branch 1 taken 1009 times.
✓ Branch 4 taken 1009 times.
✓ Branch 7 taken 1009 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1009 times.
|
1009 | if (material.model() != model()) { |
| 114 | ✗ | return false; | |
| 115 | } | ||
| 116 |
1/1✓ Branch 1 taken 1009 times.
|
1009 | layerIndex = mf_clearNullLayers(layerIndex); |
| 117 | |||
| 118 | // DLM: duplicates check in layersAreValid which is not called if strictness < Final | ||
| 119 |
3/3✓ Branch 1 taken 1009 times.
✓ Branch 3 taken 452 times.
✓ Branch 4 taken 557 times.
|
1009 | if (isFenestration()) { |
| 120 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 450 times.
|
452 | if (layerIndex >= 8) { |
| 121 | 2 | return false; | |
| 122 | } | ||
| 123 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 555 times.
|
557 | } else if (layerIndex >= 10) { |
| 124 | 2 | return false; | |
| 125 | } | ||
| 126 | |||
| 127 |
1/1✓ Branch 1 taken 1005 times.
|
1005 | unsigned n = numLayers(); |
| 128 |
1/1✓ Branch 1 taken 1005 times.
|
1005 | MaterialVector layers = this->layers(); |
| 129 | 1005 | auto layersBegin = layers.begin(); | |
| 130 | 1005 | auto layersEnd = layers.end(); | |
| 131 | 1005 | auto insertAtIt = layersBegin; | |
| 132 |
5/6✓ Branch 1 taken 1068 times.
✓ Branch 2 taken 1005 times.
✓ Branch 4 taken 1068 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1068 times.
✓ Branch 7 taken 1005 times.
|
2073 | while ((static_cast<unsigned>(insertAtIt - layersBegin) < layerIndex) && (insertAtIt != layersEnd)) { |
| 133 | 1068 | ++insertAtIt; | |
| 134 | } | ||
| 135 |
1/1✓ Branch 2 taken 1005 times.
|
1005 | layers.insert(insertAtIt, material); |
| 136 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 1005 times.
✗ Branch 4 not taken.
|
1005 | OS_ASSERT(layers.size() == ++n); |
| 137 |
6/14✓ Branch 1 taken 1005 times.
✓ Branch 4 taken 1005 times.
✓ Branch 7 taken 1005 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1005 times.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1005 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 1005 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1005 | if ((model().strictnessLevel() < StrictnessLevel::Final) || LayeredConstruction::layersAreValid(layers)) { |
| 138 |
1/1✓ Branch 2 taken 1005 times.
|
1005 | IdfExtensibleGroup idfGroup = insertExtensibleGroup(layerIndex, StringVector()); |
| 139 |
2/4✓ Branch 1 taken 1005 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1005 times.
✗ Branch 6 not taken.
|
1005 | OS_ASSERT(!idfGroup.empty()); |
| 140 |
1/1✓ Branch 1 taken 1005 times.
|
1005 | auto group = idfGroup.cast<ModelExtensibleGroup>(); |
| 141 |
2/2✓ Branch 1 taken 1005 times.
✓ Branch 4 taken 1005 times.
|
1005 | bool ok = group.setPointer(0, material.handle()); |
| 142 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 1005 times.
✗ Branch 3 not taken.
|
1005 | OS_ASSERT(ok); |
| 143 | 1005 | return true; | |
| 144 | 1005 | } | |
| 145 | |||
| 146 | ✗ | return false; | |
| 147 | 1005 | } | |
| 148 | |||
| 149 | ✗ | bool LayeredConstruction_Impl::setLayer(unsigned layerIndex, const Material& material) { | |
| 150 | ✗ | if (material.model() != model()) { | |
| 151 | ✗ | return false; | |
| 152 | } | ||
| 153 | ✗ | layerIndex = mf_clearNullLayers(layerIndex); | |
| 154 | ✗ | if (layerIndex >= numLayers()) { | |
| 155 | ✗ | LOG(Info, "Asked to change the Material at layer " << layerIndex << " in " << briefDescription() << ", but there are only " << numLayers() | |
| 156 | << " layers."); | ||
| 157 | ✗ | return false; | |
| 158 | } | ||
| 159 | |||
| 160 | ✗ | MaterialVector layers = this->layers(); | |
| 161 | ✗ | layers[layerIndex] = material; | |
| 162 | ✗ | if ((model().strictnessLevel() < StrictnessLevel::Final) || LayeredConstruction::layersAreValid(layers)) { | |
| 163 | ✗ | auto group = getExtensibleGroup(layerIndex).cast<ModelExtensibleGroup>(); | |
| 164 | ✗ | OS_ASSERT(!group.empty()); | |
| 165 | ✗ | bool ok = group.setPointer(0, material.handle()); | |
| 166 | ✗ | OS_ASSERT(ok); | |
| 167 | ✗ | return true; | |
| 168 | ✗ | } | |
| 169 | |||
| 170 | ✗ | return false; | |
| 171 | ✗ | } | |
| 172 | |||
| 173 | 1765 | bool LayeredConstruction_Impl::setLayers(const std::vector<Material>& materials) { | |
| 174 | |||
| 175 | // DLM: duplicates check in layersAreValid which is not called if strictness < Final | ||
| 176 |
2/2✓ Branch 1 taken 1763 times.
✓ Branch 2 taken 2 times.
|
1765 | if (materials.empty()) { |
| 177 | // ok | ||
| 178 |
3/3✓ Branch 2 taken 1763 times.
✓ Branch 5 taken 371 times.
✓ Branch 6 taken 1392 times.
|
3526 | } else if (materials[0].optionalCast<FenestrationMaterial>()) { |
| 179 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 370 times.
|
371 | if (materials.size() > 8) { |
| 180 | 1 | return false; | |
| 181 | } | ||
| 182 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 2 taken 1391 times.
|
1392 | } else if (materials.size() > 10) { |
| 183 | 1 | return false; | |
| 184 | } | ||
| 185 |
2/2✓ Branch 5 taken 3863 times.
✓ Branch 6 taken 1763 times.
|
5626 | for (const Material& material : materials) { |
| 186 |
4/5✓ Branch 1 taken 3863 times.
✓ Branch 4 taken 3863 times.
✓ Branch 7 taken 3863 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3863 times.
|
3863 | if (material.model() != model()) { |
| 187 | ✗ | return false; | |
| 188 | } | ||
| 189 | } | ||
| 190 | |||
| 191 |
6/14✓ Branch 1 taken 1763 times.
✓ Branch 4 taken 1763 times.
✓ Branch 7 taken 1763 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1763 times.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 1763 times.
✗ Branch 18 not taken.
✓ Branch 20 taken 1763 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
|
1763 | if ((model().strictnessLevel() < StrictnessLevel::Final) || LayeredConstruction::layersAreValid(materials)) { |
| 192 |
1/1✓ Branch 1 taken 1763 times.
|
1763 | clearExtensibleGroups(); |
| 193 |
2/2✓ Branch 5 taken 3863 times.
✓ Branch 6 taken 1763 times.
|
5626 | for (const Material& material : materials) { |
| 194 |
4/6✓ Branch 1 taken 3863 times.
✓ Branch 4 taken 3863 times.
✓ Branch 7 taken 3863 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3863 times.
✗ Branch 12 not taken.
|
3863 | OS_ASSERT(material.model() == model()); |
| 195 |
2/2✓ Branch 2 taken 3863 times.
✓ Branch 5 taken 3863 times.
|
3863 | auto group = pushExtensibleGroup(StringVector(), false).cast<ModelExtensibleGroup>(); |
| 196 |
2/4✓ Branch 1 taken 3863 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3863 times.
✗ Branch 6 not taken.
|
3863 | OS_ASSERT(!group.empty()); |
| 197 |
2/2✓ Branch 1 taken 3863 times.
✓ Branch 4 taken 3863 times.
|
3863 | bool ok = group.setPointer(0, material.handle()); |
| 198 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 3863 times.
✗ Branch 3 not taken.
|
3863 | OS_ASSERT(ok); |
| 199 | 3863 | } | |
| 200 | 1763 | return true; | |
| 201 | } | ||
| 202 | |||
| 203 | ✗ | return false; | |
| 204 | } | ||
| 205 | |||
| 206 | ✗ | bool LayeredConstruction_Impl::setLayer(const ModelPartitionMaterial& modelPartitionMaterial) { | |
| 207 | |||
| 208 | ✗ | if (modelPartitionMaterial.model() != model()) { | |
| 209 | ✗ | return false; | |
| 210 | } | ||
| 211 | ✗ | clearExtensibleGroups(); | |
| 212 | ✗ | auto group = pushExtensibleGroup(StringVector(), false).cast<ModelExtensibleGroup>(); | |
| 213 | ✗ | OS_ASSERT(!group.empty()); | |
| 214 | ✗ | bool ok = group.setPointer(0, modelPartitionMaterial.handle()); | |
| 215 | ✗ | OS_ASSERT(ok); | |
| 216 | ✗ | return true; | |
| 217 | ✗ | } | |
| 218 | |||
| 219 | ✗ | bool LayeredConstruction_Impl::setUFactor(double value) { | |
| 220 | ✗ | if (isFenestration()) { | |
| 221 | ✗ | FenestrationMaterialVector fenestrationLayers = castVector<FenestrationMaterial>(layers()); | |
| 222 | // can only set if one layer == SimpleGlazing | ||
| 223 | ✗ | if ((fenestrationLayers.size() == 1) && (fenestrationLayers[0].optionalCast<SimpleGlazing>())) { | |
| 224 | ✗ | auto simpleGlazing = fenestrationLayers[0].cast<SimpleGlazing>(); | |
| 225 | ✗ | return simpleGlazing.setUFactor(value); | |
| 226 | ✗ | } | |
| 227 | ✗ | } | |
| 228 | ✗ | return false; | |
| 229 | } | ||
| 230 | |||
| 231 | ✗ | bool LayeredConstruction_Impl::setUFactor(double value, double filmResistance) { | |
| 232 | ✗ | if (isOpaque()) { | |
| 233 | // convert to conductance | ||
| 234 | ✗ | double thermalResistance = 1.0 / value - filmResistance; | |
| 235 | ✗ | return setThermalConductance(1.0 / thermalResistance); | |
| 236 | } | ||
| 237 | ✗ | if (isFenestration()) { | |
| 238 | ✗ | FenestrationMaterialVector fenestrationLayers = castVector<FenestrationMaterial>(layers()); | |
| 239 | ✗ | if (fenestrationLayers.size() == 1) { | |
| 240 | ✗ | if (fenestrationLayers[0].optionalCast<SimpleGlazing>()) { | |
| 241 | ✗ | return setUFactor(value); | |
| 242 | } | ||
| 243 | ✗ | if (fenestrationLayers[0].optionalCast<StandardGlazing>() || fenestrationLayers[0].optionalCast<RefractionExtinctionGlazing>()) { | |
| 244 | // convert to conductance | ||
| 245 | ✗ | double thermalResistance = 1.0 / value - filmResistance; | |
| 246 | ✗ | return setThermalConductance(1.0 / thermalResistance); | |
| 247 | } | ||
| 248 | } | ||
| 249 | ✗ | } | |
| 250 | ✗ | return false; | |
| 251 | } | ||
| 252 | |||
| 253 | 3 | bool LayeredConstruction_Impl::setThermalConductance(double value) { | |
| 254 |
3/6✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
|
3 | if (isOpaque() && !isGreenRoof()) { |
| 255 |
7/7✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
|
3 | LOG(Trace, "Attempting to set the thermal conductance of an opaque construction to " << value << ".") |
| 256 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | OpaqueMaterialVector opaqueLayers = castVector<OpaqueMaterial>(layers()); |
| 257 | // can set if one layer ... | ||
| 258 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (opaqueLayers.size() == 1) { |
| 259 | ✗ | LOG(Trace, "Single-layer construction, setting conductance of " << '\n' << opaqueLayers[0] << "."); | |
| 260 | ✗ | return opaqueLayers[0].setThermalConductance(value); | |
| 261 | } | ||
| 262 | // ... or if perturbable construction is called out | ||
| 263 |
1/1✓ Branch 1 taken 3 times.
|
3 | StandardsInformationConstruction stdsInfo = standardsInformation(); |
| 264 |
1/1✓ Branch 1 taken 3 times.
|
3 | OptionalMaterial oMaterial = stdsInfo.perturbableLayer(); |
| 265 |
4/7✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
|
6 | if (oMaterial && thermalConductance()) { |
| 266 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | auto perturbableLayer = oMaterial->cast<OpaqueMaterial>(); |
| 267 | // calculate required resistance of perturbableLayer | ||
| 268 | 3 | double desiredResistance = 1.0 / value; | |
| 269 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | double currentResistance = 1.0 / thermalConductance().get(); |
| 270 |
1/1✓ Branch 1 taken 3 times.
|
3 | double layerResistance = perturbableLayer.thermalResistance(); |
| 271 | // desired - contribution from other layers | ||
| 272 | 3 | double desiredLayerResistance = desiredResistance - (currentResistance - layerResistance); | |
| 273 |
10/10✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
✓ Branch 19 taken 3 times.
✓ Branch 22 taken 3 times.
✓ Branch 25 taken 3 times.
✓ Branch 28 taken 3 times.
|
3 | LOG(Trace, "Attempting to set thermal conductance of " << '\n' << perturbableLayer << " to " << desiredLayerResistance << "."); |
| 274 |
1/1✓ Branch 1 taken 3 times.
|
3 | return perturbableLayer.setThermalResistance(desiredLayerResistance); |
| 275 | 3 | } | |
| 276 | 9 | } | |
| 277 | ✗ | if (isFenestration()) { | |
| 278 | ✗ | FenestrationMaterialVector fenestrationLayers = castVector<FenestrationMaterial>(layers()); | |
| 279 | // can only set if one layer and StandardGlazing or RefractionExtinctionGlazing | ||
| 280 | ✗ | if (fenestrationLayers.size() == 1) { | |
| 281 | ✗ | OptionalStandardGlazing oStandardGlazing = fenestrationLayers[0].optionalCast<StandardGlazing>(); | |
| 282 | ✗ | if (oStandardGlazing) { | |
| 283 | ✗ | return oStandardGlazing->setThermalConductance(value); | |
| 284 | } | ||
| 285 | ✗ | OptionalRefractionExtinctionGlazing oRefractionExtinctionGlazing = fenestrationLayers[0].optionalCast<RefractionExtinctionGlazing>(); | |
| 286 | ✗ | if (oRefractionExtinctionGlazing) { | |
| 287 | ✗ | return oRefractionExtinctionGlazing->setThermalConductance(value); | |
| 288 | } | ||
| 289 | ✗ | } | |
| 290 | ✗ | } | |
| 291 | ✗ | return false; | |
| 292 | } | ||
| 293 | |||
| 294 | ✗ | bool LayeredConstruction_Impl::setThermalConductance(double value, double filmResistance) { | |
| 295 | ✗ | if (isOpaque()) { | |
| 296 | ✗ | return setThermalConductance(value); | |
| 297 | } | ||
| 298 | ✗ | if (isFenestration()) { | |
| 299 | ✗ | FenestrationMaterialVector fenestrationLayers = castVector<FenestrationMaterial>(layers()); | |
| 300 | ✗ | if (fenestrationLayers.size() == 1) { | |
| 301 | ✗ | if (fenestrationLayers[0].optionalCast<StandardGlazing>() || fenestrationLayers[0].optionalCast<RefractionExtinctionGlazing>()) { | |
| 302 | ✗ | return setThermalConductance(value); | |
| 303 | } | ||
| 304 | ✗ | if (fenestrationLayers[0].optionalCast<SimpleGlazing>()) { | |
| 305 | // convert to u-factor | ||
| 306 | ✗ | double thermalResistance = 1.0 / value + filmResistance; | |
| 307 | ✗ | return setUFactor(1.0 / thermalResistance); | |
| 308 | } | ||
| 309 | } | ||
| 310 | ✗ | } | |
| 311 | ✗ | return false; | |
| 312 | } | ||
| 313 | |||
| 314 | 3 | bool LayeredConstruction_Impl::setConductance(double value) { | |
| 315 | 3 | return setThermalConductance(value); | |
| 316 | } | ||
| 317 | |||
| 318 | ✗ | bool LayeredConstruction_Impl::setConductance(double value, double filmResistance) { | |
| 319 | ✗ | return setThermalConductance(value, filmResistance); | |
| 320 | } | ||
| 321 | |||
| 322 | 2302 | bool LayeredConstruction_Impl::isOpaque() const { | |
| 323 |
1/1✓ Branch 1 taken 2302 times.
|
2302 | MaterialVector layers = this->layers(); |
| 324 |
2/2✓ Branch 5 taken 6176 times.
✓ Branch 6 taken 1880 times.
|
8056 | for (const Material& layer : layers) { |
| 325 |
3/3✓ Branch 1 taken 6176 times.
✓ Branch 5 taken 422 times.
✓ Branch 6 taken 5754 times.
|
6176 | if (!layer.optionalCast<OpaqueMaterial>()) { |
| 326 | 422 | return false; | |
| 327 | } | ||
| 328 | } | ||
| 329 | 1880 | return true; | |
| 330 | 2302 | } | |
| 331 | |||
| 332 | 1375 | bool LayeredConstruction_Impl::isFenestration() const { | |
| 333 |
1/1✓ Branch 1 taken 1375 times.
|
1375 | MaterialVector layers = this->layers(); |
| 334 |
2/2✓ Branch 5 taken 1022 times.
✓ Branch 6 taken 690 times.
|
1712 | for (const Material& layer : layers) { |
| 335 |
3/3✓ Branch 1 taken 1022 times.
✓ Branch 5 taken 685 times.
✓ Branch 6 taken 337 times.
|
1022 | if (!layer.optionalCast<FenestrationMaterial>()) { |
| 336 | 685 | return false; | |
| 337 | } | ||
| 338 | } | ||
| 339 | 690 | return true; | |
| 340 | 1375 | } | |
| 341 | |||
| 342 | 3 | bool LayeredConstruction_Impl::isSolarDiffusing() const { | |
| 343 | |||
| 344 | // empty material is not solar diffusing | ||
| 345 |
1/1✓ Branch 1 taken 3 times.
|
3 | MaterialVector layers = this->layers(); |
| 346 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
|
3 | if (layers.empty()) { |
| 347 | ✗ | return false; | |
| 348 | } | ||
| 349 | |||
| 350 | // if not fenestration then this is not solar diffusing | ||
| 351 |
2/3✓ Branch 1 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
|
3 | if (!this->isFenestration()) { |
| 352 | ✗ | return false; | |
| 353 | } | ||
| 354 | |||
| 355 | // return true if any layer is solar diffusing | ||
| 356 |
2/2✓ Branch 5 taken 3 times.
✓ Branch 6 taken 3 times.
|
6 | for (const Material& layer : layers) { |
| 357 |
2/3✓ Branch 1 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
|
6 | if (layer.optionalCast<StandardGlazing>()) { |
| 358 | ✗ | if (layer.cast<StandardGlazing>().solarDiffusing()) { | |
| 359 | ✗ | return true; | |
| 360 | } | ||
| 361 |
2/3✓ Branch 1 taken 3 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
|
6 | } else if (layer.optionalCast<RefractionExtinctionGlazing>()) { |
| 362 | ✗ | if (layer.cast<RefractionExtinctionGlazing>().solarDiffusing()) { | |
| 363 | ✗ | return true; | |
| 364 | } | ||
| 365 |
1/1✓ Branch 1 taken 3 times.
|
6 | } else if (layer.optionalCast<SimpleGlazing>()) { |
| 366 | // DLM: we do not know if this is solar diffusing or not | ||
| 367 | // would need to add a field to OS:WindowMaterial:SimpleGlazingSystem | ||
| 368 | } | ||
| 369 | } | ||
| 370 | |||
| 371 | // otherwise false | ||
| 372 | 3 | return false; | |
| 373 | 3 | } | |
| 374 | |||
| 375 | ✗ | bool LayeredConstruction_Impl::isModelPartition() const { | |
| 376 | ✗ | MaterialVector layers = this->layers(); | |
| 377 | ✗ | for (const Material& layer : layers) { | |
| 378 | ✗ | if (!layer.optionalCast<ModelPartitionMaterial>()) { | |
| 379 | ✗ | return false; | |
| 380 | } | ||
| 381 | } | ||
| 382 | ✗ | return true; | |
| 383 | ✗ | } | |
| 384 | |||
| 385 | 3 | bool LayeredConstruction_Impl::isGreenRoof() const { | |
| 386 |
1/1✓ Branch 1 taken 3 times.
|
3 | MaterialVector layers = this->layers(); |
| 387 |
5/11✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
|
6 | if ((!layers.empty()) && (layers[0].optionalCast<RoofVegetation>())) { |
| 388 | ✗ | return true; | |
| 389 | } | ||
| 390 | 3 | return false; | |
| 391 | 3 | } | |
| 392 | |||
| 393 | 37 | bool LayeredConstruction_Impl::isSymmetric() const { | |
| 394 |
1/1✓ Branch 1 taken 37 times.
|
37 | MaterialVector layers = this->layers(); |
| 395 |
1/1✓ Branch 1 taken 37 times.
|
37 | MaterialVector reverseLayers(layers); |
| 396 |
1/1✓ Branch 3 taken 37 times.
|
37 | std::reverse(reverseLayers.begin(), reverseLayers.end()); |
| 397 | 37 | unsigned N = layers.size(); | |
| 398 |
2/2✓ Branch 0 taken 66 times.
✓ Branch 1 taken 30 times.
|
96 | for (unsigned i = 0; i < N; ++i) { |
| 399 |
5/5✓ Branch 2 taken 66 times.
✓ Branch 6 taken 66 times.
✓ Branch 9 taken 66 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 59 times.
|
66 | if (layers[i].handle() != reverseLayers[i].handle()) { |
| 400 | 7 | return false; | |
| 401 | } | ||
| 402 | } | ||
| 403 | 30 | return true; | |
| 404 | 37 | } | |
| 405 | |||
| 406 | ✗ | bool LayeredConstruction_Impl::equalLayers(const LayeredConstruction& other) const { | |
| 407 | ✗ | MaterialVector layers = this->layers(); | |
| 408 | ✗ | MaterialVector otherLayers(other.layers()); | |
| 409 | |||
| 410 | ✗ | if (layers.size() != otherLayers.size()) { | |
| 411 | ✗ | return false; | |
| 412 | } | ||
| 413 | |||
| 414 | ✗ | for (unsigned i = 0; i < layers.size(); ++i) { | |
| 415 | ✗ | if (layers[i].handle() != otherLayers[i].handle()) { | |
| 416 | ✗ | return false; | |
| 417 | } | ||
| 418 | } | ||
| 419 | |||
| 420 | ✗ | return true; | |
| 421 | ✗ | } | |
| 422 | |||
| 423 | 1961 | bool LayeredConstruction_Impl::reverseEqualLayers(const LayeredConstruction& other) const { | |
| 424 |
1/1✓ Branch 1 taken 1961 times.
|
1961 | MaterialVector layers = this->layers(); |
| 425 |
1/1✓ Branch 1 taken 1961 times.
|
1961 | MaterialVector reverseLayers(other.layers()); |
| 426 | |||
| 427 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 1961 times.
|
1961 | if (layers.size() != reverseLayers.size()) { |
| 428 | ✗ | return false; | |
| 429 | } | ||
| 430 | |||
| 431 |
1/1✓ Branch 3 taken 1961 times.
|
1961 | std::reverse(reverseLayers.begin(), reverseLayers.end()); |
| 432 | |||
| 433 |
2/2✓ Branch 1 taken 4900 times.
✓ Branch 2 taken 1961 times.
|
6861 | for (unsigned i = 0; i < layers.size(); ++i) { |
| 434 |
4/5✓ Branch 2 taken 4900 times.
✓ Branch 6 taken 4900 times.
✓ Branch 9 taken 4900 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4900 times.
|
4900 | if (layers[i].handle() != reverseLayers[i].handle()) { |
| 435 | ✗ | return false; | |
| 436 | } | ||
| 437 | } | ||
| 438 | |||
| 439 | 1961 | return true; | |
| 440 | 1961 | } | |
| 441 | |||
| 442 | 1025 | std::vector<unsigned> LayeredConstruction_Impl::nullLayers() const { | |
| 443 | 1025 | UnsignedVector result; | |
| 444 | |||
| 445 | // loop through extensible groups | ||
| 446 |
3/3✓ Branch 1 taken 1025 times.
✓ Branch 8 taken 1181 times.
✓ Branch 9 taken 1025 times.
|
2206 | for (const IdfExtensibleGroup& idfGroup : extensibleGroups()) { |
| 447 |
1/1✓ Branch 1 taken 1181 times.
|
1181 | auto group = idfGroup.cast<ModelExtensibleGroup>(); |
| 448 |
1/1✓ Branch 1 taken 1181 times.
|
1181 | OptionalMaterial oMaterial = group.getModelObjectTarget<Material>(0); |
| 449 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1181 times.
|
1181 | if (!oMaterial) { |
| 450 | ✗ | result.push_back(group.groupIndex()); // non-Material object referenced | |
| 451 | } | ||
| 452 | 2206 | } | |
| 453 | |||
| 454 | 1025 | return result; | |
| 455 | ✗ | } | |
| 456 | |||
| 457 | 1632 | unsigned LayeredConstruction_Impl::numLayers() const { | |
| 458 |
1/1✓ Branch 1 taken 1632 times.
|
1632 | return this->layers().size(); |
| 459 | } | ||
| 460 | |||
| 461 | 336 | std::vector<unsigned> LayeredConstruction_Impl::getLayerIndices(const Material& material) const { | |
| 462 | 336 | UnsignedVector result; | |
| 463 |
4/4✓ Branch 1 taken 336 times.
✓ Branch 4 taken 336 times.
✓ Branch 12 taken 1176 times.
✓ Branch 13 taken 336 times.
|
1512 | for (const ModelExtensibleGroup& group : castVector<ModelExtensibleGroup>(extensibleGroups())) { |
| 464 |
1/1✓ Branch 1 taken 1176 times.
|
1176 | OptionalMaterial oMaterial = group.getModelObjectTarget<Material>(0); |
| 465 |
7/8✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 1176 times.
✓ Branch 6 taken 1176 times.
✓ Branch 8 taken 336 times.
✓ Branch 9 taken 840 times.
✓ Branch 10 taken 336 times.
✓ Branch 11 taken 840 times.
|
1176 | if (oMaterial && (material == *oMaterial)) { |
| 466 |
2/2✓ Branch 1 taken 336 times.
✓ Branch 4 taken 336 times.
|
336 | result.push_back(group.groupIndex()); |
| 467 | } | ||
| 468 | 1512 | } | |
| 469 | 336 | return result; | |
| 470 | ✗ | } | |
| 471 | |||
| 472 | 6 | boost::optional<double> LayeredConstruction_Impl::uFactor() const { | |
| 473 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 2 times.
|
6 | if (isFenestration()) { |
| 474 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | FenestrationMaterialVector fenestrationLayers = castVector<FenestrationMaterial>(layers()); |
| 475 |
1/2✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
4 | if (fenestrationLayers.size() == 1) { |
| 476 |
1/1✓ Branch 2 taken 4 times.
|
4 | OptionalSimpleGlazing oSimpleGlazing = fenestrationLayers[0].optionalCast<SimpleGlazing>(); |
| 477 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (oSimpleGlazing) { |
| 478 | ✗ | return oSimpleGlazing->uFactor(); | |
| 479 | } | ||
| 480 | 4 | } | |
| 481 | 4 | } | |
| 482 | 6 | return boost::none; | |
| 483 | } | ||
| 484 | |||
| 485 | 4 | boost::optional<double> LayeredConstruction_Impl::uFactor(double filmResistance) const { | |
| 486 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble result = uFactor(); |
| 487 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | if (result) { |
| 488 | ✗ | return result; | |
| 489 | } | ||
| 490 |
1/1✓ Branch 1 taken 4 times.
|
4 | result = thermalConductance(); |
| 491 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | if (result) { |
| 492 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | result = 1.0 / (1.0 / (*result) + filmResistance); |
| 493 | } | ||
| 494 | 4 | return result; | |
| 495 | } | ||
| 496 | |||
| 497 | 241 | boost::optional<double> LayeredConstruction_Impl::thermalConductance() const { | |
| 498 |
2/2✓ Branch 1 taken 237 times.
✓ Branch 2 taken 4 times.
|
241 | if (isOpaque()) { |
| 499 |
2/2✓ Branch 1 taken 237 times.
✓ Branch 4 taken 237 times.
|
237 | OpaqueMaterialVector opaqueLayers = castVector<OpaqueMaterial>(layers()); |
| 500 | 237 | double thermalResistance(0.0); | |
| 501 |
2/2✓ Branch 4 taken 955 times.
✓ Branch 5 taken 237 times.
|
1192 | for (const OpaqueMaterial& layer : opaqueLayers) { |
| 502 |
1/1✓ Branch 1 taken 955 times.
|
955 | thermalResistance += layer.thermalResistance(); |
| 503 | } | ||
| 504 |
1/1✓ Branch 1 taken 237 times.
|
237 | return 1.0 / thermalResistance; |
| 505 | 237 | } | |
| 506 | 4 | return boost::none; | |
| 507 | } | ||
| 508 | |||
| 509 | 4 | boost::optional<double> LayeredConstruction_Impl::thermalConductance(double filmResistance) const { | |
| 510 |
1/1✓ Branch 1 taken 4 times.
|
4 | OptionalDouble result = thermalConductance(); |
| 511 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | if (result) { |
| 512 | 2 | return result; | |
| 513 | } | ||
| 514 |
1/1✓ Branch 1 taken 2 times.
|
2 | result = uFactor(); |
| 515 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (result) { |
| 516 | ✗ | result = 1.0 / (1.0 / (*result) - filmResistance); | |
| 517 | } | ||
| 518 | 2 | return result; | |
| 519 | } | ||
| 520 | |||
| 521 | ✗ | boost::optional<double> LayeredConstruction_Impl::heatCapacity() const { | |
| 522 | ✗ | if (isOpaque()) { | |
| 523 | ✗ | OpaqueMaterialVector opaqueLayers = castVector<OpaqueMaterial>(layers()); | |
| 524 | ✗ | double heatCapacity(0.0); | |
| 525 | ✗ | for (const auto& layer : opaqueLayers) { | |
| 526 | ✗ | OptionalDouble temp = layer.heatCapacity(); | |
| 527 | ✗ | if (temp) { | |
| 528 | ✗ | heatCapacity += *temp; | |
| 529 | } | ||
| 530 | } | ||
| 531 | ✗ | return heatCapacity; | |
| 532 | ✗ | } | |
| 533 | ✗ | return boost::none; | |
| 534 | } | ||
| 535 | |||
| 536 | 105 | boost::optional<double> LayeredConstruction_Impl::interiorVisibleAbsorptance() const { | |
| 537 |
1/1✓ Branch 1 taken 105 times.
|
105 | MaterialVector layers = this->layers(); |
| 538 |
1/2✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
|
105 | if (!layers.empty()) { |
| 539 |
1/1✓ Branch 2 taken 105 times.
|
105 | return layers.back().interiorVisibleAbsorptance(); |
| 540 | } | ||
| 541 | ✗ | return boost::none; | |
| 542 | 105 | } | |
| 543 | |||
| 544 | 105 | boost::optional<double> LayeredConstruction_Impl::exteriorVisibleAbsorptance() const { | |
| 545 |
1/1✓ Branch 1 taken 105 times.
|
105 | MaterialVector layers = this->layers(); |
| 546 |
1/2✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
|
105 | if (!layers.empty()) { |
| 547 |
1/1✓ Branch 2 taken 105 times.
|
105 | return layers.front().exteriorVisibleAbsorptance(); |
| 548 | } | ||
| 549 | ✗ | return boost::none; | |
| 550 | 105 | } | |
| 551 | |||
| 552 | 6 | boost::optional<double> LayeredConstruction_Impl::visibleTransmittance() const { | |
| 553 |
2/3✓ Branch 1 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
|
6 | if (isOpaque()) { |
| 554 | ✗ | return 0.0; | |
| 555 | } | ||
| 556 |
1/1✓ Branch 1 taken 6 times.
|
6 | MaterialVector layers = this->layers(); |
| 557 | 6 | OptionalDouble result; | |
| 558 |
1/2✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
|
6 | if (layers.size() == 1) { |
| 559 | try { | ||
| 560 |
1/1✓ Branch 2 taken 6 times.
|
6 | result = layers[0].getVisibleTransmittance(); |
| 561 | ✗ | } catch (...) { | |
| 562 | ✗ | } | |
| 563 | } | ||
| 564 | /* | ||
| 565 | // duplicates code in PlanarSurface_Impl::visibleTransmittance | ||
| 566 | if (!result){ | ||
| 567 | OptionalSqlFile mySqlFile = model().sqlFile(); | ||
| 568 | if (mySqlFile && mySqlFile->connectionOpen()) | ||
| 569 | { | ||
| 570 | boost::optional<std::string> name = this->name(); | ||
| 571 | if (name){ | ||
| 572 | std::string query = "SELECT RowName FROM tabulardatawithstrings WHERE \ | ||
| 573 | ReportName = 'EnvelopeSummary' AND \ | ||
| 574 | ReportForString = 'Entire Facility' AND \ | ||
| 575 | ColumnName = 'Construction' AND \ | ||
| 576 | Value = '"; | ||
| 577 | query += boost::to_upper_copy(*name); | ||
| 578 | query += "';"; | ||
| 579 | boost::optional<std::string> surfaceName = mySqlFile->execAndReturnFirstString(query); | ||
| 580 | if (surfaceName){ | ||
| 581 | |||
| 582 | query = "SELECT Value FROM tabulardatawithstrings WHERE \ | ||
| 583 | ReportName = 'EnvelopeSummary' AND \ | ||
| 584 | ReportForString = 'Entire Facility' AND \ | ||
| 585 | ColumnName = 'Glass Visible Transmittance' AND \ | ||
| 586 | RowName = '"; | ||
| 587 | query += boost::to_upper_copy(*surfaceName); | ||
| 588 | query += "';"; | ||
| 589 | result = mySqlFile->execAndReturnFirstDouble(query); | ||
| 590 | } | ||
| 591 | } | ||
| 592 | } | ||
| 593 | } | ||
| 594 | */ | ||
| 595 | |||
| 596 | 6 | return result; | |
| 597 | 6 | } | |
| 598 | |||
| 599 | 3 | boost::optional<OpaqueMaterial> LayeredConstruction_Impl::insulation() const { | |
| 600 |
1/1✓ Branch 1 taken 3 times.
|
3 | StandardsInformationConstruction stdsInfo = standardsInformation(); |
| 601 |
1/1✓ Branch 1 taken 3 times.
|
3 | boost::optional<std::string> perturbableLayerType = stdsInfo.perturbableLayerType(); |
| 602 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (perturbableLayerType) { |
| 603 |
4/5✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
|
6 | if (istringEqual(*perturbableLayerType, "Insulation")) { |
| 604 |
1/1✓ Branch 1 taken 3 times.
|
3 | OptionalMaterial result = stdsInfo.perturbableLayer(); |
| 605 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (result) { |
| 606 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | return result->optionalCast<OpaqueMaterial>(); |
| 607 | } | ||
| 608 | 3 | } | |
| 609 | } | ||
| 610 | ✗ | return boost::none; | |
| 611 | 3 | } | |
| 612 | |||
| 613 | 336 | bool LayeredConstruction_Impl::setInsulation(const OpaqueMaterial& insulationLayer) { | |
| 614 |
1/1✓ Branch 1 taken 336 times.
|
336 | UnsignedVector indices = getLayerIndices(insulationLayer); |
| 615 |
1/2✓ Branch 1 taken 336 times.
✗ Branch 2 not taken.
|
336 | if (indices.size() == 1) { |
| 616 |
1/1✓ Branch 1 taken 336 times.
|
336 | StandardsInformationConstruction stdsInfo = standardsInformation(); |
| 617 |
1/1✓ Branch 2 taken 336 times.
|
336 | stdsInfo.setPerturbableLayer(indices[0]); |
| 618 |
2/2✓ Branch 1 taken 336 times.
✓ Branch 4 taken 336 times.
|
336 | stdsInfo.setPerturbableLayerType("Insulation"); |
| 619 | 336 | return true; | |
| 620 | 336 | } | |
| 621 | ✗ | return false; | |
| 622 | 336 | } | |
| 623 | |||
| 624 | ✗ | void LayeredConstruction_Impl::resetInsulation() { | |
| 625 | ✗ | StandardsInformationConstruction stdsInfo = standardsInformation(); | |
| 626 | ✗ | boost::optional<std::string> perturbableLayerType = stdsInfo.perturbableLayerType(); | |
| 627 | ✗ | if (perturbableLayerType) { | |
| 628 | ✗ | if (istringEqual(*perturbableLayerType, "Insulation")) { | |
| 629 | ✗ | stdsInfo.resetPerturbableLayer(); | |
| 630 | } | ||
| 631 | } | ||
| 632 | ✗ | } | |
| 633 | |||
| 634 | 6 | void LayeredConstruction_Impl::ensureUniqueLayers() { | |
| 635 | // loop through extensible groups | ||
| 636 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 8 taken 14 times.
✓ Branch 9 taken 6 times.
|
20 | for (const IdfExtensibleGroup& idfGroup : extensibleGroups()) { |
| 637 |
1/1✓ Branch 1 taken 14 times.
|
14 | auto group = idfGroup.cast<ModelExtensibleGroup>(); |
| 638 | // get object pointed to by extensible group | ||
| 639 | // unit test checks that both layered constructions have extensible groups of size 1 | ||
| 640 | // implementation must change if that test starts failing | ||
| 641 |
1/1✓ Branch 1 taken 14 times.
|
14 | OptionalMaterial oMaterial = group.getModelObjectTarget<Material>(0); |
| 642 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
|
14 | if (!oMaterial) { |
| 643 | ✗ | LOG(Warn, "Skipping layer " << group.groupIndex() << " in " << briefDescription() | |
| 644 | << ", as there is no Material object referenced by the corresponding field."); | ||
| 645 | ✗ | continue; | |
| 646 | ✗ | } | |
| 647 |
2/2✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
|
14 | unsigned numSources = oMaterial->getModelObjectSources<LayeredConstruction>().size(); |
| 648 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12 times.
|
14 | if (numSources > 1) { |
| 649 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | ModelObject newMaterial = oMaterial->clone(); |
| 650 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | bool test = group.setPointer(0, newMaterial.handle()); |
| 651 |
1/3✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
|
2 | OS_ASSERT(test); |
| 652 | 2 | } | |
| 653 | 20 | } | |
| 654 | 6 | } | |
| 655 | |||
| 656 | 1025 | unsigned LayeredConstruction_Impl::mf_clearNullLayers(unsigned layerIndex) { | |
| 657 |
1/1✓ Branch 1 taken 1025 times.
|
1025 | UnsignedVector indices = nullLayers(); |
| 658 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1025 times.
|
1025 | for (int i = indices.size() - 1; i >= 0; --i) { |
| 659 | ✗ | unsigned index = indices[i]; | |
| 660 | ✗ | StringVector eraseResult = eraseExtensibleGroup(index); | |
| 661 | ✗ | OS_ASSERT(!eraseResult.empty()); | |
| 662 | ✗ | if (layerIndex > index) { | |
| 663 | ✗ | --layerIndex; | |
| 664 | } | ||
| 665 | ✗ | } | |
| 666 | 1025 | return layerIndex; | |
| 667 | 1025 | } | |
| 668 | |||
| 669 | ✗ | boost::optional<ModelObject> LayeredConstruction_Impl::insulationAsModelObject() const { | |
| 670 | ✗ | OptionalModelObject result; | |
| 671 | ✗ | OptionalOpaqueMaterial intermediate = insulation(); | |
| 672 | ✗ | if (intermediate) { | |
| 673 | ✗ | result = *intermediate; | |
| 674 | } | ||
| 675 | ✗ | return result; | |
| 676 | ✗ | } | |
| 677 | |||
| 678 | ✗ | bool LayeredConstruction_Impl::setInsulationAsModelObject(const boost::optional<ModelObject>& modelObject) { | |
| 679 | ✗ | if (modelObject) { | |
| 680 | ✗ | OptionalOpaqueMaterial intermediate = modelObject->optionalCast<OpaqueMaterial>(); | |
| 681 | ✗ | if (intermediate) { | |
| 682 | ✗ | return setInsulation(*intermediate); | |
| 683 | } else { | ||
| 684 | ✗ | return false; | |
| 685 | } | ||
| 686 | ✗ | } else { | |
| 687 | ✗ | resetInsulation(); | |
| 688 | } | ||
| 689 | ✗ | return true; | |
| 690 | } | ||
| 691 | |||
| 692 | } // namespace detail | ||
| 693 | |||
| 694 | 2646 | LayeredConstruction::LayeredConstruction(IddObjectType type, const Model& model) : ConstructionBase(type, model) { | |
| 695 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 2646 times.
✗ Branch 5 not taken.
|
2646 | OS_ASSERT(getImpl<detail::LayeredConstruction_Impl>()); |
| 696 | 2646 | } | |
| 697 | |||
| 698 |
1/1✓ Branch 3 taken 10291 times.
|
10291 | LayeredConstruction::LayeredConstruction(std::shared_ptr<detail::LayeredConstruction_Impl> impl) : ConstructionBase(std::move(impl)) {} |
| 699 | |||
| 700 | 2774 | std::vector<Material> LayeredConstruction::layers() const { | |
| 701 |
1/1✓ Branch 3 taken 2774 times.
|
2774 | return getImpl<detail::LayeredConstruction_Impl>()->layers(); |
| 702 | } | ||
| 703 | |||
| 704 | 8 | Material LayeredConstruction::getLayer(unsigned layerIndex) const { | |
| 705 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::LayeredConstruction_Impl>()->getLayer(layerIndex); |
| 706 | } | ||
| 707 | |||
| 708 | 16 | bool LayeredConstruction::eraseLayer(unsigned layerIndex) { | |
| 709 |
1/1✓ Branch 3 taken 16 times.
|
16 | return getImpl<detail::LayeredConstruction_Impl>()->eraseLayer(layerIndex); |
| 710 | } | ||
| 711 | |||
| 712 | 1009 | bool LayeredConstruction::insertLayer(unsigned layerIndex, const Material& material) { | |
| 713 |
1/1✓ Branch 3 taken 1009 times.
|
1009 | return getImpl<detail::LayeredConstruction_Impl>()->insertLayer(layerIndex, material); |
| 714 | } | ||
| 715 | |||
| 716 | ✗ | bool LayeredConstruction::setLayer(unsigned layerIndex, const Material& material) { | |
| 717 | ✗ | return getImpl<detail::LayeredConstruction_Impl>()->setLayer(layerIndex, material); | |
| 718 | } | ||
| 719 | |||
| 720 | 1766 | bool LayeredConstruction::setLayers(const std::vector<Material>& materials) { | |
| 721 |
1/1✓ Branch 3 taken 1766 times.
|
1766 | return getImpl<detail::LayeredConstruction_Impl>()->setLayers(materials); |
| 722 | } | ||
| 723 | |||
| 724 | ✗ | bool LayeredConstruction::setLayer(const ModelPartitionMaterial& modelPartitionMaterial) { | |
| 725 | ✗ | return getImpl<detail::LayeredConstruction_Impl>()->setLayer(modelPartitionMaterial); | |
| 726 | } | ||
| 727 | |||
| 728 | 34 | bool LayeredConstruction::isSymmetric() const { | |
| 729 |
1/1✓ Branch 3 taken 34 times.
|
34 | return getImpl<detail::LayeredConstruction_Impl>()->isSymmetric(); |
| 730 | } | ||
| 731 | |||
| 732 | ✗ | bool LayeredConstruction::equalLayers(const LayeredConstruction& other) const { | |
| 733 | ✗ | return getImpl<detail::LayeredConstruction_Impl>()->equalLayers(other); | |
| 734 | } | ||
| 735 | |||
| 736 | 1961 | bool LayeredConstruction::reverseEqualLayers(const LayeredConstruction& other) const { | |
| 737 |
1/1✓ Branch 3 taken 1961 times.
|
1961 | return getImpl<detail::LayeredConstruction_Impl>()->reverseEqualLayers(other); |
| 738 | } | ||
| 739 | |||
| 740 | ✗ | std::vector<unsigned> LayeredConstruction::nullLayers() const { | |
| 741 | ✗ | return getImpl<detail::LayeredConstruction_Impl>()->nullLayers(); | |
| 742 | } | ||
| 743 | |||
| 744 | 593 | unsigned LayeredConstruction::numLayers() const { | |
| 745 |
1/1✓ Branch 3 taken 593 times.
|
593 | return getImpl<detail::LayeredConstruction_Impl>()->numLayers(); |
| 746 | } | ||
| 747 | |||
| 748 | ✗ | std::vector<unsigned> LayeredConstruction::getLayerIndices(const Material& material) const { | |
| 749 | ✗ | return getImpl<detail::LayeredConstruction_Impl>()->getLayerIndices(material); | |
| 750 | } | ||
| 751 | |||
| 752 | 3 | boost::optional<OpaqueMaterial> LayeredConstruction::insulation() const { | |
| 753 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::LayeredConstruction_Impl>()->insulation(); |
| 754 | } | ||
| 755 | |||
| 756 | 336 | bool LayeredConstruction::setInsulation(const OpaqueMaterial& insulationLayer) { | |
| 757 |
1/1✓ Branch 3 taken 336 times.
|
336 | return getImpl<detail::LayeredConstruction_Impl>()->setInsulation(insulationLayer); |
| 758 | } | ||
| 759 | |||
| 760 | ✗ | void LayeredConstruction::resetInsulation() { | |
| 761 | ✗ | getImpl<detail::LayeredConstruction_Impl>()->resetInsulation(); | |
| 762 | ✗ | } | |
| 763 | |||
| 764 | 6 | void LayeredConstruction::ensureUniqueLayers() { | |
| 765 |
1/1✓ Branch 3 taken 6 times.
|
6 | getImpl<detail::LayeredConstruction_Impl>()->ensureUniqueLayers(); |
| 766 | 6 | } | |
| 767 | |||
| 768 | ✗ | bool LayeredConstruction::layersAreValid(const std::vector<Material>& materials) { | |
| 769 | ✗ | if (materials.empty()) { | |
| 770 | ✗ | return false; | |
| 771 | } | ||
| 772 | |||
| 773 | ✗ | if (materials[0].optionalCast<OpaqueMaterial>()) { | |
| 774 | ✗ | std::vector<OpaqueMaterial> opaqueMaterials; | |
| 775 | ✗ | for (const Material& material : materials) { | |
| 776 | ✗ | if (!material.optionalCast<OpaqueMaterial>()) { | |
| 777 | ✗ | LOG(Info, "Not all materials can be converted to OpaqueMaterial."); | |
| 778 | ✗ | return false; | |
| 779 | } | ||
| 780 | ✗ | opaqueMaterials.push_back(material.cast<OpaqueMaterial>()); | |
| 781 | } | ||
| 782 | ✗ | return layersAreValid(opaqueMaterials); | |
| 783 | ✗ | } | |
| 784 | |||
| 785 | ✗ | if (materials[0].optionalCast<FenestrationMaterial>()) { | |
| 786 | ✗ | std::vector<FenestrationMaterial> fenestrationMaterials; | |
| 787 | ✗ | for (const Material& material : materials) { | |
| 788 | ✗ | if (!material.optionalCast<FenestrationMaterial>()) { | |
| 789 | ✗ | LOG(Info, "Not all materials can be converted to FenestrationMaterial."); | |
| 790 | ✗ | return false; | |
| 791 | } | ||
| 792 | ✗ | fenestrationMaterials.push_back(material.cast<FenestrationMaterial>()); | |
| 793 | } | ||
| 794 | ✗ | return layersAreValid(fenestrationMaterials); | |
| 795 | ✗ | } | |
| 796 | |||
| 797 | ✗ | if (materials[0].optionalCast<ModelPartitionMaterial>()) { | |
| 798 | ✗ | if (materials.size() == 1) { | |
| 799 | ✗ | return true; | |
| 800 | } else { | ||
| 801 | ✗ | LOG(Info, "More than one ModelPartitionMaterial are not allowed in a layered construction."); | |
| 802 | ✗ | return false; | |
| 803 | } | ||
| 804 | } | ||
| 805 | |||
| 806 | ✗ | return false; | |
| 807 | } | ||
| 808 | |||
| 809 | ✗ | bool LayeredConstruction::layersAreValid(const std::vector<OpaqueMaterial>& opaqueMaterials) { | |
| 810 | // Rule 1: AirGap must have non-AirGap on either side. | ||
| 811 | // Rule 2: RoofVegetation must be on exterior layer. | ||
| 812 | // Rule 3: Up to 10 layers are allowed, IDD limit | ||
| 813 | |||
| 814 | // Rule 3 | ||
| 815 | ✗ | if (opaqueMaterials.size() > 10) { | |
| 816 | ✗ | return false; | |
| 817 | } | ||
| 818 | |||
| 819 | ✗ | bool previousWasNonAirGap = false; | |
| 820 | ✗ | for (unsigned i = 0, n = opaqueMaterials.size(); i < n; ++i) { | |
| 821 | // Rule 1 | ||
| 822 | ✗ | if (opaqueMaterials[i].optionalCast<AirGap>()) { | |
| 823 | ✗ | if (!previousWasNonAirGap) { | |
| 824 | ✗ | LOG(Info, "Proposed OpaqueMaterials are invalid because an AirGap at layer " << i << " either starts the construction, or is preceded by " | |
| 825 | << "another AirGap."); | ||
| 826 | ✗ | return false; | |
| 827 | } | ||
| 828 | ✗ | previousWasNonAirGap = false; | |
| 829 | } else { | ||
| 830 | ✗ | previousWasNonAirGap = true; | |
| 831 | } | ||
| 832 | // Rule 2 | ||
| 833 | ✗ | if (opaqueMaterials[i].optionalCast<RoofVegetation>() && (i > 0)) { | |
| 834 | ✗ | LOG(Info, "Proposed OpaqueMaterials are invalid because RoofVegetation must be at layer 0, " << "not layer " << i << "."); | |
| 835 | ✗ | return false; | |
| 836 | } | ||
| 837 | } | ||
| 838 | |||
| 839 | // Rule 1 -- Cannot end on an AirGap. | ||
| 840 | ✗ | if ((!opaqueMaterials.empty()) && (!previousWasNonAirGap)) { | |
| 841 | ✗ | LOG(Info, | |
| 842 | "Proposed OpaqueMaterials are invalid because an AirGap at layer " << opaqueMaterials.size() << " is the last layer in the construction."); | ||
| 843 | ✗ | return false; | |
| 844 | } | ||
| 845 | |||
| 846 | ✗ | return true; | |
| 847 | } | ||
| 848 | |||
| 849 | ✗ | bool LayeredConstruction::layersAreValid(const std::vector<FenestrationMaterial>& fenestrationMaterials) { | |
| 850 | // Rule 1 -- SimpleGlazing cannot be combined with other Glazings or any GasLayers. | ||
| 851 | // Rule 2 -- GasLayers must have non-GasLayer on either side. | ||
| 852 | // Rule 3 -- Ultimately, GasLayers must have Glazing on either side. | ||
| 853 | // Rule 4 -- Up to 8 layers are allowed, IDD limit | ||
| 854 | |||
| 855 | // Rule 4 | ||
| 856 | ✗ | if (fenestrationMaterials.size() > 8) { | |
| 857 | ✗ | return false; | |
| 858 | } | ||
| 859 | |||
| 860 | ✗ | bool hasSimpleGlazing = false; | |
| 861 | ✗ | bool hasGlazing = false; | |
| 862 | ✗ | bool hasGasLayer = false; | |
| 863 | ✗ | bool previousWasNonGasLayer = false; | |
| 864 | ✗ | bool gasLayerEnclosed = true; | |
| 865 | ✗ | for (const auto& fenestrationMaterial : fenestrationMaterials) { | |
| 866 | ✗ | bool isGlazing = fenestrationMaterial.optionalCast<Glazing>().has_value(); | |
| 867 | ✗ | bool isSimpleGlazing = fenestrationMaterial.optionalCast<SimpleGlazing>().has_value(); | |
| 868 | ✗ | bool isGasLayer = fenestrationMaterial.optionalCast<GasLayer>().has_value(); | |
| 869 | // Rule 1 | ||
| 870 | ✗ | if (isSimpleGlazing) { | |
| 871 | ✗ | if (hasGlazing) { | |
| 872 | ✗ | return false; | |
| 873 | } | ||
| 874 | ✗ | if (hasGasLayer) { | |
| 875 | ✗ | return false; | |
| 876 | } | ||
| 877 | ✗ | hasSimpleGlazing = true; | |
| 878 | ✗ | hasGlazing = true; | |
| 879 | } | ||
| 880 | ✗ | if (isGlazing && !isSimpleGlazing && hasSimpleGlazing) { | |
| 881 | ✗ | return false; | |
| 882 | } | ||
| 883 | ✗ | if (isGasLayer && hasSimpleGlazing) { | |
| 884 | ✗ | return false; | |
| 885 | } | ||
| 886 | // Rules 2 and 3 | ||
| 887 | ✗ | if (isGasLayer) { | |
| 888 | ✗ | if (!previousWasNonGasLayer) { | |
| 889 | ✗ | return false; | |
| 890 | } | ||
| 891 | ✗ | if (!hasGlazing) { | |
| 892 | ✗ | return false; | |
| 893 | } | ||
| 894 | ✗ | hasGasLayer = true; | |
| 895 | ✗ | previousWasNonGasLayer = false; | |
| 896 | ✗ | gasLayerEnclosed = false; | |
| 897 | } else { | ||
| 898 | ✗ | previousWasNonGasLayer = true; | |
| 899 | } | ||
| 900 | // Final Updates of State | ||
| 901 | ✗ | if (isGlazing) { | |
| 902 | ✗ | hasGlazing = true; | |
| 903 | ✗ | gasLayerEnclosed = true; | |
| 904 | } | ||
| 905 | } | ||
| 906 | |||
| 907 | // Rule 3 | ||
| 908 | ✗ | if ((!fenestrationMaterials.empty()) && (!previousWasNonGasLayer)) { | |
| 909 | ✗ | return false; | |
| 910 | } | ||
| 911 | ✗ | if (!gasLayerEnclosed) { | |
| 912 | ✗ | return false; | |
| 913 | } | ||
| 914 | |||
| 915 | ✗ | return true; | |
| 916 | } | ||
| 917 | |||
| 918 | } // namespace model | ||
| 919 | } // namespace openstudio | ||
| 920 |