src/energyplus/ReverseTranslator/ReverseTranslateFenestrationSurfaceDetailed.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 "../ReverseTranslator.hpp" | ||
| 7 | #include "../GeometryTranslator.hpp" | ||
| 8 | |||
| 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/Space.hpp" | ||
| 14 | #include "../../model/Space_Impl.hpp" | ||
| 15 | #include "../../model/ConstructionBase.hpp" | ||
| 16 | #include "../../model/ConstructionBase_Impl.hpp" | ||
| 17 | #include "../../model/ShadingControl.hpp" | ||
| 18 | #include "../../model/ShadingControl_Impl.hpp" | ||
| 19 | #include "../../model/WindowPropertyFrameAndDivider.hpp" | ||
| 20 | #include "../../model/WindowPropertyFrameAndDivider_Impl.hpp" | ||
| 21 | |||
| 22 | #include <utilities/idd/FenestrationSurface_Detailed_FieldEnums.hxx> | ||
| 23 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 24 | #include <utilities/idd/IddEnums.hxx> | ||
| 25 | |||
| 26 | using namespace openstudio::model; | ||
| 27 | |||
| 28 | namespace openstudio { | ||
| 29 | |||
| 30 | namespace energyplus { | ||
| 31 | |||
| 32 | 127 | OptionalModelObject ReverseTranslator::translateFenestrationSurfaceDetailed(const WorkspaceObject& workspaceObject) { | |
| 33 |
4/5✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
✓ Branch 7 taken 127 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 127 times.
|
127 | if (workspaceObject.iddObject().type() != IddObjectType::FenestrationSurface_Detailed) { |
| 34 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType: Site:FenestrationSurface_Detailed"); | |
| 35 | ✗ | return boost::none; | |
| 36 | } | ||
| 37 | |||
| 38 |
1/1✓ Branch 1 taken 127 times.
|
127 | openstudio::Point3dVector vertices = getVertices(FenestrationSurface_DetailedFields::NumberofVertices + 1, workspaceObject); |
| 39 | |||
| 40 | 127 | boost::optional<SubSurface> subSurface; | |
| 41 | try { | ||
| 42 |
2/2✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
|
127 | subSurface = SubSurface(vertices, m_model); |
| 43 | ✗ | } catch (const std::exception&) { | |
| 44 | ✗ | LOG(Error, "Cannot create SubSurface for object: " << workspaceObject); | |
| 45 | ✗ | return boost::none; | |
| 46 | ✗ | } | |
| 47 | |||
| 48 |
1/1✓ Branch 1 taken 127 times.
|
127 | OptionalString s = workspaceObject.name(); |
| 49 |
1/2✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
|
127 | if (s) { |
| 50 |
3/3✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
✓ Branch 7 taken 127 times.
|
127 | subSurface->setName(*s); |
| 51 | } | ||
| 52 | |||
| 53 |
1/1✓ Branch 1 taken 127 times.
|
127 | OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::FenestrationSurface_DetailedFields::ConstructionName); |
| 54 |
2/2✓ Branch 0 taken 121 times.
✓ Branch 1 taken 6 times.
|
127 | if (target) { |
| 55 |
2/2✓ Branch 1 taken 121 times.
✓ Branch 4 taken 121 times.
|
121 | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); |
| 56 |
1/2✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
|
121 | if (modelObject) { |
| 57 |
3/4✓ Branch 1 taken 121 times.
✓ Branch 4 taken 121 times.
✓ Branch 7 taken 121 times.
✗ Branch 8 not taken.
|
242 | if (modelObject->optionalCast<ConstructionBase>()) { |
| 58 |
4/4✓ Branch 1 taken 121 times.
✓ Branch 4 taken 121 times.
✓ Branch 7 taken 121 times.
✓ Branch 10 taken 121 times.
|
121 | subSurface->setConstruction(modelObject->cast<ConstructionBase>()); |
| 59 | } | ||
| 60 | } | ||
| 61 | 121 | } | |
| 62 | |||
| 63 |
1/1✓ Branch 1 taken 127 times.
|
127 | target = workspaceObject.getTarget(openstudio::FenestrationSurface_DetailedFields::BuildingSurfaceName); |
| 64 |
2/2✓ Branch 0 taken 126 times.
✓ Branch 1 taken 1 time.
|
127 | if (target) { |
| 65 |
2/2✓ Branch 1 taken 126 times.
✓ Branch 4 taken 126 times.
|
126 | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); |
| 66 |
1/2✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
|
126 | if (modelObject) { |
| 67 |
3/4✓ Branch 1 taken 126 times.
✓ Branch 4 taken 126 times.
✓ Branch 7 taken 126 times.
✗ Branch 8 not taken.
|
252 | if (modelObject->optionalCast<Surface>()) { |
| 68 |
4/4✓ Branch 1 taken 126 times.
✓ Branch 4 taken 126 times.
✓ Branch 7 taken 126 times.
✓ Branch 10 taken 126 times.
|
126 | subSurface->setSurface(modelObject->cast<Surface>()); |
| 69 | } | ||
| 70 | } | ||
| 71 | 126 | } | |
| 72 | |||
| 73 | // needs to be after .setSurface. | ||
| 74 |
1/1✓ Branch 1 taken 127 times.
|
127 | s = workspaceObject.getString(FenestrationSurface_DetailedFields::SurfaceType); |
| 75 |
1/2✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
|
127 | if (s) { |
| 76 |
5/5✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
✓ Branch 7 taken 127 times.
✓ Branch 10 taken 102 times.
✓ Branch 11 taken 25 times.
|
381 | if (istringEqual("Window", *s)) { |
| 77 |
1/1✓ Branch 1 taken 102 times.
|
102 | s = "FixedWindow"; |
| 78 | |||
| 79 |
2/2✓ Branch 1 taken 102 times.
✓ Branch 4 taken 102 times.
|
102 | boost::optional<Surface> surface = subSurface->surface(); |
| 80 |
1/2✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
|
102 | if (surface) { |
| 81 |
14/20✓ Branch 1 taken 102 times.
✓ Branch 4 taken 102 times.
✓ Branch 7 taken 102 times.
✓ Branch 9 taken 2 times.
✓ Branch 10 taken 100 times.
✓ Branch 12 taken 2 times.
✓ Branch 15 taken 2 times.
✓ Branch 18 taken 2 times.
✓ Branch 20 taken 2 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 2 times.
✓ Branch 23 taken 100 times.
✓ Branch 25 taken 102 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 2 times.
✓ Branch 29 taken 100 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
|
102 | if ((surface->surfaceType() == "RoofCeiling") && (surface->outsideBoundaryCondition() == "Outdoors")) { |
| 82 |
1/1✓ Branch 1 taken 2 times.
|
2 | s = "Skylight"; |
| 83 | } | ||
| 84 | } | ||
| 85 | 102 | } | |
| 86 |
3/3✓ Branch 1 taken 127 times.
✓ Branch 4 taken 127 times.
✓ Branch 7 taken 127 times.
|
127 | subSurface->setSubSurfaceType(*s); |
| 87 | } | ||
| 88 | |||
| 89 |
1/1✓ Branch 1 taken 127 times.
|
127 | target = workspaceObject.getTarget(openstudio::FenestrationSurface_DetailedFields::OutsideBoundaryConditionObject); |
| 90 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 121 times.
|
127 | if (target) { |
| 91 |
6/6✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
✓ Branch 10 taken 6 times.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 2 times.
|
6 | if (target->iddObject().type() == IddObjectType::Zone) { |
| 92 | // Zone boundary condition | ||
| 93 | |||
| 94 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); |
| 95 |
3/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
|
8 | if (modelObject->optionalCast<Space>()) { |
| 96 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | auto adjacentSpace = modelObject->cast<Space>(); |
| 97 | |||
| 98 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | OptionalSurface surface = subSurface->surface(); |
| 99 |
6/12✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 4 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
12 | if (surface && surface->space()) { |
| 100 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
4 | Space space = surface->space().get(); |
| 101 | |||
| 102 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 1 time.
✓ Branch 8 taken 3 times.
|
8 | if (surface->adjacentSurface()) { |
| 103 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | Surface adjacentSurface = surface->adjacentSurface().get(); |
| 104 | |||
| 105 |
11/20✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
✓ Branch 21 taken 1 time.
✗ Branch 22 not taken.
✓ Branch 23 taken 1 time.
✗ Branch 24 not taken.
✓ Branch 26 taken 1 time.
✗ Branch 27 not taken.
✓ Branch 29 taken 1 time.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
|
2 | if (adjacentSurface.space() && adjacentSpace.handle() == adjacentSurface.space()->handle()) { |
| 106 |
7/7✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
✓ Branch 16 taken 1 time.
✓ Branch 19 taken 1 time.
|
1 | Transformation transformation = adjacentSpace.transformation().inverse() * surface->space()->transformation(); |
| 107 | |||
| 108 | // duplicate subsurface in other space | ||
| 109 |
4/4✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
|
1 | auto adjacentSubSurface = subSurface->clone(m_model).cast<SubSurface>(); |
| 110 |
5/5✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
|
1 | adjacentSubSurface.setName(subSurface->name().get() + " Reversed"); |
| 111 |
1/1✓ Branch 3 taken 1 time.
|
1 | std::reverse(vertices.begin(), vertices.end()); |
| 112 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | adjacentSubSurface.setVertices(transformation * vertices); |
| 113 |
1/1✓ Branch 1 taken 1 time.
|
1 | adjacentSubSurface.setSurface(adjacentSurface); |
| 114 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | subSurface->setAdjacentSubSurface(adjacentSubSurface); |
| 115 | |||
| 116 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | return subSurface.get(); |
| 117 | 1 | } | |
| 118 | 1 | } | |
| 119 | 4 | } | |
| 120 | 5 | } | |
| 121 | |||
| 122 |
7/8✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 time.
✓ 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 18 not taken.
|
6 | } else if (target->iddObject().type() == IddObjectType::FenestrationSurface_Detailed) { |
| 123 | // SubSurface boundary condition | ||
| 124 | |||
| 125 | // see if we have already mapped other sub surface, don't do it here because that is circular | ||
| 126 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | auto it = m_workspaceToModelMap.find(target->handle()); |
| 127 |
2/2✓ Branch 2 taken 1 time.
✓ Branch 3 taken 1 time.
|
2 | if (it != m_workspaceToModelMap.end()) { |
| 128 |
2/3✓ Branch 2 taken 1 time.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
|
2 | if (it->second.optionalCast<SubSurface>()) { |
| 129 | // this will set other side boundary object on both surfaces | ||
| 130 |
1/1✓ Branch 2 taken 1 time.
|
1 | auto adjacentSubSurface = it->second.cast<SubSurface>(); |
| 131 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | subSurface->setAdjacentSubSurface(adjacentSubSurface); |
| 132 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | return subSurface.get(); |
| 133 | 1 | } | |
| 134 | } | ||
| 135 | } else { | ||
| 136 | ✗ | LOG(Error, "OutsideBoundaryConditionObject not yet mapped for object of type " << target->iddObject().name()); | |
| 137 | } | ||
| 138 | } | ||
| 139 | |||
| 140 | // DLM: should these be before control paths that return above? | ||
| 141 |
1/1✓ Branch 1 taken 125 times.
|
125 | OptionalDouble d = workspaceObject.getDouble(FenestrationSurface_DetailedFields::ViewFactortoGround); |
| 142 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 124 times.
|
125 | if (d) { |
| 143 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | subSurface->setViewFactortoGround(*d); |
| 144 | } | ||
| 145 | |||
| 146 |
1/1✓ Branch 1 taken 125 times.
|
125 | target = workspaceObject.getTarget(openstudio::FenestrationSurface_DetailedFields::FrameandDividerName); |
| 147 |
2/2✓ Branch 0 taken 25 times.
✓ Branch 1 taken 100 times.
|
125 | if (target) { |
| 148 |
2/2✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
|
25 | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); |
| 149 |
6/12✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
✓ Branch 10 taken 25 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 25 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 25 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
75 | if (modelObject && modelObject->optionalCast<model::WindowPropertyFrameAndDivider>()) { |
| 150 |
4/4✓ Branch 1 taken 25 times.
✓ Branch 4 taken 25 times.
✓ Branch 7 taken 25 times.
✓ Branch 10 taken 25 times.
|
25 | subSurface->setWindowPropertyFrameAndDivider(modelObject->cast<model::WindowPropertyFrameAndDivider>()); |
| 151 | } | ||
| 152 | 25 | } | |
| 153 | |||
| 154 | // DLM: what about multipliers on interior sub surfaces? | ||
| 155 |
1/1✓ Branch 1 taken 125 times.
|
125 | OptionalInt i = workspaceObject.getInt(FenestrationSurface_DetailedFields::Multiplier); |
| 156 |
2/2✓ Branch 0 taken 91 times.
✓ Branch 1 taken 34 times.
|
125 | if (i) { |
| 157 |
3/3✓ Branch 1 taken 91 times.
✓ Branch 4 taken 91 times.
✓ Branch 7 taken 91 times.
|
91 | subSurface->setMultiplier(*i); |
| 158 | } | ||
| 159 | |||
| 160 |
2/2✓ Branch 1 taken 125 times.
✓ Branch 4 taken 125 times.
|
125 | return subSurface.get(); |
| 161 | 127 | } | |
| 162 | |||
| 163 | } // namespace energyplus | ||
| 164 | |||
| 165 | } // namespace openstudio | ||
| 166 |