From 4201a24de2d1890c023ed7f00d8be7a8824e451c Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 4 Jan 2023 09:18:38 +0100 Subject: [PATCH 1/3] remove unnecessary includes --- src/opm/common/OpmLog/CounterLog.cpp | 5 +---- src/opm/input/eclipse/Schedule/ArrayDimChecker.cpp | 1 - src/opm/io/eclipse/EGrid.cpp | 4 +--- src/opm/io/eclipse/ERft.cpp | 2 -- src/opm/io/eclipse/ERst.cpp | 2 -- src/opm/io/eclipse/EclFile.cpp | 1 - src/opm/output/eclipse/AggregateUDQData.cpp | 1 - src/opm/output/eclipse/RestartIO.cpp | 1 - src/opm/output/eclipse/Summary.cpp | 1 - 9 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/opm/common/OpmLog/CounterLog.cpp b/src/opm/common/OpmLog/CounterLog.cpp index 36b8261a7..d01da06c2 100644 --- a/src/opm/common/OpmLog/CounterLog.cpp +++ b/src/opm/common/OpmLog/CounterLog.cpp @@ -16,15 +16,12 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ -#include -#include -#include #include #include #include - +#include namespace Opm { diff --git a/src/opm/input/eclipse/Schedule/ArrayDimChecker.cpp b/src/opm/input/eclipse/Schedule/ArrayDimChecker.cpp index fb36422a4..6140f1344 100644 --- a/src/opm/input/eclipse/Schedule/ArrayDimChecker.cpp +++ b/src/opm/input/eclipse/Schedule/ArrayDimChecker.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include diff --git a/src/opm/io/eclipse/EGrid.cpp b/src/opm/io/eclipse/EGrid.cpp index eb4b995c9..2f3ccfd9d 100644 --- a/src/opm/io/eclipse/EGrid.cpp +++ b/src/opm/io/eclipse/EGrid.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -30,11 +31,8 @@ #include #include #include -#include #include -#include - namespace Opm { namespace EclIO { using NNCentry = std::tuple; diff --git a/src/opm/io/eclipse/ERft.cpp b/src/opm/io/eclipse/ERft.cpp index 54f5d6215..833dc5d28 100644 --- a/src/opm/io/eclipse/ERft.cpp +++ b/src/opm/io/eclipse/ERft.cpp @@ -22,10 +22,8 @@ #include #include -#include #include #include -#include namespace Opm { namespace EclIO { diff --git a/src/opm/io/eclipse/ERst.cpp b/src/opm/io/eclipse/ERst.cpp index bc53a4aa1..6aed59e8c 100644 --- a/src/opm/io/eclipse/ERst.cpp +++ b/src/opm/io/eclipse/ERst.cpp @@ -23,10 +23,8 @@ #include #include #include -#include #include #include -#include #include #include diff --git a/src/opm/io/eclipse/EclFile.cpp b/src/opm/io/eclipse/EclFile.cpp index 02c475bc9..c9dad2db7 100644 --- a/src/opm/io/eclipse/EclFile.cpp +++ b/src/opm/io/eclipse/EclFile.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include diff --git a/src/opm/output/eclipse/AggregateUDQData.cpp b/src/opm/output/eclipse/AggregateUDQData.cpp index fbe1ea7fb..effaaa570 100644 --- a/src/opm/output/eclipse/AggregateUDQData.cpp +++ b/src/opm/output/eclipse/AggregateUDQData.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include diff --git a/src/opm/output/eclipse/RestartIO.cpp b/src/opm/output/eclipse/RestartIO.cpp index 8346f5afc..698404307 100644 --- a/src/opm/output/eclipse/RestartIO.cpp +++ b/src/opm/output/eclipse/RestartIO.cpp @@ -60,7 +60,6 @@ #include #include #include -#include #include #include #include diff --git a/src/opm/output/eclipse/Summary.cpp b/src/opm/output/eclipse/Summary.cpp index 3f64a6fff..8a45ab10e 100644 --- a/src/opm/output/eclipse/Summary.cpp +++ b/src/opm/output/eclipse/Summary.cpp @@ -77,7 +77,6 @@ #include #include #include -#include #include #include #include From beb0e8ec85aebb9624f00a65054e30a57e0cc2ad Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 4 Jan 2023 09:18:38 +0100 Subject: [PATCH 2/3] remove unnecessary includes --- src/opm/input/eclipse/Parser/Parser.cpp | 2 -- src/opm/input/eclipse/Schedule/Action/PyAction.cpp | 1 - src/opm/output/eclipse/RestartIO.cpp | 2 -- 3 files changed, 5 deletions(-) diff --git a/src/opm/input/eclipse/Parser/Parser.cpp b/src/opm/input/eclipse/Parser/Parser.cpp index 8458efc7e..cc059d516 100644 --- a/src/opm/input/eclipse/Parser/Parser.cpp +++ b/src/opm/input/eclipse/Parser/Parser.cpp @@ -19,9 +19,7 @@ #include #include -#include #include -#include #include #include #include diff --git a/src/opm/input/eclipse/Schedule/Action/PyAction.cpp b/src/opm/input/eclipse/Schedule/Action/PyAction.cpp index 64fe5c9c4..aa952fc89 100644 --- a/src/opm/input/eclipse/Schedule/Action/PyAction.cpp +++ b/src/opm/input/eclipse/Schedule/Action/PyAction.cpp @@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ -#include #include #ifdef EMBEDDED_PYTHON diff --git a/src/opm/output/eclipse/RestartIO.cpp b/src/opm/output/eclipse/RestartIO.cpp index 698404307..853f7245e 100644 --- a/src/opm/output/eclipse/RestartIO.cpp +++ b/src/opm/output/eclipse/RestartIO.cpp @@ -56,9 +56,7 @@ #include #include #include -#include #include -#include #include #include #include From acf4f98bea30b658dcd59e4c10281221d2deed79 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 4 Jan 2023 09:19:14 +0100 Subject: [PATCH 3/3] EModel: use {fmt} to format error messages --- src/opm/utility/EModel.cpp | 50 +++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/src/opm/utility/EModel.cpp b/src/opm/utility/EModel.cpp index eac19b2ea..60d0c8c5d 100644 --- a/src/opm/utility/EModel.cpp +++ b/src/opm/utility/EModel.cpp @@ -21,14 +21,11 @@ #include -#include -#include -#include -#include -#include -#include #include - +#include +#include +#include +#include using EclEntry = std::tuple; using ParamEntry = std::tuple; @@ -191,8 +188,10 @@ void EModel::initSolutionData(int rstep){ void EModel::get_cell_volumes_from_grid() { if (!grid.has_value()){ - std::string message = "\nnot possible to calculate cell columes without an Egrid file. "; - message = message + "The grid file must have same root name as the init file selected for this object"; + std::string message = "\nNot possible to calculate cell volumes " + "without an Egrid file. " + "The grid file must have same root name as " + "the init file selected for this object"; throw std::runtime_error(message); } @@ -279,7 +278,8 @@ void EModel::updateActiveFilter(const std::vector& paramVect, const std::stri ActFilter[i] = false; } else { - std::string message = "Unknown opprator " + opperator + ", used to set filter"; + const std::string message = + fmt::format("Unknown operator {} used to set filter", opperator); throw std::invalid_argument(message); } @@ -295,7 +295,9 @@ void EModel::updateActiveFilter(const std::vector& paramVect, const std::stri ActFilter[i] = false; } else { - throw std::invalid_argument("Unknown opprator " + opperator + ", used to set filter"); + const std::string message = + fmt::format("Unknown operator {} used to set filter", opperator); + throw std::invalid_argument(message); } activeFilter = true; @@ -314,7 +316,10 @@ const std::vector& EModel::get_filter_param(const std::string& param) else if (hasInitParameter(param)) return initfile.get(param); - throw std::invalid_argument("parameter " + param + ", used to set filter, could not be found"); + const std::string message = + fmt::format("parameter {}, used to set filter, could not be found", + param); + throw std::invalid_argument(message); } else if constexpr (std::is_same::value){ if (param == "PORV") @@ -329,7 +334,10 @@ const std::vector& EModel::get_filter_param(const std::string& param) else if (hasSolutionParameter(param)) return getSolutionFloat(param); - throw std::invalid_argument("parameter " + param + ", used to set filter, could not be found"); + const std::string message = + fmt::format("parameter {}, used to set filter, could not be found", + param); + throw std::invalid_argument(message); } } @@ -366,8 +374,10 @@ void EModel::addFilter(const std::string& param1, const std::string& oppe void EModel::addHCvolFilter() { - if (FreeWaterlevel.size()==0) - throw std::runtime_error("free water level needs to be inputted via function setDepthfwl before using filter HC filter"); + if (FreeWaterlevel.empty()) + throw std::runtime_error("free water level needs to be input via " + "function setDepthfwl before using " + "filter HC filter"); auto eqlnum = initfile.get("EQLNUM"); auto depth = initfile.get("DEPTH"); @@ -435,7 +445,9 @@ const std::vector& EModel::getInitFloat(const std::string& name) const std::vector& EModel::getSolutionFloat(const std::string& name) { if (!hasSolutionParameter(name)) { - std::string message = "parameter " + name + " not found for step 0 in restart file "; + const std::string message = + fmt::format("parameter {} not found for step 0 in restart file ", + name); throw std::invalid_argument(message); } @@ -456,7 +468,11 @@ void EModel::setDepthfwl(const std::vector& fwl) int maxEqlnum = *it; if (maxEqlnum > nEqlnum){ - std::string message= "FWL not defined for all eql regions. # Contacts input: " + std::to_string(nEqlnum) + " needed (max value in EQLNUM): " + std::to_string(maxEqlnum); + const std::string message = + fmt::format("FWL not defined for all eql regions. " + "# Contacts input: {} needed " + "(max value in EQLNUM): {}", + nEqlnum, maxEqlnum); throw std::invalid_argument(message); } }