Skip to content

Commit

Permalink
Initial unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mjwitte committed May 8, 2024
1 parent c40c608 commit bcf2046
Showing 1 changed file with 130 additions and 0 deletions.
130 changes: 130 additions & 0 deletions tst/EnergyPlus/unit/DataSurfaces.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,136 @@ TEST_F(EnergyPlusFixture, SurfaceTest_Surface2D)
}
}

TEST_F(EnergyPlusFixture, SurfaceTest_Surface2D_bigVertices)
{
using Vector2D = Surface2D::Vector2D;
SurfaceData s;
s.Vertex.dimension(22);
// convex, >nVerticesBig, simple shape
s.Vertex = {Vector(0, 0, 0), Vector(0.1, 0.2, 0), Vector(0.2, 0.4, 0), Vector(0.3, 0.6, 0), Vector(0.4, 0.8, 0), Vector(0.5, 1.0, 0),
Vector(0.6, 1.2, 0), Vector(0.7, 1.4, 0), Vector(0.8, 1.6, 0), Vector(0.9, 1.8, 0), Vector(1.0, 1.9, 0), Vector(1.1, 1.8, 0),
Vector(1.2, 1.6, 0), Vector(1.3, 1.4, 0), Vector(1.4, 1.2, 0), Vector(1.5, 1.0, 0), Vector(1.6, 0.8, 0), Vector(1.7, 0.6, 0),
Vector(1.8, 0.4, 0), Vector(1.9, 0.2, 0), Vector(2.0, 0.1, 0), Vector(2.0, 0, 0)};
s.Shape = SurfaceShape::Polygonal;
s.set_computed_geometry();

Surface2D const &s2d(s.surface2d);
EXPECT_EQ(2, s2d.axis); // Projection along z axis
EXPECT_EQ(Vector2D(0.0, 0.0), s2d.vertices[0]);
EXPECT_EQ(Vector2D(2.0, 0.0), s2d.vertices[1]);
EXPECT_EQ(Vector2D(2.0, 0.1), s2d.vertices[2]);
EXPECT_EQ(Vector2D(1.9, 0.2), s2d.vertices[3]);
EXPECT_EQ(Vector2D(1.8, 0.4), s2d.vertices[4]);
EXPECT_EQ(Vector2D(1.7, 0.6), s2d.vertices[5]);
EXPECT_EQ(Vector2D(1.6, 0.8), s2d.vertices[6]);
EXPECT_EQ(Vector2D(1.5, 1.0), s2d.vertices[7]);
EXPECT_EQ(Vector2D(1.4, 1.2), s2d.vertices[8]);
EXPECT_EQ(Vector2D(1.3, 1.4), s2d.vertices[9]);
EXPECT_EQ(Vector2D(1.2, 1.6), s2d.vertices[10]);
EXPECT_EQ(Vector2D(1.1, 1.8), s2d.vertices[11]);
EXPECT_EQ(Vector2D(1.0, 1.9), s2d.vertices[12]);
EXPECT_EQ(Vector2D(0.9, 1.8), s2d.vertices[13]);
EXPECT_EQ(Vector2D(0.8, 1.6), s2d.vertices[14]);
EXPECT_EQ(Vector2D(0.7, 1.4), s2d.vertices[15]);
EXPECT_EQ(Vector2D(0.6, 1.2), s2d.vertices[16]);
EXPECT_EQ(Vector2D(0.5, 1.0), s2d.vertices[17]);
EXPECT_EQ(Vector2D(0.4, 0.8), s2d.vertices[18]);
EXPECT_EQ(Vector2D(0.3, 0.6), s2d.vertices[19]);
EXPECT_EQ(Vector2D(0.2, 0.4), s2d.vertices[20]);
EXPECT_EQ(Vector2D(0.1, 0.2), s2d.vertices[21]);
EXPECT_DOUBLE_EQ(0.0, s2d.vl.x);
EXPECT_DOUBLE_EQ(0.0, s2d.vl.y);
EXPECT_DOUBLE_EQ(2.0, s2d.vu.x);
EXPECT_DOUBLE_EQ(1.9, s2d.vu.y);
EXPECT_EQ(11u, s2d.slabs.size());
// Slabs here all have 2 edges
EXPECT_EQ(2u, s2d.slabs[0].edges.size());
EXPECT_EQ(2u, s2d.slabs[1].edges.size());
EXPECT_EQ(2u, s2d.slabs[2].edges.size());
EXPECT_EQ(2u, s2d.slabs[3].edges.size());
EXPECT_EQ(2u, s2d.slabs[4].edges.size());
EXPECT_EQ(2u, s2d.slabs[5].edges.size());
EXPECT_EQ(2u, s2d.slabs[6].edges.size());
EXPECT_EQ(2u, s2d.slabs[7].edges.size());
EXPECT_EQ(2u, s2d.slabs[8].edges.size());
EXPECT_EQ(2u, s2d.slabs[9].edges.size());
EXPECT_EQ(2u, s2d.slabs[10].edges.size());
}

