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

Remove select_case_vars & enum class cleanup #9385

Merged
merged 9 commits into from
Apr 19, 2022
Merged

Conversation

dareumnam
Copy link
Collaborator

Pull request overview

  • Remove select_case_vars in
    • Autosizing\CoolingAirFlowSizing
    • Autosizing\HeatingAirFlowSizing.cc
    • Autosizing\HeatingCapacitySizing.cc
    • DataHeatBalance.cc
    • Datasizing.cc
    • DesiccantDehumidifiers.cc
    • DXCoils.cc
    • FanCoilUnits.cc
    • Furnaces.cc
    • HeatBalanceSurfaceManager.cc
    • HeatingCoils.cc
    • Humidifiers.cc
  • enum class cleanup

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

@dareumnam dareumnam added the Refactoring Includes code changes that don't change the functionality of the program, just perform refactoring label Apr 14, 2022
@dareumnam dareumnam added this to the EnergyPlus 22.2 milestone Apr 14, 2022
@dareumnam dareumnam self-assigned this Apr 14, 2022
auto const SELECT_CASE_var(this->zoneEqSizing(this->curZoneEqNum).SizingMethod(DataHVACGlobals::CoolingAirflowSizing));
if ((SELECT_CASE_var == DataSizing::SupplyAirFlowRate) || (SELECT_CASE_var == DataSizing::None) ||
(SELECT_CASE_var == DataSizing::FlowPerFloorArea)) {
switch (this->zoneEqSizing(this->curZoneEqNum).SizingMethod(DataHVACGlobals::CoolingAirflowSizing)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not going to harp on this because I want this stuff merged, but this is a good candidate for
auto & thisZoneEqSizing = this->zoneEqSizing(this->curZoneEqNum); etc.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, given what we are seeing in the debug builds and the desire to move to EPVector I will be harping on this more. 😁

auto const SELECT_CASE_var(this->curDuctType);
if (SELECT_CASE_var == DataHVACGlobals::Main) {
switch (this->curDuctType) {
case DataHVACGlobals::Main: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Main, Other, and default are all the same case. Can be combined.

}
}
} else {
switch (this->curDuctType) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

And also here.

state, DXCoilNum, CompressorOperation::On, FirstHVACIteration, PartLoadRatio, FanOpMode, CompCycRatio, _, AirFlowRatio, MaxCap);
} break;
case CoilVRF_Heating: {
CalcDXHeatingCoil(state, DXCoilNum, PartLoadRatio, FanOpMode, AirFlowRatio, MaxCap);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be VRF?

Copy link
Contributor

Choose a reason for hiding this comment

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

The VRF heating coil model re-uses the old DX heating coil calc routine. The VRF cooling coil has a few different equations so that coil type has it's own calc routine although we could probably incorporate new routine equations into the old if needed.


} break;
default: {
ShowSevereError(state, "Error detected in DX Coil=" + std::string{CompName});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mmmmm ... could this be an assert? Wouldn't getInput have caught this?

state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType + " \"" + state.dataDXCoils->DXCoil(DXCoilNum).Name +
"\" - Requested enhanced dehumidification mode not available.");
}
if (state.dataDXCoils->DXCoil(DXCoilNum).DXCoilType_Num == CoilDX_CoolingTwoStageWHumControl) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

auto & dxCoil = state.dataDXCoils->DXCoils(DXCoilNum);

default: {
if (state.dataSurface->Surface(numSurf).ExtBoundCond > 0) { // interzone partition
// use companion surface in adjacent zone
switch (state.dataSurface->Surface(state.dataSurface->Surface(numSurf).ExtBoundCond).Class) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can probably make this into a lookup std::array.

Par[1] = 1.0;
} else {
Par[1] = 0.0;
switch (DesicDehum(DesicDehumNum).RegenCoilType_Num) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

auto & desicDehum = state.dataDesicDehum->DesicDehum(DesicDehumNum); is a much more useful shortcut than auto & DesicDehum = state.dataDesicDehum->DesicDehum;. In general, don't have shortcut references to arrays, use them for individual elements.

Par[1] = 0.0;
}
Par[2] = RegenCoilLoad;
General::SolveRoot(
Copy link
Collaborator

Choose a reason for hiding this comment

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

📌 Replace this templated function with actual lambdas. There is an issue about this.

} else if (SELECT_CASE_var == Coil_HeatingDesuperheater) {
coilObjClassName = "Coil:Heating:Desuperheater";
}
switch (state.dataHeatingCoils->HeatingCoil(CoilNum).HCoilType_Num) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

📌 Should be able to get these from the constexpr std::array<std::string_view> once these are converted to enum class.

SPE = 1, // Specific people object
OBJ = 2, // People object average
PEO = 3, // People number average
NO, // No multiple people objects
Copy link
Collaborator

Choose a reason for hiding this comment

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

These names!

@Myoldmopar
Copy link
Member

Tested this with develop too and everything is good. There are a few comments here from @amirroth that should be kept for the next round so that this can merge in. Is that OK @amirroth or should we address more things in this branch?

@dareumnam
Copy link
Collaborator Author

@Myoldmopar @amirroth I'll make a separate follow-up branch to pick up all comments here.

@Myoldmopar
Copy link
Member

Sounds like a plan to me @dareumnam, let's get this merged in, thanks!

@Myoldmopar Myoldmopar merged commit c2a7f60 into develop Apr 19, 2022
@Myoldmopar Myoldmopar deleted the enumclasses branch April 19, 2022 19:24
state, state.dataOutRptPredefined->pdchHeatCoilNomCap, HeatingCoil(CoilNum).Name, HeatingCoil(CoilNum).NominalCapacity);
PreDefTableEntry(state, state.dataOutRptPredefined->pdchHeatCoilNomEff, HeatingCoil(CoilNum).Name, HeatingCoil(CoilNum).Efficiency);
}
switch (HeatingCoil(CoilNum).HCoilType_Num) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

auto & heatingCoil = state.dataHeatingCoils->HeatingCoil(CoilNum);

} else if (SELECT_CASE_var == "NO") {
state.dataUserDefinedComponents->UserCoil(CompLoop).PlantIsConnected = false;
}
if (cAlphaArgs(8) == "YES") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

📌 There should probably be a function for this like bool getBoolValue(std::string_view str).

@amirroth
Copy link
Collaborator

Tested this with develop too and everything is good. There are a few comments here from @amirroth that should be kept for the next round so that this can merge in. Is that OK @amirroth or should we address more things in this branch?

Please don't hold this up.

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