From 18fad484ed72384c7133327e2f131e3aac95fbb2 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 19 Sep 2013 10:00:31 +0200 Subject: [PATCH 1/5] Use struct since that was the original declaration Otherwise we get a warning later when the real thing is defined. --- opm/core/simulator/SimulatorIncompTwophase.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/simulator/SimulatorIncompTwophase.hpp b/opm/core/simulator/SimulatorIncompTwophase.hpp index 437afe5f..d44cbbfb 100644 --- a/opm/core/simulator/SimulatorIncompTwophase.hpp +++ b/opm/core/simulator/SimulatorIncompTwophase.hpp @@ -39,7 +39,7 @@ namespace Opm class TwophaseState; class WellState; struct SimulatorReport; - class Event; + struct Event; /// Class collecting all necessary components for a two-phase simulation. class SimulatorIncompTwophase From a7f32b934bdea2ceb63847bdff94efcec9987c76 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 19 Sep 2013 10:32:49 +0200 Subject: [PATCH 2/5] Set linear solver steps in criterion instead of ctor The constructor that takes the number of steps is deprecated; this generates needless warnings. --- opm/core/linalg/LinearSolverIstl.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/opm/core/linalg/LinearSolverIstl.cpp b/opm/core/linalg/LinearSolverIstl.cpp index 167de42d..8ad7dde2 100644 --- a/opm/core/linalg/LinearSolverIstl.cpp +++ b/opm/core/linalg/LinearSolverIstl.cpp @@ -249,13 +249,16 @@ namespace Opm template void setUpCriterion(C& criterion, double linsolver_prolongate_factor, - int verbosity) + int verbosity, std::size_t linsolver_smooth_steps) { criterion.setDebugLevel(verbosity); #if ANISOTROPIC_3D criterion.setDefaultValuesAnisotropic(3, 2); #endif criterion.setProlongationDampingFactor(linsolver_prolongate_factor); + criterion.setNoPreSmoothSteps(linsolver_smooth_steps); + criterion.setNoPostSmoothSteps(linsolver_smooth_steps); + criterion.setGamma(1); // V-cycle; this is the default } LinearSolverInterface::LinearSolverReport @@ -288,9 +291,9 @@ namespace Opm Criterion criterion; Precond::SmootherArgs smootherArgs; Operator opA(A); - setUpCriterion(criterion, linsolver_prolongate_factor, verbosity); - Precond precond(opA, criterion, smootherArgs, 1, linsolver_smooth_steps, - linsolver_smooth_steps); + setUpCriterion(criterion, linsolver_prolongate_factor, verbosity, + linsolver_smooth_steps); + Precond precond(opA, criterion, smootherArgs); // Construct linear solver. Dune::CGSolver linsolve(opA, precond, tolerance, maxit, verbosity); @@ -339,9 +342,9 @@ namespace Opm Operator opA(A); Precond::SmootherArgs smootherArgs; Criterion criterion; - setUpCriterion(criterion, linsolver_prolongate_factor, verbosity); - Precond precond(opA, criterion, smootherArgs, 1, linsolver_smooth_steps, - linsolver_smooth_steps); + setUpCriterion(criterion, linsolver_prolongate_factor, verbosity, + linsolver_smooth_steps); + Precond precond(opA, criterion, smootherArgs); // Construct linear solver. Dune::GeneralizedPCGSolver linsolve(opA, precond, tolerance, maxit, verbosity); From 244c867505785c26136585cc23eb384ecd910f92 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 19 Sep 2013 10:59:41 +0200 Subject: [PATCH 3/5] Don't warn about functions not emitted If a function is used by a template but this template is not instantiated, the function will still be defined in the header of a module but it won't be callable because it is in an anonymous namespace and thus we get a warning. This only happens in Clang; GCC consider functions referenced from templates as used. fixup! Don't warn about functions not emitted --- opm/core/simulator/initState_impl.hpp | 3 +++ tests/test_velocityinterpolation.cpp | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/opm/core/simulator/initState_impl.hpp b/opm/core/simulator/initState_impl.hpp index 34cf08bb..94398fea 100644 --- a/opm/core/simulator/initState_impl.hpp +++ b/opm/core/simulator/initState_impl.hpp @@ -40,6 +40,8 @@ namespace Opm namespace { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunneeded-internal-declaration" // Find the cells that are below and above a depth. // TODO: add 'anitialiasing', obtaining a more precise split // by f. ex. subdividing cells cut by the split depths. @@ -61,6 +63,7 @@ namespace Opm } } } +#pragma clang diagnostic pop enum WaterInit { WaterBelow, WaterAbove }; diff --git a/tests/test_velocityinterpolation.cpp b/tests/test_velocityinterpolation.cpp index c5c2630a..05a2ff5d 100644 --- a/tests/test_velocityinterpolation.cpp +++ b/tests/test_velocityinterpolation.cpp @@ -62,7 +62,8 @@ namespace } } - +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunneeded-internal-declaration" // Compute flux corresponding to a velocity vector v = v0 + x*v1. void computeFluxLinear(const UnstructuredGrid& grid, const std::vector& v0, @@ -81,7 +82,7 @@ namespace flux[face] = std::inner_product(v.begin(), v.end(), grid.face_normals + face*dim, 0.0); } } - +#pragma clang diagnostic pop double vectorDiff2(const std::vector& v1, const std::vector& v2) { From 82cf04d9f14ab9288d7062df763bdc9bf018598d Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 19 Sep 2013 11:05:15 +0200 Subject: [PATCH 4/5] Convert functions in anonymous namespace into statics These functions are referred to from templates which may not be instantiated. Since they were in an anonymous namespace they were not reachable otherwise, and a warning is emitted. This only applies to Clang; GCC consider them used. If we make them static helper functions instead, the warning disappears. --- opm/core/utility/parameters/ParameterGroup.hpp | 6 ++++++ .../utility/parameters/ParameterGroup_impl.hpp | 17 +++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/opm/core/utility/parameters/ParameterGroup.hpp b/opm/core/utility/parameters/ParameterGroup.hpp index 4521592f..466d242c 100644 --- a/opm/core/utility/parameters/ParameterGroup.hpp +++ b/opm/core/utility/parameters/ParameterGroup.hpp @@ -282,6 +282,12 @@ namespace Opm { template void parseCommandLineArguments(int argc, StringArray argv); void recursiveSetIsOutputEnabled(bool output_is_enabled); + + // helper routines to do textual I/O + template + static std::string to_string(const T& val); + static std::pair + filename_split(const std::string& filename); }; } // namespace parameter } // namespace Opm diff --git a/opm/core/utility/parameters/ParameterGroup_impl.hpp b/opm/core/utility/parameters/ParameterGroup_impl.hpp index 8de64958..dfeb9acf 100644 --- a/opm/core/utility/parameters/ParameterGroup_impl.hpp +++ b/opm/core/utility/parameters/ParameterGroup_impl.hpp @@ -66,18 +66,18 @@ namespace Opm { static std::string type() {return "ParameterGroup";} }; - namespace { template inline std::string - to_string(const T& val) + ParameterGroup::to_string(const T& val) { std::ostringstream os; os << val; return os.str(); } + template <> inline std::string - to_string(const bool b) { + ParameterGroup::to_string(const bool& b) { if (b) { return ID_true; } else { @@ -85,14 +85,15 @@ namespace Opm { } } + template <> inline std::string - to_string(const ParameterGroup&) + ParameterGroup::to_string(const ParameterGroup&) { return std::string(""); } - std::pair - filename_split(const std::string& filename) + inline std::pair + ParameterGroup::filename_split(const std::string& filename) { int fpos = filename.rfind('.'); std::string name = filename.substr(0, fpos); @@ -100,10 +101,6 @@ namespace Opm { return std::make_pair(name, type); } - } - - - template ParameterGroup::ParameterGroup(int argc, StringArray argv, bool verify_syntax) : path_(ID_path_root), parent_(0), output_is_enabled_(true) From 13705d0394a91db19e5804491fd77e2f1152e838 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 19 Sep 2013 13:09:03 +0200 Subject: [PATCH 5/5] Issue warning if unknown parameters are given --- examples/compute_tof.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/compute_tof.cpp b/examples/compute_tof.cpp index 2db691d8..2e89c2c8 100644 --- a/examples/compute_tof.cpp +++ b/examples/compute_tof.cpp @@ -226,6 +226,9 @@ try Opm::WellState well_state; well_state.init(wells->c_wells(), state); + // Check if we have misspelled anything + warnIfUnusedParams(param); + // Main solvers. Opm::time::StopWatch pressure_timer; double ptime = 0.0;