@@ -11853,3 +11853,108 @@ TEST_F(EnergyPlusFixture, SurfaceGeometry_SurroundingSurfacesViewFactorTest)
11853
11853
EXPECT_DOUBLE_EQ(0.2, surface_east_wall.ViewFactorGroundIR);
11854
11854
EXPECT_DOUBLE_EQ(1.0, surface_east_wall.ViewFactorSrdSurfs + surface_east_wall.ViewFactorSkyIR + surface_east_wall.ViewFactorGroundIR);
11855
11855
}
11856
+
11857
+ TEST_F(EnergyPlusFixture, Fix_checkSubSurfAzTiltNorm_Horizontal_Surf_Random)
11858
+ {
11859
+ // Unit Test for Pull Request 10104 that addresses a potential illy functioned (or redudant) `if` condition
11860
+ SurfaceData BaseSurface;
11861
+ SurfaceData SubSurface;
11862
+ SurfaceData SubSurface_Same;
11863
+ bool surfaceError;
11864
+
11865
+ // Test Base surf and subsurf normal vectors assignment
11866
+ surfaceError = false;
11867
+
11868
+ BaseSurface.Vertex.dimension(4);
11869
+
11870
+ BaseSurface.Vertex = {
11871
+ DataVectorTypes::Vector(0, 0, 1), DataVectorTypes::Vector(1, 0, 1), DataVectorTypes::Vector(1, 1, 1), DataVectorTypes::Vector(0, 1, 1)};
11872
+ Vectors::CreateNewellSurfaceNormalVector(BaseSurface.Vertex, BaseSurface.Vertex.size(), BaseSurface.NewellSurfaceNormalVector);
11873
+ Vectors::DetermineAzimuthAndTilt(BaseSurface.Vertex,
11874
+ BaseSurface.Azimuth,
11875
+ BaseSurface.Tilt,
11876
+ BaseSurface.lcsx,
11877
+ BaseSurface.lcsy,
11878
+ BaseSurface.lcsz,
11879
+ BaseSurface.NewellSurfaceNormalVector);
11880
+
11881
+ SubSurface.Vertex.dimension(4);
11882
+
11883
+ SubSurface.Vertex = {DataVectorTypes::Vector(0, 0, 1),
11884
+ DataVectorTypes::Vector(1, 0, 1),
11885
+ DataVectorTypes::Vector(1, 1, 1.0003),
11886
+ DataVectorTypes::Vector(0, 1, 1.0003)};
11887
+ Vectors::CreateNewellSurfaceNormalVector(SubSurface.Vertex, SubSurface.Vertex.size(), SubSurface.NewellSurfaceNormalVector);
11888
+ Vectors::DetermineAzimuthAndTilt(SubSurface.Vertex,
11889
+ SubSurface.Azimuth,
11890
+ SubSurface.Tilt,
11891
+ SubSurface.lcsx,
11892
+ SubSurface.lcsy,
11893
+ SubSurface.lcsz,
11894
+ SubSurface.NewellSurfaceNormalVector);
11895
+
11896
+ bool sameSurfNormal(false);
11897
+
11898
+ // This is the sameSurfNormal test used in checkSubSurfAzTiltNorm()
11899
+ Vectors::CompareTwoVectors(BaseSurface.NewellSurfaceNormalVector, SubSurface.NewellSurfaceNormalVector, sameSurfNormal, 0.001);
11900
+
11901
+ // The surface normals are not exactly the same
11902
+ EXPECT_GE(std::abs(BaseSurface.NewellSurfaceNormalVector.y - SubSurface.NewellSurfaceNormalVector.y), 1e-5);
11903
+ EXPECT_GE(std::abs(BaseSurface.NewellSurfaceNormalVector.z - SubSurface.NewellSurfaceNormalVector.z), 1e-10);
11904
+
11905
+ // But should pass the sameSurfNormal test
11906
+ EXPECT_TRUE(sameSurfNormal);
11907
+
11908
+ checkSubSurfAzTiltNorm(*state, BaseSurface, SubSurface, surfaceError);
11909
+
11910
+ // These should pass
11911
+ EXPECT_FALSE(surfaceError);
11912
+ EXPECT_FALSE(has_err_output());
11913
+
11914
+ // The base and the sub surfaces now should be adjusted to be exactly the same
11915
+ EXPECT_DOUBLE_EQ(BaseSurface.lcsz.z, SubSurface.lcsz.z);
11916
+ EXPECT_DOUBLE_EQ(BaseSurface.lcsz.y, SubSurface.lcsz.y);
11917
+ EXPECT_DOUBLE_EQ(BaseSurface.lcsz.x, SubSurface.lcsz.x);
11918
+
11919
+ // Now do a test with the same SubSurface but with slightly different (but still valid) vertices input order
11920
+ // Then the same test should pass all the same with the PR 10104 fix
11921
+ // But it would expect to fail in the original develop branch without RP 10104 fix
11922
+ SubSurface_Same.Vertex.dimension(4);
11923
+ SubSurface_Same.Vertex = {DataVectorTypes::Vector(1, 0, 1),
11924
+ DataVectorTypes::Vector(1, 1, 1.0003),
11925
+ DataVectorTypes::Vector(0, 1, 1.0003),
11926
+ DataVectorTypes::Vector(0, 0, 1)};
11927
+ Vectors::CreateNewellSurfaceNormalVector(SubSurface_Same.Vertex, SubSurface_Same.Vertex.size(), SubSurface_Same.NewellSurfaceNormalVector);
11928
+ Vectors::DetermineAzimuthAndTilt(SubSurface_Same.Vertex,
11929
+ SubSurface_Same.Azimuth,
11930
+ SubSurface_Same.Tilt,
11931
+ SubSurface_Same.lcsx,
11932
+ SubSurface_Same.lcsy,
11933
+ SubSurface_Same.lcsz,
11934
+ SubSurface_Same.NewellSurfaceNormalVector);
11935
+
11936
+ sameSurfNormal = false;
11937
+
11938
+ // This is the sameSurfNormal test used in checkSubSurfAzTiltNorm()
11939
+ Vectors::CompareTwoVectors(BaseSurface.NewellSurfaceNormalVector, SubSurface_Same.NewellSurfaceNormalVector, sameSurfNormal, 0.001);
11940
+
11941
+ // The surface normals are not exactly the same
11942
+ EXPECT_GE(std::abs(BaseSurface.NewellSurfaceNormalVector.y - SubSurface_Same.NewellSurfaceNormalVector.y), 1e-5);
11943
+ EXPECT_GE(std::abs(BaseSurface.NewellSurfaceNormalVector.z - SubSurface_Same.NewellSurfaceNormalVector.z), 1e-10);
11944
+
11945
+ // But should pass the sameSurfNormal test
11946
+ EXPECT_TRUE(sameSurfNormal);
11947
+
11948
+ checkSubSurfAzTiltNorm(*state, BaseSurface, SubSurface_Same, surfaceError);
11949
+
11950
+ // These should pass
11951
+ EXPECT_FALSE(surfaceError);
11952
+ EXPECT_FALSE(has_err_output());
11953
+
11954
+ // At least one of the following tests are expected to fail in the original develop branch without PR 10104 fix
11955
+ // But with PR 10104 fix they should all pass
11956
+ // The base and the sub surfaces now should be adjusted to be exactly the same
11957
+ EXPECT_DOUBLE_EQ(BaseSurface.lcsz.z, SubSurface_Same.lcsz.z);
11958
+ EXPECT_DOUBLE_EQ(BaseSurface.lcsz.y, SubSurface_Same.lcsz.y);
11959
+ EXPECT_DOUBLE_EQ(BaseSurface.lcsz.x, SubSurface_Same.lcsz.x);
11960
+ }
0 commit comments