Skip to content

Commit e5d85a3

Browse files
authored
Merge pull request #10693 from NREL/CppCheck-PipeHeatTrasfer
CppCheck PipeHeatTransfer
2 parents 2ca0614 + ae3f5ef commit e5d85a3

File tree

3 files changed

+84
-149
lines changed

3 files changed

+84
-149
lines changed

src/EnergyPlus/PipeHeatTransfer.cc

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,12 @@ void GetPipesHeatTransfer(EnergyPlusData &state)
218218
bool ErrorsFound(false); // Set to true if errors in input,
219219

220220
// fatal at end of routine
221-
int IOStatus; // Used in GetObjectItem
222-
int Item; // Item to be "gotten"
223-
int PipeItem;
221+
int IOStatus; // Used in GetObjectItem
224222
int NumAlphas; // Number of Alphas for each GetObjectItem call
225223
int NumNumbers; // Number of Numbers for each GetObjectItem call
226224
int NumOfPipeHTInt; // Number of Pipe Heat Transfer objects
227225
int NumOfPipeHTExt; // Number of Pipe Heat Transfer objects
228226
int NumOfPipeHTUG; // Number of Pipe Heat Transfer objects
229-
int NumSections; // total number of sections in pipe
230227
auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject;
231228
// Initializations and allocations
232229
cCurrentModuleObject = "Pipe:Indoor";
@@ -242,10 +239,10 @@ void GetPipesHeatTransfer(EnergyPlusData &state)
242239

243240
state.dataPipeHT->PipeHT.allocate(state.dataPipeHT->nsvNumOfPipeHT);
244241
state.dataPipeHT->PipeHTUniqueNames.reserve(static_cast<unsigned>(state.dataPipeHT->nsvNumOfPipeHT));
245-
Item = 0;
242+
int Item = 0;
246243

