Skip to content

Commit

Permalink
Merge pull request #8937 from NREL/8919ConductionFDCrashUnusedConstru…
Browse files Browse the repository at this point in the history
…ction

Fixed Crash in CondFD for Interzone Surfaces for Very Specific Condition
  • Loading branch information
Myoldmopar authored Aug 21, 2021
2 parents 55404d8 + ebc15a5 commit 7931e6d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/EnergyPlus/DataHeatBalance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ int AssignReverseConstructionNumber(EnergyPlusData &state,
}
if (Found) {
NewConstrNum = Loop;
state.dataConstruction->Construct(Loop).IsUsed = true;
break;
}
}
Expand Down
47 changes: 47 additions & 0 deletions tst/EnergyPlus/unit/DataHeatBalance.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -991,3 +991,50 @@ TEST_F(EnergyPlusFixture, DataHeatBalance_setNodeSourceAndUserTemp)
EXPECT_EQ(expectedNodeNumberAtSource, thisConstruct.NodeSource);
EXPECT_EQ(expectedNodeNumberAtUserSpecifiedLocation, thisConstruct.NodeUserTemp);
}

TEST_F(EnergyPlusFixture, DataHeatBalance_AssignReverseConstructionNumberTest)
{
int ConstrNum;
int expectedResultRevConstrNum;
int functionResultRevConstrNum;
bool ErrorsFound = false;

state->dataHeatBal->TotConstructs = 2;
state->dataConstruction->Construct.allocate(state->dataHeatBal->TotConstructs);
state->dataConstruction->LayerPoint.allocate(Construction::MaxLayersInConstruct);

auto &thisConstruct(state->dataConstruction->Construct(1));
auto &otherConstruct(state->dataConstruction->Construct(2));

// Test: For an interzone surface that uses the zone as the other side, a new
// interzone surface for that zone has to be created. That interzone has
// to have the reversed construction. If that reversed construction is
// not used for any defined surface, the variable IsUsed is false. However,
// since it now is being used, IsUsed has to be set to true. Prior to
// work on Defect #8919, when using CondFD and a zone other side condition
// for an interzone surface (implied or E+ internally created other side)
// for a construction that was reversed in the input file but not used
// for other defined surfaces, IsUsed was set to false and this construction
// was then skipped in the CondFD routine that calculates the number of
// nodes. This led to a hard crash. This test simply makes sure that
// IsUsed is set to true when the reversed construction already exists.
ConstrNum = 1;
thisConstruct.IsUsed = true;
thisConstruct.TotLayers = 2;
thisConstruct.LayerPoint.allocate(Construction::MaxLayersInConstruct);
thisConstruct.LayerPoint = 0;
thisConstruct.LayerPoint(1) = 10;
thisConstruct.LayerPoint(2) = 12;
otherConstruct.IsUsed = false;
otherConstruct.TotLayers = 2;
otherConstruct.LayerPoint.allocate(Construction::MaxLayersInConstruct);
otherConstruct.LayerPoint = 0;
otherConstruct.LayerPoint(1) = 12;
otherConstruct.LayerPoint(2) = 10;
expectedResultRevConstrNum = 2;

functionResultRevConstrNum = AssignReverseConstructionNumber(*state, ConstrNum, ErrorsFound);
EXPECT_EQ(expectedResultRevConstrNum, functionResultRevConstrNum);
EXPECT_TRUE(otherConstruct.IsUsed);
EXPECT_FALSE(ErrorsFound);
}

5 comments on commit 7931e6d

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

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

develop (Myoldmopar) - x86_64-MacOS-10.15-clang-11.0.0: OK (2402 of 2402 tests passed, 0 test warnings)

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.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-18.04-gcc-7.5: OK (2423 of 2423 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.

develop (Myoldmopar) - Win64-Windows-10-VisualStudio-16: OK (2381 of 2381 tests passed, 0 test warnings)

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.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-UnitTestsCoverage-Debug: OK (1674 of 1674 tests passed, 0 test warnings)

Build Badge Test Badge Coverage 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.

develop (Myoldmopar) - x86_64-Linux-Ubuntu-18.04-gcc-7.5-IntegrationCoverage-Debug: OK (731 of 731 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.