diff --git a/msim/include/opm/msim/msim.hpp b/msim/include/opm/msim/msim.hpp index 92565f73ee1..a21c576de53 100644 --- a/msim/include/opm/msim/msim.hpp +++ b/msim/include/opm/msim/msim.hpp @@ -42,9 +42,23 @@ class msim { void post_step(data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, const time_point& sim_time); private: + void run_step(const WellTestState& wtest_state, + UDQState& udq_state, + data::Solution& sol, + data::Wells& well_data, + data::GroupAndNetworkValues& group_nwrk_data, + size_t report_step, + EclipseIO& io); + + void run_step(const WellTestState& wtest_state, + UDQState& udq_state, + data::Solution& sol, + data::Wells& well_data, + data::GroupAndNetworkValues& group_nwrk_data, + size_t report_step, + double dt, + EclipseIO& io); - void run_step(WellTestState& wtest_state, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, EclipseIO& io); - void run_step(WellTestState& wtest_state, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, double dt, EclipseIO& io); void output(const WellTestState& wtest_state, const UDQState& udq_state, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, diff --git a/msim/src/msim.cpp b/msim/src/msim.cpp index 34566294cfe..9b4064bf098 100644 --- a/msim/src/msim.cpp +++ b/msim/src/msim.cpp @@ -148,7 +148,7 @@ void msim::post_step(data::Solution& /* sol */, } -void msim::run_step(WellTestState& wtest_state, +void msim::run_step(const WellTestState& wtest_state, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, @@ -160,7 +160,7 @@ void msim::run_step(WellTestState& wtest_state, report_step, schedule.stepLength(report_step - 1), io); } -void msim::run_step(WellTestState& wtest_state, +void msim::run_step(const WellTestState& wtest_state, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, diff --git a/opm/input/eclipse/Schedule/KeywordHandlers.cpp b/opm/input/eclipse/Schedule/KeywordHandlers.cpp index 8ef94af0fba..61c17654d41 100644 --- a/opm/input/eclipse/Schedule/KeywordHandlers.cpp +++ b/opm/input/eclipse/Schedule/KeywordHandlers.cpp @@ -70,12 +70,12 @@ namespace Opm { namespace { -void handleAQUCT(HandlerContext& handlerContext) +void handleAQUCT(const HandlerContext& handlerContext) { throw OpmInputError("AQUCT is not supported as SCHEDULE keyword", handlerContext.keyword.location()); } -void handleAQUFETP(HandlerContext& handlerContext) +void handleAQUFETP(const HandlerContext& handlerContext) { throw OpmInputError("AQUFETP is not supported as SCHEDULE keyword", handlerContext.keyword.location()); } diff --git a/opm/input/eclipse/Schedule/Schedule.cpp b/opm/input/eclipse/Schedule/Schedule.cpp index 1b6277f04d1..ad243dc1640 100644 --- a/opm/input/eclipse/Schedule/Schedule.cpp +++ b/opm/input/eclipse/Schedule/Schedule.cpp @@ -455,7 +455,7 @@ namespace /// \brief Check whether each MS well has COMPSEGS entry andissue error if not. /// \param welsegs All wells with a WELSEGS entry together with the location. /// \param compegs All wells with a COMPSEGS entry -void check_compsegs_consistency(Opm::WelSegsSet& welsegs, +void check_compsegs_consistency(const Opm::WelSegsSet& welsegs, const std::set& compsegs, const std::vector<::Opm::Well>& wells) { diff --git a/opm/input/eclipse/Schedule/UDQ/UDQConfig.cpp b/opm/input/eclipse/Schedule/UDQ/UDQConfig.cpp index 44ab3842fb6..d12445bded9 100644 --- a/opm/input/eclipse/Schedule/UDQ/UDQConfig.cpp +++ b/opm/input/eclipse/Schedule/UDQ/UDQConfig.cpp @@ -608,7 +608,7 @@ namespace Opm { } void UDQConfig::eval_define(const std::size_t report_step, - UDQState& udq_state, + const UDQState& udq_state, UDQContext& context) const { auto var_type_bit = [](const UDQVarType var_type) diff --git a/opm/input/eclipse/Schedule/UDQ/UDQConfig.hpp b/opm/input/eclipse/Schedule/UDQ/UDQConfig.hpp index 87d11eb03cc..28e8fef5959 100644 --- a/opm/input/eclipse/Schedule/UDQ/UDQConfig.hpp +++ b/opm/input/eclipse/Schedule/UDQ/UDQConfig.hpp @@ -196,7 +196,7 @@ namespace Opm { UDQContext& context) const; void eval_define(std::size_t report_step, - UDQState& udq_state, + const UDQState& udq_state, UDQContext& context) const; void add_named_assign(const std::string& quantity, diff --git a/opm/io/eclipse/SummaryNode.cpp b/opm/io/eclipse/SummaryNode.cpp index 13e72915d34..f8372d2dd56 100644 --- a/opm/io/eclipse/SummaryNode.cpp +++ b/opm/io/eclipse/SummaryNode.cpp @@ -151,7 +151,7 @@ std::string Opm::EclIO::SummaryNode::unique_key(number_renderer render_number) c if (auto opt = display_number(render_number)) key_parts.emplace_back(opt.value()); - auto compose_key = [](std::string& key, const std::string& key_part) -> std::string { + auto compose_key = [](const std::string& key, const std::string& key_part) -> std::string { constexpr auto delimiter { ':' } ; return key.empty() ? key_part : key + delimiter + key_part; }; diff --git a/opm/output/eclipse/AggregateActionxData.hpp b/opm/output/eclipse/AggregateActionxData.hpp index ba2fca8bbc1..20e5bbcb809 100644 --- a/opm/output/eclipse/AggregateActionxData.hpp +++ b/opm/output/eclipse/AggregateActionxData.hpp @@ -25,9 +25,7 @@ #include #include -#include #include -#include namespace Opm { class Actdims; diff --git a/opm/output/eclipse/AggregateNetworkData.cpp b/opm/output/eclipse/AggregateNetworkData.cpp index 00f5b099a2f..0f20d5aa64a 100644 --- a/opm/output/eclipse/AggregateNetworkData.cpp +++ b/opm/output/eclipse/AggregateNetworkData.cpp @@ -120,7 +120,7 @@ std::optional findInVector(const std::vector & vecOfElements, const T return (it != vecOfElements.end()) ? std::optional{std::distance(vecOfElements.begin(), it)} : std::nullopt; } -int next_branch(int node_no, std::vector& inlets, std::vector& outlets) +int next_branch(int node_no, const std::vector& inlets, const std::vector& outlets) { int nxt_br = 0; auto res_inlets = findInVector(inlets, node_no); diff --git a/opm/output/eclipse/EclipseGridInspector.cpp b/opm/output/eclipse/EclipseGridInspector.cpp index b667cd0a51d..9835abd642f 100644 --- a/opm/output/eclipse/EclipseGridInspector.cpp +++ b/opm/output/eclipse/EclipseGridInspector.cpp @@ -225,31 +225,31 @@ double EclipseGridInspector::cellVolumeVerticalPillars(int i, int j, int k) cons // Computing the base area as half the 2d cross product of the diagonals. int numxpill = logical_gridsize_[0] + 1; int pix = i + j*numxpill; - double px[4] = { pillc[6*pix], - pillc[6*(pix + 1)], - pillc[6*(pix + numxpill)], - pillc[6*(pix + numxpill + 1)] }; - double py[4] = { pillc[6*pix + 1], - pillc[6*(pix + 1) + 1], - pillc[6*(pix + numxpill) + 1], - pillc[6*(pix + numxpill + 1) + 1] }; - double diag1[2] = { px[3] - px[0], py[3] - py[0] }; - double diag2[2] = { px[2] - px[1], py[2] - py[1] }; - double area = 0.5*(diag1[0]*diag2[1] - diag1[1]*diag2[0]); + const double px[4] = {pillc[6 * pix], + pillc[6 * (pix + 1)], + pillc[6 * (pix + numxpill)], + pillc[6 * (pix + numxpill + 1)]}; + const double py[4] = {pillc[6 * pix + 1], + pillc[6 * (pix + 1) + 1], + pillc[6 * (pix + numxpill) + 1], + pillc[6 * (pix + numxpill + 1) + 1]}; + const double diag1[2] = {px[3] - px[0], py[3] - py[0]}; + const double diag2[2] = {px[2] - px[1], py[2] - py[1]}; + const double area = 0.5*(diag1[0] * diag2[1] - diag1[1] * diag2[0]); // Computing the average of the z-differences along each pillar. - int delta[3] = { 1, - 2*logical_gridsize_[0], - 4*logical_gridsize_[0]*logical_gridsize_[1] }; + const int delta[3] = {1, + 2 * logical_gridsize_[0], + 4 * logical_gridsize_[0] * logical_gridsize_[1]}; int ix = 2*(i*delta[0] + j*delta[1] + k*delta[2]); - double cellz[8] = { z[ix], z[ix + delta[0]], - z[ix + delta[1]], z[ix + delta[1] + delta[0]], - z[ix + delta[2]], z[ix + delta[2] + delta[0]], - z[ix + delta[2] + delta[1]], z[ix + delta[2] + delta[1] + delta[0]] }; - double diffz[4] = { cellz[4] - cellz[0], - cellz[5] - cellz[1], - cellz[6] - cellz[2], - cellz[7] - cellz[3] }; + const double cellz[8] = {z[ix], z[ix + delta[0]], + z[ix + delta[1]], z[ix + delta[1] + delta[0]], + z[ix + delta[2]], z[ix + delta[2] + delta[0]], + z[ix + delta[2] + delta[1]], z[ix + delta[2] + delta[1] + delta[0]]}; + const double diffz[4] = {cellz[4] - cellz[0], + cellz[5] - cellz[1], + cellz[6] - cellz[2], + cellz[7] - cellz[3]}; double averzdiff = 0.25*std::accumulate(diffz, diffz + 4, 0.0); return averzdiff*area; } diff --git a/opm/output/eclipse/report/WELSPECS.cpp b/opm/output/eclipse/report/WELSPECS.cpp index 6ad5b6534f0..91449c6a072 100644 --- a/opm/output/eclipse/report/WELSPECS.cpp +++ b/opm/output/eclipse/report/WELSPECS.cpp @@ -435,7 +435,7 @@ namespace { std::string grid_block(const context&, std::size_t, std::size_t) const { const std::array ijk { connection.getI() + 1, connection.getJ() + 1, connection.getK() + 1 } ; - auto compose_coordinates { [](std::string& out, int in) -> std::string { + auto compose_coordinates { [](const std::string& out, const int in) -> std::string { constexpr auto delimiter { ',' } ; std::string coordinate_part { std::to_string(in) } ; right_align(coordinate_part, 3); diff --git a/test_util/EclFilesComparator.cpp b/test_util/EclFilesComparator.cpp index 04d6e4127bb..ba57582b0d2 100644 --- a/test_util/EclFilesComparator.cpp +++ b/test_util/EclFilesComparator.cpp @@ -26,9 +26,7 @@ #include #include #include -#include #include -#include #include #include @@ -46,7 +44,14 @@ using Opm::EclIO::EGrid; template -void ECLFilesComparator::printValuesForCell(const std::string& keyword, const std::string& reference, size_t kw_size, size_t cell, EGrid *grid, const T& value1, const T& value2) const { +void ECLFilesComparator:: +printValuesForCell(const std::string& keyword, + const std::string& reference, + size_t kw_size, size_t cell, + const EGrid *grid, + const T& value1, + const T& value2) const +{ if (grid) { int nActive = grid->activeCells(); int nTot = grid->totalNumberOfCells(); @@ -85,15 +90,24 @@ void ECLFilesComparator::printValuesForCell(const std::string& keyword, const st << "(first value, second value) = (" << value1 << ", " << value2 << ")\n\n"; } -template void ECLFilesComparator::printValuesForCell (const std::string& keyword, const std::string& reference, size_t kw_size, size_t cell, EGrid *grid, const bool& value1, const bool& value2) const; -template void ECLFilesComparator::printValuesForCell (const std::string& keyword, const std::string& reference, size_t kw_size, size_t cell, EGrid *grid, const int& value1, const int& value2) const; -template void ECLFilesComparator::printValuesForCell (const std::string& keyword, const std::string& reference, size_t kw_size, size_t cell, EGrid *grid, const double& value1, const double& value2) const; -template void ECLFilesComparator::printValuesForCell(const std::string& keyword, const std::string& reference, size_t kw_size, size_t cell, EGrid *grid, const std::string& value1, const std::string& value2) const; +#define INSTANTIATE_PRINTCELL(T) \ + template void ECLFilesComparator::printValuesForCell(const std::string&, \ + const std::string&, \ + size_t, size_t, \ + const EGrid *grid, \ + const T&, \ + const T&) const; + // Hack to work around case where std::vector::const_reference is not a bool. If it is we will initialize printValuesForCell otherwise printValuesForCell::const_reference> using boolConstReference = typename std::vector::const_reference; using boolTypeHelper = typename std::remove_const::type>::type; using boolType = typename std::conditional::value, char, boolTypeHelper>::type; -template void ECLFilesComparator::printValuesForCell (const std::string& keyword, const std::string& reference, size_t kw_size, size_t cell, EGrid *grid, const boolType& value1, const boolType& value2) const; + +INSTANTIATE_PRINTCELL(bool) +INSTANTIATE_PRINTCELL(int) +INSTANTIATE_PRINTCELL(double) +INSTANTIATE_PRINTCELL(std::string) +INSTANTIATE_PRINTCELL(boolType) ECLFilesComparator::ECLFilesComparator(const std::string& basename1, const std::string& basename2, diff --git a/test_util/EclFilesComparator.hpp b/test_util/EclFilesComparator.hpp index 193fc98dada..6fd54aafd99 100644 --- a/test_util/EclFilesComparator.hpp +++ b/test_util/EclFilesComparator.hpp @@ -81,7 +81,7 @@ class ECLFilesComparator { const std::string& reference, size_t kw_size, size_t cell, - Opm::EclIO::EGrid *grid, + const Opm::EclIO::EGrid *grid, const T& value1, const T& value2) const; diff --git a/test_util/convertECL.cpp b/test_util/convertECL.cpp index 6b4b719ec02..da90cf1279b 100644 --- a/test_util/convertECL.cpp +++ b/test_util/convertECL.cpp @@ -84,14 +84,17 @@ void writeArray(std::string name, eclArrType arrType, T& file1, int index, int r } -void writeC0nnArray(std::string name, int elementSize, EclFile& file1, int index, EclOutput& outFile) +void writeC0nnArray(const std::string& name, int elementSize, EclFile& file1, int index, EclOutput& outFile) { auto vect = file1.get(index); outFile.write(name, vect, elementSize); } -void writeArrayList(std::vector& arrayList, std::vector& elementSizeList, EclFile file1, EclOutput& outFile) { +void writeArrayList(std::vector& arrayList, + const std::vector& elementSizeList, + EclFile& file1, EclOutput& outFile) +{ for (size_t index = 0; index < arrayList.size(); index++) { std::string name = std::get<0>(arrayList[index]); diff --git a/tests/parser/ScheduleTests.cpp b/tests/parser/ScheduleTests.cpp index 87581b897de..0a97d052a62 100644 --- a/tests/parser/ScheduleTests.cpp +++ b/tests/parser/ScheduleTests.cpp @@ -5290,7 +5290,8 @@ bool compare_dates(const time_point& t, int year, int month, int day) { return t == TimeService::from_time_t( asTimeT( TimeStampUTC(year, month, day))); } -bool compare_dates(const time_point& t, std::array& ymd) { +bool compare_dates(const time_point& t, const std::array& ymd) +{ return compare_dates(t, ymd[0], ymd[1], ymd[2]); } diff --git a/tests/test_EclIO.cpp b/tests/test_EclIO.cpp index 17a1481ba9c..2db89b89ffd 100644 --- a/tests/test_EclIO.cpp +++ b/tests/test_EclIO.cpp @@ -75,7 +75,9 @@ bool operator==(const std::vector & t1, const std::vector & t2) return std::equal(t1.begin(), t1.end(), t2.begin(), t2.end()); } -void write_header(std::ofstream& ofileH, std::string& arrName, int size, std::string arrtype){ +void write_header(std::ofstream& ofileH, const std::string& arrName, + int size, const std::string& arrtype) +{ int bhead = flipEndianInt(16); int fsize = flipEndianInt(size);