TEST_F(EnergyPlusFixture, SurfaceTest_Surface2D_bigVertices2)
{
using Vector2D = Surface2D::Vector2D;
SurfaceData s;
s.Vertex.dimension(24);
// convex, >nVerticesBig, Issue 10490 defect file failed surface
s.Vertex = {Vector(4.5047023, 14.8653133, 35.35), Vector(6.5689151, 13.4862441, 35.35), Vector(6.1242243, 12.8206238, 35.35),
Vector(7.8836902, 11.6451513, 35.35), Vector(8.2156112, 12.1419759, 35.35), Vector(8.7993282, 11.7520035, 35.35),
Vector(8.9659831, 12.0014552, 35.35), Vector(9.2241656, 11.8289674, 35.35), Vector(9.4352618, 12.1449395, 35.35),
Vector(8.5933623, 12.7073998, 35.35), Vector(9.6032909, 14.219077, 35.35), Vector(9.5550636, 14.251297, 35.35),
Vector(8.5268029, 12.71218, 35.35), Vector(9.1313075, 12.3083197, 35.35), Vector(8.7902205, 11.7977752, 35.35),
Vector(8.1857159, 12.2016356, 35.35), Vector(7.8676828, 11.7255986, 35.35), Vector(6.2046715, 12.8366312, 35.35),
Vector(6.6740828, 13.5392534, 35.35), Vector(4.646872, 14.8936022, 35.35), Vector(5.8684524, 16.7220831, 35.35),
Vector(7.8474358, 15.3999543, 35.35), Vector(7.8796558, 15.4481816, 35.35), Vector(5.815443, 16.8272508, 35.35)};
s.Shape = SurfaceShape::Polygonal;
s.set_computed_geometry();

Surface2D const &s2d(s.surface2d);
EXPECT_EQ(2, s2d.axis); // Projection along z axis
EXPECT_EQ(Vector2D(4.5047023, 14.8653133), s2d.vertices[0]);
EXPECT_EQ(Vector2D(6.5689151, 13.4862441), s2d.vertices[1]);
EXPECT_EQ(Vector2D(6.1242243, 12.8206238), s2d.vertices[2]);
EXPECT_EQ(Vector2D(7.8836902, 11.6451513), s2d.vertices[3]);
EXPECT_EQ(Vector2D(8.2156112, 12.1419759), s2d.vertices[4]);
EXPECT_EQ(Vector2D(8.7993282, 11.7520035), s2d.vertices[5]);
EXPECT_EQ(Vector2D(8.9659831, 12.0014552), s2d.vertices[6]);
EXPECT_EQ(Vector2D(9.2241656, 11.8289674), s2d.vertices[7]);
EXPECT_EQ(Vector2D(9.4352618, 12.1449395), s2d.vertices[8]);
EXPECT_EQ(Vector2D(8.5933623, 12.7073998), s2d.vertices[9]);
EXPECT_EQ(Vector2D(9.6032909, 14.219077), s2d.vertices[10]);
EXPECT_EQ(Vector2D(9.5550636, 14.251297), s2d.vertices[11]);
EXPECT_EQ(Vector2D(8.5268029, 12.71218), s2d.vertices[12]);
EXPECT_EQ(Vector2D(9.1313075, 12.3083197), s2d.vertices[13]);
EXPECT_EQ(Vector2D(8.7902205, 11.7977752), s2d.vertices[14]);
EXPECT_EQ(Vector2D(8.1857159, 12.2016356), s2d.vertices[15]);
EXPECT_EQ(Vector2D(7.8676828, 11.7255986), s2d.vertices[16]);
EXPECT_EQ(Vector2D(6.2046715, 12.8366312), s2d.vertices[17]);
EXPECT_EQ(Vector2D(6.6740828, 13.5392534), s2d.vertices[18]);
EXPECT_EQ(Vector2D(4.646872, 14.8936022), s2d.vertices[19]);
EXPECT_EQ(Vector2D(5.8684524, 16.7220831), s2d.vertices[20]);
EXPECT_EQ(Vector2D(7.8474358, 15.3999543), s2d.vertices[21]);
EXPECT_EQ(Vector2D(7.8796558, 15.4481816), s2d.vertices[22]);
EXPECT_EQ(Vector2D(5.815443, 16.8272508), s2d.vertices[23]);
EXPECT_DOUBLE_EQ(4.5047023, s2d.vl.x);
EXPECT_DOUBLE_EQ(11.6451513, s2d.vl.y);
EXPECT_DOUBLE_EQ(9.6032909, s2d.vu.x);
EXPECT_DOUBLE_EQ(16.8272508, s2d.vu.y);
EXPECT_EQ(23u, s2d.slabs.size());
// Slabs here have anywhere from 2 to 10 edges??
EXPECT_EQ(2u, s2d.slabs[0].edges.size());
EXPECT_EQ(4u, s2d.slabs[1].edges.size());
EXPECT_EQ(6u, s2d.slabs[2].edges.size());
EXPECT_EQ(8u, s2d.slabs[3].edges.size());
EXPECT_EQ(10u, s2d.slabs[4].edges.size());
EXPECT_EQ(8u, s2d.slabs[5].edges.size());
EXPECT_EQ(6u, s2d.slabs[6].edges.size());
EXPECT_EQ(6u, s2d.slabs[7].edges.size());
EXPECT_EQ(4u, s2d.slabs[8].edges.size());
EXPECT_EQ(4u, s2d.slabs[9].edges.size());
EXPECT_EQ(4u, s2d.slabs[10].edges.size());
EXPECT_EQ(4u, s2d.slabs[11].edges.size());
EXPECT_EQ(4u, s2d.slabs[12].edges.size());
EXPECT_EQ(4u, s2d.slabs[13].edges.size());
EXPECT_EQ(4u, s2d.slabs[14].edges.size());
EXPECT_EQ(4u, s2d.slabs[15].edges.size());
EXPECT_EQ(4u, s2d.slabs[16].edges.size());
EXPECT_EQ(2u, s2d.slabs[17].edges.size());
EXPECT_EQ(2u, s2d.slabs[18].edges.size());
EXPECT_EQ(2u, s2d.slabs[19].edges.size());
EXPECT_EQ(4u, s2d.slabs[20].edges.size());
EXPECT_EQ(4u, s2d.slabs[21].edges.size());
EXPECT_EQ(2u, s2d.slabs[22].edges.size());
}

TEST_F(EnergyPlusFixture, SurfaceTest_AverageHeightRectangle)
{
{
Expand Down

4 comments on commit bcf2046

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

InterzonewindowsAndSurfs20PlusVertices (mjwitte) - x86_64-Linux-Ubuntu-22.04-gcc-11.4: OK (3604 of 3604 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

InterzonewindowsAndSurfs20PlusVertices (mjwitte) - Win64-Windows-10-VisualStudio-16: OK (2775 of 2775 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

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

InterzonewindowsAndSurfs20PlusVertices (mjwitte) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-UnitTestsCoverage-Debug: OK (1987 of 1987 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

InterzonewindowsAndSurfs20PlusVertices (mjwitte) - x86_64-Linux-Ubuntu-22.04-gcc-11.4-IntegrationCoverage-Debug: OK (791 of 791 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.