Skip to content

Commit

Permalink
Add else after return
Browse files Browse the repository at this point in the history
  • Loading branch information
kursatyurt committed Mar 31, 2023
1 parent 822b092 commit 0363953
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Checks: '-*,modernize-avoid-bind,modernize-deprecated-headers,modernize-deprecated-ios-base-aliases,modernize-macro-to-enum,modernize-pass-by-value,modernize-raw-string-literal,modernize-redundant-void-arg,modernize-replace-auto-ptr,modernize-replace-disallow-copy-and-assign-macro,modernize-replace-random-shuffle,modernize-return-braced-init-list,modernize-shrink-to-fit,modernize-unary-static-assert,modernize-use-auto,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-emplace,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-noexcept,modernize-use-nullptr,modernize-use-override,modernize-use-transparent-functors,modernize-use-using,readability-const-return-type,readability-avoid-const-params-in-decls,readability-container-data-pointer,readability-container-size-empty,readability-delete-null-pointer,readability-duplicate-include,readability-non-const-parameter,readability-redundant-access-specifiers,readability-redundant-control-flow,readability-redundant-declaration,readability-redundant-function-ptr-dereference,readability-redundant-smartptr-get,readability-redundant-string-cstr,readability-redundant-string-init,readability-simplify-boolean-expr,readability-simplify-subscript-expr,performance-*'
Checks: '-*,modernize-avoid-bind,modernize-deprecated-headers,modernize-deprecated-ios-base-aliases,modernize-macro-to-enum,modernize-pass-by-value,modernize-raw-string-literal,modernize-redundant-void-arg,modernize-replace-auto-ptr,modernize-replace-disallow-copy-and-assign-macro,modernize-replace-random-shuffle,modernize-return-braced-init-list,modernize-shrink-to-fit,modernize-unary-static-assert,modernize-use-auto,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-emplace,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-noexcept,modernize-use-nullptr,modernize-use-override,modernize-use-transparent-functors,modernize-use-using,readability-const-return-type,readability-avoid-const-params-in-decls,readability-container-data-pointer,readability-container-size-empty,readability-delete-null-pointer,readability-duplicate-include,readability-non-const-parameter,readability-redundant-access-specifiers,readability-redundant-control-flow,readability-redundant-declaration,readability-redundant-function-ptr-dereference,readability-redundant-smartptr-get,readability-redundant-string-cstr,readability-redundant-string-init,readability-simplify-boolean-expr,readability-simplify-subscript-expr,readability-else-after-return,performance-*'
CheckOptions:
- {key: modernize-use-override.AllowOverrideAndFinal, value: 'true'}
- {key: performance-unnecessary-copy-initialization.AllowedTypes, value: 'su2double'}
Expand Down
10 changes: 4 additions & 6 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7659,9 +7659,8 @@ bool CConfig::TokenizeString(string & str, string & option_name,
}
it = option_value.begin(); // go back to beginning; not efficient
continue;
} else {
it++;
}
} it++;

}
#if 0
cout << "option value(s) = ";
Expand Down Expand Up @@ -8842,9 +8841,8 @@ const su2double* CConfig::GetInlet_TurbVal(const string& val_marker) const {
}
if (Kind_Turb_Model == TURB_MODEL::SST) {
return TurbIntensityAndViscRatioFreeStream;
} else {
return &NuFactor_FreeStream;
}
} return &NuFactor_FreeStream;

}

