-
Notifications
You must be signed in to change notification settings - Fork 397
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 vector error for when a zone or space has no surfaces #10309
Conversation
Defect file error output before:
With this branch;
|
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 walk through.
@@ -499,7 +500,10 @@ namespace HeatBalanceIntRadExchange { | |||
thisEnclosure.NumOfSurfaces = numEnclosureSurfaces; | |||
state.dataHeatBalIntRadExchg->MaxNumOfRadEnclosureSurfs = | |||
max(state.dataHeatBalIntRadExchg->MaxNumOfRadEnclosureSurfs, numEnclosureSurfaces); | |||
if (numEnclosureSurfaces < 1) ShowFatalError(state, "No surfaces in an enclosure in InitInteriorRadExchange"); | |||
if (numEnclosureSurfaces < 1) { | |||
ShowSevereError(state, format("{}No surfaces in enclosure={}.", RoutineName, thisEnclosure.Name)); |
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 error message cleanup - should throw a severe here and set ErrorsFound
, then fatal throws later.
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.
That's a nice addition - let it find more errors on the first pass.
Real64 TotSurfArea = 0.0; | ||
thisZone.Centroid = Vector(0.0, 0.0, 0.0); | ||
if (state.dataSurface->Surface(thisZone.AllSurfaceFirst).Sides > 0) { | ||
if ((thisZone.AllSurfaceFirst > 0) && (state.dataSurface->Surface(thisZone.AllSurfaceFirst).Sides > 0)) { |
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.
Check for valid subscript before using it.
if (thisSurface.Class == SurfaceClass::IntMass) { | ||
internalMassSurfacesPresent = true; | ||
continue; | ||
} | ||
if (!thisSurface.IsAirBoundarySurf) nonInternalMassSurfacesPresent = true; |
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.
Clean up this check. Previously, the internal mass warning below was firing even when there was no internal mass in the zone (or any surfaces at all). Also, an air boundary surface shouldn't be counted as a valid nonInternalMassSurface
.
@@ -2257,110 +2261,7 @@ namespace SurfaceGeometry { | |||
} | |||
} | |||
|
|||
//********************************************************************************** | |||
// Set up Zone Surface Pointers |
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.
The methodology here for setting *SurfaceFirst/Last
for zone and spaces was flawed, especially if a space had no surfaces. This has been redone and move to a new function setSurfaceFirstLast
.
// TODO MJW: Is this necessary? Check that all Spaces have at least one Surface | ||
for (int spaceNum = 1; spaceNum < state.dataGlobal->numSpaces; ++spaceNum) { | ||
for (int spaceNum = 1; spaceNum <= state.dataGlobal->numSpaces; ++spaceNum) { | ||
if (int(state.dataHeatBal->space(spaceNum).surfaces.size()) == 0) { | ||
ShowSevereError(state, format("{}Space = {} has no surfaces.", RoutineName, state.dataHeatBal->space(spaceNum).Name)); | ||
ErrorsFound = true; | ||
ShowWarningError(state, format("{}Space={} has no surfaces.", RoutineName, state.dataHeatBal->space(spaceNum).Name)); |
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.
Changed this to allow a space with no surfaces to pass through. However, if an enclosure has no surfaces, that will severe/fatal out. This does open the possibility of having a space with no surfaces sharing the same enclosure with other space(s) that do have surfaces. So, is that something we really want to allow?
} | ||
} | ||
} | ||
|
||
void setSurfaceFirstLast(EnergyPlusData &state) |
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.
The new function with a more robust method.
@@ -8661,10 +8661,6 @@ TEST_F(EnergyPlusFixture, GetSurfaceData_SurfaceOrder) | |||
|
|||
SetupZoneGeometry(*state, ErrorsFound); | |||
EXPECT_FALSE(ErrorsFound); // expect no errors | |||
|
|||
GetSurfaceData(*state, ErrorsFound); // setup zone geometry and get zone data |
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 function is already called from SetupZoneGeometry
. Otherwise, no substantive changes to the exisiting GetSurfaceData_SurfaceOrder
unit test.
@@ -9058,6 +9054,2395 @@ TEST_F(EnergyPlusFixture, GetSurfaceData_SurfaceOrder) | |||
EXPECT_FALSE(std::find(HTKivaSurfaces.begin(), HTKivaSurfaces.end(), thisSurface) != HTKivaSurfaces.end()); | |||
} | |||
|
|||
TEST_F(EnergyPlusFixture, GetSurfaceData_SurfaceOrder2) |
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 three new unit tests that are subsets of GetSurfaceData_SurfaceOrder
where the first zone/space has no surfaces (GetSurfaceData_SurfaceOrder2
), the middle zone has no surfaces (GetSurfaceData_SurfaceOrder3
), and the last zone has no surfaces (GetSurfaceData_SurfaceOrder4
).
CI is all green. Ready for review. |
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 looks great to me. Thanks @mjwitte
@@ -499,7 +500,10 @@ namespace HeatBalanceIntRadExchange { | |||
thisEnclosure.NumOfSurfaces = numEnclosureSurfaces; | |||
state.dataHeatBalIntRadExchg->MaxNumOfRadEnclosureSurfs = | |||
max(state.dataHeatBalIntRadExchg->MaxNumOfRadEnclosureSurfs, numEnclosureSurfaces); | |||
if (numEnclosureSurfaces < 1) ShowFatalError(state, "No surfaces in an enclosure in InitInteriorRadExchange"); | |||
if (numEnclosureSurfaces < 1) { | |||
ShowSevereError(state, format("{}No surfaces in enclosure={}.", RoutineName, thisEnclosure.Name)); |
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.
That's a nice addition - let it find more errors on the first pass.
int firstSpaceNum = state.dataHeatBal->Zone(ZoneNum).spaceIndexes(1); | ||
state.dataHeatBal->Zone(ZoneNum).AllSurfaceFirst = state.dataHeatBal->space(firstSpaceNum).AllSurfaceFirst; | ||
} | ||
} |
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.
It's a little difficult to grasp the changes since the code is moved entirely, but I understand that this is a positive move. And your unit tests are fleshed out heavily, so that builds confidence.
CI is 100% green, and this branch is up to date with develop, so this goes right in. Thanks @mjwitte |
Pull request overview
AllSurfaceFirst/Last
as a subscript.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.