Skip to content

Commit 2d3141b

Browse files
authored
Merge pull request #6426 from akva2/janitoring_sca
Janitoring: quell some SCA warnings
2 parents fc6d116 + a55133c commit 2d3141b

9 files changed

Lines changed: 15 additions & 22 deletions

examples/art2dgf.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
#include <algorithm>
2929
#include <fstream>
30-
#include <iomanip>
31-
#include <memory>
3230
#include <stdexcept>
3331
#include <sstream>
3432
#include <string>
@@ -70,7 +68,7 @@ namespace Ewoms {
7068
// remove comments
7169
auto commentPos = curLine.find("%");
7270
if (commentPos != curLine.npos) {
73-
curLine = curLine.substr(0, commentPos);
71+
curLine.erase(commentPos);
7472
}
7573

7674
// remove leading whitespace
@@ -86,7 +84,7 @@ namespace Ewoms {
8684
while (curLine.size() > numTrailingSpaces
8785
&& std::isspace(curLine[curLine.size() - numTrailingSpaces]))
8886
++numTrailingSpaces;
89-
curLine = curLine.substr(0, curLine.size() - numTrailingSpaces);
87+
curLine.erase(numTrailingSpaces);
9088

9189
// a section of the file is finished, go to the next one
9290
if (curLine == "$") {

opm/models/blackoil/blackoilpolymerparams.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ initFromState(const EclipseState& eclState)
231231
shearMultiplier[i] *= refViscMult;
232232
shearMultiplier[i] -= 1;
233233
shearMultiplier[i] /= (refViscMult - 1);
234-
shearMultiplier[i] = shearMultiplier[i];
235234
}
236235
plyshlogShearEffectRefMultiplier_[pvtRegionIdx].resize(waterVelocity.size());
237236
plyshlogShearEffectRefLogVelocity_[pvtRegionIdx].resize(waterVelocity.size());

opm/simulators/flow/SimulatorSerializer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ void SimulatorSerializer::checkSerializedCmdLine(const std::string& current,
223223
curr_strings.begin(), curr_strings.end(),
224224
std::back_inserter(difference));
225225

226-
std::vector<std::string> only_stored, only_curr;
227226
if (!difference.empty()) {
227+
std::vector<std::string> only_stored, only_curr;
228228
for (std::size_t i = 0; i < difference.size(); ) {
229229
auto stored_it = std::find(stored_strings.begin(),
230230
stored_strings.end(), difference[i]);

opm/simulators/wells/BlackoilWellModelGasLift_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ updateWellPotentials(const Simulator& simulator,
331331

332332
const auto it = node_pressures.find(well->wellEcl().groupName());
333333
if (it != node_pressures.end()) {
334-
std::vector<Scalar> potentials;
335334
std::string cur_exc_msg;
336335
auto cur_exc_type = ExceptionType::NONE;
337336
try {
337+
std::vector<Scalar> potentials;
338338
well->computeWellPotentials(simulator, well_state_copy, potentials, deferred_logger);
339339
auto& ws = wellState.well(well->indexOfWell());
340340
for (int p = 0; p < np; ++p) {

opm/simulators/wells/GasLiftCommon.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ displayDebugMessageOnRank0_(const std::string& msg) const
5252
{
5353
// This output should be identical for all ranks.
5454

55-
if ( (!this->debug_output_only_on_rank0)
56-
|| (this->debug_output_only_on_rank0 && this->comm_.rank() == 0) ) {
55+
if (!this->debug_output_only_on_rank0 || this->comm_.rank() == 0) {
5756
displayDebugMessage_(msg);
5857
}
5958
}

opm/simulators/wells/GasLiftStage2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ addOrRemoveALQincrement_(GradMap &grad_map,
111111
if (it == this->well_state_map_.end())
112112
return;
113113

114-
GasLiftWellState<Scalar>& state = *(it->second.get());
115114
const GradInfo& gi = grad_map.at(well_name);
116115
if (this->debug) {
117116
auto new_alq = gi.alq;
117+
const GasLiftWellState<Scalar>& state = *(it->second.get());
118118
auto old_alq = state.alq();
119119
const std::string msg = fmt::format("well {} : {} ALQ increment, "
120120
"old alq: {}, new alq: {}",
@@ -1182,14 +1182,14 @@ computeDelta(const std::string& well_name)
11821182
// compute the delta on wells on own rank
11831183
if (this->parent.well_state_map_.count(well_name) > 0) {
11841184
const GradInfo& gi = this->parent.dec_grads_.at(well_name);
1185-
GasLiftWellState<Scalar>& state = *(this->parent.well_state_map_.at(well_name).get());
11861185
GasLiftSingleWell& gs_well = *(this->parent.stage1_wells_.at(well_name).get());
11871186
const WellInterfaceGeneric<Scalar>& well = gs_well.getWell();
11881187
// only get deltas for wells owned by this rank
11891188
if (this->parent.well_state_.wellIsOwned(well.indexOfWell(), well_name)) {
11901189
const auto& well_ecl = well.wellEcl();
11911190
Scalar factor = well_ecl.getEfficiencyFactor() *
11921191
this->well_state[well_name].efficiency_scaling_factor;
1192+
const GasLiftWellState<Scalar>& state = *(this->parent.well_state_map_.at(well_name).get());
11931193
auto& [delta_oil, delta_gas, delta_water, delta_alq] = delta;
11941194
delta_oil = factor * (gi.new_oil_rate - state.oilRate());
11951195
delta_gas = factor * (gi.new_gas_rate - state.gasRate());

opm/simulators/wells/MultisegmentWellEval.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,6 @@ assembleDefaultPressureEq(const int seg,
264264
// TODO: we might be able to add member variables to store these values, then we update well state
265265
// after converged
266266

267-
auto& ws = well_state.well(baseif_.indexOfWell());
268-
auto& segments = ws.segments;
269-
270267
if (this->frictionalPressureLossConsidered()) {
271268
const auto friction_pressure_drop = segments_.getFrictionPressureLoss(seg);
272269
if (reverseFlow){
@@ -276,7 +273,8 @@ assembleDefaultPressureEq(const int seg,
276273
assemblePressureEqExtraDerivatives(seg, seg_upwind, extra_derivatives, linSys_);
277274
}
278275
pressure_equation -= friction_pressure_drop;
279-
segments.pressure_drop_friction[seg] = friction_pressure_drop.value();
276+
auto& ws = well_state.well(baseif_.indexOfWell());
277+
ws.segments.pressure_drop_friction[seg] = friction_pressure_drop.value();
280278
}
281279

282280
// contribution from the outlet segment

opm/simulators/wells/VFPHelpers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ intersectWithIPR(const VFPProdTable& table,
578578
}
579579
// find largest flo (flo_x) for which y = bhp(flo) + (flo-a)/b = 0 and dy/dflo > 0
580580
Scalar flo_x = -1.0;
581-
Scalar flo0, flo1;
581+
Scalar flo0;
582582
Scalar y0, y1;
583583
flo0 = 0.0; // start by checking flo=0
584584
auto flo_i = findInterpData(flo0, table.getFloAxis());
@@ -587,7 +587,7 @@ intersectWithIPR(const VFPProdTable& table,
587587

588588
const std::vector<double>& flos = table.getFloAxis();
589589
for (size_t i = 0; i < flos.size(); ++i) {
590-
flo1 = flos[i];
590+
const auto flo1 = flos[i];
591591
flo_i = findInterpData(flo1, flos);
592592
bhp_i = interpolate(table, flo_i, thp_i, wfr_i, gfr_i, alq_i);
593593
y1 = adjust_bhp(bhp_i.value) + (flo1 - ipr_a)/ipr_b;

opm/simulators/wells/WellBhpThpCalculator.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,8 @@ computeBhpAtThpLimitInjImpl(const std::function<std::vector<Scalar>(const Scalar
548548
const Scalar low = 10.0 * unit::barsa;
549549
const Scalar high = 800.0 * unit::barsa;
550550
const Scalar flo_tolerance = flo_rel_tol * std::fabs(flo_samples.back());
551-
int iteration = 0;
552551
try {
552+
int iteration = 0;
553553
const Scalar solved_bhp = RegulaFalsiBisection<ErrorPolicy>::
554554
solve(eq, low, high, max_iteration, flo_tolerance, iteration);
555555
bhp_samples.push_back(solved_bhp);
@@ -610,7 +610,6 @@ computeBhpAtThpLimitInjImpl(const std::function<std::vector<Scalar>(const Scalar
610610
const Scalar low = bhp_samples[sign_change_index + 1];
611611
const Scalar high = bhp_samples[sign_change_index];
612612
const Scalar bhp_tolerance = 0.01 * unit::barsa;
613-
int iteration = 0;
614613
if (low == high) {
615614
// We are in the high flow regime where the bhp_samples
616615
// are all equal to the bhp_limit.
@@ -620,6 +619,7 @@ computeBhpAtThpLimitInjImpl(const std::function<std::vector<Scalar>(const Scalar
620619
return std::nullopt;
621620
}
622621
try {
622+
int iteration = 0;
623623
const Scalar solved_bhp = RegulaFalsiBisection<ErrorPolicy>::
624624
solve(eq, low, high, max_iteration, bhp_tolerance, iteration);
625625
if constexpr (extraBhpAtThpLimitOutput) {
@@ -773,8 +773,8 @@ computeBhpAtThpLimit(const std::function<std::vector<Scalar>(const Scalar)>& fra
773773
// Solve for the proper solution in the given interval.
774774
const int max_iteration = 100;
775775
const Scalar bhp_tolerance = 0.01 * unit::barsa;
776-
int iteration = 0;
777776
try {
777+
int iteration = 0;
778778
const Scalar solved_bhp = RegulaFalsiBisection<ThrowOnError>::
779779
solve(eq, low, high, max_iteration, bhp_tolerance, iteration);
780780
return solved_bhp;
@@ -1053,10 +1053,9 @@ bruteForceBracketCommonTHP(const std::function<Scalar(const Scalar)>& eq,
10531053
constexpr int sample_number = 1000;
10541054
constexpr Scalar interval = 1E5;
10551055
Scalar eq_low = eq(min_thp);
1056-
Scalar eq_high = 0.0;
10571056
for (int i = 0; i < sample_number + 1; ++i) {
10581057
max_thp = min_thp + interval * i;
1059-
eq_high = eq(max_thp);
1058+
const Scalar eq_high = eq(max_thp);
10601059
if (eq_high * eq_low <= 0.) {
10611060
bracket_found = true;
10621061
min_thp = max_thp - interval;

0 commit comments

Comments
 (0)