Skip to content

Commit

Permalink
Merge pull request #4012 from NREL/issue-2895
Browse files Browse the repository at this point in the history
Addresses #2895, cannot add window frame and divider to skylights
  • Loading branch information
joseph-robertson authored Jul 10, 2020
2 parents 46d9979 + 2a26849 commit b529688
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
46 changes: 45 additions & 1 deletion src/energyplus/Test/SubSurface_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@
#include "../../model/SubSurface_Impl.hpp"
#include "../../model/Surface.hpp"
#include "../../model/Surface_Impl.hpp"
#include "../../model/Space.hpp"
#include "../../model/Space_Impl.hpp"
#include "../../model/ThermalZone.hpp"
#include "../../model/ThermalZone_Impl.hpp"
#include "../../model/WindowPropertyFrameAndDivider.hpp"
#include "../../model/WindowPropertyFrameAndDivider_Impl.hpp"

#include <utilities/idd/Daylighting_Controls_FieldEnums.hxx>
#include <utilities/idd/FenestrationSurface_Detailed_FieldEnums.hxx>
#include <utilities/idd/IddEnums.hxx>

#include <resources.hxx>
Expand Down Expand Up @@ -83,6 +89,44 @@ TEST_F(EnergyPlusFixture,ReverseTranslator_GlassDoorToSubSurface) {
TEST_F(EnergyPlusFixture,ForwardTranslator_SubSurface)
{
Model model;

ThermalZone thermalZone(model);

Space space(model);
space.setThermalZone(thermalZone);

std::vector<Point3d> vertices;
vertices.push_back(Point3d(0, 2, 0));
vertices.push_back(Point3d(0, 0, 0));
vertices.push_back(Point3d(2, 0, 0));
vertices.push_back(Point3d(2, 2, 0));
Surface surface(vertices, model);
surface.setSpace(space);

vertices.clear();
vertices.push_back(Point3d(0, 1, 0));
vertices.push_back(Point3d(0, 0, 0));
vertices.push_back(Point3d(1, 0, 0));
vertices.push_back(Point3d(1, 1, 0));

SubSurface subSurface(vertices, model);
subSurface.setSurface(surface);
subSurface.assignDefaultSubSurfaceType();

WindowPropertyFrameAndDivider frame(model);
subSurface.setWindowPropertyFrameAndDivider(frame);

ForwardTranslator forwardTranslator;
Workspace workspace = forwardTranslator.translateModel(model);

ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::FenestrationSurface_Detailed).size());
ASSERT_EQ(1u, workspace.getObjectsByType(IddObjectType::WindowProperty_FrameAndDivider).size());

WorkspaceObject subSurfaceObject = workspace.getObjectsByType(IddObjectType::FenestrationSurface_Detailed)[0];
WorkspaceObject frameObject = workspace.getObjectsByType(IddObjectType::WindowProperty_FrameAndDivider)[0];

ASSERT_TRUE(subSurfaceObject.getTarget(FenestrationSurface_DetailedFields::FrameandDividerName));
EXPECT_EQ(frameObject.handle(), subSurfaceObject.getTarget(FenestrationSurface_DetailedFields::FrameandDividerName)->handle());
}


