-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix array bounds error for interzone windows and fix convexity of mirrored surfaces #10498
base: develop
Are you sure you want to change the base?
Conversation
…indowsAndSurfs20PlusVertices
Added some unit tests for surfaces with >=20 vertices. Here's a plot of the vertices for the defect file surface that fails the original Here's the surface object shown above
|
Noticed this comment in EnergyPlus/src/EnergyPlus/SurfaceGeometry.cc Lines 9758 to 9761 in 4d39dff
But vertices haven't been So let's try |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code walkthrough.
Real64 constexpr OneThousandth = 1.0e-3; // Used as a tolerance in various places | ||
Real64 constexpr OneMillionth = 1.0e-6; // Used as a tolerance in various places | ||
|
||
Real64 constexpr DistTooSmall(1.e-4); // Geometric tolerance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some new constants that are used as tolerances in various places in surface geometry and shadowing calculations. DistToolSmall
was moved up from a local declaration in Vectors.cc - decided to keep the same name.
@@ -88,15 +87,6 @@ using namespace WindowManager; | |||
|
|||
Array1D_string const cExtBoundCondition({-6, 0}, {"KivaFoundation", "FCGround", "OSCM", "OSC", "OSC", "Ground", "ExternalEnvironment"}); | |||
|
|||
// Parameters to indicate surface classes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed some comments that were left behind at some point when the parameters were moved to an enum
.
assert((shapeCat == ShapeCat::Nonconvex) || (crossEdges.size() == 2)); | ||
assert((shapeCat == ShapeCat::Nonconvex) || (crossEdges.size() == 2u)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the assert that was failing. Initially, I thought it was incorrect and should be >=2
, but in the end the failing surface was ShapeCat:Convex
here when it should have been Nonconvex
.
auto &origSurface = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); | ||
auto &newSurface = state.dataSurfaceGeometry->SurfaceTmp(SurfNum + 1); | ||
newSurface = origSurface; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In MakeMirrorSurface
just copy the entire original surface into the new surface instead of trying to copy each pertinent field individually. Then go about modifying name, vertices and other things. See #10498 (comment).
@@ -110,16 +106,6 @@ Vector const XUnit(1.0, 0.0, 0.0); | |||
Vector const YUnit(0.0, 1.0, 0.0); | |||
Vector const ZUnit(0.0, 0.0, 1.0); | |||
|
|||
// DERIVED TYPE DEFINITIONS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some housekeeping throughout Vectors.cc.
@@ -244,6 +244,154 @@ TEST_F(EnergyPlusFixture, SurfaceTest_Surface2D) | |||
} | |||
} | |||
|
|||
TEST_F(EnergyPlusFixture, SurfaceTest_Surface2D_bigVertices) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 new unit tests added related to the failed assert in Surface2D
. The first is a convex surface, the second is nonconvex. In hindsight, this isn't focusing on the root problems.
Pull request overview
MakeMirrorSurface
to properly setIsConvex
for the mirrored surface. When a mirrored surface is created, the original surface has already setIsConvex
for itself. The formerMakeMirrorSurface
copied a list of specific attributes to the new surface, but did not copyIsConvex
so it was always true. This resulted in a non-convex surface being classified as convex which then failed debug assert inSurface2D
for mirrored nonconvex shading surfaces with 20 or more vertices (that's a mouthful). The defect file tripped on thisassert
in a debug build, masking the arrays bounds issue.MakeMirrorSurface
.1.0e-6
and the like.Defects Fixed
Revised defect file (which runs faster): 10490.idf.txt
The defect file crashed with a release build and failed an assert with a debug build revealing two separate issues.
The defect file now runs to completion with both release and debug builds.
Diffs
There are no diffs. There was an expectation that diffs might show up from fixing the mirrored surface convexity. This fix only impacts the mirrored side of a non-convex shading surface which will only impact the results if the mirrored side casts shadows toward the building and if the non-convex shape is such that the Polygon Clipping Algorithm does not handle it correctly.
Pull Request Author
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
Reviewer
This will not be exhaustively relevant to every PR.