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

[Refactor] Enums - Psychrometrics.hh #8864

Merged
merged 31 commits into from
Jul 17, 2021
Merged

[Refactor] Enums - Psychrometrics.hh #8864

merged 31 commits into from
Jul 17, 2021

Conversation

jmythms
Copy link
Contributor

@jmythms jmythms commented Jul 2, 2021

Pull request overview

  1. Converts the constexpr ints in Psychrometrics.hh to enums.
  2. Converts ObjexxFCL arrays to std::arrays.

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

@jmythms jmythms added the Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring label Jul 2, 2021
@jmythms jmythms added this to the EnergyPlus 9.6 IOFreeze milestone Jul 2, 2021
@jmythms jmythms self-assigned this Jul 2, 2021
@amirroth
Copy link
Collaborator

amirroth commented Jul 3, 2021

I would like to throw a couple more things into this branch if I can:

  • Replace the cached_Tsat, cached_Psat, etc. arrays themselves with std::arrays.
  • Replace function local RoutineNames with references to PsyRoutineNames[].

Comment on lines 185 to 195
#ifdef EP_cache_PsyTwbFnTdbWPb
cached_Twb.clear();
cached_Twb.fill(cached_twb_t());
#endif
#ifdef EP_cache_PsyPsatFnTemp
cached_Psat.clear();
cached_Psat.fill(cached_psat_t());
#endif
#ifdef EP_cache_PsyTsatFnPb
cached_Tsat.clear();
cached_Tsat.fill(cached_tsat_h_pb());
#endif
#ifdef EP_cache_PsyTsatFnHPb
cached_Tsat_HPb.clear();
cached_Tsat_HPb.fill(cached_tsat_h_pb());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::array does not have a .clear() method. So, I .fill()ed them with the default constructor call for those structs.

Comment on lines 121 to 131
#ifdef EP_cache_PsyTwbFnTdbWPb
state.dataPsychCache->cached_Twb.allocate({0, twbcache_size});
state.dataPsychCache->cached_Twb.fill(cached_twb_t());
#endif
#ifdef EP_cache_PsyPsatFnTemp
state.dataPsychCache->cached_Psat.allocate({0, psatcache_size});
state.dataPsychCache->cached_Psat.fill(cached_psat_t());
#endif
#ifdef EP_cache_PsyTsatFnPb
state.dataPsychCache->cached_Tsat.allocate({0, tsatcache_size});
state.dataPsychCache->cached_Tsat.fill(cached_tsat_h_pb());
#endif
#ifdef EP_cache_PsyTsatFnHPb
state.dataPsychCache->cached_Tsat_HPb.allocate({0, tsat_hbp_cache_size});
state.dataPsychCache->cached_Tsat_HPb.fill(cached_tsat_h_pb());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.fill()ed with the default constructor call for these structs.

@@ -845,10 +844,10 @@ namespace Psychrometrics {
// values from PsyRhFnTdbWPb

// FUNCTION PARAMETER DEFINITIONS:
static std::string const RoutineName("PsyRhFnTdbRhov");
static constexpr std::string_view RoutineName(PsyRoutineNames[static_cast<int>(PsychrometricFunction::RhFnTdbRhov)]); // PsyRhFnTdbRhov
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the static keyword? I left RoutineNames as separate variables for readability.

Copy link
Member

@Myoldmopar Myoldmopar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. There are a couple tiny comment-only changes that don't necessarily need to hold up the PR. If anyone else has any comments to add, and any commits are needed, then go ahead and clean those comments at the same time. Otherwise I'll do final testing and see if we can get this merged directly.

#ifdef EP_cache_PsyTsatFnHPb
constexpr int tsat_hbp_cache_size = 1024 * 1024;
constexpr int tsat_hbp_precision_bits = 28;
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constexpr FTW!

@@ -121,40 +163,28 @@ struct PsychrometricCacheData : BaseGlobalStruct
{

#ifdef EP_cache_PsyTwbFnTdbWPb
Array1D<cached_twb_t> cached_Twb; // DIMENSION(0:twbcache_size)
std::array<cached_twb_t, twbcache_size> cached_Twb;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, very very much better!

"PsyWFnTdbTwbPb",
"PsyTsatFnPb",
"PsyTwbFnTdbWPb_cache",
"PsyPsatFnTemp_cache"}; // 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this initialization, I wonder if the comment block at the end is really necessary. I suggest either moving the comments up to each individual element, or delete the comment block if not necessary.

false,
false,
true,
true}; // PsyTdpFnTdbTwbPb 1 | PsyRhFnTdbWPb 2 | PsyTwbFnTdbWPb 3 | PsyVFnTdbWPb 4 |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this comment block. On this one it is probably worth pulling each one up to its associated element for clarity.

@@ -513,7 +512,7 @@ namespace Psychrometrics {
// ASHRAE handbook 1993 Fundamentals,

#ifdef EP_psych_stats
++state.dataPsychCache->NumTimesCalled(iPsyRhFnTdbRhovLBnd0C);
++state.dataPsychCache->NumTimesCalled[static_cast<int>(PsychrometricFunction::RhFnTdbRhovLBnd0C)];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is the pattern we are going for, so this is good.

@Myoldmopar
Copy link
Member

I pulled develop in, and I want to wait until the GHA alternate build configurations run on this branch because some of the conflicts were instead of #ifdef scopes that I'm not building. If it is happy, I believe everything is good to go here.

@Myoldmopar
Copy link
Member

So far so good. I'm going to go ahead and let Decent catch up, but I suspect I'll merge this either tonight or tomorrow morning. Thanks @jmythms !

@Myoldmopar
Copy link
Member

Well, unfortunately develop moved again. Those diffs are unrelated. I can run regressions locally on this branch to get a good set of results.

@Myoldmopar
Copy link
Member

I just built and ran the full test suite on my machine and got zero diffs. This is good to go. Thanks @jmythms

@Myoldmopar Myoldmopar merged commit f11d103 into develop Jul 17, 2021
@Myoldmopar Myoldmopar deleted the enumsPsychrometrics branch July 17, 2021 03:07
@jmythms
Copy link
Contributor Author

jmythms commented Jul 17, 2021

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants