From c114def85167ca07e61f682cb6f2abc6c83850f8 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 22 Jan 2025 17:41:25 +0100 Subject: [PATCH] mark parameters/variables as const where appropriate --- examples/problems/fingerproblem.hh | 4 ++-- opm/models/blackoil/blackoildispersionmodule.hh | 2 +- .../aquifers/BlackoilAquiferModel_impl.hpp | 4 ++-- opm/simulators/flow/FlowUtils.cpp | 2 +- opm/simulators/flow/FlowUtils.hpp | 2 +- .../flow/GenericThresholdPressure_impl.hpp | 2 +- opm/simulators/flow/InterRegFlows.cpp | 4 ++-- opm/simulators/flow/OutputBlackoilModule.hpp | 4 ++-- .../flow/SimulatorFullyImplicitBlackoil.hpp | 4 ++-- opm/simulators/flow/TracerModel.hpp | 2 +- opm/simulators/linalg/gpubridge/BlockedMatrix.cpp | 9 +++++---- opm/simulators/linalg/gpubridge/BlockedMatrix.hpp | 3 ++- opm/simulators/linalg/gpubridge/Reorder.cpp | 12 ++++++------ opm/simulators/linalg/gpubridge/Reorder.hpp | 12 ++++++------ .../linalg/gpubridge/amgclSolverBackend.cpp | 4 ++-- .../linalg/gpubridge/amgclSolverBackend.hpp | 4 ++-- .../linalg/gpubridge/opencl/openclBILU0.cpp | 2 +- .../linalg/gpuistl/GpuOwnerOverlapCopy.hpp | 4 ++-- opm/simulators/linalg/twolevelmethodcpr.hh | 8 ++------ .../utils/ParallelNLDDPartitioningZoltan.cpp | 2 +- opm/simulators/wells/BlackoilWellModel.hpp | 2 +- opm/simulators/wells/BlackoilWellModelGeneric.cpp | 2 +- opm/simulators/wells/BlackoilWellModel_impl.hpp | 10 +++++----- opm/simulators/wells/GasLiftSingleWellGeneric.cpp | 2 +- opm/simulators/wells/GasLiftSingleWell_impl.hpp | 2 +- opm/simulators/wells/GasLiftStage2.cpp | 2 +- opm/simulators/wells/GroupState.hpp | 2 +- .../wells/WellConnectionAuxiliaryModule.hpp | 4 ++-- opm/simulators/wells/WellInterface_impl.hpp | 2 +- tests/test_openclSolver.cpp | 6 ++++-- 30 files changed, 62 insertions(+), 62 deletions(-) diff --git a/examples/problems/fingerproblem.hh b/examples/problems/fingerproblem.hh index 06acf4a7c..b2df35fba 100644 --- a/examples/problems/fingerproblem.hh +++ b/examples/problems/fingerproblem.hh @@ -509,8 +509,8 @@ private: if (!onUpperBoundary_(pos)) return false; - Scalar xInject[] = { 0.25, 0.75 }; - Scalar injectLen[] = { 0.1, 0.1 }; + const Scalar xInject[] = { 0.25, 0.75 }; + const Scalar injectLen[] = { 0.1, 0.1 }; for (unsigned i = 0; i < sizeof(xInject) / sizeof(Scalar); ++i) { if (xInject[i] - injectLen[i] / 2 < lambda && lambda < xInject[i] + injectLen[i] / 2) diff --git a/opm/models/blackoil/blackoildispersionmodule.hh b/opm/models/blackoil/blackoildispersionmodule.hh index 822603be5..346b7f415 100644 --- a/opm/models/blackoil/blackoildispersionmodule.hh +++ b/opm/models/blackoil/blackoildispersionmodule.hh @@ -373,7 +373,7 @@ protected: for (unsigned i = 0; i < phaseIdxs.size(); ++i) { normVelocityCell_[i] = 0; } - for (auto& velocityInfo : velocityInfos) { + for (const auto& velocityInfo : velocityInfos) { for (unsigned i = 0; i < phaseIdxs.size(); ++i) { if (FluidSystem::phaseIsActive(phaseIdxs[i])) { normVelocityCell_[phaseIdxs[i]] = max( normVelocityCell_[phaseIdxs[i]], diff --git a/opm/simulators/aquifers/BlackoilAquiferModel_impl.hpp b/opm/simulators/aquifers/BlackoilAquiferModel_impl.hpp index 633618170..57398a11a 100644 --- a/opm/simulators/aquifers/BlackoilAquiferModel_impl.hpp +++ b/opm/simulators/aquifers/BlackoilAquiferModel_impl.hpp @@ -136,9 +136,9 @@ BlackoilAquiferModel::endTimeStep() { using NumAq = AquiferNumerical; - for (auto& aquifer : this->aquifers) { + for (const auto& aquifer : this->aquifers) { aquifer->endTimeStep(); - NumAq* num = dynamic_cast(aquifer.get()); + const NumAq* num = dynamic_cast(aquifer.get()); if (num) { this->simulator_.vanguard().grid().comm().barrier(); } diff --git a/opm/simulators/flow/FlowUtils.cpp b/opm/simulators/flow/FlowUtils.cpp index b38ef09ec..53de3495b 100644 --- a/opm/simulators/flow/FlowUtils.cpp +++ b/opm/simulators/flow/FlowUtils.cpp @@ -81,7 +81,7 @@ void mergeParallelLogFiles(std::string_view output_dir, enableLoggingFalloutWarning)); } -void handleExtraConvergenceOutput(SimulatorReport& report, +void handleExtraConvergenceOutput(const SimulatorReport& report, std::string_view option, std::string_view optionName, std::string_view output_dir, diff --git a/opm/simulators/flow/FlowUtils.hpp b/opm/simulators/flow/FlowUtils.hpp index d44607521..3eee572de 100644 --- a/opm/simulators/flow/FlowUtils.hpp +++ b/opm/simulators/flow/FlowUtils.hpp @@ -36,7 +36,7 @@ void mergeParallelLogFiles(std::string_view output_dir, std::string_view deck_filename, bool enableLoggingFalloutWarning); -void handleExtraConvergenceOutput(SimulatorReport& report, +void handleExtraConvergenceOutput(const SimulatorReport& report, std::string_view option, std::string_view optionName, std::string_view output_dir, diff --git a/opm/simulators/flow/GenericThresholdPressure_impl.hpp b/opm/simulators/flow/GenericThresholdPressure_impl.hpp index 8a7e2910f..322f3e771 100644 --- a/opm/simulators/flow/GenericThresholdPressure_impl.hpp +++ b/opm/simulators/flow/GenericThresholdPressure_impl.hpp @@ -216,7 +216,7 @@ configureThpresft_() thpresftValues_.resize(numFaults, -1.0); cartElemFaultIdx_.resize(numCartesianElem, -1); for (std::size_t faultIdx = 0; faultIdx < faults.size(); ++faultIdx) { - auto& fault = faults.getFault(faultIdx); + const auto& fault = faults.getFault(faultIdx); thpresftValues_[faultIdx] = thpres.getThresholdPressureFault(faultIdx); for (const FaultFace& face : fault) { // "face" is a misnomer because the object describes a set of cell diff --git a/opm/simulators/flow/InterRegFlows.cpp b/opm/simulators/flow/InterRegFlows.cpp index 2f6aa5634..d7db02e72 100644 --- a/opm/simulators/flow/InterRegFlows.cpp +++ b/opm/simulators/flow/InterRegFlows.cpp @@ -190,7 +190,7 @@ Opm::InterRegFlowMap::getInterRegFlows() const auto maps = std::vector{}; maps.reserve(this->regionMaps_.size()); - for (auto& regionMap : this->regionMaps_) { + for (const auto& regionMap : this->regionMaps_) { maps.push_back(regionMap.getInterRegFlows()); } @@ -203,7 +203,7 @@ Opm::InterRegFlowMap::getLocalMaxRegionID() const auto maxLocalRegionID = std::vector{}; maxLocalRegionID.reserve(this->regionMaps_.size()); - for (auto& regionMap : this->regionMaps_) { + for (const auto& regionMap : this->regionMaps_) { maxLocalRegionID.push_back(regionMap.getLocalMaxRegionID()); } diff --git a/opm/simulators/flow/OutputBlackoilModule.hpp b/opm/simulators/flow/OutputBlackoilModule.hpp index 176d5181a..72f9a9417 100644 --- a/opm/simulators/flow/OutputBlackoilModule.hpp +++ b/opm/simulators/flow/OutputBlackoilModule.hpp @@ -711,7 +711,7 @@ public: if (!problem.model().linearizer().getFlowsInfo().empty()) { const auto& flowsInf = problem.model().linearizer().getFlowsInfo(); auto flowsInfos = flowsInf[globalDofIdx]; - for (auto& flowsInfo : flowsInfos) { + for (const auto& flowsInfo : flowsInfos) { if (flowsInfo.faceId >= 0) { if (!this->flows_[flowsInfo.faceId][gasCompIdx].empty()) { this->flows_[flowsInfo.faceId][gasCompIdx][globalDofIdx] @@ -750,7 +750,7 @@ public: if (!problem.model().linearizer().getFloresInfo().empty()) { const auto& floresInf = problem.model().linearizer().getFloresInfo(); auto floresInfos =floresInf[globalDofIdx]; - for (auto& floresInfo : floresInfos) { + for (const auto& floresInfo : floresInfos) { if (floresInfo.faceId >= 0) { if (!this->flores_[floresInfo.faceId][gasCompIdx].empty()) { this->flores_[floresInfo.faceId][gasCompIdx][globalDofIdx] diff --git a/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp b/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp index 459969f85..f828fcbc7 100644 --- a/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp +++ b/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp @@ -244,7 +244,7 @@ public: #ifdef RESERVOIR_COUPLING_ENABLED // NOTE: The argc and argv will be used when launching a slave process - void init(SimulatorTimer &timer, int argc, char** argv) + void init(const SimulatorTimer& timer, int argc, char** argv) { auto slave_mode = Parameters::Get(); if (slave_mode) { @@ -269,7 +269,7 @@ public: } } #else - void init(SimulatorTimer &timer) + void init(const SimulatorTimer& timer) { #endif simulator_.setEpisodeIndex(-1); diff --git a/opm/simulators/flow/TracerModel.hpp b/opm/simulators/flow/TracerModel.hpp index 6ea2d23b2..8d34b7568 100644 --- a/opm/simulators/flow/TracerModel.hpp +++ b/opm/simulators/flow/TracerModel.hpp @@ -616,7 +616,7 @@ protected: if (elem.partitionType() != Dune::InteriorEntity) { // Dirichlet boundary conditions needed for the parallel matrix - for (auto& tr : tbatch) { + for (const auto& tr : tbatch) { if (tr.numTracer() != 0) { (*tr.mat)[I][I][0][0] = 1.; (*tr.mat)[I][I][1][1] = 1.; diff --git a/opm/simulators/linalg/gpubridge/BlockedMatrix.cpp b/opm/simulators/linalg/gpubridge/BlockedMatrix.cpp index 2cc2433f2..526ebe8ad 100644 --- a/opm/simulators/linalg/gpubridge/BlockedMatrix.cpp +++ b/opm/simulators/linalg/gpubridge/BlockedMatrix.cpp @@ -61,7 +61,7 @@ void sortRow(int *colIndices, int *data, int left, int right) // LUMat->nnzValues[ik] = LUMat->nnzValues[ik] - (pivot * LUMat->nnzValues[jk]) in ilu decomposition // a = a - (b * c) template -void blockMultSub(Scalar* a, Scalar* b, Scalar* c, unsigned int block_size) +void blockMultSub(Scalar* a, const Scalar* b, const Scalar* c, unsigned int block_size) { for (unsigned int row = 0; row < block_size; row++) { for (unsigned int col = 0; col < block_size; col++) { @@ -76,7 +76,8 @@ void blockMultSub(Scalar* a, Scalar* b, Scalar* c, unsigned int block_size) /*Perform a 3x3 matrix-matrix multiplicationj on two blocks*/ template -void blockMult(Scalar* mat1, Scalar* mat2, Scalar* resMat, unsigned int block_size) +void blockMult(const Scalar* mat1, const Scalar* mat2, + Scalar* resMat, unsigned int block_size) { for (unsigned int row = 0; row < block_size; row++) { for (unsigned int col = 0; col < block_size; col++) { @@ -90,8 +91,8 @@ void blockMult(Scalar* mat1, Scalar* mat2, Scalar* resMat, unsigned int block_si } #define INSTANTIATE_TYPE(T) \ - template void blockMultSub(T*, T*, T*, unsigned int); \ - template void blockMult(T*, T*, T*, unsigned int); + template void blockMultSub(T*, const T*, const T*, unsigned int); \ + template void blockMult(const T*, const T*, T*, unsigned int); INSTANTIATE_TYPE(double) diff --git a/opm/simulators/linalg/gpubridge/BlockedMatrix.hpp b/opm/simulators/linalg/gpubridge/BlockedMatrix.hpp index fa8f3e80d..57dc702e3 100644 --- a/opm/simulators/linalg/gpubridge/BlockedMatrix.hpp +++ b/opm/simulators/linalg/gpubridge/BlockedMatrix.hpp @@ -111,7 +111,8 @@ void sortRow(int* colIndices, int* data, int left, int right); /// \param[in] c input block /// \param[in] block_size size of block template -void blockMultSub(Scalar* a, Scalar* b, Scalar* c, unsigned int block_size); +void blockMultSub(Scalar* a, const Scalar* b, + const Scalar* c, unsigned int block_size); /// Perform a matrix-matrix multiplication on two blocks /// resMat = mat1 * mat2 diff --git a/opm/simulators/linalg/gpubridge/Reorder.cpp b/opm/simulators/linalg/gpubridge/Reorder.cpp index f8d029c5e..642202104 100644 --- a/opm/simulators/linalg/gpubridge/Reorder.cpp +++ b/opm/simulators/linalg/gpubridge/Reorder.cpp @@ -61,10 +61,10 @@ bool canBeStarted(const int rowIndex, * "Iterative methods for Sparse Linear Systems" by Yousef Saad in section 11.6.3 */ -void findLevelScheduling(int* CSRColIndices, - int* CSRRowPointers, - int* CSCRowIndices, - int* CSCColPointers, +void findLevelScheduling(const int* CSRColIndices, + const int* CSRRowPointers, + const int* CSCRowIndices, + const int* CSCColPointers, int Nb, int* numColors, int* toOrder, @@ -129,8 +129,8 @@ void findLevelScheduling(int* CSRColIndices, } // based on the scipy package from python, scipy/sparse/sparsetools/csr.h on github -void csrPatternToCsc(int* CSRColIndices, - int* CSRRowPointers, +void csrPatternToCsc(const int* CSRColIndices, + const int* CSRRowPointers, int* CSCRowIndices, int* CSCColPointers, int Nb) diff --git a/opm/simulators/linalg/gpubridge/Reorder.hpp b/opm/simulators/linalg/gpubridge/Reorder.hpp index 0e75bc7fc..c81d8d601 100644 --- a/opm/simulators/linalg/gpubridge/Reorder.hpp +++ b/opm/simulators/linalg/gpubridge/Reorder.hpp @@ -46,10 +46,10 @@ bool canBeStarted(const int rowIndex, /// \param[out] toOrder the reorder pattern that was found, which lists for each index in the original order, to which index in the new order it should be moved /// \param[out] fromOrder the reorder pattern that was found, which lists for each index in the new order, from which index in the original order it was moved /// \param[out] rowsPerColor for each color, an array of all rowIndices in that color, this function uses emplace_back() to fill -void findLevelScheduling(int* CSRColIndices, - int* CSRRowPointers, - int* CSCRowIndices, - int* CSCColPointers, +void findLevelScheduling(const int* CSRColIndices, + const int* CSRRowPointers, + const int* CSCRowIndices, + const int* CSCColPointers, int Nb, int* numColors, int* toOrder, @@ -64,8 +64,8 @@ void findLevelScheduling(int* CSRColIndices, /// \param[inout] CSCRowIndices row indices of the result CSC representation of the pattern /// \param[inout] CSCColPointers column pointers of the result CSC representation of the pattern /// \param[in] Nb number of blockrows in the matrix -void csrPatternToCsc(int* CSRColIndices, - int* CSRRowPointers, +void csrPatternToCsc(const int* CSRColIndices, + const int* CSRRowPointers, int* CSCRowIndices, int* CSCColPointers, int Nb); diff --git a/opm/simulators/linalg/gpubridge/amgclSolverBackend.cpp b/opm/simulators/linalg/gpubridge/amgclSolverBackend.cpp index a43424dda..5582d8ebf 100644 --- a/opm/simulators/linalg/gpubridge/amgclSolverBackend.cpp +++ b/opm/simulators/linalg/gpubridge/amgclSolverBackend.cpp @@ -163,7 +163,7 @@ void amgclSolverBackend::initialize(int Nb_, int nnzbs) template void amgclSolverBackend:: -convert_sparsity_pattern(int* rows, int* cols) +convert_sparsity_pattern(const int* rows, const int* cols) { Timer t; const unsigned int bs = block_size; @@ -193,7 +193,7 @@ convert_sparsity_pattern(int* rows, int* cols) template void amgclSolverBackend:: -convert_data(Scalar* vals, int* rows) +convert_data(const Scalar* vals, const int* rows) { Timer t; const unsigned int bs = block_size; diff --git a/opm/simulators/linalg/gpubridge/amgclSolverBackend.hpp b/opm/simulators/linalg/gpubridge/amgclSolverBackend.hpp index a9b4e0e3a..a69159bfd 100644 --- a/opm/simulators/linalg/gpubridge/amgclSolverBackend.hpp +++ b/opm/simulators/linalg/gpubridge/amgclSolverBackend.hpp @@ -105,12 +105,12 @@ private: /// Convert the BCSR sparsity pattern to a CSR one /// \param[in] rows array of rowPointers, contains N/dim+1 values /// \param[in] cols array of columnIndices, contains nnz values - void convert_sparsity_pattern(int *rows, int *cols); + void convert_sparsity_pattern(const int *rows, const int *cols); /// Convert the BCSR nonzero data to a CSR format /// \param[in] vals array of nonzeroes, each block is stored row-wise and contiguous, contains nnz values /// \param[in] rows array of rowPointers, contains N/dim+1 values - void convert_data(Scalar* vals, int* rows); + void convert_data(const Scalar* vals, const int* rows); /// Solve linear system /// \param[in] b pointer to b vector diff --git a/opm/simulators/linalg/gpubridge/opencl/openclBILU0.cpp b/opm/simulators/linalg/gpubridge/opencl/openclBILU0.cpp index 138eae98c..f4dbbc9e6 100644 --- a/opm/simulators/linalg/gpubridge/opencl/openclBILU0.cpp +++ b/opm/simulators/linalg/gpubridge/opencl/openclBILU0.cpp @@ -194,7 +194,7 @@ create_preconditioner(BlockedMatrix* mat, BlockedMatrix* jacMat) { const unsigned int bs = block_size; - auto *matToDecompose = jacMat ? jacMat : mat; + const auto* matToDecompose = jacMat ? jacMat : mat; bool use_multithreading = true; #if HAVE_OPENMP diff --git a/opm/simulators/linalg/gpuistl/GpuOwnerOverlapCopy.hpp b/opm/simulators/linalg/gpuistl/GpuOwnerOverlapCopy.hpp index 6b7012d8d..fd5a7613a 100644 --- a/opm/simulators/linalg/gpuistl/GpuOwnerOverlapCopy.hpp +++ b/opm/simulators/linalg/gpuistl/GpuOwnerOverlapCopy.hpp @@ -285,11 +285,11 @@ private: void buildCommPairIdxs() const { - auto &ri = this->m_cpuOwnerOverlapCopy.remoteIndices(); + const auto& ri = this->m_cpuOwnerOverlapCopy.remoteIndices(); std::vector commpairIndicesCopyOnCPU; std::vector commpairIndicesOwnerCPU; - for (auto process : ri) { + for (const auto& process : ri) { m_im[process.first] = std::pair(std::vector(), std::vector()); for (int send = 0; send < 2; ++send) { auto remoteEnd = send ? process.second.first->end() diff --git a/opm/simulators/linalg/twolevelmethodcpr.hh b/opm/simulators/linalg/twolevelmethodcpr.hh index d211bd955..f955a5bc2 100644 --- a/opm/simulators/linalg/twolevelmethodcpr.hh +++ b/opm/simulators/linalg/twolevelmethodcpr.hh @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -193,13 +194,8 @@ public: ParallelInformation pinfo; std::size_t aggregates = coarsen(renumberer, pinfo, pg, vm,*aggregatesMap_, noAggregates, true); - std::vector& visited=excluded; - typedef std::vector::iterator Iterator; - - for(Iterator iter= visited.begin(), end=visited.end(); - iter != end; ++iter) - *iter=false; + std::fill(excluded.begin(), excluded.end(), false); matrix_.reset(productBuilder.build(mg, vm, SequentialInformation(), *aggregatesMap_, diff --git a/opm/simulators/utils/ParallelNLDDPartitioningZoltan.cpp b/opm/simulators/utils/ParallelNLDDPartitioningZoltan.cpp index 53726c5d0..d14aa263b 100644 --- a/opm/simulators/utils/ParallelNLDDPartitioningZoltan.cpp +++ b/opm/simulators/utils/ParallelNLDDPartitioningZoltan.cpp @@ -542,7 +542,7 @@ extern "C" { if (cells.empty()) { return; } const auto first = parts[cells.front()]; - for (auto& cell : cells) { + for (const auto& cell : cells) { parts[cell] = first; } } diff --git a/opm/simulators/wells/BlackoilWellModel.hpp b/opm/simulators/wells/BlackoilWellModel.hpp index 2f957ed91..04f399e8e 100644 --- a/opm/simulators/wells/BlackoilWellModel.hpp +++ b/opm/simulators/wells/BlackoilWellModel.hpp @@ -259,7 +259,7 @@ template class WellContributions; // add source from wells to the reservoir matrix void addReservoirSourceTerms(GlobalEqVector& residual, - std::vector& diagMatAddress) const; + const std::vector& diagMatAddress) const; // called at the beginning of a report step void beginReportStep(const int time_step); diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index c19d664f7..3635bb83c 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -1906,7 +1906,7 @@ getMaxWellConnections() const const auto possibleFutureConnectionSetIt = possibleFutureConnections.find(well.name()); if (possibleFutureConnectionSetIt != possibleFutureConnections.end()) { - for (auto& global_index : possibleFutureConnectionSetIt->second) { + for (const auto& global_index : possibleFutureConnectionSetIt->second) { int compressed_idx = compressedIndexForInterior(global_index); if (compressed_idx >= 0) { // Ignore connections in inactive/remote cells. compressed_well_perforations.push_back(compressed_idx); diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index fcb82ca9b..a8ed5693f 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -433,7 +433,7 @@ namespace Opm { // have proper multi-phase rates proportional to rates at bhp zero. // This is done only for producers, as injectors will only have a single // nonzero phase anyway. - for (auto& well : well_container_) { + for (const auto& well : well_container_) { const bool zero_target = well->stoppedOrZeroRateTarget(simulator_, this->wellState(), local_deferredLogger); if (well->isProducer() && !zero_target) { well->updateWellStateRates(simulator_, this->wellState(), local_deferredLogger); @@ -441,7 +441,7 @@ namespace Opm { } } - for (auto& well : well_container_) { + for (const auto& well : well_container_) { if (well->isVFPActive(local_deferredLogger)){ well->setPrevSurfaceRates(this->wellState(), this->prevWellState()); } @@ -478,7 +478,7 @@ namespace Opm { auto exc_type = ExceptionType::NONE; // update gpmaint targets if (this->schedule_[reportStepIdx].has_gpmaint()) { - for (auto& calculator : regionalAveragePressureCalculator_) { + for (const auto& calculator : regionalAveragePressureCalculator_) { calculator.second->template defineState(simulator_); } const double dt = simulator_.timeStepSize(); @@ -1641,7 +1641,7 @@ namespace Opm { template void BlackoilWellModel:: addReservoirSourceTerms(GlobalEqVector& residual, - std::vector& diagMatAddress) const + const std::vector& diagMatAddress) const { // NB this loop may write multiple times to the same element // if a cell is perforated by more than one well, so it should @@ -2022,7 +2022,7 @@ namespace Opm { // if a well or group change control it affects all wells that are under the same group for (const auto& well : well_container_) { // We only want to update wells under group-control here - auto& ws = this->wellState().well(well->indexOfWell()); + const auto& ws = this->wellState().well(well->indexOfWell()); if (ws.production_cmode == Well::ProducerCMode::GRUP || ws.injection_cmode == Well::InjectorCMode::GRUP) { diff --git a/opm/simulators/wells/GasLiftSingleWellGeneric.cpp b/opm/simulators/wells/GasLiftSingleWellGeneric.cpp index a6036125b..c7f760b31 100644 --- a/opm/simulators/wells/GasLiftSingleWellGeneric.cpp +++ b/opm/simulators/wells/GasLiftSingleWellGeneric.cpp @@ -1590,7 +1590,7 @@ template void GasLiftSingleWellGeneric:: updateWellStateAlqFixedValue_(const GasLiftWell& well) { - auto& max_alq_optional = well.max_rate(); + const auto& max_alq_optional = well.max_rate(); if (max_alq_optional) { // According to WLIFTOPT, item 3: // If item 2 is NO, then item 3 is regarded as the fixed diff --git a/opm/simulators/wells/GasLiftSingleWell_impl.hpp b/opm/simulators/wells/GasLiftSingleWell_impl.hpp index 78a9d2ff8..f06a53d78 100644 --- a/opm/simulators/wells/GasLiftSingleWell_impl.hpp +++ b/opm/simulators/wells/GasLiftSingleWell_impl.hpp @@ -215,7 +215,7 @@ void GasLiftSingleWell:: setAlqMaxRate_(const GasLiftWell& well) { - auto& max_alq_optional = well.max_rate(); + const auto& max_alq_optional = well.max_rate(); if (max_alq_optional) { // NOTE: To prevent extrapolation of the VFP tables, any value // entered here must not exceed the largest ALQ value in the well's VFP table. diff --git a/opm/simulators/wells/GasLiftStage2.cpp b/opm/simulators/wells/GasLiftStage2.cpp index 85ffad70e..05a2cc336 100644 --- a/opm/simulators/wells/GasLiftStage2.cpp +++ b/opm/simulators/wells/GasLiftStage2.cpp @@ -474,7 +474,7 @@ recalculateGradientAndUpdateData_(GradPairItr& grad_itr, // only applies to wells in the well_state_map (i.e. wells on this rank) // the grads and other grads are synchronized later if(this->stage1_wells_.count(name) > 0) { - GasLiftSingleWell &gs_well = *(this->stage1_wells_.at(name).get()); + const GasLiftSingleWell& gs_well = *(this->stage1_wells_.at(name).get()); { auto grad = calcIncOrDecGrad_(name, gs_well, gr_name_dont_limit, increase); if (grad) { diff --git a/opm/simulators/wells/GroupState.hpp b/opm/simulators/wells/GroupState.hpp index e98a77d9f..06bf1466f 100644 --- a/opm/simulators/wells/GroupState.hpp +++ b/opm/simulators/wells/GroupState.hpp @@ -121,7 +121,7 @@ public: // Create a function that calls some function // for all the individual data items to simplify // the further code. - auto iterateContainer = [](auto& container, auto& func) { + auto iterateContainer = [](auto& container, const auto& func) { for (auto& x : container) { func(x.second); } diff --git a/opm/simulators/wells/WellConnectionAuxiliaryModule.hpp b/opm/simulators/wells/WellConnectionAuxiliaryModule.hpp index 72ff79ed6..ce6203a18 100644 --- a/opm/simulators/wells/WellConnectionAuxiliaryModule.hpp +++ b/opm/simulators/wells/WellConnectionAuxiliaryModule.hpp @@ -81,7 +81,7 @@ public: // Now add the cells of the possible future connections const auto possibleFutureConnectionSetIt = possibleFutureConnections.find(well.name()); if (possibleFutureConnectionSetIt != possibleFutureConnections.end()) { - for (auto& global_index : possibleFutureConnectionSetIt->second) { + for (const auto& global_index : possibleFutureConnectionSetIt->second) { int compressed_idx = model_.compressedIndexForInterior(global_index); if (compressed_idx >= 0) { // Ignore connections in inactive/remote cells. wellCells.push_back(compressed_idx); @@ -126,7 +126,7 @@ public: } } - void postSolveDomain(GlobalEqVector& deltaX, const Domain& domain) + void postSolveDomain(const GlobalEqVector& deltaX, const Domain& domain) { model_.recoverWellSolutionAndUpdateWellStateDomain(deltaX, domain); } diff --git a/opm/simulators/wells/WellInterface_impl.hpp b/opm/simulators/wells/WellInterface_impl.hpp index bdcb89811..827ba55e6 100644 --- a/opm/simulators/wells/WellInterface_impl.hpp +++ b/opm/simulators/wells/WellInterface_impl.hpp @@ -476,7 +476,7 @@ namespace Opm deferred_logger.info(msg); // also reopen completions - for (auto& completion : this->well_ecl_.getCompletions()) { + for (const auto& completion : this->well_ecl_.getCompletions()) { if (!welltest_state_temp.completion_is_closed(this->name(), completion.first)) well_test_state.open_completion(this->name(), completion.first); } diff --git a/tests/test_openclSolver.cpp b/tests/test_openclSolver.cpp index 99050fa63..8dada17f1 100644 --- a/tests/test_openclSolver.cpp +++ b/tests/test_openclSolver.cpp @@ -116,7 +116,8 @@ createBridge(const boost::property_tree::ptree& prm, std::unique_ptr Dune::BlockVector> -testOpenclSolver(Opm::GpuBridge, Vector, bz>& bridge, Matrix& matrix, Vector& rhs) +testOpenclSolver(Opm::GpuBridge, Vector, bz>& bridge, + const Matrix& matrix, Vector& rhs) { Dune::InverseOperatorResult result; Vector x(rhs.size()); @@ -131,7 +132,8 @@ testOpenclSolver(Opm::GpuBridge, Vector, bz>& bridge, Matrix& template Dune::BlockVector> -testOpenclSolverJacobi(Opm::GpuBridge, Vector, bz>& bridge, Matrix& matrix, Vector& rhs) +testOpenclSolverJacobi(Opm::GpuBridge, Vector, bz>& bridge, + const Matrix& matrix, Vector& rhs) { Dune::InverseOperatorResult result; Vector x(rhs.size());