-
Notifications
You must be signed in to change notification settings - Fork 394
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
Enum Refactor: DataZoneEquipment #9163
Conversation
src/EnergyPlus/BaseboardElectric.cc
Outdated
@@ -338,7 +337,8 @@ namespace BaseboardElectric { | |||
|
|||
for (CtrlZone = 1; CtrlZone <= state.dataGlobal->NumOfZones; ++CtrlZone) { | |||
for (ZoneEquipTypeNum = 1; ZoneEquipTypeNum <= state.dataZoneEquip->ZoneEquipList(CtrlZone).NumOfEquipTypes; ++ZoneEquipTypeNum) { | |||
if (state.dataZoneEquip->ZoneEquipList(CtrlZone).EquipType_Num(ZoneEquipTypeNum) == BBElectricConvective_Num && | |||
if (state.dataZoneEquip->ZoneEquipList(CtrlZone).EquipType_Num(ZoneEquipTypeNum) == |
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 know this is pedantic, but we should call things Type
rather than TypeNum
. Not so critical here, more important for member names.
constexpr int ZoneMixer_Type(3); | ||
constexpr int ZoneReturnPlenum_Type(4); | ||
enum class CompType | ||
{ |
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.
Not sure CompType
is a good name for this enum
. Also, need to add Num
to the ends of these.
enum ZoneEquip | ||
{ | ||
Unassigned = -1, | ||
FanCoil4Pipe = 1, |
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.
Why is this not 0? Is it because there are Array1D
that use these as indices? That should be a sign to switch those to std::array
. Can do this in a subsequent PR I guess.
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.
@dareumnam any comment on 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.
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.
Per my comment above, arrays indexed by enum
should be turned into std::array
. Per same comment, no need to hold up this PR for that single change.
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.
👍
src/EnergyPlus/DataZoneEquipment.hh
Outdated
RefrigerationAirChillerSet, | ||
UserDefinedZoneHVACForcedAir, | ||
CoolingPanel, | ||
ZoneUnitarySys |
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.
Add Num
.
Unassgined = -1, | ||
DCVByCurrentLevel, | ||
ByDesignLevel | ||
}; |
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.
Add Num
.
src/EnergyPlus/DataZoneEquipment.hh
Outdated
@@ -358,7 +374,7 @@ namespace DataZoneEquipment { | |||
int NumAvailHeatEquip; // Number of pieces of equipment available for heating | |||
int NumAvailCoolEquip; // Number of pieces of equipment available for cooling | |||
Array1D_string EquipType; | |||
Array1D_int EquipType_Num; | |||
Array1D<DataZoneEquipment::ZoneEquip> EquipType_Num; |
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.
No _Num
. I understand that there is already an array called EquipType
which is an array of strings, but that array should not be necessary. You should convert things from string to enum
as we parse the IDF and only use enum
internally. If you want, you can put a pin in these comments and do them in a separate PR.
src/EnergyPlus/DataZoneEquipment.hh
Outdated
@@ -407,7 +423,7 @@ namespace DataZoneEquipment { | |||
int NumOfComponents; | |||
int InletNodeNum; | |||
Array1D_string ComponentType; | |||
Array1D_int ComponentType_Num; | |||
Array1D<DataZoneEquipment::CompType> ComponentType_Num; |
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.
Same comment as above.
src/EnergyPlus/DataZoneEquipment.hh
Outdated
@@ -431,7 +447,7 @@ namespace DataZoneEquipment { | |||
int NumOfComponents; | |||
int OutletNodeNum; | |||
Array1D_string ComponentType; | |||
Array1D_int ComponentType_Num; | |||
Array1D<DataZoneEquipment::CompType> ComponentType_Num; |
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.
Same comment.
@@ -712,7 +712,7 @@ namespace FanCoilUnits { | |||
state.dataFanCoilUnits->ATMixerOutNode, | |||
FanCoil(FanCoilNum).AirOutNode); | |||
FanCoil(FanCoilNum).ControlZoneNum = | |||
DataZoneEquipment::GetZoneEquipControlledZoneNum(state, DataZoneEquipment::FanCoil4Pipe_Num, FanCoil(FanCoilNum).Name); | |||
DataZoneEquipment::GetZoneEquipControlledZoneNum(state, DataZoneEquipment::ZoneEquip::FanCoil4Pipe, FanCoil(FanCoilNum).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.
Probably not something you want to handle in this PR, but ... why are we doing this lookup by FanCoil name if we already know FanCoil index?
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.
ZoneEquipConfig stores the component type and name so to look up the correct component needed the type and name (back then). Now that code is progressing a new method might be used.
@@ -516,107 +516,107 @@ void GetZoneEquipmentData(EnergyPlusData &state) | |||
auto const SELECT_CASE_var(UtilityRoutines::MakeUPPERCase(thisZoneEquipList.EquipType(ZoneEquipTypeNum))); | |||
|
|||
if (SELECT_CASE_var == "ZONEHVAC:AIRDISTRIBUTIONUNIT") { |
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.
This code should be converted to a getEnumerationValue
.
@@ -191,9 +188,9 @@ namespace ReturnAirPathManager { | |||
ErrorsFound = true; | |||
} | |||
if (UtilityRoutines::SameString(state.dataIPShortCut->cAlphaArgs(Counter), "AirLoopHVAC:ZoneMixer")) | |||
state.dataZoneEquip->ReturnAirPath(PathNum).ComponentType_Num(CompNum) = ZoneMixer_Type; | |||
state.dataZoneEquip->ReturnAirPath(PathNum).ComponentType_Num(CompNum) = DataZoneEquipment::CompType::ZoneMixer; |
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.
getEnumerationValue
.
src/EnergyPlus/SystemReports.cc
Outdated
@@ -4539,7 +4539,7 @@ void ReportMaxVentilationLoads(EnergyPlusData &state) | |||
.EquipType_Num(thisZoneEquipNum)); | |||
// case statement to cover all possible zone forced air units that could have outside air | |||
|
|||
if (SELECT_CASE_var == WindowAC_Num) { // Window Air Conditioner | |||
if (SELECT_CASE_var == DataZoneEquipment::ZoneEquip::WindowAC) { // Window Air Conditioner |
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.
This should be a switch
/case
.
@@ -3065,7 +3065,7 @@ void SimZoneEquipment(EnergyPlusData &state, bool const FirstHVACIteration, bool | |||
{ | |||
auto const SELECT_CASE_var(state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).ComponentType_Num(CompNum)); | |||
|
|||
if (SELECT_CASE_var == ZoneSplitter_Type) { // 'AirLoopHVAC:ZoneSplitter' | |||
if (SELECT_CASE_var == DataZoneEquipment::CompType::ZoneSplitter) { // 'AirLoopHVAC:ZoneSplitter' |
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.
switch
/case
.
Looks like comments have been addressed here, but speak up if there is anything still waiting. I pulled develop into this locally and re-ran regressions. Everything passes beautifully. If no one has an issue, I'll merge this this afternoon. |
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.
Everything looks OK to me. There appears to be one unanswered question which I noted in my comments, but even that is something for later. I think this is good to go.
@@ -12325,9 +12325,6 @@ namespace AirflowNetworkBalanceManager { | |||
// PURPOSE OF THIS SUBROUTINE: | |||
// This subroutine validate zone exhaust fan and associated surface | |||
|
|||
// Using/Aliasing | |||
using DataZoneEquipment::ZoneExhaustFan_Num; |
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.
A simple but nice change.
case PurchasedAir_Num: | ||
switch (state.dataZoneEquip->ZoneEquipList(state.dataZoneEquip->ZoneEquipConfig(ZoneNum).EquipListIndex).EquipTypeEnum(EquipNum)) { | ||
case DataZoneEquipment::ZoneEquip::AirDistUnit: | ||
case DataZoneEquipment::ZoneEquip::PurchasedAir: |
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.
This reads so much nicer.
Intermediate, | ||
Outlet, | ||
NUM | ||
}; |
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.
Awesome.
enum ZoneEquip | ||
{ | ||
Unassigned = -1, | ||
FanCoil4Pipe = 1, |
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.
@dareumnam any comment on this?
@Myoldmopar Thanks for your review. I keep addressing comments on my local branch, but it is okay if this gets merged in first. I can open a separate PR. |
Alright, pulled develop in just for fun after the version change and it's still passing fine. @dareumnam just make sure to address the last little pieces here on your next PR. Thanks! Merging! |
Enum Refactor: DataZoneEquipment
Pull request overview
Remove
constexpr int
s in DataZoneEquipment objectNOTE: 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.