-
Notifications
You must be signed in to change notification settings - Fork 392
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
Round2 init state use #10662
base: develop
Are you sure you want to change the base?
Round2 init state use #10662
Changes from all commits
f6e0e8a
758b5e1
4dbd4c4
5aefd65
167a8bb
339fe3b
f7ba56c
5774851
85a2ef2
de455d7
0dafbab
730845a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,15 +61,13 @@ | |
|
||
// EnergyPlus Headers | ||
#include <EnergyPlus/CurveManager.hh> | ||
#include <EnergyPlus/Data/EnergyPlusData.hh> | ||
#include <EnergyPlus/DataBranchAirLoopPlant.hh> | ||
#include <EnergyPlus/DataIPShortCuts.hh> | ||
#include <EnergyPlus/DataLoopNode.hh> | ||
#include <EnergyPlus/DataSystemVariables.hh> | ||
#include <EnergyPlus/EMSManager.hh> | ||
#include <EnergyPlus/FileSystem.hh> | ||
#include <EnergyPlus/GlobalNames.hh> | ||
#include <EnergyPlus/InputProcessing/InputProcessor.hh> | ||
#include <EnergyPlus/OutputProcessor.hh> | ||
#include <EnergyPlus/UtilityRoutines.hh> | ||
|
||
|
@@ -572,7 +570,6 @@ namespace Curve { | |
bool GetInputErrorsFound = false; | ||
|
||
GetCurveInputData(state, GetInputErrorsFound); | ||
state.dataCurveManager->GetCurvesInputFlag = false; | ||
|
||
if (GetInputErrorsFound) { | ||
ShowFatalError(state, "GetCurveInput: Errors found in getting Curve Objects. Preceding condition(s) cause termination."); | ||
|
@@ -611,6 +608,8 @@ namespace Curve { | |
int IOStatus; // Used in GetObjectItem | ||
std::string CurrentModuleObject; // for ease in renaming. | ||
|
||
if (!state.dataCurveManager->GetCurvesInputFlag) return; | ||
state.dataCurveManager->GetCurvesInputFlag = false; | ||
// Find the number of each type of curve (note: Current Module object not used here, must rename manually) | ||
|
||
int const NumBiQuad = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Curve:Biquadratic"); | ||
|
@@ -653,6 +652,7 @@ namespace Curve { | |
// initialize the array | ||
|
||
int CurveNum = 0; // keep track of the current curve index in the main curve array | ||
state.dataCurveManager->UniqueCurveNames.clear(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only change needed to allow curve manager getInput to be called more than once. It will likely not be called more than once but if it does it will give the same answer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably better to set a flag and make sure the body is not called twice. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, the outer getInput call does protect from the second call. If a unit test calls the root function multiple times it would need to give the same answer. I think I did this before removing init_state from the unit test fixture (last thing I did) so maybe I can fix this and not have to change any unit tests. I'll just move that flag down into GetCurveInputData.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a general practice in EnergyPlus of "protecting functions from bad inputs or bad calling contexts". This is actually counter-productive because it hides bad uses of the function. It's better programming to assert good inputs and good context (to the extent possible) within a function and then use those to progressively clean up the calling contexts. |
||
|
||
// Loop over biquadratic curves and load data | ||
CurrentModuleObject = "Curve:Biquadratic"; | ||
|
@@ -675,6 +675,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getObjectItem removes an object from the unusedInputs list just because it was read in. This change puts that curve back in the list and waits for a call to getCurveIndex before removing the curve from the unusedInputs list. This change was prompted by IndoorLivingWall not showing the unused curve warning in this branch. Now curves shown as unused are actually not used in the simulation (i.e., if I have 10 curves in the input and only use 1 then 9 curves are unused). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably change |
||
++CurveNum; | ||
|
||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
@@ -758,6 +759,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -824,6 +826,7 @@ namespace Curve { | |
_, | ||
state.dataIPShortCut->cAlphaFieldNames, | ||
state.dataIPShortCut->cNumericFieldNames); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
GlobalNames::VerifyUniqueInterObjectName(state, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't have to be part of this PR, but look at how I am using |
||
state.dataCurveManager->UniqueCurveNames, | ||
|
@@ -894,6 +897,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -958,6 +962,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -1022,6 +1027,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -1103,6 +1109,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -1184,6 +1191,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -1248,6 +1256,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -1329,6 +1338,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -1451,6 +1461,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -1530,6 +1541,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -1610,6 +1622,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -1663,6 +1676,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -1731,6 +1745,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -1797,6 +1812,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -1863,6 +1879,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -1929,6 +1946,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -1995,6 +2013,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -2061,6 +2080,7 @@ namespace Curve { | |
CurrentModuleObject, | ||
state.dataIPShortCut->cAlphaFieldNames(1), | ||
ErrorsFound); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
Curve *thisCurve = state.dataCurveManager->PerfCurve(CurveNum); | ||
|
||
|
@@ -2121,6 +2141,7 @@ namespace Curve { | |
state.dataIPShortCut->cAlphaFieldNames, | ||
state.dataIPShortCut->cNumericFieldNames); | ||
|
||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
std::string wpcName = Alphas(1); // Name of CP array | ||
int numWindDir = NumNumbers; | ||
std::vector<Real64> windDirs(numWindDir); | ||
|
@@ -2171,6 +2192,7 @@ namespace Curve { | |
_, | ||
state.dataIPShortCut->cAlphaFieldNames, | ||
state.dataIPShortCut->cNumericFieldNames); | ||
state.dataInputProcessing->inputProcessor->unusedInputs.emplace(CurrentModuleObject, Alphas(1)); | ||
++CurveNum; | ||
GlobalNames::VerifyUniqueInterObjectName(state, | ||
state.dataCurveManager->UniqueCurveNames, | ||
|
@@ -3071,7 +3093,10 @@ namespace Curve { | |
|
||
if (state.dataCurveManager->NumCurves > 0) { | ||
for (int Count = 1; Count <= (int)state.dataCurveManager->PerfCurve.size(); ++Count) { | ||
if (CurveName == state.dataCurveManager->PerfCurve(Count)->Name) return Count; | ||
if (CurveName == state.dataCurveManager->PerfCurve(Count)->Name) { | ||
state.dataCurveManager->PerfCurve(Count)->markUsed(state); | ||
return Count; | ||
} | ||
} | ||
return 0; // Not found | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,12 +65,14 @@ | |
|
||
// EnergyPlus Headers | ||
#include <EnergyPlus/Data/BaseData.hh> | ||
#include <EnergyPlus/Data/EnergyPlusData.hh> | ||
#include <EnergyPlus/DataBranchAirLoopPlant.hh> | ||
#include <EnergyPlus/DataGlobals.hh> | ||
#include <EnergyPlus/EPVector.hh> | ||
#include <EnergyPlus/EnergyPlus.hh> | ||
#include <EnergyPlus/EnergyPlusLogger.hh> | ||
#include <EnergyPlus/FileSystem.hh> | ||
#include <EnergyPlus/InputProcessing/InputProcessor.hh> | ||
#include <EnergyPlus/UtilityRoutines.hh> | ||
|
||
namespace EnergyPlus { | ||
|
@@ -150,7 +152,8 @@ namespace Curve { | |
struct Curve | ||
{ | ||
// Basic data | ||
std::string Name; // Curve Name | ||
std::string Name; // Curve Name | ||
bool used = true; | ||
CurveType curveType = CurveType::Invalid; // Curve type (see parameter definitions above) | ||
// Table data stuff | ||
InterpType interpolationType = InterpType::Invalid; // Table interpolation method | ||
|
@@ -207,6 +210,17 @@ namespace Curve { | |
const Real64 Var4, // 4th independent variable | ||
const Real64 Var5, // 5th independent variable | ||
const Real64 Var6); | ||
|
||
void markUsed(EnergyPlusData &state) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like this. Leave it for now but I'm going to look at how |
||
{ | ||
if (!this->used || this->curveType == CurveType::Invalid) return; | ||
auto const find_unused = | ||
state.dataInputProcessing->inputProcessor->unusedInputs.find({std::string(objectNames[int(this->curveType)]), this->Name}); | ||
if (find_unused != state.dataInputProcessing->inputProcessor->unusedInputs.end()) { | ||
state.dataInputProcessing->inputProcessor->unusedInputs.erase(find_unused); | ||
} | ||
this->used = false; | ||
}; | ||
}; | ||
|
||
// Table file objects | ||
|
@@ -469,8 +483,11 @@ struct CurveManagerData : BaseGlobalStruct | |
this->PerfCurve.push_back(new EnergyPlus::Curve::Curve); | ||
} | ||
|
||
void init_state([[maybe_unused]] EnergyPlusData &state) override | ||
void init_state(EnergyPlusData &state) override | ||
{ | ||
Curve::GetCurveInput(state); | ||
Curve::GetPressureSystemInput(state); | ||
state.dataCurveManager->GetCurvesInputFlag = false; | ||
} | ||
|
||
void clear_state() override | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -572,14 +572,18 @@ void EnergyPlusData::clear_state() | |
void EnergyPlusData::init_state(EnergyPlusData &state) | ||
{ | ||
if (this->init_state_called) return; | ||
|
||
state.dataGlobal->InputsFlag = true; | ||
this->init_state_called = true; | ||
// The order in which we do this matters. We're going to try to | ||
// do this in "topological" order meaning the first to go are the | ||
// objects that do not reference any other objects, like fluids, | ||
// schedules, curves, etc. | ||
this->dataSimulationManager->init_state(state); // GetProjectData | ||
this->dataSimulationManager->init_state(state); // OpenOutputFiles, GetProjectData, SetPreConstructionInputParameters | ||
this->dataFluidProps->init_state(state); // GetFluidPropertiesData | ||
this->dataPsychrometrics->init_state(state); // InitializePsychRoutines | ||
this->dataScheduleMgr->init_state(state); // ProcessScheduleInput - requires NumOfTimeStepInHour and AnyEnergyManagementSystemInModel | ||
this->dataCurveManager->init_state(state); // GetCurveInput, GetPressureSystemInput | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added schedules and curves to init_state |
||
|
||
this->dataAirLoop->init_state(state); | ||
this->dataAirLoopHVACDOAS->init_state(state); | ||
|
@@ -614,7 +618,6 @@ void EnergyPlusData::init_state(EnergyPlusData &state) | |
this->dataCoolTower->init_state(state); | ||
this->dataCostEstimateManager->init_state(state); | ||
this->dataCrossVentMgr->init_state(state); | ||
this->dataCurveManager->init_state(state); | ||
this->dataDXCoils->init_state(state); | ||
this->dataDXFEarClipping->init_state(state); | ||
this->dataDaylightingDevices->init_state(state); | ||
|
@@ -758,7 +761,6 @@ void EnergyPlusData::init_state(EnergyPlusData &state) | |
this->dataRuntimeLang->init_state(state); | ||
this->dataRuntimeLangProcessor->init_state(state); | ||
this->dataSQLiteProcedures->init_state(state); | ||
this->dataScheduleMgr->init_state(state); | ||
this->dataSetPointManager->init_state(state); | ||
this->dataShadowComb->init_state(state); | ||
this->dataSimAirServingZones->init_state(state); | ||
|
@@ -826,6 +828,8 @@ void EnergyPlusData::init_state(EnergyPlusData &state) | |
this->dataZoneEquipmentManager->init_state(state); | ||
this->dataZonePlenum->init_state(state); | ||
this->dataZoneTempPredictorCorrector->init_state(state); | ||
|
||
state.dataGlobal->InputsFlag = false; | ||
} | ||
|
||
} // namespace EnergyPlus |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,7 +340,8 @@ bool InputProcessor::checkVersionMatch(EnergyPlusData &state) | |
Which = static_cast<int>(index(v, MatchVersion)); | ||
} | ||
if (Which != 0) { | ||
ShowWarningError(state, "Version: in IDF=\"" + v + "\" not the same as expected=\"" + MatchVersion + "\""); | ||
// this is reported in GetProjectData | ||
// ShowWarningError(state, "Version: in IDF=\"" + v + "\" not the same as expected=\"" + MatchVersion + "\""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am seeing duplicate messages so either the version issue is reported here or where the version object is read. I chose to comment this out here but maybe there is a reason to do the opposite (e.g., API calls).
|
||
return false; | ||
} | ||
} | ||
|
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.
😆 🤣 😄 This is excellent @rraustad !
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.
Wow.