src/energyplus/ForwardTranslator/ForwardTranslateSurface.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/Surface.hpp" | ||
| 10 | #include "../../model/Surface_Impl.hpp" | ||
| 11 | #include "../../model/SubSurface.hpp" | ||
| 12 | #include "../../model/SubSurface_Impl.hpp" | ||
| 13 | #include "../../model/Space.hpp" | ||
| 14 | #include "../../model/Space_Impl.hpp" | ||
| 15 | #include "../../model/ThermalZone.hpp" | ||
| 16 | #include "../../model/ThermalZone_Impl.hpp" | ||
| 17 | #include "../../model/ConstructionBase.hpp" | ||
| 18 | #include "../../model/ConstructionBase_Impl.hpp" | ||
| 19 | #include "../../model/SurfaceControlMovableInsulation.hpp" | ||
| 20 | #include "../../model/SurfaceControlMovableInsulation_Impl.hpp" | ||
| 21 | #include "../../model/SurfacePropertyOtherSideCoefficients.hpp" | ||
| 22 | #include "../../model/SurfacePropertyOtherSideConditionsModel.hpp" | ||
| 23 | #include "../../model/SurfacePropertyConvectionCoefficients.hpp" | ||
| 24 | #include "../../model/SurfacePropertyLocalEnvironment.hpp" | ||
| 25 | #include "../../model/PlanarSurface.hpp" | ||
| 26 | #include "../../model/FoundationKiva.hpp" | ||
| 27 | #include "../../model/FoundationKiva_Impl.hpp" | ||
| 28 | #include "../../model/SurfacePropertyExposedFoundationPerimeter.hpp" | ||
| 29 | #include "../../model/SurfacePropertyExposedFoundationPerimeter_Impl.hpp" | ||
| 30 | |||
| 31 | #include "../../utilities/idf/IdfExtensibleGroup.hpp" | ||
| 32 | |||
| 33 | #include <utilities/idd/BuildingSurface_Detailed_FieldEnums.hxx> | ||
| 34 | |||
| 35 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 36 | #include <utilities/idd/IddEnums.hxx> | ||
| 37 | #include <utilities/idd/IddFactory.hxx> | ||
| 38 | |||
| 39 | #include "../../utilities/core/Assert.hpp" | ||
| 40 | |||
| 41 | using namespace openstudio::model; | ||
| 42 | |||
| 43 | using namespace std; | ||
| 44 | |||
| 45 | namespace openstudio { | ||
| 46 | |||
| 47 | namespace energyplus { | ||
| 48 | |||
| 49 | 3261 | boost::optional<IdfObject> ForwardTranslator::translateSurface(model::Surface& modelObject) { | |
| 50 |
2/2✓ Branch 1 taken 3261 times.
✓ Branch 4 taken 3261 times.
|
3261 | IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::BuildingSurface_Detailed, modelObject); |
| 51 | |||
| 52 |
1/1✓ Branch 1 taken 3261 times.
|
3261 | std::string surfaceType = modelObject.surfaceType(); |
| 53 |
4/4✓ Branch 1 taken 3261 times.
✓ Branch 4 taken 3261 times.
✓ Branch 7 taken 593 times.
✓ Branch 8 taken 2668 times.
|
6522 | if (istringEqual("RoofCeiling", surfaceType)) { |
| 54 |
3/3✓ Branch 1 taken 593 times.
✓ Branch 3 taken 479 times.
✓ Branch 4 taken 114 times.
|
593 | if (modelObject.isPartOfEnvelope()) { |
| 55 |
1/1✓ Branch 1 taken 479 times.
|
479 | surfaceType = "Roof"; |
| 56 | } else { | ||
| 57 |
1/1✓ Branch 1 taken 114 times.
|
114 | surfaceType = "Ceiling"; |
| 58 | } | ||
| 59 | } | ||
| 60 |
1/1✓ Branch 1 taken 3261 times.
|
3261 | idfObject.setString(BuildingSurface_DetailedFields::SurfaceType, surfaceType); |
| 61 | |||
| 62 |
1/1✓ Branch 1 taken 3261 times.
|
3261 | boost::optional<ConstructionBase> construction = modelObject.construction(); |
| 63 |
2/2✓ Branch 0 taken 2013 times.
✓ Branch 1 taken 1248 times.
|
3261 | if (construction) { |
| 64 |
3/3✓ Branch 1 taken 2013 times.
✓ Branch 4 taken 2013 times.
✓ Branch 7 taken 2013 times.
|
2013 | idfObject.setString(BuildingSurface_DetailedFields::ConstructionName, construction->nameString()); |
| 65 | } | ||
| 66 | |||
| 67 |
1/1✓ Branch 1 taken 3261 times.
|
3261 | boost::optional<Space> space = modelObject.space(); |
| 68 |
1/2✓ Branch 0 taken 3261 times.
✗ Branch 1 not taken.
|
3261 | if (space) { |
| 69 |
2/2✓ Branch 1 taken 3261 times.
✓ Branch 4 taken 3261 times.
|
3261 | boost::optional<ThermalZone> thermalZone = space->thermalZone(); |
| 70 |
1/2✓ Branch 0 taken 3261 times.
✗ Branch 1 not taken.
|
3261 | if (thermalZone) { |
| 71 |
3/3✓ Branch 1 taken 3261 times.
✓ Branch 4 taken 3261 times.
✓ Branch 7 taken 3261 times.
|
3261 | idfObject.setString(BuildingSurface_DetailedFields::ZoneName, thermalZone->nameString()); |
| 72 | } | ||
| 73 | // TODO: do we want that? | ||
| 74 |
3/3✓ Branch 1 taken 3261 times.
✓ Branch 3 taken 2855 times.
✓ Branch 4 taken 406 times.
|
3261 | if (!m_forwardTranslatorOptions.excludeSpaceTranslation()) { |
| 75 |
3/3✓ Branch 1 taken 2855 times.
✓ Branch 4 taken 2855 times.
✓ Branch 7 taken 2855 times.
|
2855 | idfObject.setString(BuildingSurface_DetailedFields::SpaceName, space->nameString()); |
| 76 | } | ||
| 77 | 3261 | } | |
| 78 | |||
| 79 |
1/1✓ Branch 1 taken 3261 times.
|
3261 | boost::optional<Surface> adjacentSurface = modelObject.adjacentSurface(); |
| 80 |
1/1✓ Branch 1 taken 3261 times.
|
3261 | boost::optional<FoundationKiva> adjacentFoundation = modelObject.adjacentFoundation(); |
| 81 |
1/1✓ Branch 1 taken 3261 times.
|
3261 | boost::optional<SurfacePropertyOtherSideCoefficients> surfacePropertyOtherSideCoefficients = modelObject.surfacePropertyOtherSideCoefficients(); |
| 82 | boost::optional<SurfacePropertyOtherSideConditionsModel> surfacePropertyOtherSideConditionsModel = | ||
| 83 |
1/1✓ Branch 1 taken 3261 times.
|
3261 | modelObject.surfacePropertyOtherSideConditionsModel(); |
| 84 |
1/1✓ Branch 1 taken 3261 times.
|
3261 | std::string outsideBoundaryCondition = modelObject.outsideBoundaryCondition(); |
| 85 |
4/4✓ Branch 1 taken 3261 times.
✓ Branch 4 taken 3261 times.
✓ Branch 7 taken 1041 times.
✓ Branch 8 taken 2220 times.
|
6522 | if (istringEqual("Surface", outsideBoundaryCondition)) { |
| 86 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1041 times.
|
1041 | if (!adjacentSurface) { |
| 87 | ✗ | LOG(Warn, "Surface '" << modelObject.nameString() | |
| 88 | << "' has blank Outside Boundary Condition Object. " | ||
| 89 | "Changing Outside Boundary Condition from 'Surface' to 'Adiabatic'"); | ||
| 90 | |||
| 91 | ✗ | outsideBoundaryCondition = "Adiabatic"; | |
| 92 | } | ||
| 93 |
3/4✓ Branch 1 taken 2220 times.
✓ Branch 4 taken 2220 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2220 times.
|
4440 | } else if (istringEqual("OtherSideCoefficients", outsideBoundaryCondition)) { |
| 94 | ✗ | if (!surfacePropertyOtherSideCoefficients) { | |
| 95 | ✗ | LOG(Warn, "Surface '" << modelObject.nameString() | |
| 96 | << "' has blank Outside Boundary Condition Object. " | ||
| 97 | "Changing Outside Boundary Condition from 'Surface' to 'Adiabatic'"); | ||
| 98 | |||
| 99 | ✗ | outsideBoundaryCondition = "OtherSideCoefficients"; | |
| 100 | } | ||
| 101 |
4/4✓ Branch 1 taken 2220 times.
✓ Branch 4 taken 2220 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2218 times.
|
4440 | } else if (istringEqual("OtherSideConditionsModel", outsideBoundaryCondition)) { |
| 102 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | if (!surfacePropertyOtherSideConditionsModel) { |
| 103 | ✗ | LOG(Warn, "Surface '" << modelObject.nameString() | |
| 104 | << "' has blank Outside Boundary Condition Object. " | ||
| 105 | "Changing Outside Boundary Condition from 'OtherSideConditionsModel' to 'Adiabatic'"); | ||
| 106 | |||
| 107 | ✗ | outsideBoundaryCondition = "Adiabatic"; | |
| 108 | } | ||
| 109 | } | ||
| 110 | |||
| 111 |
3/4✓ Branch 1 taken 3261 times.
✓ Branch 4 taken 3261 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3261 times.
|
6522 | if (istringEqual("Adiabatic", outsideBoundaryCondition)) { |
| 112 | ✗ | std::vector<SubSurface> subSurfaces = modelObject.subSurfaces(); | |
| 113 | ✗ | if (!subSurfaces.empty()) { | |
| 114 | ✗ | LOG(Warn, "Surface '" << modelObject.nameString() << "' is adiabatic, removing all sub surfaces"); | |
| 115 | ✗ | for (auto& subSurface : subSurfaces) { | |
| 116 | ✗ | subSurface.remove(); | |
| 117 | } | ||
| 118 | } | ||
| 119 | ✗ | } | |
| 120 | |||
| 121 |
1/1✓ Branch 1 taken 3261 times.
|
3261 | idfObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryCondition, outsideBoundaryCondition); |
| 122 | |||
| 123 |
2/2✓ Branch 0 taken 1041 times.
✓ Branch 1 taken 2220 times.
|
3261 | if (adjacentSurface) { |
| 124 | // do not translate and map here, wait for adjacent surface to be translated on its own | ||
| 125 |
3/3✓ Branch 1 taken 1041 times.
✓ Branch 4 taken 1041 times.
✓ Branch 7 taken 1041 times.
|
1041 | idfObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryConditionObject, adjacentSurface->nameString()); |
| 126 | } | ||
| 127 | |||
| 128 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3261 times.
|
3261 | if (adjacentFoundation) { |
| 129 | // do not translate and map here, wait for adjacent foundation to be translated on its own | ||
| 130 | ✗ | idfObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryConditionObject, adjacentFoundation->nameString()); | |
| 131 | } | ||
| 132 | |||
| 133 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3261 times.
|
3261 | if (surfacePropertyOtherSideCoefficients) { |
| 134 | ✗ | boost::optional<IdfObject> osc = translateAndMapModelObject(*surfacePropertyOtherSideCoefficients); | |
| 135 | ✗ | if (osc && osc->name()) { | |
| 136 | ✗ | idfObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryConditionObject, osc->nameString()); | |
| 137 | } else { | ||
| 138 | ✗ | LOG(Error, "Surface '" << modelObject.nameString() << "', could not translate OutsideBoundaryConditionObject"); | |
| 139 | } | ||
| 140 | ✗ | } | |
| 141 | |||
| 142 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3259 times.
|
3261 | if (surfacePropertyOtherSideConditionsModel) { |
| 143 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | boost::optional<IdfObject> oscm = translateAndMapModelObject(*surfacePropertyOtherSideConditionsModel); |
| 144 |
6/12✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 2 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
6 | if (oscm && oscm->name()) { |
| 145 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | idfObject.setString(BuildingSurface_DetailedFields::OutsideBoundaryConditionObject, oscm->nameString()); |
| 146 | } else { | ||
| 147 | ✗ | LOG(Error, "Surface '" << modelObject.nameString() << "', could not translate OutsideBoundaryConditionObject"); | |
| 148 | } | ||
| 149 | 2 | } | |
| 150 | |||
| 151 |
2/3✓ Branch 1 taken 3261 times.
✓ Branch 3 taken 3261 times.
✗ Branch 4 not taken.
|
3261 | if (!modelObject.isSunExposureDefaulted()) { |
| 152 |
2/2✓ Branch 1 taken 3261 times.
✓ Branch 4 taken 3261 times.
|
3261 | idfObject.setString(BuildingSurface_DetailedFields::SunExposure, modelObject.sunExposure()); |
| 153 | } | ||
| 154 | |||
| 155 |
2/3✓ Branch 1 taken 3261 times.
✓ Branch 3 taken 3261 times.
✗ Branch 4 not taken.
|
3261 | if (!modelObject.isWindExposureDefaulted()) { |
| 156 |
2/2✓ Branch 1 taken 3261 times.
✓ Branch 4 taken 3261 times.
|
3261 | idfObject.setString(BuildingSurface_DetailedFields::WindExposure, modelObject.windExposure()); |
| 157 | } | ||
| 158 | |||
| 159 |
1/1✓ Branch 1 taken 3261 times.
|
3261 | boost::optional<double> viewFactortoGround = modelObject.viewFactortoGround(); |
| 160 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3256 times.
|
3261 | if (viewFactortoGround) { |
| 161 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | idfObject.setDouble(BuildingSurface_DetailedFields::ViewFactortoGround, *viewFactortoGround); |
| 162 | } | ||
| 163 | |||
| 164 |
1/1✓ Branch 1 taken 3261 times.
|
3261 | idfObject.clearExtensibleGroups(); |
| 165 |
3/3✓ Branch 1 taken 3261 times.
✓ Branch 8 taken 13760 times.
✓ Branch 9 taken 3261 times.
|
17021 | for (const Point3d& point : modelObject.vertices()) { |
| 166 |
1/1✓ Branch 1 taken 13760 times.
|
13760 | IdfExtensibleGroup group = idfObject.pushExtensibleGroup(); |
| 167 |
2/4✓ Branch 1 taken 13760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13760 times.
✗ Branch 6 not taken.
|
13760 | OS_ASSERT(group.numFields() == 3); |
| 168 |
2/2✓ Branch 1 taken 13760 times.
✓ Branch 4 taken 13760 times.
|
13760 | group.setDouble(0, point.x()); |
| 169 |
2/2✓ Branch 1 taken 13760 times.
✓ Branch 4 taken 13760 times.
|
13760 | group.setDouble(1, point.y()); |
| 170 |
2/2✓ Branch 1 taken 13760 times.
✓ Branch 4 taken 13760 times.
|
13760 | group.setDouble(2, point.z()); |
| 171 | 17021 | } | |
| 172 | |||
| 173 | // translate subsurfaces | ||
| 174 |
1/1✓ Branch 1 taken 3261 times.
|
3261 | SubSurfaceVector subSurfaces = modelObject.subSurfaces(); |
| 175 |
1/1✓ Branch 3 taken 3261 times.
|
3261 | std::sort(subSurfaces.begin(), subSurfaces.end(), WorkspaceObjectNameLess()); |
| 176 |
2/2✓ Branch 4 taken 397 times.
✓ Branch 5 taken 3261 times.
|
3658 | for (SubSurface& subSurface : subSurfaces) { |
| 177 |
1/1✓ Branch 1 taken 397 times.
|
397 | translateAndMapModelObject(subSurface); |
| 178 | } | ||
| 179 | |||
| 180 | // Call the translation of these objects, which has two advantages: | ||
| 181 | // * will not translate them if they are orphaned (=not referencing a surface), and, | ||
| 182 | // * makes the order of these objects in the IDF deterministic | ||
| 183 |
3/3✓ Branch 1 taken 3261 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 3260 times.
|
6522 | if (boost::optional<SurfaceControlMovableInsulation> _sIns = modelObject.surfaceControlMovableInsulation()) { |
| 184 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | translateAndMapModelObject(_sIns.get()); |
| 185 | 3261 | } | |
| 186 | |||
| 187 |
3/3✓ Branch 1 taken 3261 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 3260 times.
|
6522 | if (boost::optional<SurfacePropertyConvectionCoefficients> _sCoefs = modelObject.surfacePropertyConvectionCoefficients()) { |
| 188 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | translateAndMapModelObject(_sCoefs.get()); |
| 189 | 3261 | } | |
| 190 | |||
| 191 |
3/3✓ Branch 1 taken 3261 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 3257 times.
|
6522 | if (boost::optional<SurfacePropertyLocalEnvironment> localEnv_ = modelObject.surfacePropertyLocalEnvironment()) { |
| 192 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | translateAndMapModelObject(localEnv_.get()); |
| 193 | 3261 | } | |
| 194 | |||
| 195 |
2/3✓ Branch 1 taken 3261 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3261 times.
|
6522 | if (boost::optional<SurfacePropertyExposedFoundationPerimeter> _sProps = modelObject.surfacePropertyExposedFoundationPerimeter()) { |
| 196 | ✗ | translateAndMapModelObject(_sProps.get()); | |
| 197 | } else { | ||
| 198 | // create a defaulted SurfacePropertyExposedFoundationPerimeter object if it doesn't exist | ||
| 199 |
2/7✗ Branch 0 not taken.
✓ Branch 1 taken 3261 times.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 3261 times.
|
3261 | if ((adjacentFoundation) && (surfaceType == "Floor")) { |
| 200 | boost::optional<SurfacePropertyExposedFoundationPerimeter> optprop = | ||
| 201 | ✗ | modelObject.createSurfacePropertyExposedFoundationPerimeter("ExposedPerimeterFraction", 1); | |
| 202 | ✗ | translateAndMapModelObject(optprop.get()); | |
| 203 | ✗ | } | |
| 204 | 3261 | } | |
| 205 | |||
| 206 |
1/1✓ Branch 1 taken 3261 times.
|
6522 | return idfObject; |
| 207 | 3261 | } | |
| 208 | |||
| 209 | } // namespace energyplus | ||
| 210 | |||
| 211 | } // namespace openstudio | ||
| 212 |