Skip to content

Commit

Permalink
Merge pull request #10740 from NREL/CppCheck-OutputReportTabular
Browse files Browse the repository at this point in the history
CppCheck OutputReportTabular
  • Loading branch information
Myoldmopar authored Nov 21, 2024
2 parents aebb3ef + fd85f09 commit 1b6a3d2
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 134 deletions.
2 changes: 1 addition & 1 deletion src/EnergyPlus/OutputReportPredefined.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ namespace OutputReportPredefined {

// Climate Summary Report

auto &s(state.dataOutRptPredefined);
auto const &s = state.dataOutRptPredefined;

s->pdrClim = newPreDefReport(state, "ClimaticDataSummary", "Clim", "Climatic Data Summary");

Expand Down
24 changes: 12 additions & 12 deletions src/EnergyPlus/OutputReportTabular.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3892,10 +3892,10 @@ void GatherBEPSResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeSt
using DataStringGlobals::CharTab;

auto &ort = state.dataOutRptTab;
auto &op = state.dataOutputProcessor;
// if no beps report is called then skip

if ((ort->displayTabularBEPS || ort->displayLEEDSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
auto &op = state.dataOutputProcessor;
// add the current time to the total elapsed time
// FOLLOWING LINE MOVED TO UPDATETABULARREPORTS because used even when beps is not called
// gatherElapsedTimeBEPS = gatherElapsedTimeBEPS + TimeStepZone
Expand Down Expand Up @@ -11048,7 +11048,7 @@ void WriteVeriSumTable(EnergyPlusData &state)
SIunit = "[m3]";
LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m3_unitName);
state.dataOutRptTab->m3_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
SIunit = "[W/m2]";
// SIunit = "[W/m2]";
// LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->Wm2_unitName);
state.dataOutRptTab->Wm2_unitName = "[W/ft2]";
state.dataOutRptTab->Wm2_unitConv = 0.3048 * 0.3048; // ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
Expand Down Expand Up @@ -14590,7 +14590,7 @@ void AllocateLoadComponentArrays(EnergyPlusData &state)
ort->AllocateLoadComponentArraysDoAllocate = false;
}

void DeallocateLoadComponentArrays(EnergyPlusData &state)
void DeallocateLoadComponentArrays(EnergyPlusData const &state)
{
// SUBROUTINE INFORMATION:
// AUTHOR Jason Glazer
Expand Down Expand Up @@ -16467,7 +16467,7 @@ void LoadSummaryUnitConversion(EnergyPlusData &state, CompLoadTablesType &compLo
}

// make a list of the zones for the airloop component loads report
void CreateListOfZonesForAirLoop(EnergyPlusData &state, CompLoadTablesType &compLoad, Array1D_int const &zoneToAirLoop, int const curAirLoop)
void CreateListOfZonesForAirLoop(EnergyPlusData const &state, CompLoadTablesType &compLoad, Array1D_int const &zoneToAirLoop, int const curAirLoop)
{
int counter = 0;
for (int zi = 1; zi <= state.dataGlobal->NumOfZones; ++zi) {
Expand Down Expand Up @@ -17744,13 +17744,13 @@ void ResetMonthlyGathering(EnergyPlusData &state)
}
}

void ResetBinGathering(EnergyPlusData &state)
void ResetBinGathering(EnergyPlusData const &state)
{
// Jason Glazer - October 2015
// Reset all timebins gathering arrays to zero for multi-year simulations
// so that only last year is reported in tabular reports
Real64 constexpr bigVal(0.0); // used with HUGE: Value doesn't matter, only type: Initialize so compiler doesn't warn about use uninitialized
auto &ort = state.dataOutRptTab;
auto const &ort = state.dataOutRptTab;

// clear the binning arrays to zeros
for (auto &e : ort->BinResults) {
Expand All @@ -17776,12 +17776,12 @@ void ResetBinGathering(EnergyPlusData &state)
}
}

void ResetBEPSGathering(EnergyPlusData &state)
void ResetBEPSGathering(EnergyPlusData const &state)
{
// Jason Glazer - October 2015
// Reset all ABUPS gathering arrays to zero for multi-year simulations
// so that only last year is reported in tabular reports
auto &ort = state.dataOutRptTab;
auto const &ort = state.dataOutRptTab;
ort->gatherTotalsBEPS = 0.0;
ort->gatherEndUseBEPS = 0.0;
ort->gatherEndUseSubBEPS = 0.0;
Expand Down Expand Up @@ -17809,22 +17809,22 @@ void ResetBEPSGathering(EnergyPlusData &state)
ort->gatherWaterEndUseTotal = 0.0;
}

void ResetSourceEnergyEndUseGathering(EnergyPlusData &state)
void ResetSourceEnergyEndUseGathering(EnergyPlusData const &state)
{
// Jason Glazer - October 2015
// Reset all source energy end use table gathering arrays to zero for multi-year simulations
// so that only last year is reported in tabular reports
auto &ort = state.dataOutRptTab;
auto const &ort = state.dataOutRptTab;
ort->gatherTotalsBySourceBEPS = 0.0;
ort->gatherEndUseBySourceBEPS = 0.0;
}

void ResetPeakDemandGathering(EnergyPlusData &state)
void ResetPeakDemandGathering(EnergyPlusData const &state)
{
// Jason Glazer - October 2015
// Reset all demand end use components table gathering arrays to zero for multi-year simulations
// so that only last year is reported in tabular reports
auto &ort = state.dataOutRptTab;
auto const &ort = state.dataOutRptTab;
ort->gatherDemandTotal = 0.0;
ort->gatherDemandTimeStamp = 0;
ort->gatherDemandEndUse = 0.0;
Expand Down
12 changes: 6 additions & 6 deletions src/EnergyPlus/OutputReportTabular.hh
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ namespace OutputReportTabular {

void AllocateLoadComponentArrays(EnergyPlusData &state);

void DeallocateLoadComponentArrays(EnergyPlusData &state);
void DeallocateLoadComponentArrays(EnergyPlusData const &state);

void ComputeLoadComponentDecayCurve(EnergyPlusData &state);

Expand Down Expand Up @@ -824,7 +824,7 @@ namespace OutputReportTabular {

void LoadSummaryUnitConversion(EnergyPlusData &state, CompLoadTablesType &compLoadTotal, UnitsStyle unitsStyle_para);

void CreateListOfZonesForAirLoop(EnergyPlusData &state, CompLoadTablesType &compLoad, Array1D_int const &zoneToAirLoop, int curAirLoop);
void CreateListOfZonesForAirLoop(EnergyPlusData const &state, CompLoadTablesType &compLoad, Array1D_int const &zoneToAirLoop, int curAirLoop);

void OutputCompLoadSummary(EnergyPlusData &state,
EnergyPlus::OutputReportTabular::OutputType kind,
Expand Down Expand Up @@ -891,13 +891,13 @@ namespace OutputReportTabular {

void ResetMonthlyGathering(EnergyPlusData &state);

void ResetBinGathering(EnergyPlusData &state);
void ResetBinGathering(EnergyPlusData const &state);

void ResetBEPSGathering(EnergyPlusData &state);
void ResetBEPSGathering(EnergyPlusData const &state);

void ResetSourceEnergyEndUseGathering(EnergyPlusData &state);
void ResetSourceEnergyEndUseGathering(EnergyPlusData const &state);

void ResetPeakDemandGathering(EnergyPlusData &state);
void ResetPeakDemandGathering(EnergyPlusData const &state);

void ResetHeatGainGathering(EnergyPlusData &state);

Expand Down
20 changes: 7 additions & 13 deletions src/EnergyPlus/OutputReportTabularAnnual.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ void GetInputTabularAnnual(EnergyPlusData &state)
int IOStat; // IO Status when calling get input subroutine
// static bool ErrorsFound( false );
int objCount(0);
int indexNums(0);
std::string curVarMtr("");
std::string curAggTyp("");
int curNumDgts(2);
int curNumDgts;
AnnualFieldSet::AggregationKind curAgg(AnnualFieldSet::AggregationKind::sumOrAvg);

auto &annualTables = state.dataOutputReportTabularAnnual->annualTables;
Expand Down Expand Up @@ -128,7 +125,7 @@ void GetInputTabularAnnual(EnergyPlusData &state)
annualTables.push_back(AnnualTable(state, alphArray(1), alphArray(2), alphArray(3)));
// the remaining fields are repeating in groups of three and need to be added to the data structure
for (jAlpha = 4; jAlpha <= numAlphas; jAlpha += 2) {
curVarMtr = alphArray(jAlpha);
std::string curVarMtr = alphArray(jAlpha);
if (curVarMtr.empty()) {
ShowWarningError(state,
format("{}: Blank column specified in '{}', need to provide a variable or meter or EMS variable name ",
Expand All @@ -141,7 +138,7 @@ void GetInputTabularAnnual(EnergyPlusData &state)
} else {
curAgg = AnnualFieldSet::AggregationKind::sumOrAvg; // if missing aggregation type use SumOrAverage
}
indexNums = 1 + (jAlpha - 3) / 2; // compute the corresponding field index in the numArray
int indexNums = 1 + (jAlpha - 3) / 2; // compute the corresponding field index in the numArray
if (indexNums <= numNums) {
curNumDgts = numArray(indexNums);
} else {
Expand Down Expand Up @@ -180,7 +177,6 @@ void AnnualTable::setupGathering(EnergyPlusData &state)
// This method is used after GetInput for REPORT:TABLE:ANNUAL to set up how output variables, meters,
// input fields, and ems variables are gathered.
{
int keyCount = 0;
OutputProcessor::VariableType typeVar = OutputProcessor::VariableType::Invalid;
OutputProcessor::StoreType avgSumVar;
OutputProcessor::TimeStepType stepTypeVar;
Expand All @@ -195,7 +191,7 @@ void AnnualTable::setupGathering(EnergyPlusData &state)

std::vector<AnnualFieldSet>::iterator fldStIt;
for (fldStIt = m_annualFields.begin(); fldStIt != m_annualFields.end(); ++fldStIt) {
keyCount = fldStIt->getVariableKeyCountandTypeFromFldSt(state, typeVar, avgSumVar, stepTypeVar, unitsVar);
int keyCount = fldStIt->getVariableKeyCountandTypeFromFldSt(state, typeVar, avgSumVar, stepTypeVar, unitsVar);
fldStIt->getVariableKeysFromFldSt(state, typeVar, keyCount, fldStIt->m_namesOfKeys, fldStIt->m_indexesForKeyVar);
for (std::string nm : fldStIt->m_namesOfKeys) {
std::string nmUpper = nm;
Expand Down Expand Up @@ -1294,16 +1290,15 @@ void AnnualTable::convertUnitForDeferredResults(EnergyPlusData &state,
{
Real64 curConversionFactor;
Real64 curConversionOffset;
std::string varNameWithUnits;
int indexUnitConv;
std::string curUnits;
std::string energyUnitsString;
Real64 curSI;
Real64 curIP;
Real64 energyUnitsConversionFactor = AnnualTable::setEnergyUnitStringAndFactor(unitsStyle, energyUnitsString);
// do the unit conversions
if (unitsStyle == OutputReportTabular::UnitsStyle::InchPound || unitsStyle == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
varNameWithUnits = format("{} [{}]", fldStIt->m_variMeter, Constant::unitNames[(int)fldStIt->m_varUnits]);
int indexUnitConv;
std::string varNameWithUnits = format("{} [{}]", fldStIt->m_variMeter, Constant::unitNames[(int)fldStIt->m_varUnits]);
OutputReportTabular::LookupSItoIP(state, varNameWithUnits, indexUnitConv, curUnits);
OutputReportTabular::GetUnitConversion(state, indexUnitConv, curConversionFactor, curConversionOffset, curUnits);
} else { // just do the Joule conversion
Expand Down Expand Up @@ -1342,7 +1337,6 @@ std::vector<Real64> AnnualTable::calculateBins(int const numberOfBins,
Real64 &timeBelowBottomBin)
{
std::vector<Real64> returnBins(0.0);
int binNum = 0;
returnBins.resize(numberOfBins);
Real64 intervalSize = (topOfBins - bottomOfBins) / float(numberOfBins);
timeAboveTopBin = 0.0;
Expand All @@ -1357,7 +1351,7 @@ std::vector<Real64> AnnualTable::calculateBins(int const numberOfBins,
timeAboveTopBin += *elapsedTimeIt;
} else {
// determine which bin the results are in
binNum = int((*valueIt - bottomOfBins) / intervalSize);
int binNum = int((*valueIt - bottomOfBins) / intervalSize);
if (binNum < numberOfBins && binNum >= 0) {
returnBins[binNum] += *elapsedTimeIt;
}
Expand Down
13 changes: 5 additions & 8 deletions src/EnergyPlus/OutputReports.cc
Original file line number Diff line number Diff line change
Expand Up @@ -952,14 +952,11 @@ void DetailsForSurfaces(EnergyPlusData &state, int const RptType) // (1=Vertices
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
std::string BaseSurfName;
std::string ConstructionName;
std::string ScheduleName;
std::string IntConvCoeffCalc;
std::string ExtConvCoeffCalc;
Real64 NominalUwithConvCoeffs;
std::string cNominalU;
std::string cNominalUwithConvCoeffs;
std::string cSchedMin;
std::string cSchedMax;
std::string SolarDiffusing;
std::string AlgoName;

Expand Down Expand Up @@ -1030,10 +1027,13 @@ void DetailsForSurfaces(EnergyPlusData &state, int const RptType) // (1=Vertices
int surf2 = 0;
for (int surf : state.dataSurface->AllSurfaceListReportOrder) {
surf2 = surf;
auto &thisSurface = state.dataSurface->Surface(surf);
auto const &thisSurface = state.dataSurface->Surface(surf);
if (thisSurface.Zone != 0) break;
}
if ((surf2 - 1) > 0) {
std::string ScheduleName;
std::string cSchedMin;
std::string cSchedMax;
*eiostream << "Shading Surfaces,"
<< "Number of Shading Surfaces," << surf2 - 1 << '\n';
for (int surf : state.dataSurface->AllSurfaceListReportOrder) {
Expand Down Expand Up @@ -1352,7 +1352,7 @@ void CostInfoOut(EnergyPlusData &state)
uniqueSurf.dimension(state.dataSurface->TotSurfaces, true);

for (int surf : state.dataSurface->AllSurfaceListReportOrder) {
auto &thisSurface = state.dataSurface->Surface(surf);
auto const &thisSurface = state.dataSurface->Surface(surf);
if (thisSurface.ExtBoundCond > 0) {
if (thisSurface.ExtBoundCond < surf) { // already cycled through
uniqueSurf(surf) = false;
Expand Down Expand Up @@ -1425,7 +1425,6 @@ void VRMLOut(EnergyPlusData &state, const std::string &PolygonAction, const std:
"WALL", "WINDOW", "FIXEDSHADE", "SUBSHADE", "ROOF", "FLOOR", "BLDGSHADE"};

// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
std::string ShadeType;
bool ThickPolyline(false);
bool RegularPolyline(false);
std::string PolylineWidth(" 0.55");
Expand Down Expand Up @@ -1502,10 +1501,8 @@ void VRMLOut(EnergyPlusData &state, const std::string &PolygonAction, const std:
if (thisSurface.Class == DataSurfaces::SurfaceClass::Detached_F) colorindex = Color::FixedShade;
if (thisSurface.Class == DataSurfaces::SurfaceClass::Detached_B) colorindex = Color::BldgShade;
if (thisSurface.Class == DataSurfaces::SurfaceClass::Detached_F) {
ShadeType = "Fixed Shading";
print(wrlfile, "# Fixed Shading:{}\n", thisSurface.Name);
} else if (thisSurface.Class == DataSurfaces::SurfaceClass::Detached_B) {
ShadeType = "Building Shading";
print(wrlfile, "# Building Shading:{}", thisSurface.Name);
}
print<check_syntax(Format_801)>(wrlfile, Format_801, colorstring[static_cast<int>(colorindex)], "Surf", surf);
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyPlus/OutsideEnergySources.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void GetOutsideEnergySourcesInput(EnergyPlusData &state)
EnergyType = DataPlant::PlantEquipmentType::PurchHotWater;
heatWaterIndex++;
thisIndex = heatWaterIndex;
} else if (EnergySourceNum > NumDistrictUnitsHeatWater && EnergySourceNum <= NumDistrictUnitsHeatWater + NumDistrictUnitsCool) {
} else if (EnergySourceNum <= NumDistrictUnitsHeatWater + NumDistrictUnitsCool) {
state.dataIPShortCut->cCurrentModuleObject = "DistrictCooling";
objType = DataLoopNode::ConnectionObjectType::DistrictCooling;
nodeNames = "Chilled Water Nodes";
Expand Down
12 changes: 5 additions & 7 deletions src/EnergyPlus/PhaseChangeModeling/HysteresisModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ namespace Material {
Tau2 = this->deltaTempMeltingHigh;
if (updatedTempTDT < TempLowPCM) {
phaseChangeState = Phase::Crystallized;
} else if (updatedTempTDT >= TempLowPCM && updatedTempTDT <= TempHighPCM) {
} else if (updatedTempTDT <= TempHighPCM) {
phaseChangeState = Phase::Melting;
if (prevPhaseChangeState == Phase::Freezing || prevPhaseChangeState == Phase::Transition) {
phaseChangeState = Phase::Transition;
}
} else if (updatedTempTDT > TempHighPCM) {
} else {
phaseChangeState = Phase::Liquid;
}
} else { // phaseChangeDeltaT > 0
Expand All @@ -109,12 +109,12 @@ namespace Material {
Tau2 = this->deltaTempFreezingHigh;
if (updatedTempTDT < TempLowPCF) {
phaseChangeState = Phase::Crystallized;
} else if (updatedTempTDT >= TempLowPCF && updatedTempTDT <= TempHighPCF) {
} else if (updatedTempTDT <= TempHighPCF) {
phaseChangeState = Phase::Freezing;
if (prevPhaseChangeState == Phase::Melting || prevPhaseChangeState == Phase::Transition) {
phaseChangeState = Phase::Transition;
}
} else if (updatedTempTDT > TempHighPCF) {
} else {
phaseChangeState = Phase::Liquid;
}
}
Expand Down Expand Up @@ -266,13 +266,11 @@ namespace Material {
return (Cp1 + DEta1);
} else if (T == criticalTemperature) {
return (EnthalpyNew - EnthalpyOld) / (temperatureCurrent - temperaturePrev);
} else if (T > criticalTemperature) {
} else {
Real64 DEta2 = (this->totalLatentHeat * (T - criticalTemperature) * exp(-2 * std::abs(T - criticalTemperature) / tau2)) /
(tau2 * std::abs(T - criticalTemperature));
Real64 Cp2 = this->specificHeatLiquid;
return Cp2 + DEta2;
} else {
return 0;
}
}

Expand Down
Loading

1 comment on commit 1b6a3d2

@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 (2895 of 2895 tests passed, 0 test warnings)

Build Badge Test Badge

Please sign in to comment.