su2double CConfig::GetOutlet_Pressure(const string& val_marker) const {
Expand Down
9 changes: 4 additions & 5 deletions Common/src/fem/fem_geometry_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,10 @@ bool CSortFaces::operator()(const CFaceOfElement& f0, const CFaceOfElement& f1)
to their element ID's in order to increase cache performance. */
if (elemIDMin0 != elemIDMin1) return elemIDMin0 < elemIDMin1;
return elemIDMax0 < elemIDMax1;
} else {
/* One face is a local face and the other is not. Make sure that
the local faces are numbered first. */
return face0IsLocal;
}
} /* One face is a local face and the other is not. Make sure that
the local faces are numbered first. */
return face0IsLocal;

} else if (elemIDMax0 >= nVolElemTot && elemIDMax1 >= nVolElemTot) {
/* Both faces are non-matching internal faces. Sort them according to
their relevant element ID. The time level is not taken into account
Expand Down
2 changes: 1 addition & 1 deletion Common/src/geometry/CGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ bool CGeometry::SegmentIntersectsLine(const su2double point0[2], const su2double

length = diff0_A * diff0_A + diff1_A * diff1_A;

return !((dist0 > length) || (dist1 > length));
return (dist0 <= length) && (dist1 <= length);
}

bool CGeometry::SegmentIntersectsTriangle(su2double point0[3], const su2double point1[3], su2double vert0[3],
Expand Down
4 changes: 2 additions & 2 deletions Common/src/geometry/meshreader/CCGNSMeshReaderFVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,8 @@ void CCGNSMeshReaderFVM::ReadCGNSVolumeSection(int val_section) {

/*--- Free temporary memory from communications ---*/

if (connSendReq != nullptr) delete[] connSendReq;
if (connRecvReq != nullptr) delete[] connRecvReq;
delete[] connSendReq;
delete[] connRecvReq;

delete[] connSend;
delete[] connRecv;
Expand Down
15 changes: 7 additions & 8 deletions Common/src/grid_movement/CBezierBlending.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,14 @@ su2double CBezierBlending::GetBernsteinDerivative(short val_n, short val_i, su2d
if (val_i == 0) {
value = val_n * (-GetBernsteinDerivative(val_n - 1, val_i, val_t, val_order_der - 1));
return value;
}
if (val_n == 0) {
value = val_t;
return value;
} else {
if (val_n == 0) {
value = val_t;
return value;
} else {
value = val_n * (GetBernsteinDerivative(val_n - 1, val_i - 1, val_t, val_order_der - 1) -
GetBernsteinDerivative(val_n - 1, val_i, val_t, val_order_der - 1));
return value;
}
value = val_n * (GetBernsteinDerivative(val_n - 1, val_i - 1, val_t, val_order_der - 1) -
GetBernsteinDerivative(val_n - 1, val_i, val_t, val_order_der - 1));
return value;
}

return value;
Expand Down
3 changes: 1 addition & 2 deletions SU2_CFD/src/drivers/CDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2821,8 +2821,7 @@ void CDriver::PrintDirectResidual(RECORDING kind_recording) {
auto iVar_iZone2string = [&](unsigned short ivar, unsigned short izone) {
if (multizone)
return "[" + std::to_string(ivar) + "][" + std::to_string(izone) + "]";
else
return "[" + std::to_string(ivar) + "]";
return "[" + std::to_string(ivar) + "]";
};

/*--- Print residuals in the first iteration ---*/
Expand Down
4 changes: 2 additions & 2 deletions SU2_CFD/src/drivers/CMultizoneDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ bool CMultizoneDriver::Monitor(unsigned long TimeIter){

return (MaxIterationsReached || InnerConvergence);
}
else { // i.e. unsteady simulation
// i.e. unsteady simulation

/*--- Check whether the outer time integration has reached the final time ---*/
const auto TimeConvergence = GetTimeConvergence();
Expand All @@ -641,7 +641,7 @@ bool CMultizoneDriver::Monitor(unsigned long TimeIter){
}

return (FinalTimeReached || MaxIterationsReached);
}


}

Expand Down
19 changes: 8 additions & 11 deletions SU2_CFD/src/fluid/CSU2TCLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ void CSU2TCLib::ComputeKeqConstants(unsigned short val_Reaction) {
for (ii = 0; ii < 5; ii++)
A[ii] = RxnConstantTable(0,ii);
return;
} else if (iIndex >= 5) {
} if (iIndex >= 5) {
for (ii = 0; ii < 5; ii++)
A[ii] = RxnConstantTable(5,ii);
return;
Expand Down Expand Up @@ -1902,7 +1902,7 @@ su2double CSU2TCLib::ComputeCollisionCrossSection(unsigned iSpecies, unsigned jS

if (Omega11(iSpecies, jSpecies, 0) == 1.0 && d1) {
return 1E-20 * 5E15 * pi * pow((debyeLength / T), 2) * log(D1_a*T_star*(1 - C1_a * exp(-c1_a * T_star))+1);
} else if (Omega11(iSpecies, jSpecies, 0) == -1.0 && d1) {
} if (Omega11(iSpecies, jSpecies, 0) == -1.0 && d1) {
return 1E-20 * 5E15 * pi * pow((debyeLength / T), 2) * log(D1_r*T_star*(1 - C1_r * exp(-c1_r * T_star))+1);
} else if (Omega22(iSpecies, jSpecies, 0) == 1.0 && !d1) {
return 1E-20 * 5E15 * pi * pow((debyeLength / T), 2) * log(D2_a*T_star*(1 - C2_a * exp(-c2_a * T_star))+1);
Expand All @@ -1913,9 +1913,8 @@ su2double CSU2TCLib::ComputeCollisionCrossSection(unsigned iSpecies, unsigned jS
} else {
if (d1) {
return 1E-20 * Omega11(iSpecies,jSpecies,3) * pow(T, Omega11(iSpecies,jSpecies,0)*log(T)*log(T) + Omega11(iSpecies,jSpecies,1)*log(T) + Omega11(iSpecies,jSpecies,2));
} else {
return 1E-20 * Omega22(iSpecies,jSpecies,3) * pow(T, Omega22(iSpecies,jSpecies,0)*log(T)*log(T) + Omega22(iSpecies,jSpecies,1)*log(T) + Omega22(iSpecies,jSpecies,2));
}
} return 1E-20 * Omega22(iSpecies,jSpecies,3) * pow(T, Omega22(iSpecies,jSpecies,0)*log(T)*log(T) + Omega22(iSpecies,jSpecies,1)*log(T) + Omega22(iSpecies,jSpecies,2));

}
}

Expand Down Expand Up @@ -2169,9 +2168,8 @@ vector<su2double>& CSU2TCLib::ComputeTemperatures(vector<su2double>& val_rhos, s
NRconvg = true;
Tve = Tve2;
break;
} else {
Tve = Tve2;
}
} Tve = Tve2;

}

// If the Newton-Raphson method has converged, assign the value of Tve.
Expand All @@ -2186,10 +2184,9 @@ vector<su2double>& CSU2TCLib::ComputeTemperatures(vector<su2double>& val_rhos, s
if (fabs(rhoEve_t - rhoEve) < Btol) {
Bconvg = true;
break;
} else {
if (rhoEve_t > rhoEve) Tve2 = Tve;
} if (rhoEve_t > rhoEve) Tve2 = Tve;
else Tve_o = Tve;
}

}
}

