-
Notifications
You must be signed in to change notification settings - Fork 444
Fix #10933 - Unable to read Site:GroundDomain:Slab with Site:GroundTemperature:Undisturbed:FiniteDifference #10934
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
Conversation
``` [ RUN ] EnergyPlusFixture.SiteGroundDomainSlab_FiniteDifference /home/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/PlantPipingSystemsManager.unit.cc:2320: Failure Expected: ReadZoneCoupledDomainInputs(*state, 1, 1, errorsFound) doesn't throw an exception. Actual: it throws EnergyPlus::FatalError with description "Site:GroundTemperature:Undisturbed:FiniteDifference--Errors getting input for ground temperature model". /home/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc:211: Failure Expected equality of these values: expected_string Which is: "" stream_str Which is: " ** Fatal ** Site:GroundTemperature:Undisturbed:FiniteDifference--Errors getting input for ground temperature model\n ...Summary of Errors that led to program termination:\n ..... Reference severe error count=0\n ..... Last severe error=\n" With diff: @@ -1,1 +1,4 @@ -"" + ** Fatal ** Site:GroundTemperature:Undisturbed:FiniteDifference--Errors getting input for ground temperature model + ...Summary of Errors that led to program termination: + ..... Reference severe error count=0 + ..... Last severe error=\n /home/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/PlantPipingSystemsManager.unit.cc:2323: Failure Value of: compare_err_stream("") Actual: false Expected: true [ FAILED ] EnergyPlusFixture.SiteGroundDomainSlab_FiniteDifference (931 ms) ```
state->dataPlantPipingSysMgr->domains.resize(1); | ||
EXPECT_NO_THROW(ReadZoneCoupledDomainInputs(*state, 1, 1, errorsFound)); | ||
|
||
EXPECT_FALSE(errorsFound); | ||
EXPECT_TRUE(compare_err_stream("")); |
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.
Unit test. Would fail with a bad error messsage
[ RUN ] EnergyPlusFixture.SiteGroundDomainSlab_FiniteDifference
/home/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/PlantPipingSystemsManager.unit.cc:2320: Failure
Expected: ReadZoneCoupledDomainInputs(*state, 1, 1, errorsFound) doesn't throw an exception.
Actual: it throws EnergyPlus::FatalError with description "Site:GroundTemperature:Undisturbed:FiniteDifference--Errors getting input for ground temperature model".
/home/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/Fixtures/EnergyPlusFixture.cc:211: Failure
Expected equality of these values:
expected_string
Which is: ""
stream_str
Which is: " ** Fatal ** Site:GroundTemperature:Undisturbed:FiniteDifference--Errors getting input for ground temperature model\n ...Summary of Errors that led to program termination:\n ..... Reference severe error count=0\n ..... Last severe error=\n"
With diff:
@@ -1,1 +1,4 @@
-""
+ ** Fatal ** Site:GroundTemperature:Undisturbed:FiniteDifference--Errors getting input for ground temperature model
+ ...Summary of Errors that led to program termination:
+ ..... Reference severe error count=0
+ ..... Last severe error=\n
/home/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/PlantPipingSystemsManager.unit.cc:2323: Failure
Value of: compare_err_stream("")
Actual: false
Expected: true
[ FAILED ] EnergyPlusFixture.SiteGroundDomainSlab_FiniteDifference (931 ms)
this comparison couldn't work because objectName was poiting to dataIPShortcuts->cAlphaArgs(3) and that just got reassigned by getObjectItem
EnergyPlus/src/EnergyPlus/GroundTemperatureModeling/FiniteDifferenceGroundTemperatureModel.cc
Line 108 in a339be9
if (objectName == state.dataIPShortCut->cAlphaArgs(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.
👍
// Ok, this is a finicky bug, but I have to make a copy here. GetGroundTempModelAndInit takes name (last param) by const ref& | ||
// It then calls FiniteDiffGroundTempsModel::FiniteDiffGTMFactory which also takes objectName by const ref& | ||
// But it calls getObjectItem with s_ipsc->cAlphaArgs which overrides it, then the comparison fails | ||
std::string const groundTempModelName = s_ipsc->cAlphaArgs(3); | ||
thisDomain.groundTempModel = GroundTemp::GetGroundTempModelAndInit(state, gtmType, groundTempModelName); |
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.
The fix is here. Take a copy.
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.
Yep, these DataIPShortCuts arrays can definitely be abused. They were incredibly valuable in Fortran when we had to pre-size array arguments to pass to functions. With vectors, it's just unnecessary. Probably time to deprecate that stuff and just use local variables.
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.
Should we open an issue for this? I haven't looked if there's one (on a mobile device right now)
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 is a great little fix. These can certainly be tough to debug too, when the value suddenly changes. Spooky :)
// Ok, this is a finicky bug, but I have to make a copy here. GetGroundTempModelAndInit takes name (last param) by const ref& | ||
// It then calls FiniteDiffGroundTempsModel::FiniteDiffGTMFactory which also takes objectName by const ref& | ||
// But it calls getObjectItem with s_ipsc->cAlphaArgs which overrides it, then the comparison fails | ||
std::string const groundTempModelName = s_ipsc->cAlphaArgs(3); | ||
thisDomain.groundTempModel = GroundTemp::GetGroundTempModelAndInit(state, gtmType, groundTempModelName); |
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.
Yep, these DataIPShortCuts arrays can definitely be abused. They were incredibly valuable in Fortran when we had to pre-size array arguments to pass to functions. With vectors, it's just unnecessary. Probably time to deprecate that stuff and just use local variables.
state->dataPlantPipingSysMgr->domains.resize(1); | ||
EXPECT_NO_THROW(ReadZoneCoupledDomainInputs(*state, 1, 1, errorsFound)); | ||
|
||
EXPECT_FALSE(errorsFound); | ||
EXPECT_TRUE(compare_err_stream("")); |
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.
👍
All happy here, let's get this merged. Thanks @jmarrec |
Pull request overview
Description of the purpose of this PR
Unable to read Site:GroundDomain:Slab with Site:GroundTemperature:Undisturbed:FiniteDifference
Opening this PR, I just noticed @Myoldmopar seem to have caught a similar bug in KusudaAchenbach 3 months ago: 1980d22#diff-f58e3210edb785bf9d28bcc7801f467c941feb911b1981fdf562abd401bb8285R81
(I had intended to fix #10807 but after hours of sleuthing I found the root cause but don't understand how to fix it:
)
Pull Request Author
Reviewer