Skip to content

Commit

Permalink
Adjust existing test and fix order of vertices being printed when a w…
Browse files Browse the repository at this point in the history
…rap around is happening
  • Loading branch information
jmarrec committed Jul 18, 2023
1 parent 4dfb7bd commit a55576d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 37 deletions.
10 changes: 7 additions & 3 deletions src/EnergyPlus/SurfaceGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9555,12 +9555,16 @@ namespace SurfaceGeometry {
RoutineName,
state.dataSurfaceGeometry->SurfaceTmp(SurfNum).Name,
state.dataSurfaceGeometry->SurfaceTmp(SurfNum).ZoneName));
if (poppedVertexIndex > keptVertexIndex && poppedVertexIndex != nSides) {
ShowContinueError(state, format("Vertex [{}]=({:.2R},{:.2R},{:.2R})", keptVertexIndex, itKept->x, itKept->y, itKept->z));

bool const printPoppedFirst = (poppedVertexIndex < keptVertexIndex) ? !(poppedVertexIndex == 1 and keptVertexIndex == nSides)
: (poppedVertexIndex == nSides and keptVertexIndex == 1);

if (printPoppedFirst) {
ShowContinueError(state, format("Vertex [{}]=({:.2R},{:.2R},{:.2R})", poppedVertexIndex, it->x, it->y, it->z));
ShowContinueError(state, format("Vertex [{}]=({:.2R},{:.2R},{:.2R})", keptVertexIndex, itKept->x, itKept->y, itKept->z));
} else {
ShowContinueError(state, format("Vertex [{}]=({:.2R},{:.2R},{:.2R})", poppedVertexIndex, it->x, it->y, it->z));
ShowContinueError(state, format("Vertex [{}]=({:.2R},{:.2R},{:.2R})", keptVertexIndex, itKept->x, itKept->y, itKept->z));
ShowContinueError(state, format("Vertex [{}]=({:.2R},{:.2R},{:.2R})", poppedVertexIndex, it->x, it->y, it->z));
}
}
++state.dataErrTracking->TotalCoincidentVertices;
Expand Down
84 changes: 50 additions & 34 deletions tst/EnergyPlus/unit/SurfaceGeometry.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10072,27 +10072,25 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_GetSurfaceGroundSurfsTest)

TEST_F(EnergyPlusFixture, SurfaceGeometry_GetVerticesDropDuplicates)
{
// Test for #9123
// Test for #9123 - We expect the point marked "x" to be popped.
// Once it is popped, point "y" is still below tolerance with the "#" point:
// * Floor: originally 6 but now 5
// * Ceiling: 1
//
// ▲ ▲
// │ │
// 4 o────────o 5 3 o────────o 2
// │ │ │ │
// ╵ ╵ ╵ ╵
// ╵ Floor ╵ ╵Ceiling ╵
// ╵ ╵ ╵ ╵
// 3 │ 2 │ 4 │ 5 │
// o─────y │ o─────y │
// │ │ │ │ │ │
// └─────x──#───► └─────x──#───►
// 1 6 6 1

std::string const idf_objects = delimited_string({
"BuildingSurface:Detailed,",
" Zn001:Ceiling002, !- Name",
" Ceiling, !- Surface Type",
" FLOOR, !- Construction Name",
" ZONE 1, !- Zone Name",
" , !- Space Name",
" Surface, !- Outside Boundary Condition",
" Zn002:Flr002, !- Outside Boundary Condition Object",
" NoSun, !- Sun Exposure",
" NoWind, !- Wind Exposure",
" , !- View Factor to Ground",
" , !- Number of Vertices",
" 54.379, -28.887, 3.7, !- X,Y,Z Vertex 1 {m}",
" 54.379, -23.003, 3.7, !- X,Y,Z Vertex 2 {m}",
" 54.36, -23.003, 3.7, !- X,Y,Z Vertex 3 {m}",
" 54.36, -28.881, 3.7, !- X,Y,Z Vertex 4 {m}",
" 54.373, -28.881, 3.7, !- X,Y,Z Vertex 5 {m}",
" 54.373, -28.887, 3.7; !- X,Y,Z Vertex 6 {m}",
"",
"BuildingSurface:Detailed,",
" Zn002:Flr002, !- Name",
" Floor, !- Surface Type",
Expand All @@ -10112,6 +10110,24 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_GetVerticesDropDuplicates)
" 54.379, -23.003, 3.7, !- X,Y,Z Vertex 5 {m}",
" 54.379, -28.887, 3.7; !- X,Y,Z Vertex 6 {m}",

"BuildingSurface:Detailed,",
" Zn001:Ceiling002, !- Name",
" Ceiling, !- Surface Type",
" FLOOR, !- Construction Name",
" ZONE 1, !- Zone Name",
" , !- Space Name",
" Surface, !- Outside Boundary Condition",
" Zn002:Flr002, !- Outside Boundary Condition Object",
" NoSun, !- Sun Exposure",
" NoWind, !- Wind Exposure",
" , !- View Factor to Ground",
" , !- Number of Vertices",
" 54.379, -28.887, 3.7, !- X,Y,Z Vertex 1 {m}",
" 54.379, -23.003, 3.7, !- X,Y,Z Vertex 2 {m}",
" 54.36, -23.003, 3.7, !- X,Y,Z Vertex 3 {m}",
" 54.36, -28.881, 3.7, !- X,Y,Z Vertex 4 {m}",
" 54.373, -28.881, 3.7, !- X,Y,Z Vertex 5 {m}",
" 54.373, -28.887, 3.7; !- X,Y,Z Vertex 6 {m}",
});

