src/energyplus/ReverseTranslator/ReverseTranslateBuildingSurfaceDetailed.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/Surface.hpp" | ||
| 10 | #include "../../model/Surface_Impl.hpp" | ||
| 11 | #include "../../model/ConstructionBase.hpp" | ||
| 12 | #include "../../model/ConstructionBase_Impl.hpp" | ||
| 13 | #include "../../model/Space.hpp" | ||
| 14 | #include "../../model/Space_Impl.hpp" | ||
| 15 | #include "../../model/FoundationKiva.hpp" | ||
| 16 | #include "../../model/FoundationKiva_Impl.hpp" | ||
| 17 | |||
| 18 | #include <utilities/idd/BuildingSurface_Detailed_FieldEnums.hxx> | ||
| 19 | #include "../../utilities/idd/IddEnums.hpp" | ||
| 20 | #include <utilities/idd/IddEnums.hxx> | ||
| 21 | |||
| 22 | using namespace openstudio::model; | ||
| 23 | |||
| 24 | namespace openstudio { | ||
| 25 | |||
| 26 | namespace energyplus { | ||
| 27 | |||
| 28 | 411 | OptionalModelObject ReverseTranslator::translateBuildingSurfaceDetailed(const WorkspaceObject& workspaceObject) { | |
| 29 |
4/5✓ Branch 1 taken 411 times.
✓ Branch 4 taken 411 times.
✓ Branch 7 taken 411 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 411 times.
|
411 | if (workspaceObject.iddObject().type() != IddObjectType::BuildingSurface_Detailed) { |
| 30 | ✗ | LOG(Error, "WorkspaceObject is not IddObjectType: BuildingSurface:Detailed"); | |
| 31 | ✗ | return boost::none; | |
| 32 | } | ||
| 33 | |||
| 34 |
1/1✓ Branch 1 taken 411 times.
|
411 | openstudio::Point3dVector vertices = getVertices(BuildingSurface_DetailedFields::NumberofVertices + 1, workspaceObject); |
| 35 | |||
| 36 | 411 | boost::optional<Surface> surface; | |
| 37 | try { | ||
| 38 |
2/2✓ Branch 1 taken 411 times.
✓ Branch 4 taken 411 times.
|
411 | surface = Surface(vertices, m_model); |
| 39 | ✗ | } catch (const std::exception&) { | |
| 40 | ✗ | LOG(Error, "Cannot create Surface for object: " << workspaceObject); | |
| 41 | ✗ | return boost::none; | |
| 42 | ✗ | } | |
| 43 | |||
| 44 |
1/1✓ Branch 1 taken 411 times.
|
411 | OptionalString s = workspaceObject.name(); |
| 45 |
1/2✓ Branch 0 taken 411 times.
✗ Branch 1 not taken.
|
411 | if (s) { |
| 46 |
3/3✓ Branch 1 taken 411 times.
✓ Branch 4 taken 411 times.
✓ Branch 7 taken 411 times.
|
411 | surface->setName(*s); |
| 47 | } | ||
| 48 | |||
| 49 |
1/1✓ Branch 1 taken 411 times.
|
411 | OptionalWorkspaceObject target = workspaceObject.getTarget(openstudio::BuildingSurface_DetailedFields::ConstructionName); |
| 50 |
2/2✓ Branch 0 taken 394 times.
✓ Branch 1 taken 17 times.
|
411 | if (target) { |
| 51 |
2/2✓ Branch 1 taken 394 times.
✓ Branch 4 taken 394 times.
|
394 | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); |
| 52 |
1/2✓ Branch 0 taken 394 times.
✗ Branch 1 not taken.
|
394 | if (modelObject) { |
| 53 |
3/4✓ Branch 1 taken 394 times.
✓ Branch 4 taken 394 times.
✓ Branch 7 taken 394 times.
✗ Branch 8 not taken.
|
788 | if (modelObject->optionalCast<ConstructionBase>()) { |
| 54 |
4/4✓ Branch 1 taken 394 times.
✓ Branch 4 taken 394 times.
✓ Branch 7 taken 394 times.
✓ Branch 10 taken 394 times.
|
394 | surface->setConstruction(modelObject->cast<ConstructionBase>()); |
| 55 | } | ||
| 56 | } | ||
| 57 | 394 | } | |
| 58 | |||
| 59 |
1/1✓ Branch 1 taken 411 times.
|
411 | target = workspaceObject.getTarget(openstudio::BuildingSurface_DetailedFields::ZoneName); |
| 60 |
2/2✓ Branch 0 taken 387 times.
✓ Branch 1 taken 24 times.
|
411 | if (target) { |
| 61 |
2/2✓ Branch 1 taken 387 times.
✓ Branch 4 taken 387 times.
|
387 | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); |
| 62 |
1/2✓ Branch 0 taken 387 times.
✗ Branch 1 not taken.
|
387 | if (modelObject) { |
| 63 |
3/4✓ Branch 1 taken 387 times.
✓ Branch 4 taken 387 times.
✓ Branch 7 taken 387 times.
✗ Branch 8 not taken.
|
774 | if (modelObject->optionalCast<Space>()) { |
| 64 |
4/4✓ Branch 1 taken 387 times.
✓ Branch 4 taken 387 times.
✓ Branch 7 taken 387 times.
✓ Branch 10 taken 387 times.
|
387 | surface->setSpace(modelObject->cast<Space>()); |
| 65 | } | ||
| 66 | } | ||
| 67 | 387 | } | |
| 68 | |||
| 69 |
1/1✓ Branch 1 taken 411 times.
|
411 | s = workspaceObject.getString(BuildingSurface_DetailedFields::SurfaceType); |
| 70 |
1/2✓ Branch 0 taken 411 times.
✗ Branch 1 not taken.
|
411 | if (s) { |
| 71 |
18/28✓ Branch 1 taken 411 times.
✓ Branch 4 taken 411 times.
✓ Branch 7 taken 411 times.
✓ Branch 9 taken 385 times.
✓ Branch 10 taken 26 times.
✓ Branch 12 taken 385 times.
✓ Branch 15 taken 385 times.
✓ Branch 18 taken 385 times.
✓ Branch 20 taken 47 times.
✓ Branch 21 taken 338 times.
✓ Branch 22 taken 385 times.
✓ Branch 23 taken 26 times.
✓ Branch 25 taken 385 times.
✓ Branch 26 taken 26 times.
✓ Branch 27 taken 411 times.
✗ Branch 28 not taken.
✓ Branch 30 taken 411 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 73 times.
✓ Branch 33 taken 338 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
|
2003 | if (istringEqual("Roof", *s) || istringEqual("Ceiling", *s)) { |
| 72 |
1/1✓ Branch 1 taken 73 times.
|
73 | s = "RoofCeiling"; |
| 73 | } | ||
| 74 |
3/3✓ Branch 1 taken 411 times.
✓ Branch 4 taken 411 times.
✓ Branch 7 taken 411 times.
|
411 | surface->setSurfaceType(*s); |
| 75 | } | ||
| 76 | //std::string surfaceType = surface->surfaceType(); | ||
| 77 | |||
| 78 |
1/1✓ Branch 1 taken 411 times.
|
411 | s = workspaceObject.getString(BuildingSurface_DetailedFields::SunExposure); |
| 79 |
1/2✓ Branch 0 taken 411 times.
✗ Branch 1 not taken.
|
411 | if (s) { |
| 80 |
3/3✓ Branch 1 taken 411 times.
✓ Branch 4 taken 411 times.
✓ Branch 7 taken 411 times.
|
411 | surface->setSunExposure(*s); |
| 81 | } | ||
| 82 | |||
| 83 |
1/1✓ Branch 1 taken 411 times.
|
411 | s = workspaceObject.getString(BuildingSurface_DetailedFields::WindExposure); |
| 84 |
1/2✓ Branch 0 taken 411 times.
✗ Branch 1 not taken.
|
411 | if (s) { |
| 85 |
3/3✓ Branch 1 taken 411 times.
✓ Branch 4 taken 411 times.
✓ Branch 7 taken 411 times.
|
411 | surface->setWindExposure(*s); |
| 86 | } | ||
| 87 | |||
| 88 |
1/1✓ Branch 1 taken 411 times.
|
411 | OptionalDouble d = workspaceObject.getDouble(BuildingSurface_DetailedFields::ViewFactortoGround); |
| 89 |
2/2✓ Branch 0 taken 30 times.
✓ Branch 1 taken 381 times.
|
411 | if (d) { |
| 90 |
3/3✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
✓ Branch 7 taken 30 times.
|
30 | surface->setViewFactortoGround(*d); |
| 91 | } | ||
| 92 | |||
| 93 |
1/1✓ Branch 1 taken 411 times.
|
411 | target = workspaceObject.getTarget(openstudio::BuildingSurface_DetailedFields::OutsideBoundaryConditionObject); |
| 94 |
2/2✓ Branch 0 taken 204 times.
✓ Branch 1 taken 207 times.
|
411 | if (target) { |
| 95 | |||
| 96 |
6/6✓ Branch 1 taken 204 times.
✓ Branch 4 taken 204 times.
✓ Branch 7 taken 204 times.
✓ Branch 10 taken 204 times.
✓ Branch 14 taken 2 times.
✓ Branch 15 taken 202 times.
|
204 | if (target->iddObject().type() == IddObjectType::Zone) { |
| 97 | // Zone boundary condition | ||
| 98 | |||
| 99 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); |
| 100 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
4 | if (modelObject->optionalCast<Space>()) { |
| 101 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | auto adjacentSpace = modelObject->cast<Space>(); |
| 102 | |||
| 103 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
4 | if (surface->space()) { |
| 104 | // insert this surface in the map so subsurface translation can find it | ||
| 105 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
|
2 | m_workspaceToModelMap.insert(std::make_pair(workspaceObject.handle(), surface.get())); |
| 106 | |||
| 107 | // need to translate all sub surfaces here so they will be in adjacent space | ||
| 108 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 2 times.
|
5 | for (const WorkspaceObject& workspaceSubSurface : workspaceObject.getSources(IddObjectType::FenestrationSurface_Detailed)) { |
| 109 |
1/1✓ Branch 1 taken 3 times.
|
3 | translateAndMapWorkspaceObject(workspaceSubSurface); |
| 110 | 2 | } | |
| 111 | |||
| 112 | // create adjacent surface in other space | ||
| 113 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | surface->createAdjacentSurface(adjacentSpace); |
| 114 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | return surface.get(); |
| 115 | } | ||
| 116 | 2 | } | |
| 117 | |||
| 118 |
7/8✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 4 taken 202 times.
✓ Branch 7 taken 202 times.
✓ Branch 10 taken 202 times.
✓ Branch 13 taken 202 times.
✓ Branch 17 taken 200 times.
✓ Branch 18 taken 2 times.
|
204 | } else if (target->iddObject().type() == IddObjectType::BuildingSurface_Detailed) { |
| 119 | // Surface boundary condition | ||
| 120 | |||
| 121 | // see if we have already mapped other surface, don't do it here because that is circular | ||
| 122 |
6/6✓ Branch 1 taken 200 times.
✓ Branch 4 taken 200 times.
✓ Branch 7 taken 200 times.
✓ Branch 10 taken 200 times.
✓ Branch 12 taken 12 times.
✓ Branch 13 taken 188 times.
|
200 | if (target->handle() == workspaceObject.handle()) { |
| 123 | // these objects are the same, set boundary condition to adiabatic | ||
| 124 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
|
24 | surface->setOutsideBoundaryCondition("Adiabatic"); |
| 125 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | return surface.get(); |
| 126 | } else { | ||
| 127 |
3/3✓ Branch 1 taken 188 times.
✓ Branch 4 taken 188 times.
✓ Branch 7 taken 188 times.
|
188 | auto it = m_workspaceToModelMap.find(target->handle()); |
| 128 |
2/2✓ Branch 2 taken 94 times.
✓ Branch 3 taken 94 times.
|
188 | if (it != m_workspaceToModelMap.end()) { |
| 129 |
2/3✓ Branch 2 taken 94 times.
✓ Branch 5 taken 94 times.
✗ Branch 6 not taken.
|
188 | if (it->second.optionalCast<Surface>()) { |
| 130 | // this will set other side boundary object on both surfaces | ||
| 131 |
1/1✓ Branch 2 taken 94 times.
|
94 | auto adjacentSurface = it->second.cast<Surface>(); |
| 132 |
2/2✓ Branch 1 taken 94 times.
✓ Branch 4 taken 94 times.
|
94 | surface->setAdjacentSurface(adjacentSurface); |
| 133 |
2/2✓ Branch 1 taken 94 times.
✓ Branch 4 taken 94 times.
|
94 | return surface.get(); |
| 134 | 94 | } | |
| 135 | } | ||
| 136 | } | ||
| 137 | |||
| 138 |
5/6✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
|
2 | } else if (target->iddObject().type() == IddObjectType::Foundation_Kiva) { |
| 139 | // Foundation boundary condition | ||
| 140 | |||
| 141 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | OptionalModelObject modelObject = translateAndMapWorkspaceObject(*target); |
| 142 |
3/4✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
|
4 | if (modelObject->optionalCast<FoundationKiva>()) { |
| 143 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | auto foundationKiva = modelObject->cast<FoundationKiva>(); |
| 144 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | surface->setAdjacentFoundation(foundationKiva); |
| 145 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | return surface.get(); |
| 146 | 2 | } | |
| 147 | |||
| 148 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
|
2 | } else { |
| 149 | ✗ | LOG(Error, "OutsideBoundaryConditionObject not yet mapped for object of type " << target->iddObject().name()); | |
| 150 | } | ||
| 151 | } | ||
| 152 | |||
| 153 |
1/1✓ Branch 1 taken 301 times.
|
301 | s = workspaceObject.getString(BuildingSurface_DetailedFields::OutsideBoundaryCondition); |
| 154 |
1/2✓ Branch 0 taken 301 times.
✗ Branch 1 not taken.
|
301 | if (s) { |
| 155 |
3/3✓ Branch 1 taken 301 times.
✓ Branch 4 taken 301 times.
✓ Branch 7 taken 301 times.
|
301 | surface->setOutsideBoundaryCondition(*s); |
| 156 | } | ||
| 157 | |||
| 158 |
2/2✓ Branch 1 taken 301 times.
✓ Branch 4 taken 301 times.
|
301 | return surface.get(); |
| 159 | 411 | } | |
| 160 | |||
| 161 | } // namespace energyplus | ||
| 162 | |||
| 163 | } // namespace openstudio | ||
| 164 |