Skip to content
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

Merged
merged 3 commits into from
Jan 6, 2022

Conversation

jcyuan2020
Copy link
Contributor

Pull request overview

  • Fixes Kiva problem when using clockwise geometry rule #9103
  • Also, along with the conditional statement fix it is necessary to change the auto i = 0 to int i = 0 as the auto-cast will get an unsigned integer. Otherwise, it will cause a problem since i will very large positive number when i 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.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies

Reviewer

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

@jcyuan2020 jcyuan2020 added the Defect Includes code to repair a defect in EnergyPlus label Sep 28, 2021
@@ -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) {
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

@Myoldmopar
Copy link
Member

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?

@jcyuan2020
Copy link
Contributor Author

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.

@jcyuan2020
Copy link
Contributor Author

Based on debugging run of the defect file, the further work would be here inside the same function as the current fix:

floorAggregator.add_instance(kivaInstances[inst].instance.ground.get(), floorWeight);

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?

@nrel-bot-2c
Copy link

@jcyuan2020 @Myoldmopar it has been 28 days since this pull request was last updated.

@Myoldmopar
Copy link
Member

@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).

@nealkruis
Copy link
Member

@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?

@jcyuan2020
Copy link
Contributor Author

@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.

@jcyuan2020 jcyuan2020 marked this pull request as ready for review January 4, 2022 20:30
@Myoldmopar
Copy link
Member

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

@Myoldmopar Myoldmopar merged commit 4a865aa into NREL:develop Jan 6, 2022
yujiex pushed a commit that referenced this pull request Jan 27, 2022
Fix kiva clockwise geometry rule issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defect Includes code to repair a defect in EnergyPlus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kiva problem when using clockwise geometry rule
8 participants