-
Notifications
You must be signed in to change notification settings - Fork 392
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 kiva clockwise geometry rule issue #9104
Conversation
ad06821
to
2250ced
Compare
@@ -730,7 +730,7 @@ bool KivaManager::setupKivaInstances(EnergyPlusData &state) | |||
} | |||
} | |||
} else { | |||
for (auto i = surface.Vertex.size() - 1; i <= 0; --i) { | |||
for (int i = surface.Vertex.size() - 1; i >= 0; --i) { |
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'd probably keep it a size_t
to match the other side of the IF block.
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.
Here it clearly needs a signed integer as it needs to get to the value of -1 to stop. The size_t
seems to be an unsigned one--any signed counterpart of 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.
@jcyuan2020, you can get around this with:
for (auto i = surface.Vertex.size() - 1; i < surface.Vertex.size() /* i>=0 */; --i)
This exploits the unsigned int underflow that occurs at 0 - 1
while preserving the type comparison.
Otherwise this change makes sense to me. It's a good catch and probably something I should have tested better originally.
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.
@nealkruis Thanks! I was just writing some notes address to you to take a look at this issue--see the comments under #9103. It seems that additional fixes might be needed to fix this.
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.
Gah, OK, yeah I see the signed integer is needed, sorry about that.
So is there additional work on this then? For now it can stay an int as far as I'm concerned. Oh and do you anticipate drafting up a test for this? |
Some further work needed in order to let the defect file run after the fix. See the comments in the original issue post #9103. For the existing part, I am not sure for now whether modified function would be executed to complete a unit test (or say, if the unit test would be dependent on the further fixes)--I will take a check on this soon. |
Based on debugging run of the defect file, the further work would be here inside the same function as the current fix:
This might mean it could be a little difficult to get pass through (at a first glance) in a unit test. Any comments or suggestions before jumping into creating a unit test? |
@jcyuan2020 @Myoldmopar it has been 28 days since this pull request was last updated. |
@jcyuan2020 if you want to just wrap this one up as-is, and then do a follow-up PR that addresses the remaining issue and adds more testing that is fine. I'd like to get this one merged in soon though, so if you plan to do that, we can review this and call this piece done when you feel it is ready (it's obviously a good step). |
@Myoldmopar, we had talked about me taking this one over and addressing the other part of the issue too. I'm fine either way though. @jcyuan2020 how would you like to proceed? |
@Myoldmopar @nealkruis Thanks! I've updated it with the most recent develop and it should be ok to go in as is, but obviously without a unit test since the function would not pass without further fixes. |
OK, I'm going to go ahead and merge this. I pulled it down and tested with latest develop, no problem. I hope a follow-up PR can address any remaining issues and add testing to cover this change. Thanks @jcyuan2020 and @nealkruis |
Fix kiva clockwise geometry rule issue
Pull request overview
auto i = 0
toint i = 0
as the auto-cast will get an unsigned integer. Otherwise, it will cause a problem sincei
will very large positive number wheni
decreases one more tick from 0---which will not end the loop and point to some elements way out of bound.NOTE: ENHANCEMENTS MUST FOLLOW A SUBMISSION PROCESS INCLUDING A FEATURE PROPOSAL AND DESIGN DOCUMENT PRIOR TO SUBMITTING CODE
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.