ASSERT_TRUE(process_idf(idf_objects));
Expand Down Expand Up @@ -10151,29 +10167,29 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_GetVerticesDropDuplicates)

EXPECT_EQ(2, SurfNum);
auto const error_string = delimited_string({
" ** Warning ** GetVertices: Distance between two vertices < .01, possibly coincident. for Surface=ZN001:CEILING002, in Zone=ZONE 1",
" ** ~~~ ** Vertex [5]=(54.37,-28.88,3.70)",
" ** ~~~ ** Vertex [6]=(54.37,-28.89,3.70)",
" ** ~~~ ** Dropping Vertex [6].",
" ** Warning ** GetVertices: Distance between two vertices < .01, possibly coincident. for Surface=ZN001:CEILING002, in Zone=ZONE 1",
" ** ~~~ ** Vertex [5]=(54.37,-28.88,3.70)",
" ** ~~~ ** Vertex [1]=(54.38,-28.89,3.70)",
" ** ~~~ ** Dropping Vertex [1].",
" ** Warning ** GetVertices: Distance between two vertices < .01, possibly coincident. for Surface=ZN002:FLR002, in Zone=ZONE 2",
" ** ~~~ ** Vertex [1]=(54.37,-28.89,3.70)",
" ** ~~~ ** Vertex [2]=(54.37,-28.88,3.70)",
" ** ~~~ ** Dropping Vertex [2].",
" ** ~~~ ** Dropping Vertex [1].",
" ** Warning ** GetVertices: Distance between two vertices < .01, possibly coincident. for Surface=ZN002:FLR002, in Zone=ZONE 2",
" ** ~~~ ** Vertex [5]=(54.38,-28.89,3.70)",
" ** ~~~ ** Vertex [1]=(54.37,-28.89,3.70)",
" ** ~~~ ** Vertex [1]=(54.37,-28.88,3.70)",
" ** ~~~ ** Dropping Vertex [1].",
" ** Warning ** GetVertices: Distance between two vertices < .01, possibly coincident. for Surface=ZN001:CEILING002, in Zone=ZONE 1",
" ** ~~~ ** Vertex [6]=(54.37,-28.89,3.70)",
" ** ~~~ ** Vertex [1]=(54.38,-28.89,3.70)",
" ** ~~~ ** Dropping Vertex [6].",
" ** Warning ** GetVertices: Distance between two vertices < .01, possibly coincident. for Surface=ZN001:CEILING002, in Zone=ZONE 1",
" ** ~~~ ** Vertex [5]=(54.37,-28.88,3.70)",
" ** ~~~ ** Vertex [1]=(54.38,-28.89,3.70)",
" ** ~~~ ** Dropping Vertex [5].",
});
EXPECT_TRUE(compare_err_stream(error_string, true));

const auto &sf_temps = state->dataSurfaceGeometry->SurfaceTmp;
EXPECT_EQ(2, sf_temps.size());
EXPECT_EQ("ZN001:CEILING002", sf_temps(1).Name);
EXPECT_EQ("ZN002:FLR002", sf_temps(2).Name);
EXPECT_EQ("ZN002:FLR002", sf_temps(1).Name);
EXPECT_EQ("ZN001:CEILING002", sf_temps(2).Name);

EXPECT_EQ(4, sf_temps(1).Sides);
EXPECT_EQ(4, sf_temps(1).Vertex.size());
Expand All @@ -10185,9 +10201,9 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_GetVerticesDropDuplicates)
EXPECT_NEAR(11.80, sf_temps(2).Perimeter, 0.02);
}

TEST_F(EnergyPlusFixture, SurfaceGeometry_GetVerticesDropDuplicates_Tiny)
TEST_F(EnergyPlusFixture, SurfaceGeometry_GetVerticesDropDuplicates_Once)
{
// Test for #9873 - We expect the point marked "x" to be popped
// Test for #9873 - We expect the point marked "x" to be popped. Once it is popped, there are no distances that are below tolerance.
// ▲ ▲
// │ │
// 2 o────────o 3 5 o────────o 4
Expand Down

3 comments on commit a55576d

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9873-GetVertices_Consistency (jmarrec) - x86_64-Linux-Ubuntu-22.04-gcc-11.3: OK (3482 of 3482 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9873-GetVertices_Consistency (jmarrec) - x86_64-Linux-Ubuntu-22.04-gcc-11.3-UnitTestsCoverage-Debug: OK (1895 of 1895 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9873-GetVertices_Consistency (jmarrec) - x86_64-Linux-Ubuntu-22.04-gcc-11.3-IntegrationCoverage-Debug: OK (776 of 776 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.