Skip to content

Commit

Permalink
Fix assert/memory issue
Browse files Browse the repository at this point in the history
  • Loading branch information
amirroth committed Jun 25, 2023
1 parent bf386e5 commit d57668f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/EnergyPlus/DataRoomAirModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ namespace RoomAir {
Real64 Texhaust = 0.0; // temperature for exhaust air node
int totNumSurfs = 0; // total surfs for this zone
int firstSurfID = 0; // Index of first surface
int RAFNNum = 0; // RAFN number
int roomAFNNodeNum = 0; // RAFN number
};

struct BegEnd {
Expand Down
45 changes: 14 additions & 31 deletions src/EnergyPlus/RoomAirModelAirflowNetwork.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,28 +131,26 @@ namespace RoomAir {
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:

auto &afnZoneInfo = state.dataRoomAir->AFNZoneInfo(ZoneNum);
int RAFNNum = afnZoneInfo.RAFNNum;

if (RAFNNum == 0) {
// At this point, this should probably be an assert, not a ShowFatalError. This should have been trapped already.
if (afnZoneInfo.roomAFNNodeNum == 0) {
ShowFatalError(state,
format("SimRoomAirModelAirflowNetwork: Zone is not defined in the RoomAirModelAirflowNetwork model ={}",
state.dataHeatBal->Zone(ZoneNum).Name));
}

auto &thisRAFN(state.dataRoomAirflowNetModel->RAFN(RAFNNum));
thisRAFN.ZoneNum = ZoneNum;
auto &roomAFNNode = state.dataRoomAirflowNetModel->RAFN(afnZoneInfo.roomAFNNodeNum);
roomAFNNode.ZoneNum = ZoneNum;

// model control volume for each roomAir:node in the zone.
for (int ThisRoomAirNode = 1; ThisRoomAirNode <= afnZoneInfo.NumOfAirNodes; ++ThisRoomAirNode) {
for (int roomAirNode = 1; roomAirNode <= afnZoneInfo.NumOfAirNodes; ++roomAirNode) {

thisRAFN.RoomAirNode = ThisRoomAirNode;

thisRAFN.InitRoomAirModelAirflowNetwork(state, ThisRoomAirNode);

thisRAFN.CalcRoomAirModelAirflowNetwork(state, ThisRoomAirNode);
roomAFNNode.RoomAirNode = roomAirNode;
roomAFNNode.InitRoomAirModelAirflowNetwork(state, roomAirNode);
roomAFNNode.CalcRoomAirModelAirflowNetwork(state, roomAirNode);
}

thisRAFN.UpdateRoomAirModelAirflowNetwork(state);
roomAFNNode.UpdateRoomAirModelAirflowNetwork(state);

} // SimRoomAirModelAirflowNetwork

Expand All @@ -166,22 +164,10 @@ namespace RoomAir {
// SUBROUTINE INFORMATION:
// AUTHOR Lixing Gu
// DATE WRITTEN June, 2015
// MODIFIED na
// RE-ENGINEERED na

// PURPOSE OF THIS SUBROUTINE:
// Predict zone loads at a controlled node

// METHODOLOGY EMPLOYED:
// na

// REFERENCES:
// na

// USE STATEMENTS:
// na

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
//////////// hoisted into namespace ////////////////////////////////////////////////
// static bool OneTimeFlag_FindFirstLastPtr( true ); // one time setup flag //
// state.dataRoomAirflowNetModel->LoadPredictionRoomAirModelAirflowNetworkOneTimeFlag
Expand All @@ -192,17 +178,15 @@ namespace RoomAir {
}

auto &afnZoneInfo = state.dataRoomAir->AFNZoneInfo(ZoneNum);
int RAFNNum = afnZoneInfo.RAFNNum;

if (RAFNNum == 0) {
if (afnZoneInfo.roomAFNNodeNum == 0) { // Again?
ShowFatalError(state,
format("LoadPredictionRoomAirModelAirflowNetwork: Zone is not defined in the RoomAirModelAirflowNetwork model ={}",
state.dataHeatBal->Zone(ZoneNum).Name));
}
auto &thisRAFN(state.dataRoomAirflowNetModel->RAFN(RAFNNum));
thisRAFN.ZoneNum = ZoneNum;

thisRAFN.InitRoomAirModelAirflowNetwork(state, RoomAirNode);
auto &roomAFNNode = state.dataRoomAirflowNetModel->RAFN(afnZoneInfo.roomAFNNodeNum);
roomAFNNode.ZoneNum = ZoneNum;
roomAFNNode.InitRoomAirModelAirflowNetwork(state, RoomAirNode);

} // LoadPredictionRoomAirModelAirflowNetwork

Expand All @@ -215,7 +199,6 @@ namespace RoomAir {
// AUTHOR B. Griffith
// DATE WRITTEN November 2009
// MODIFIED Lixing Gu, Aug. 2015 for v8.4 release
// RE-ENGINEERED na

// PURPOSE OF THIS SUBROUTINE:
// Perform one-time checking and term calculations
Expand Down Expand Up @@ -259,7 +242,7 @@ namespace RoomAir {
if (state.dataRoomAirflowNetModel->InitRoomAirModelAirflowNetworkOneTimeFlag) { // then do one - time setup inits

// loop over all zones with RoomAirflowNetwork model
for (LoopZone = 1; LoopZone <= state.dataGlobal->NumOfZones; ++LoopZone) {
for (int LoopZone = 1; LoopZone <= state.dataGlobal->NumOfZones; ++LoopZone) {
if (!state.dataRoomAir->AFNZoneInfo(LoopZone).IsUsed) continue;
int NumSurfs = 0;
for (int spaceNum : state.dataHeatBal->Zone(ZoneNum).spaceIndexes) {
Expand Down
6 changes: 3 additions & 3 deletions src/EnergyPlus/RoomAirModelManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ namespace RoomAir {

auto &roomAFNZoneInfo = state.dataRoomAir->AFNZoneInfo(ZoneNum);
roomAFNZoneInfo.ZoneID = ZoneNum;
roomAFNZoneInfo.RAFNNum = Loop;
roomAFNZoneInfo.roomAFNNodeNum = Loop;
roomAFNZoneInfo.IsUsed = true;
roomAFNZoneInfo.Name = ipsc->cAlphaArgs(1);
roomAFNZoneInfo.ZoneName = ipsc->cAlphaArgs(2); // Zone Name
Expand Down Expand Up @@ -2120,10 +2120,10 @@ namespace RoomAir {
state.dataRoomAir->MATFloor = 23.0;
state.dataRoomAir->XMATFloor = {23.0, 23.0, 23.0, 23.0};
state.dataRoomAir->DSXMATFloor = {23.0, 23.0, 23.0, 23.0};
state.dataRoomAir->MATOC = {23.0, 23.0, 23.0, 23.0};
state.dataRoomAir->MATOC = 23.0;
state.dataRoomAir->XMATOC = {23.0, 23.0, 23.0, 23.0};
state.dataRoomAir->DSXMATOC = {23.0, 23.0, 23.0, 23.0};
state.dataRoomAir->MATMX = {23.0, 23.0, 23.0, 23.0};
state.dataRoomAir->MATMX = 23.0;
state.dataRoomAir->XMATMX = {23.0, 23.0, 23.0, 23.0};
state.dataRoomAir->DSXMATMX = {23.0, 23.0, 23.0, 23.0};
state.dataRoomAir->ZTMFloor = {23.0, 23.0, 23.0};
Expand Down

4 comments on commit d57668f

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

HVACGlobals1 (amirroth) - x86_64-Linux-Ubuntu-22.04-gcc-11.3: OK (3477 of 3477 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

HVACGlobals1 (amirroth) - Win64-Windows-10-VisualStudio-16: OK (2658 of 2663 tests passed, 0 test warnings)

Failures:\n

integration Test Summary

  • Passed: 770
  • Failed: 5

Build Badge Test Badge

@nrel-bot-2c
Copy link

Choose a reason for hiding this comment

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

HVACGlobals1 (amirroth) - x86_64-Linux-Ubuntu-22.04-gcc-11.3-UnitTestsCoverage-Debug: OK (1890 of 1890 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

HVACGlobals1 (amirroth) - x86_64-Linux-Ubuntu-22.04-gcc-11.3-IntegrationCoverage-Debug: OK (776 of 776 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.