Expand Down
20 changes: 8 additions & 12 deletions SU2_CFD/src/interfaces/CInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,10 @@ void CInterface::PreprocessAverage(CGeometry *donor_geometry, CGeometry *target_
/*--- Exit the for loop: we have found the local index for Mixing-Plane interface ---*/
break;
}
else {
/*--- If the tag hasn't matched any tag within the donor markers ---*/
/*--- If the tag hasn't matched any tag within the donor markers ---*/
Marker_Donor = -1;
Donor_Flag = -1;
}

}

#ifdef HAVE_MPI
Expand Down Expand Up @@ -273,10 +272,9 @@ void CInterface::PreprocessAverage(CGeometry *donor_geometry, CGeometry *target_
/*--- Exit the for loop: we have found the local index for iMarkerFSI on the FEA side ---*/
break;
}
else {
/*--- If the tag hasn't matched any tag within the Flow markers ---*/
/*--- If the tag hasn't matched any tag within the Flow markers ---*/
Marker_Target = -1;
}

}

if (Marker_Target != -1 && Marker_Donor != -1){
Expand Down Expand Up @@ -418,10 +416,9 @@ void CInterface::AllgatherAverage(CSolver *donor_solution, CSolver *target_solut
/*--- Exit the for loop: we have found the local index for Mixing-Plane interface ---*/
break;
}
else {
/*--- If the tag hasn't matched any tag within the donor markers ---*/
/*--- If the tag hasn't matched any tag within the donor markers ---*/
Marker_Donor = -1;
}

}
/*--- Here we want to make available the quantities for all the processors and collect them in a buffer
* for each span of the donor the span-wise height vector also so
Expand Down Expand Up @@ -534,10 +531,9 @@ void CInterface::AllgatherAverage(CSolver *donor_solution, CSolver *target_solut
/*--- Exit the for loop: we have found the local index for iMarkerFSI on the FEA side ---*/
break;
}
else {
/*--- If the tag hasn't matched any tag within the Flow markers ---*/
/*--- If the tag hasn't matched any tag within the Flow markers ---*/
Marker_Target = -1;
}

}


Expand Down
5 changes: 2 additions & 3 deletions SU2_CFD/src/iteration/CFEAIteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@ void CFEAIteration::Iterate(COutput* output, CIntegration**** integration, CGeom
if (disc_adj_fem) {
config[val_iZone]->SetInnerIter(CurIter);
break;
} else {
StopCalc = Monitor(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement,
} StopCalc = Monitor(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement,
FFDBox, val_iZone, INST_0);

if (StopCalc && (IntIter > 0)) break;
}

}

} else {
Expand Down
5 changes: 2 additions & 3 deletions SU2_CFD/src/iteration/CFluidIteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,8 @@ void CFluidIteration::SetDualTime_Aeroelastic(CConfig* config) const {
Monitoring_Tag = config->GetMarker_Monitoring_TagBound(iMarker_Monitoring);
Marker_Tag = config->GetMarker_All_TagBound(iMarker);
if (Marker_Tag == Monitoring_Tag) { owner = 1; break;
} else {
owner = 0;
}
} owner = 0;


}
plunge = config->GetAeroelastic_plunge(iMarker_Monitoring);
Expand Down
4 changes: 2 additions & 2 deletions SU2_CFD/src/numerics/CNumerics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "../../include/numerics/CNumerics.hpp"
#include "../../include/fluid/CFluidModel.hpp"