247244
cCurrentModuleObject = "Pipe:Indoor";
248-
for (PipeItem = 1; PipeItem <= NumOfPipeHTInt; ++PipeItem) {
245+
for (int PipeItem = 1; PipeItem <= NumOfPipeHTInt; ++PipeItem) {
249246
++Item;
250247
// get the object name
251248
state.dataInputProcessing->inputProcessor->getObjectItem(state,
@@ -399,7 +396,7 @@ void GetPipesHeatTransfer(EnergyPlusData &state)
399396
} // end of input loop
400397

401398
cCurrentModuleObject = "Pipe:Outdoor";
402-
for (PipeItem = 1; PipeItem <= NumOfPipeHTExt; ++PipeItem) {
399+
for (int PipeItem = 1; PipeItem <= NumOfPipeHTExt; ++PipeItem) {
403400
++Item;
404401
// get the object name
405402
state.dataInputProcessing->inputProcessor->getObjectItem(state,
@@ -534,7 +531,7 @@ void GetPipesHeatTransfer(EnergyPlusData &state)
534531
} // end of input loop
535532

536533
cCurrentModuleObject = "Pipe:Underground";
537-
for (PipeItem = 1; PipeItem <= NumOfPipeHTUG; ++PipeItem) {
534+
for (int PipeItem = 1; PipeItem <= NumOfPipeHTUG; ++PipeItem) {
538535

539536
++Item;
540537
// get the object name
@@ -693,7 +690,6 @@ void GetPipesHeatTransfer(EnergyPlusData &state)
693690
GetGroundTempModelAndInit(state, state.dataIPShortCut->cAlphaArgs(7), state.dataIPShortCut->cAlphaArgs(8));
694691

695692
// Select number of pipe sections. Hanby's optimal number of 20 section is selected.
696-
NumSections = NumPipeSections;
697693
state.dataPipeHT->PipeHT(Item).NumSections = NumPipeSections;
698694

699695
// For buried pipes, we need to allocate the cartesian finite difference array
@@ -707,7 +703,7 @@ void GetPipesHeatTransfer(EnergyPlusData &state)
707703

708704
for (Item = 1; Item <= state.dataPipeHT->nsvNumOfPipeHT; ++Item) {
709705
// Select number of pipe sections. Hanby's optimal number of 20 section is selected.
710-
NumSections = NumPipeSections;
706+
int NumSections = NumPipeSections;
711707
state.dataPipeHT->PipeHT(Item).NumSections = NumPipeSections;
712708

713709
// We need to allocate the Hanby model arrays for all pipes, including buried
@@ -1191,9 +1187,6 @@ void PipeHTData::CalcPipesHeatTransfer(EnergyPlusData &state, ObjexxFCL::Optiona
11911187
Real64 EnvHeatTransCoef(0.0); // external convection coefficient (outside pipe)
11921188
Real64 FluidNodeHeatCapacity(0.0); // local var for MCp for single node of pipe
11931189

1194-
int PipeDepth(0);
1195-
int PipeWidth(0);
1196-
int curnode;
11971190
Real64 TempBelow;
11981191
Real64 TempBeside;
11991192
Real64 TempAbove;
@@ -1274,8 +1267,8 @@ void PipeHTData::CalcPipesHeatTransfer(EnergyPlusData &state, ObjexxFCL::Optiona
12741267

12751268
if (present(LengthIndex)) { // Just simulate the single section if being called from Pipe:Underground
12761269

1277-
PipeDepth = this->PipeNodeDepth;
1278-
PipeWidth = this->PipeNodeWidth;
1270+
int PipeDepth = this->PipeNodeDepth;
1271+
int PipeWidth = this->PipeNodeWidth;
12791272
TempBelow = this->T(PipeWidth, PipeDepth + 1, LengthIndex, TimeIndex::Current);
12801273
TempBeside = this->T(PipeWidth - 1, PipeDepth, LengthIndex, TimeIndex::Current);
12811274
TempAbove = this->T(PipeWidth, PipeDepth - 1, LengthIndex, TimeIndex::Current);
@@ -1301,7 +1294,7 @@ void PipeHTData::CalcPipesHeatTransfer(EnergyPlusData &state, ObjexxFCL::Optiona
13011294

13021295
// start loop along pipe
13031296
// b1 must not be zero but this should have been checked on input
1304-
for (curnode = 1; curnode <= this->NumSections; ++curnode) {
1297+
for (int curnode = 1; curnode <= this->NumSections; ++curnode) {
13051298
this->TentativeFluidTemp(curnode) = (A2 * this->TentativeFluidTemp(curnode - 1) +
13061299
A3 / B1 * (B3 * state.dataPipeHT->nsvEnvironmentTemp + B4 * this->PreviousPipeTemp(curnode)) +
13071300
A4 * this->PreviousFluidTemp(curnode)) /
@@ -1356,7 +1349,6 @@ void PipeHTData::CalcBuriedPipeSoil(EnergyPlusData &state) // Current Simulation
13561349

13571350
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
13581351
int IterationIndex(0); // Index when stepping through equations
1359-
int LengthIndex(0); // Index for nodes along length of pipe
13601352
int DepthIndex(0); // Index for nodes in the depth direction
13611353
int WidthIndex(0); // Index for nodes in the width direction
13621354
Real64 ConvCoef(0.0); // Current convection coefficient = f(Wind Speed,Roughness)
@@ -1394,7 +1386,7 @@ void PipeHTData::CalcBuriedPipeSoil(EnergyPlusData &state) // Current Simulation
13941386
}
13951387

13961388
// Store computed values in T_O array
1397-
for (LengthIndex = 2; LengthIndex <= this->NumSections; ++LengthIndex) {
1389+
for (int LengthIndex = 2; LengthIndex <= this->NumSections; ++LengthIndex) {
13981390
for (DepthIndex = 1; DepthIndex <= this->NumDepthNodes - 1; ++DepthIndex) {
13991391
for (WidthIndex = 2; WidthIndex <= this->PipeNodeWidth; ++WidthIndex) {
14001392
T_O(WidthIndex, DepthIndex, LengthIndex) = this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Tentative);
@@ -1403,7 +1395,7 @@ void PipeHTData::CalcBuriedPipeSoil(EnergyPlusData &state) // Current Simulation
14031395
}
14041396

14051397
// Loop along entire length of pipe, analyzing cross sects
1406-
for (LengthIndex = 1; LengthIndex <= this->NumSections; ++LengthIndex) {
1398+
for (int LengthIndex = 1; LengthIndex <= this->NumSections; ++LengthIndex) {
14071399
for (DepthIndex = 1; DepthIndex <= this->NumDepthNodes - 1; ++DepthIndex) {
14081400
for (WidthIndex = 2; WidthIndex <= this->PipeNodeWidth; ++WidthIndex) {
14091401

@@ -1479,7 +1471,7 @@ void PipeHTData::CalcBuriedPipeSoil(EnergyPlusData &state) // Current Simulation
14791471
//-Update node for cartesian system
14801472
this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Tentative) = this->PipeTemp(LengthIndex);
14811473

1482-
} else if (DepthIndex != 1) { // Not surface node
1474+
} else { // Not surface node
14831475

14841476
//-Coefficients and Temperatures
14851477
NodeLeft = this->T(WidthIndex - 1, DepthIndex, LengthIndex, TimeIndex::Current);
@@ -1515,7 +1507,7 @@ void PipeHTData::CalcBuriedPipeSoil(EnergyPlusData &state) // Current Simulation
15151507
}
15161508

15171509
// Check for convergence
1518-
for (LengthIndex = 2; LengthIndex <= this->NumSections; ++LengthIndex) {
1510+
for (int LengthIndex = 2; LengthIndex <= this->NumSections; ++LengthIndex) {
15191511
for (DepthIndex = 1; DepthIndex <= this->NumDepthNodes - 1; ++DepthIndex) {
15201512
for (WidthIndex = 2; WidthIndex <= this->PipeNodeWidth; ++WidthIndex) {
15211513
Ttemp = this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Tentative);

0 commit comments

Comments
 (0)