-
Notifications
You must be signed in to change notification settings - Fork 460
Fix space assignment for zone outside boundary condition and add space option #10903
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
Conversation
|
Need to test that this works for cases where the surface is adjacent to the same zone/space, such as a middle floor that's multiplied. |
|
|
One of the new unit tests fails with develop: |
mjwitte
left a comment
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 walkthru
| \key Adiabatic | ||
| \key Surface | ||
| \key Zone | ||
| \key Space |
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.
New outside boundary condition choice for the Detailed surface types.
| int constexpr UnenteredAdjacentZoneSurface = -998; // allows users to enter one zone surface ("Zone") | ||
| // referencing another in adjacent zone | ||
| int constexpr UnreconciledZoneSurface = -999; // interim value between entering surfaces ("Surface") and reconciling | ||
| int constexpr unenteredAdjacentSpaceSurface = -997; // allows users to enter one zone surface ("Space") |
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.
New flag variable for Space outside BC.
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.
Seems ripe for an enum instead of hardcoded values, but there may be a reason that isn't ideal here. Either way this doesn't have to hold up for it.
| int constexpr unenteredAdjacentZoneSurface = -998; // allows users to enter one zone surface ("Zone") | ||
| // referencing another in adjacent zone | ||
| int constexpr unreconciledZoneSurface = -999; // interim value between entering surfaces ("Surface") and reconciling |
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.
Somewhat gratuitous name changes to lower case to help reveal where these flags get used.
| for (int SurfNum = 1; SurfNum <= FirstTotalSurfaces; ++SurfNum) { | ||
| auto &surfTemp = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); | ||
| if (surfTemp.ExtBoundCond != UnenteredAdjacentZoneSurface) continue; | ||
| if ((surfTemp.ExtBoundCond != unenteredAdjacentZoneSurface) && (surfTemp.ExtBoundCond != unenteredAdjacentSpaceSurface)) continue; |
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.
For both the zone and space BC, need to add the new companion surface.
| ++CurNewSurf; | ||
| // Debug write(outputfiledebug,*) ' adding surface=',curnewsurf | ||
| state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf) = state.dataSurfaceGeometry->SurfaceTmp(SurfNum); | ||
| auto &newSurf = state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf); |
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.
Lots of diffs here just due to the new shortcut for newSurf.
| newSurf.spaceNum = Found; | ||
| int zoneNum = state.dataHeatBal->space(Found).zoneNum; | ||
| newSurf.Zone = zoneNum; | ||
| newSurf.ZoneName = state.dataHeatBal->Zone(zoneNum).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.
For space BC, set spaceNum here and locate the zone for that space.
The remaining changes in this function are just from the newSurf shortcut.
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.
newSurf shortcut is a worthwhile cleanup for sure.
This is a message to anyone, not just you. If you want to do these renaming changes, but they are going to cause lots of code diffs, feel free to fix them all up quickly in their own branch, and we can get it merged quickly so you can then make your targeted changes in a more compact PR.
In this case, it's not even close to worth doing that, it's just a few dozen extra lines changed. So just noting it.
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.
And it would actually be nice if you could add a pattern match on GitHub's UI to ignore some changes. You can already ignore whitespace-only changes, so the capability is somewhat in place. If you could just say "ignore any changes that are purely from "state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf)" to "newSurf", that would be incredible.
FWIW I think they are using the --ignore-all-space or whatever argument with Git Diff. There are other diff arguments that could be leveraged (-G along with --pickaxe-regex). OK I'm done I'm done.
| } else if (thisSurf.ExtBoundCond != unreconciledZoneSurface) { | ||
| anySurfacesWithoutSpace(thisSurf.Zone) = true; | ||
| } else if (thisSurf.Name.substr(0, 3) != "iz-") { | ||
| // Only trigger a new space if the spaceless surface is not an autogenerated interzone surface | ||
| anySurfacesWithoutSpace(thisSurf.Zone) = 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.
Without breaking other situations where a surface has no space assigned, set the appropriate flags so that an autogenerated surface with the Zone BC gets assigned to an appropriate space.
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.
So you don't need an else block anymore at all?
| thisSurf.spaceNum = lastSpaceForZone; | ||
| if ((thisSurf.ExtBoundCond == unreconciledZoneSurface) && (thisSurf.Name.substr(0, 3) == "iz-")) { | ||
| if (state.dataHeatBal->Zone(thisSurf.Zone).numSpaces > 1) { | ||
| // Only trigger warning if the spaceless surface is an autogenerated interzone surface | ||
| ShowWarningError(state, | ||
| format("{}Surface=\"{}\" has Outside Boundary Condition=Zone, but Zone=\"{}\" has more than 1 Space.", | ||
| RoutineName, | ||
| thisSurf.Name.substr(3), | ||
| thisSurf.ZoneName)); | ||
| ShowContinueError(state, | ||
| format("Auto-generated surface=\"{}\" will be assigned to Space=\"{}\"", | ||
| thisSurf.Name, | ||
| state.dataHeatBal->space(thisSurf.spaceNum).Name)); | ||
| ShowContinueError(state, "Use Outside Boundary Condition = Space to specify the exact Space for the outside boundary."); | ||
| } | ||
| } |
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.
After all of the spaces have been set up, every surface is already assigned to a zone, but some or all surfaces may not be assigned to a space yet. The existing logic assigns the last space in the zone. That logic remains the same here.
But if the surface was autogenerated using the Zone BC, but the other side zone has more than one space, a warning is issued, because the desired space is ambiguous.
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.
I think I'm tracking this. And seems reasonable to assume that and emit a warning.
| if (Found == 0) { | ||
| ShowSevereError(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.
Severe error is space BC is specified, but the other side space name is not found.
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.
Yes, reasonable.
| EXPECT_FALSE(thisSG->SurfaceTmp(8).HeatTransSurf); | ||
| EXPECT_TRUE(thisSG->SurfaceTmp(8).ExtSolar); | ||
| } | ||
| TEST_F(EnergyPlusFixture, SurfaceGeometry_ZoneOutsideBC_SpacesNotInput) |
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.
3 new unit test to exercise various combinations of zone and space BC.
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.
Excellence.
|
Myoldmopar
left a comment
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.
Minor comments, but this looks great. I'll look locally regarding my comment about the now-deleted else. I'm assuming you have the logic in place there, and it just caught me off guard in review. Anyway, I'll test locally and confirm things.
| int constexpr UnenteredAdjacentZoneSurface = -998; // allows users to enter one zone surface ("Zone") | ||
| // referencing another in adjacent zone | ||
| int constexpr UnreconciledZoneSurface = -999; // interim value between entering surfaces ("Surface") and reconciling | ||
| int constexpr unenteredAdjacentSpaceSurface = -997; // allows users to enter one zone surface ("Space") |
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.
Seems ripe for an enum instead of hardcoded values, but there may be a reason that isn't ideal here. Either way this doesn't have to hold up for it.
| newSurf.spaceNum = Found; | ||
| int zoneNum = state.dataHeatBal->space(Found).zoneNum; | ||
| newSurf.Zone = zoneNum; | ||
| newSurf.ZoneName = state.dataHeatBal->Zone(zoneNum).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.
newSurf shortcut is a worthwhile cleanup for sure.
This is a message to anyone, not just you. If you want to do these renaming changes, but they are going to cause lots of code diffs, feel free to fix them all up quickly in their own branch, and we can get it merged quickly so you can then make your targeted changes in a more compact PR.
In this case, it's not even close to worth doing that, it's just a few dozen extra lines changed. So just noting it.
| newSurf.spaceNum = Found; | ||
| int zoneNum = state.dataHeatBal->space(Found).zoneNum; | ||
| newSurf.Zone = zoneNum; | ||
| newSurf.ZoneName = state.dataHeatBal->Zone(zoneNum).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.
And it would actually be nice if you could add a pattern match on GitHub's UI to ignore some changes. You can already ignore whitespace-only changes, so the capability is somewhat in place. If you could just say "ignore any changes that are purely from "state.dataSurfaceGeometry->SurfaceTmp(CurNewSurf)" to "newSurf", that would be incredible.
FWIW I think they are using the --ignore-all-space or whatever argument with Git Diff. There are other diff arguments that could be leveraged (-G along with --pickaxe-regex). OK I'm done I'm done.
| } else if (thisSurf.ExtBoundCond != unreconciledZoneSurface) { | ||
| anySurfacesWithoutSpace(thisSurf.Zone) = true; | ||
| } else if (thisSurf.Name.substr(0, 3) != "iz-") { | ||
| // Only trigger a new space if the spaceless surface is not an autogenerated interzone surface | ||
| anySurfacesWithoutSpace(thisSurf.Zone) = 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.
So you don't need an else block anymore at all?
| thisSurf.spaceNum = lastSpaceForZone; | ||
| if ((thisSurf.ExtBoundCond == unreconciledZoneSurface) && (thisSurf.Name.substr(0, 3) == "iz-")) { | ||
| if (state.dataHeatBal->Zone(thisSurf.Zone).numSpaces > 1) { | ||
| // Only trigger warning if the spaceless surface is an autogenerated interzone surface | ||
| ShowWarningError(state, | ||
| format("{}Surface=\"{}\" has Outside Boundary Condition=Zone, but Zone=\"{}\" has more than 1 Space.", | ||
| RoutineName, | ||
| thisSurf.Name.substr(3), | ||
| thisSurf.ZoneName)); | ||
| ShowContinueError(state, | ||
| format("Auto-generated surface=\"{}\" will be assigned to Space=\"{}\"", | ||
| thisSurf.Name, | ||
| state.dataHeatBal->space(thisSurf.spaceNum).Name)); | ||
| ShowContinueError(state, "Use Outside Boundary Condition = Space to specify the exact Space for the outside boundary."); | ||
| } | ||
| } |
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.
I think I'm tracking this. And seems reasonable to assume that and emit a warning.
| surfTemp.ExtBoundCond = DataSurfaces::ExternalEnvironment; | ||
| } else if (Util::SameString(s_ipsc->cAlphaArgs(ArgPointer), "Adiabatic")) { | ||
| surfTemp.ExtBoundCond = UnreconciledZoneSurface; | ||
| surfTemp.ExtBoundCond = unreconciledZoneSurface; |
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.
I will say this would look real nice as an enum instead...
tempSurface.exteriorBoundaryCondition = BC::UnreconciledZoneSurface;| if (Found == 0) { | ||
| ShowSevereError(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.
Yes, reasonable.
| EXPECT_FALSE(thisSG->SurfaceTmp(8).HeatTransSurf); | ||
| EXPECT_TRUE(thisSG->SurfaceTmp(8).ExtSolar); | ||
| } | ||
| TEST_F(EnergyPlusFixture, SurfaceGeometry_ZoneOutsideBC_SpacesNotInput) |
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.
Excellence.
|
Yeah this looks good to go. Merging. Thanks @mjwitte ! |






Pull request overview
BuildingSurface:Detailed,Wall:Detailed,RoofCeiling:Detailed, andFloor:Detailedadd "Space" as a choice for Outside Boundary Condition, so the user can specify the adjacent Space name.Wall:Interzone,Ceiling:Interzone, andFloor:Interzoneenforce the single-space requirement.Window:Interzone,Door:Interzone, andGlazedDoor:Interzone, fix the code to use the same Space as the base surface.Pull Request Author
Add to this list or remove from it as applicable. This is a simple templated set of guidelines.
If any diffs are expected, author must demonstrate they are justified using plots and descriptionsIf IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange labelIf structural output changes, add to output rules file and add OutputChange labelIf adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependenciesReviewer
This will not be exhaustively relevant to every PR.