CNumerics::CNumerics(void) {
CNumerics::CNumerics() {

Proj_Flux_Tensor = nullptr;

Expand Down Expand Up @@ -75,7 +75,7 @@ CNumerics::CNumerics(unsigned short val_nDim, unsigned short val_nVar,

}

CNumerics::~CNumerics(void) {
CNumerics::~CNumerics() {

// visc
delete [] Proj_Flux_Tensor;
Expand Down
5 changes: 2 additions & 3 deletions SU2_CFD/src/output/CFlowOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,8 @@ void CFlowOutput::SetCustomOutputs(const CSolver* const* solver, const CGeometry
const auto varIdx = i % CustomOutput::MAX_VARS_PER_SOLVER;
if (solIdx == FLOW_SOL) {
return flowNodes->GetPrimitive(iPoint, varIdx);
} else {
return solver[solIdx]->GetNodes()->GetSolution(iPoint, varIdx);
}
} return solver[solIdx]->GetNodes()->GetSolution(iPoint, varIdx);

} else {
return *output.otherOutputs[i - CustomOutput::NOT_A_VARIABLE];
}
Expand Down
5 changes: 2 additions & 3 deletions SU2_CFD/src/output/COutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2134,9 +2134,8 @@ bool COutput::WriteVolumeOutput(CConfig *config, unsigned long Iter, bool force_

return ((Iter % config->GetVolumeOutputFrequency(iFile) == 0)) || force_writing;
}
else {
return ((Iter > 0) && (Iter % config->GetVolumeOutputFrequency(iFile) == 0)) || force_writing;
}
return ((Iter > 0) && (Iter % config->GetVolumeOutputFrequency(iFile) == 0)) || force_writing;

}

void COutput::SetCommonHistoryFields() {
Expand Down
4 changes: 2 additions & 2 deletions SU2_CFD/src/variables/CNEMOEulerVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ bool CNEMOEulerVariable::Cons2PrimVar(su2double *U, su2double *V,

// Determine if the temperature lies within the acceptable range
if (V[T_INDEX] <= Tmin) { nonPhys = true; return nonPhys;}
else if (V[T_INDEX] >= Tmax) { nonPhys = true; return nonPhys;}
if (V[T_INDEX] >= Tmax) { nonPhys = true; return nonPhys;}
else if (V[T_INDEX] != V[T_INDEX]){ nonPhys = true; return nonPhys;}

if (!monoatomic){
if (V[TVE_INDEX] <= Tvemin) { nonPhys = true; return nonPhys;}
else if (V[TVE_INDEX] >= Tvemax) { nonPhys = true; return nonPhys;}
if (V[TVE_INDEX] >= Tvemax) { nonPhys = true; return nonPhys;}
else if (V[TVE_INDEX] != V[TVE_INDEX]){ nonPhys = true; return nonPhys;}
}
else {V[TVE_INDEX] = Tve_Freestream;}
Expand Down
19 changes: 9 additions & 10 deletions SU2_DEF/src/drivers/CDiscAdjDeformationDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,16 @@ void CDiscAdjDeformationDriver::Run() {
for (iZone = 0; iZone < nZone; iZone++) {
if (!config_container[iZone]->GetDiscrete_Adjoint()) {
continue;
}
if (rank == MASTER_NODE)
cout << "\n---------------------- Mesh sensitivity computation ---------------------" << endl;
if (config_container[iZone]->GetDiscrete_Adjoint() && config_container[iZone]->GetSmoothGradient() &&
config_container[iZone]->GetSobMode() == ENUM_SOBOLEV_MODUS::MESH_LEVEL) {
DerivativeTreatment_MeshSensitivity(geometry_container[iZone][INST_0][MESH_0], config_container[iZone],
grid_movement[iZone][INST_0]);
} else {
if (rank == MASTER_NODE)
cout << "\n---------------------- Mesh sensitivity computation ---------------------" << endl;
if (config_container[iZone]->GetDiscrete_Adjoint() && config_container[iZone]->GetSmoothGradient() &&
config_container[iZone]->GetSobMode() == ENUM_SOBOLEV_MODUS::MESH_LEVEL) {
DerivativeTreatment_MeshSensitivity(geometry_container[iZone][INST_0][MESH_0], config_container[iZone],
grid_movement[iZone][INST_0]);
} else {
grid_movement[iZone][INST_0]->SetVolume_Deformation(geometry_container[iZone][INST_0][MESH_0],
config_container[iZone], false, true);
}
grid_movement[iZone][INST_0]->SetVolume_Deformation(geometry_container[iZone][INST_0][MESH_0],
config_container[iZone], false, true);
}
}

Expand Down

0 comments on commit 0363953

Please sign in to comment.