Skip to content
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

CppCheck SetPointManager #10757

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions src/EnergyPlus/SetPointManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void ManageSetPoints(EnergyPlusData &state)
}
} // ManageSetPoints()

int GetSetPointManagerIndex(EnergyPlusData &state, std::string const &Name)
int GetSetPointManagerIndex(EnergyPlusData const &state, std::string const &Name)
{
auto found = state.dataSetPointManager->spmMap.find(Name);
return (found != state.dataSetPointManager->spmMap.end()) ? found->second : 0;
Expand Down Expand Up @@ -1728,7 +1728,6 @@ void InitSetPointManagers(EnergyPlusData &state)
int MixedAirNode = 0;
int InletBranchNum = 0;
int LoopInNode = 0;
bool LookForFan = false;

// find the index in the ZoneEquipConfig array of the control zone (the one with the main or only thermostat)
int ConZoneNum = 0;
Expand Down Expand Up @@ -1774,6 +1773,7 @@ void InitSetPointManagers(EnergyPlusData &state)
LoopInNode = primaryAirSystem.Branch(InletBranchNum).NodeNumIn;
// get the supply fan inlet and outlet nodes
if (MixedAirNode > 0) {
bool LookForFan = false;
for (auto const &branch : primaryAirSystem.Branch) {
for (auto const &comp : branch.Comp) {
if (MixedAirNode == comp.NodeNumIn) {
Expand Down Expand Up @@ -1871,7 +1871,7 @@ void InitSetPointManagers(EnergyPlusData &state)
ErrorsFound = true;
}

auto &primaryAirSystem = state.dataAirSystemsData->PrimaryAirSystems(spmRAB->airLoopNum);
auto const &primaryAirSystem = state.dataAirSystemsData->PrimaryAirSystems(spmRAB->airLoopNum);
if (primaryAirSystem.RABExists) {
spmRAB->rabMixInNodeNum = primaryAirSystem.RABMixInNode;
spmRAB->supMixInNodeNum = primaryAirSystem.SupMixInNode;
Expand Down Expand Up @@ -1985,7 +1985,7 @@ void InitSetPointManagers(EnergyPlusData &state)
auto &branch = plantLoop.LoopSide(LoopSideLocation::Demand).Branch(BranchNum);

for (int CompNum = 1; CompNum <= branch.TotalComponents; ++CompNum) {
auto &comp = branch.Comp(CompNum);
auto const &comp = branch.Comp(CompNum);
switch (comp.Type) {

case PlantEquipmentType::Chiller_Absorption:
Expand Down Expand Up @@ -2093,7 +2093,7 @@ void InitSetPointManagers(EnergyPlusData &state)
for (int BranchNum2 = 1; BranchNum2 <= supplySide2.TotalBranches; ++BranchNum2) {
auto &branch2 = supplySide2.Branch(BranchNum2);
for (int CompNum2 = 1; CompNum2 <= branch2.TotalComponents; ++CompNum2) {
auto &comp2 = branch2.Comp(CompNum2);
auto const &comp2 = branch2.Comp(CompNum2);
InitType = comp2.Type;
if (InitType == ChillerType) {
++NumChiller;
Expand All @@ -2102,7 +2102,7 @@ void InitSetPointManagers(EnergyPlusData &state)
for (int BranchNum3 = 1; BranchNum3 <= supplySide2.TotalBranches; ++BranchNum3) {
auto &branch3 = supplySide2.Branch(BranchNum3);
for (int CompNum3 = 1; CompNum3 <= branch3.TotalComponents; ++CompNum3) {
auto &comp3 = branch3.Comp(CompNum3);
auto const &comp3 = branch3.Comp(CompNum3);
InitType = comp3.Type;
if (InitType == PlantEquipmentType::PumpVariableSpeed ||
InitType == PlantEquipmentType::PumpConstantSpeed) {
Expand Down Expand Up @@ -2936,8 +2936,8 @@ void SPMMixedAir::calculate(EnergyPlusData &state)

this->setPt = refNode.TempSetPoint - (fanOutNode.Temp - fanInNode.Temp);
if (this->coolCoilInNodeNum > 0 && this->coolCoilOutNodeNum > 0) {
auto &coolCoilInNode = state.dataLoopNodes->Node(this->coolCoilInNodeNum);
auto &coolCoilOutNode = state.dataLoopNodes->Node(this->coolCoilOutNodeNum);
auto const &coolCoilInNode = state.dataLoopNodes->Node(this->coolCoilInNodeNum);
auto const &coolCoilOutNode = state.dataLoopNodes->Node(this->coolCoilOutNodeNum);
Real64 dtFan = fanOutNode.Temp - fanInNode.Temp;
Real64 dtCoolCoil = coolCoilInNode.Temp - coolCoilOutNode.Temp;
if (dtCoolCoil > 0.0 && this->minCoolCoilOutTemp > state.dataEnvrn->OutDryBulbTemp) {
Expand Down Expand Up @@ -3088,7 +3088,7 @@ void SPMTempest::calculate(EnergyPlusData &state)
for (int iZoneNum = 1; iZoneNum <= airToZoneNode.NumZonesCooled; ++iZoneNum) {
int CtrlZoneNum = airToZoneNode.CoolCtrlZoneNums(iZoneNum);
auto &zoneInletNode = state.dataLoopNodes->Node(airToZoneNode.CoolZoneInletNodes(iZoneNum));
auto &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode);
auto const &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode);

Real64 ZoneMassFlowMax = zoneInletNode.MassFlowRateMax;
Real64 ZoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(CtrlZoneNum).TotalOutputRequired;
Expand Down Expand Up @@ -3118,7 +3118,7 @@ void SPMTempest::calculate(EnergyPlusData &state)
for (int iZoneNum = 1; iZoneNum <= airToZoneNode.NumZonesHeated; ++iZoneNum) {
int CtrlZoneNum = airToZoneNode.HeatCtrlZoneNums(iZoneNum);
auto &zoneInletNode = state.dataLoopNodes->Node(airToZoneNode.HeatZoneInletNodes(iZoneNum));
auto &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode);
auto const &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode);
Real64 ZoneMassFlowMax = zoneInletNode.MassFlowRateMax;
Real64 ZoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(CtrlZoneNum).TotalOutputRequired;
Real64 ZoneTemp = zoneNode.Temp;
Expand All @@ -3137,7 +3137,7 @@ void SPMTempest::calculate(EnergyPlusData &state)
for (int iZoneNum = 1; iZoneNum <= airToZoneNode.NumZonesCooled; ++iZoneNum) {
int CtrlZoneNum = airToZoneNode.CoolCtrlZoneNums(iZoneNum);
auto &zoneInletNode = state.dataLoopNodes->Node(airToZoneNode.CoolZoneInletNodes(iZoneNum));
auto &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode);
auto const &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode);
Real64 ZoneMassFlowMax = zoneInletNode.MassFlowRateMax;
Real64 ZoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(CtrlZoneNum).TotalOutputRequired;
Real64 ZoneTemp = zoneNode.Temp;
Expand Down Expand Up @@ -3193,7 +3193,7 @@ void SPMWarmestTempFlow::calculate(EnergyPlusData &state)
for (int iZoneNum = 1; iZoneNum <= airToZoneNode.NumZonesCooled; ++iZoneNum) {
int CtrlZoneNum = airToZoneNode.CoolCtrlZoneNums(iZoneNum);
auto &zoneInletNode = state.dataLoopNodes->Node(airToZoneNode.CoolZoneInletNodes(iZoneNum));
auto &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode);
auto const &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode);

Real64 ZoneMassFlowMax = zoneInletNode.MassFlowRateMax;
Real64 ZoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(CtrlZoneNum).TotalOutputRequired;
Expand Down Expand Up @@ -3377,9 +3377,9 @@ void SPMMultiZoneHum::calculate(EnergyPlusData &state)

for (int iZoneNum = 1; iZoneNum <= airToZoneNode.NumZonesCooled; ++iZoneNum) {
int CtrlZoneNum = airToZoneNode.CoolCtrlZoneNums(iZoneNum);
auto &zoneInletNode = state.dataLoopNodes->Node(airToZoneNode.CoolZoneInletNodes(iZoneNum));
auto &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode);
auto &zoneMoistureDemand = state.dataZoneEnergyDemand->ZoneSysMoistureDemand(CtrlZoneNum);
auto const &zoneInletNode = state.dataLoopNodes->Node(airToZoneNode.CoolZoneInletNodes(iZoneNum));
auto const &zoneNode = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneNode);
auto const &zoneMoistureDemand = state.dataZoneEnergyDemand->ZoneSysMoistureDemand(CtrlZoneNum);
Real64 ZoneMassFlowRate = zoneInletNode.MassFlowRate;
Real64 MoistureLoad = (this->type == SPMType::MZMinHum || this->type == SPMType::MZMinHumAverage)
? zoneMoistureDemand.OutputRequiredToHumidifyingSP
Expand Down Expand Up @@ -3935,18 +3935,14 @@ void SPMIdealCondenserEnteringTemp::SetupMeteredVarsForSetPt(EnergyPlusData &sta
using namespace DataPlant;

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
std::string TypeOfComp;
std::string NameOfComp;

Array1D<OutputProcessor::MeteredVar> meteredVars;
int NumVariables;

auto &plantLoop = state.dataPlnt->PlantLoop(this->chillerPloc.loopNum);
auto &supplySide = plantLoop.LoopSide(this->chillerPloc.loopSideNum);
auto &chillerBranch = supplySide.Branch(this->chillerPloc.branchNum);
auto &chillerComp = chillerBranch.Comp(this->chillerPloc.compNum);

NumVariables = GetNumMeteredVariables(state, chillerComp.TypeOf, chillerComp.Name);
int NumVariables = GetNumMeteredVariables(state, chillerComp.TypeOf, chillerComp.Name);
meteredVars.allocate(NumVariables);

GetMeteredVariables(state, chillerComp.Name, meteredVars);
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/SetPointManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ namespace SetPointManager {
void calculate(EnergyPlusData &state) override;
};

int GetSetPointManagerIndex(EnergyPlusData &state, std::string const &Name);
int GetSetPointManagerIndex(EnergyPlusData const &state, std::string const &Name);

void ManageSetPoints(EnergyPlusData &state);

Expand Down
44 changes: 19 additions & 25 deletions src/EnergyPlus/SimulationManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ namespace SimulationManager {

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
bool ErrorsFound(false);
bool TerminalError(false);
bool oneTimeUnderwaterBoundaryCheck = true;
bool AnyUnderwaterBoundaries = false;

Expand Down Expand Up @@ -280,9 +279,10 @@ namespace SimulationManager {
state.dataReportFlag->DoWeatherInitReporting = true;

// Note: All the inputs have been 'gotten' by the time we get here.
bool ErrFound = false;
if (state.dataGlobal->DoOutputReporting) {
DisplayString(state, "Reporting Surfaces");
bool ErrFound = false;
bool TerminalError = false;

ReportSurfaces(state);

Expand Down Expand Up @@ -1539,35 +1539,29 @@ namespace SimulationManager {
// SUBROUTINE INFORMATION:
// AUTHOR Linda Lawrie
// DATE WRITTEN January 2009
// MODIFIED na
// RE-ENGINEERED na

// PURPOSE OF THIS SUBROUTINE:
// EnergyPlus does not automatically produce any results files. Because of this, users may not request
// reports and may get confused when nothing is produced. This routine will provide a warning when
// results should be produced (either sizing periods or weather files are run) but no reports are
// requested.

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
bool SimPeriods;
bool ReportingRequested;

ReportingRequested = false;
SimPeriods = (state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileConditionType") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "RunPeriod") > 0);
bool SimPeriods = (state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileConditionType") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "RunPeriod") > 0);

if ((state.dataGlobal->DoDesDaySim || state.dataGlobal->DoWeathSim || state.dataGlobal->DoPureLoadCalc) && SimPeriods) {
ReportingRequested = (state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:SummaryReports") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:TimeBins") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:Monthly") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:Annual") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Variable") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:MeterFileOnly") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:Cumulative") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:Cumulative:MeterFileOnly") > 0);
bool ReportingRequested =
(state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:SummaryReports") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:TimeBins") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:Monthly") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Table:Annual") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Variable") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:MeterFileOnly") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:Cumulative") > 0 ||
state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Output:Meter:Cumulative:MeterFileOnly") > 0);
// Not testing for : Output:SQLite or Output:EnvironmentalImpactFactors
if (!ReportingRequested) {
ShowWarningError(state, "No reporting elements have been requested. No simulation results produced.");
Expand Down Expand Up @@ -2650,9 +2644,9 @@ namespace SimulationManager {
// EXTERNAL SUBROUTINES:

void Resimulate(EnergyPlusData &state,
bool &ResimExt, // Flag to resimulate the exterior energy use simulation
bool &ResimHB, // Flag to resimulate the heat balance simulation (including HVAC)
bool &ResimHVAC // Flag to resimulate the HVAC simulation
bool const ResimExt, // Flag to resimulate the exterior energy use simulation
bool const ResimHB, // Flag to resimulate the heat balance simulation (including HVAC)
bool &ResimHVAC // Flag to resimulate the HVAC simulation
)
{

Expand Down
6 changes: 3 additions & 3 deletions src/EnergyPlus/SimulationManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ struct SimulationManagerData : BaseGlobalStruct
};

void Resimulate(EnergyPlusData &state,
bool &ResimExt, // Flag to resimulate the exterior energy use simulation
bool &ResimHB, // Flag to resimulate the heat balance simulation (including HVAC)
bool &ResimHVAC // Flag to resimulate the HVAC simulation
bool const ResimExt, // Flag to resimulate the exterior energy use simulation
bool const ResimHB, // Flag to resimulate the heat balance simulation (including HVAC)
bool &ResimHVAC // Flag to resimulate the HVAC simulation
);

} // namespace EnergyPlus
Expand Down
Loading