1 change: 1 addition & 0 deletions src/model/SubSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ namespace detail {
std::string subSurfaceType = this->subSurfaceType();
if (istringEqual("FixedWindow", subSurfaceType) ||
istringEqual("OperableWindow", subSurfaceType) ||
istringEqual("Skylight", subSurfaceType) ||
istringEqual("GlassDoor", subSurfaceType))
{
result = true;
Expand Down
45 changes: 45 additions & 0 deletions src/model/test/SubSurface_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include "../SubSurface_Impl.hpp"
#include "../Building.hpp"
#include "../Building_Impl.hpp"
#include "../WindowPropertyFrameAndDivider.hpp"
#include "../WindowPropertyFrameAndDivider_Impl.hpp"
#include "../SimpleGlazing.hpp"
#include "../Construction.hpp"
#include "../DefaultSubSurfaceConstructions.hpp"
Expand Down Expand Up @@ -1036,6 +1038,13 @@ TEST_F(ModelFixture, DefaultSubSurfaceType)
SubSurface s(vertices, model);
s.assignDefaultSubSurfaceType();
EXPECT_EQ("Skylight", s.subSurfaceType());

WindowPropertyFrameAndDivider frame(model);
EXPECT_TRUE(s.allowWindowPropertyFrameAndDivider());
ASSERT_TRUE(s.setWindowPropertyFrameAndDivider(frame));
ASSERT_TRUE(s.windowPropertyFrameAndDivider());
WindowPropertyFrameAndDivider frame2 = s.windowPropertyFrameAndDivider().get();
EXPECT_EQ(frame, frame2);
}
{
// normal 0,1,0
Expand All @@ -1048,6 +1057,13 @@ TEST_F(ModelFixture, DefaultSubSurfaceType)
SubSurface s(vertices, model);
s.assignDefaultSubSurfaceType();
EXPECT_EQ("FixedWindow", s.subSurfaceType());

WindowPropertyFrameAndDivider frame(model);
EXPECT_TRUE(s.allowWindowPropertyFrameAndDivider());
ASSERT_TRUE(s.setWindowPropertyFrameAndDivider(frame));
ASSERT_TRUE(s.windowPropertyFrameAndDivider());
WindowPropertyFrameAndDivider frame2 = s.windowPropertyFrameAndDivider().get();
EXPECT_EQ(frame, frame2);
}

// with base surface the default type is set based on base surface
Expand Down Expand Up @@ -1093,9 +1109,20 @@ TEST_F(ModelFixture, DefaultSubSurfaceType)
s.assignDefaultSubSurfaceType();
EXPECT_EQ("Door", s.subSurfaceType());

WindowPropertyFrameAndDivider frame(model);
EXPECT_FALSE(s.allowWindowPropertyFrameAndDivider());
EXPECT_FALSE(s.setWindowPropertyFrameAndDivider(frame));
ASSERT_FALSE(s.windowPropertyFrameAndDivider());

EXPECT_TRUE(s.setSubSurfaceType("GlassDoor"));
s.assignDefaultSubSurfaceType();
EXPECT_EQ("GlassDoor", s.subSurfaceType());

EXPECT_TRUE(s.allowWindowPropertyFrameAndDivider());
ASSERT_TRUE(s.setWindowPropertyFrameAndDivider(frame));
ASSERT_TRUE(s.windowPropertyFrameAndDivider());
WindowPropertyFrameAndDivider frame2 = s.windowPropertyFrameAndDivider().get();
EXPECT_EQ(frame, frame2);
}
{
// normal 0,1,0 not on bottom edge
Expand All @@ -1110,6 +1137,13 @@ TEST_F(ModelFixture, DefaultSubSurfaceType)
EXPECT_EQ("FixedWindow", s.subSurfaceType());
s.assignDefaultSubSurfaceType();
EXPECT_EQ("FixedWindow", s.subSurfaceType());

WindowPropertyFrameAndDivider frame(model);
EXPECT_TRUE(s.allowWindowPropertyFrameAndDivider());
ASSERT_TRUE(s.setWindowPropertyFrameAndDivider(frame));
ASSERT_TRUE(s.windowPropertyFrameAndDivider());
WindowPropertyFrameAndDivider frame2 = s.windowPropertyFrameAndDivider().get();
EXPECT_EQ(frame, frame2);
}

// set default window construction, reproduces #1924
Expand Down Expand Up @@ -1143,9 +1177,20 @@ TEST_F(ModelFixture, DefaultSubSurfaceType)
s.assignDefaultSubSurfaceType();
EXPECT_EQ("Door", s.subSurfaceType());

WindowPropertyFrameAndDivider frame(model);
EXPECT_FALSE(s.allowWindowPropertyFrameAndDivider());
EXPECT_FALSE(s.setWindowPropertyFrameAndDivider(frame));
ASSERT_FALSE(s.windowPropertyFrameAndDivider());

s.setConstruction(construction);
s.assignDefaultSubSurfaceType();
EXPECT_EQ("GlassDoor", s.subSurfaceType());

EXPECT_TRUE(s.allowWindowPropertyFrameAndDivider());
ASSERT_TRUE(s.setWindowPropertyFrameAndDivider(frame));
ASSERT_TRUE(s.windowPropertyFrameAndDivider());
WindowPropertyFrameAndDivider frame2 = s.windowPropertyFrameAndDivider().get();
EXPECT_EQ(frame, frame2);
}
}

Expand Down

0 comments on commit b529688

Please sign in to comment.