Skip to content

Commit

Permalink
Eliminate repeated allocation of return nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Myoldmopar committed Jan 23, 2019
1 parent f0a4a37 commit 0ac3fd3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/EnergyPlus/ZoneEquipmentManager.cc
Expand Up @@ -4943,14 +4943,24 @@ namespace ZoneEquipmentManager {
Real64 &FinalTotalReturnMassFlow // Final total return air mass flow rate
)
{
static Array1D_bool fixedReturn;
static bool AllocateFlag = true;
if (AllocateFlag) {
AllocateFlag = false;
int maxReturnNodes = 0;
for (auto & z : ZoneEquipConfig) {
maxReturnNodes = max(maxReturnNodes, z.NumReturnNodes);
}
fixedReturn.allocate(maxReturnNodes);
}
auto &thisZoneEquip(ZoneEquipConfig(ZoneNum));
int numRetNodes = thisZoneEquip.NumReturnNodes;
Real64 totReturnFlow = 0.0; // Total flow to all return nodes in the zone (kg/s)
Real64 totVarReturnFlow =
0.0; // Total variable return flow, for return nodes connected to an airloop with an OA system or not with specified flow (kg/s)
Real64 returnSchedFrac = ScheduleManager::GetCurrentScheduleValue(thisZoneEquip.ReturnFlowSchedPtrNum);
Array1D_bool fixedReturn; // If true, this return flow may not be adjusted
fixedReturn.allocate(numRetNodes);
// Array1D_bool fixedReturn; // If true, this return flow may not be adjusted
// fixedReturn.allocate(numRetNodes);
fixedReturn = false;
FinalTotalReturnMassFlow = 0.0;

Expand Down

4 comments on commit 0ac3fd3

@nmerket
Copy link
Member

@nmerket nmerket commented on 0ac3fd3 Feb 7, 2019

Choose a reason for hiding this comment

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

@Myoldmopar this breaks unit tests because these aren't deallocated in a clear_state call.

@mjwitte
Copy link
Contributor

@mjwitte mjwitte commented on 0ac3fd3 Feb 7, 2019

Choose a reason for hiding this comment

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

@Myoldmopar The AllocateFlag needs to be bumped up to the module level and added to clear_state. Or would it be better to just move fixedReturn into ZoneEquipConfig ? If you want to revert this, I can do that over in #7059

@Myoldmopar
Copy link
Member Author

Choose a reason for hiding this comment

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

Either way is OK with me. Moving it up to the module level might be one step easier, but if you are inclined to add that to the zone equipment struct that's really great. I was about to just hot fix this but I'll step away and let you to add in #7059. Thanks @mjwitte ! And thanks for diagnosing this detective @nmerket !

@mjwitte
Copy link
Contributor

@mjwitte mjwitte commented on 0ac3fd3 Feb 7, 2019

Choose a reason for hiding this comment

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

Actually, maybe you should hotfix it for now, 'cause the other may be a few days before it gets in. Sorry to flipflop.

Please sign in to comment.