src/energyplus/ForwardTranslator/ForwardTranslateSubSurface.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 "../ForwardTranslator.hpp" | ||
| 7 | |||
| 8 | #include "../../model/Model.hpp" | ||
| 9 | #include "../../model/SubSurface.hpp" | ||
| 10 | #include "../../model/SubSurface_Impl.hpp" | ||
| 11 | #include "../../model/Surface.hpp" | ||
| 12 | #include "../../model/Surface_Impl.hpp" | ||
| 13 | #include "../../model/ConstructionBase.hpp" | ||
| 14 | #include "../../model/ConstructionBase_Impl.hpp" | ||
| 15 | #include "../../model/WindowPropertyFrameAndDivider.hpp" | ||
| 16 | #include "../../model/WindowPropertyFrameAndDivider_Impl.hpp" | ||
| 17 | #include "../../model/SurfacePropertyOtherSideCoefficients.hpp" | ||
| 18 | #include "../../model/SurfacePropertyOtherSideConditionsModel.hpp" | ||
| 19 | #include "../../model/SurfacePropertyConvectionCoefficients.hpp" | ||
| 20 | #include "../../model/SurfacePropertyLocalEnvironment.hpp" | ||
| 21 | #include "../../model/SurfacePropertyIncidentSolarMultiplier.hpp" | ||
| 22 | |||
| 23 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 24 | |||
| 25 | #include <utilities/idd/FenestrationSurface_Detailed_FieldEnums.hxx> | ||
| 26 | |||
| 27 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 28 | #include <utilities/idd/IddEnums.hxx> | ||
| 29 | #include <utilities/idd/IddFactory.hxx> | ||
| 30 | |||
| 31 | #include "../../utilities/geometry/Vector3d.hpp" | ||
| 32 | |||
| 33 | using namespace openstudio::model; | ||
| 34 | |||
| 35 | using namespace std; | ||
| 36 | |||
| 37 | namespace openstudio { | ||
| 38 | |||
| 39 | namespace energyplus { | ||
| 40 | |||
| 41 | 417 | boost::optional<IdfObject> ForwardTranslator::translateSubSurface(model::SubSurface& modelObject) { | |
| 42 |
2/2✓ Branch 1 taken 417 times.
✓ Branch 4 taken 417 times.
|
417 | IdfObject idfObject(openstudio::IddObjectType::FenestrationSurface_Detailed); |
| 43 | |||
| 44 |
3/3✓ Branch 1 taken 417 times.
✓ Branch 4 taken 417 times.
✓ Branch 7 taken 417 times.
|
417 | idfObject.setString(FenestrationSurface_DetailedFields::Name, modelObject.name().get()); |
| 45 | |||
| 46 |
1/1✓ Branch 1 taken 417 times.
|
417 | idfObject.clearExtensibleGroups(); |
| 47 | |||
| 48 |
1/1✓ Branch 1 taken 417 times.
|
417 | openstudio::Vector3d offset(0, 0, 0); |
| 49 |
1/1✓ Branch 1 taken 417 times.
|
417 | boost::optional<WindowPropertyFrameAndDivider> frameAndDivider = modelObject.windowPropertyFrameAndDivider(); |
| 50 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 415 times.
|
417 | if (frameAndDivider) { |
| 51 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 1 time.
|
2 | if (!frameAndDivider->isOutsideRevealDepthDefaulted()) { |
| 52 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | offset = -frameAndDivider->outsideRevealDepth() * modelObject.outwardNormal(); |
| 53 | } | ||
| 54 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | idfObject.setString(FenestrationSurface_DetailedFields::FrameandDividerName, frameAndDivider->name().get()); |
| 55 | } | ||
| 56 | |||
| 57 |
3/3✓ Branch 1 taken 417 times.
✓ Branch 8 taken 1675 times.
✓ Branch 9 taken 408 times.
|
2083 | for (const Point3d& point : modelObject.vertices()) { |
| 58 |
1/1✓ Branch 1 taken 1675 times.
|
1675 | IdfExtensibleGroup group = idfObject.pushExtensibleGroup(); |
| 59 |
3/3✓ Branch 1 taken 1675 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 1666 times.
|
1675 | if (group.empty()) { |
| 60 |
8/8✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 10 taken 9 times.
✓ Branch 13 taken 9 times.
✓ Branch 17 taken 9 times.
✓ Branch 20 taken 9 times.
✓ Branch 23 taken 9 times.
|
9 | LOG(Error, |
| 61 | "Currently unable to translate " << modelObject.briefDescription() << ", because it has more vertices than allowed by EnergyPlus."); | ||
| 62 | 9 | return boost::none; | |
| 63 | } | ||
| 64 | |||
| 65 |
1/1✓ Branch 1 taken 1666 times.
|
1666 | const Point3d newPoint = point + offset; |
| 66 | |||
| 67 |
2/2✓ Branch 1 taken 1666 times.
✓ Branch 4 taken 1666 times.
|
1666 | group.setDouble(0, newPoint.x()); |
| 68 |
2/2✓ Branch 1 taken 1666 times.
✓ Branch 4 taken 1666 times.
|
1666 | group.setDouble(1, newPoint.y()); |
| 69 |
2/2✓ Branch 1 taken 1666 times.
✓ Branch 4 taken 1666 times.
|
1666 | group.setDouble(2, newPoint.z()); |
| 70 | 2092 | } | |
| 71 | |||
| 72 | // Register and emplace into m_map, so that any child object such as translateSurfacePropertyIncidentSolarMultiplier | ||
| 73 | // can retrieve the subsurface namestring and we don't risk duplicating the subsurface when that child also calls | ||
| 74 | // translateAndMapModelObject(subSurface) | ||
| 75 |
1/1✓ Branch 1 taken 408 times.
|
408 | m_idfObjects.push_back(idfObject); |
| 76 |
3/3✓ Branch 1 taken 408 times.
✓ Branch 4 taken 408 times.
✓ Branch 7 taken 408 times.
|
408 | m_map.insert(std::make_pair(modelObject.handle(), idfObject)); |
| 77 | |||
| 78 |
1/1✓ Branch 1 taken 408 times.
|
408 | std::string subSurfaceType = modelObject.subSurfaceType(); |
| 79 | |||
| 80 |
1/1✓ Branch 1 taken 408 times.
|
408 | boost::optional<ConstructionBase> construction = modelObject.construction(); |
| 81 |
2/2✓ Branch 0 taken 344 times.
✓ Branch 1 taken 64 times.
|
408 | if (construction) { |
| 82 | |||
| 83 | 344 | bool typeFlipped = false; | |
| 84 |
2/2✓ Branch 1 taken 344 times.
✓ Branch 4 taken 344 times.
|
344 | const bool isFenestration = construction->isFenestration(); |
| 85 |
20/28✓ Branch 0 taken 219 times.
✓ Branch 1 taken 125 times.
✓ Branch 3 taken 219 times.
✓ Branch 6 taken 219 times.
✓ Branch 8 taken 217 times.
✓ Branch 9 taken 2 times.
✓ Branch 11 taken 217 times.
✓ Branch 14 taken 217 times.
✓ Branch 16 taken 2 times.
✓ Branch 17 taken 215 times.
✓ Branch 18 taken 217 times.
✓ Branch 19 taken 127 times.
✓ Branch 21 taken 217 times.
✓ Branch 22 taken 127 times.
✓ Branch 23 taken 219 times.
✓ Branch 24 taken 125 times.
✓ Branch 26 taken 219 times.
✓ Branch 27 taken 125 times.
✓ Branch 28 taken 4 times.
✓ Branch 29 taken 340 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
|
1216 | if (isFenestration && (istringEqual("Door", subSurfaceType) || istringEqual("OverheadDoor", subSurfaceType))) { |
| 86 |
10/10✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
✓ Branch 19 taken 4 times.
✓ Branch 23 taken 4 times.
✓ Branch 26 taken 4 times.
✓ Branch 29 taken 4 times.
|
4 | LOG(Warn, "SubSurface '" << modelObject.nameString() << "' of type " << subSurfaceType |
| 87 | << " uses fenestration construction, changing SubSurfaceType to GlassDoor"); | ||
| 88 |
1/1✓ Branch 1 taken 4 times.
|
4 | subSurfaceType = "GlassDoor"; |
| 89 | 4 | typeFlipped = true; | |
| 90 |
12/16✓ Branch 0 taken 125 times.
✓ Branch 1 taken 215 times.
✓ Branch 3 taken 125 times.
✓ Branch 6 taken 125 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 123 times.
✓ Branch 10 taken 125 times.
✓ Branch 11 taken 215 times.
✓ Branch 13 taken 125 times.
✓ Branch 14 taken 215 times.
✓ Branch 15 taken 2 times.
✓ Branch 16 taken 338 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
|
590 | } else if (!isFenestration && istringEqual("GlassDoor", subSurfaceType)) { |
| 91 |
8/8✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 17 taken 2 times.
✓ Branch 20 taken 2 times.
✓ Branch 23 taken 2 times.
|
2 | LOG(Warn, "SubSurface '" << modelObject.nameString() << "' uses non-fenestration construction, changing SubSurfaceType to Door"); |
| 92 |
1/1✓ Branch 1 taken 2 times.
|
2 | subSurfaceType = "Door"; |
| 93 | 2 | typeFlipped = true; | |
| 94 | } | ||
| 95 | |||
| 96 | // Write the construction: | ||
| 97 | // - When it is hard-assigned | ||
| 98 | // - When the SubSurfaceType was changed above: E+ would look it up in a different ConstructionAssignmentSet slot | ||
| 99 | // - When the construction assignment sets are excluded | ||
| 100 |
10/10✓ Branch 0 taken 338 times.
✓ Branch 1 taken 6 times.
✓ Branch 3 taken 338 times.
✓ Branch 5 taken 67 times.
✓ Branch 6 taken 271 times.
✓ Branch 8 taken 67 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 65 times.
✓ Branch 12 taken 279 times.
✓ Branch 13 taken 65 times.
|
344 | if (typeFlipped || !modelObject.isConstructionDefaulted() || m_forwardTranslatorOptions.excludeConstructionAssignmentSets()) { |
| 101 |
4/4✓ Branch 1 taken 279 times.
✓ Branch 4 taken 279 times.
✓ Branch 7 taken 279 times.
✓ Branch 10 taken 279 times.
|
279 | idfObject.setString(FenestrationSurface_DetailedFields::ConstructionName, construction->name().get()); |
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 |
1/1✓ Branch 1 taken 408 times.
|
408 | idfObject.setString(FenestrationSurface_DetailedFields::SurfaceType, subSurfaceType); |
| 106 | |||
| 107 |
1/1✓ Branch 1 taken 408 times.
|
408 | boost::optional<Surface> surface = modelObject.surface(); |
| 108 |
1/2✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
|
408 | if (surface) { |
| 109 |
4/4✓ Branch 1 taken 408 times.
✓ Branch 4 taken 408 times.
✓ Branch 7 taken 408 times.
✓ Branch 10 taken 408 times.
|
408 | idfObject.setString(FenestrationSurface_DetailedFields::BuildingSurfaceName, surface->name().get()); |
| 110 | } | ||
| 111 | |||
| 112 |
1/1✓ Branch 1 taken 408 times.
|
408 | boost::optional<SubSurface> adjacentSubSurface = modelObject.adjacentSubSurface(); |
| 113 |
2/2✓ Branch 0 taken 88 times.
✓ Branch 1 taken 320 times.
|
408 | if (adjacentSubSurface) { |
| 114 |
4/4✓ Branch 1 taken 88 times.
✓ Branch 4 taken 88 times.
✓ Branch 7 taken 88 times.
✓ Branch 10 taken 88 times.
|
88 | idfObject.setString(FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject, adjacentSubSurface->name().get()); |
| 115 | } | ||
| 116 | |||
| 117 |
1/1✓ Branch 1 taken 408 times.
|
408 | boost::optional<SurfacePropertyOtherSideCoefficients> surfacePropertyOtherSideCoefficients = modelObject.surfacePropertyOtherSideCoefficients(); |
| 118 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
|
408 | if (surfacePropertyOtherSideCoefficients) { |
| 119 | ✗ | boost::optional<IdfObject> osc = translateAndMapModelObject(*surfacePropertyOtherSideCoefficients); | |
| 120 | ✗ | if (osc && osc->name()) { | |
| 121 | ✗ | idfObject.setString(FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject, osc->name().get()); | |
| 122 | } else { | ||
| 123 | ✗ | LOG(Error, "SubSurface '" << modelObject.name().get() << "', could not translate OutsideBoundaryConditionObject"); | |
| 124 | } | ||
| 125 | ✗ | } | |
| 126 | |||
| 127 | boost::optional<SurfacePropertyOtherSideConditionsModel> surfacePropertyOtherSideConditionsModel = | ||
| 128 |
1/1✓ Branch 1 taken 408 times.
|
408 | modelObject.surfacePropertyOtherSideConditionsModel(); |
| 129 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
|
408 | if (surfacePropertyOtherSideConditionsModel) { |
| 130 | ✗ | boost::optional<IdfObject> oscm = translateAndMapModelObject(*surfacePropertyOtherSideConditionsModel); | |
| 131 | ✗ | if (oscm && oscm->name()) { | |
| 132 | ✗ | idfObject.setString(FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject, oscm->name().get()); | |
| 133 | } else { | ||
| 134 | ✗ | LOG(Error, "SubSurface '" << modelObject.name().get() << "', could not translate OutsideBoundaryConditionObject"); | |
| 135 | } | ||
| 136 | ✗ | } | |
| 137 | |||
| 138 | // Call the translation of the SurfacePropertyConvectionCoefficients, which has two advantages: | ||
| 139 | // * will not translate them if they are orphaned (=not referencing a surface or subsurface), and, | ||
| 140 | // * makes the order of these objects in the IDF deterministic | ||
| 141 |
2/3✓ Branch 1 taken 408 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 408 times.
|
816 | if (boost::optional<SurfacePropertyConvectionCoefficients> _sCoefs = modelObject.surfacePropertyConvectionCoefficients()) { |
| 142 | ✗ | translateAndMapModelObject(_sCoefs.get()); | |
| 143 | 408 | } | |
| 144 | |||
| 145 |
3/3✓ Branch 1 taken 408 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 407 times.
|
816 | if (boost::optional<SurfacePropertyLocalEnvironment> localEnv_ = modelObject.surfacePropertyLocalEnvironment()) { |
| 146 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | translateAndMapModelObject(localEnv_.get()); |
| 147 | 408 | } | |
| 148 | |||
| 149 |
1/1✓ Branch 1 taken 408 times.
|
408 | boost::optional<double> viewFactortoGround = modelObject.viewFactortoGround(); |
| 150 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
|
408 | if (viewFactortoGround) { |
| 151 | ✗ | idfObject.setDouble(FenestrationSurface_DetailedFields::ViewFactortoGround, *viewFactortoGround); | |
| 152 | } | ||
| 153 | |||
| 154 |
3/3✓ Branch 1 taken 408 times.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 364 times.
|
408 | if (!modelObject.isMultiplierDefaulted()) { |
| 155 |
2/2✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
|
44 | idfObject.setDouble(FenestrationSurface_DetailedFields::Multiplier, modelObject.multiplier()); |
| 156 | } | ||
| 157 | |||
| 158 |
3/3✓ Branch 1 taken 408 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 407 times.
|
816 | if (boost::optional<SurfacePropertyIncidentSolarMultiplier> spMult_ = modelObject.surfacePropertyIncidentSolarMultiplier()) { |
| 159 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | translateAndMapModelObject(spMult_.get()); |
| 160 | 408 | } | |
| 161 | |||
| 162 |
1/1✓ Branch 1 taken 408 times.
|
408 | return idfObject; |
| 163 | 417 | } | |
| 164 | |||
| 165 | } // namespace energyplus | ||
| 166 | |||
| 167 | } // namespace openstudio | ||
| 168 |