From b83bb7bf923df81b320c79f83c7334001229d97e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 19 Feb 2015 09:03:22 +0100 Subject: [PATCH 1/2] Remove unused function. --- .../FullyImplicitBlackoilSolver_impl.hpp | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp index 01829b663..502a6ea07 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp @@ -96,35 +96,6 @@ namespace { - template - V computePerfPress(const Grid& grid, const Wells& wells, const V& rho, const double grav) - { - using namespace Opm::AutoDiffGrid; - const int nw = wells.number_of_wells; - const int nperf = wells.well_connpos[nw]; - const int dim = dimensions(grid); - V wdp = V::Zero(nperf,1); - assert(wdp.size() == rho.size()); - - // Main loop, iterate over all perforations, - // using the following formula: - // wdp(perf) = g*(perf_z - well_ref_z)*rho(perf) - // where the total density rho(perf) is taken to be - // sum_p (rho_p*saturation_p) in the perforation cell. - // [although this is computed on the outside of this function]. - for (int w = 0; w < nw; ++w) { - const double ref_depth = wells.depth_ref[w]; - for (int j = wells.well_connpos[w]; j < wells.well_connpos[w + 1]; ++j) { - const int cell = wells.well_cells[j]; - const double cell_depth = cellCentroid(grid, cell)[dim - 1]; - wdp[j] = rho[j]*grav*(cell_depth - ref_depth); - } - } - return wdp; - } - - - template std::vector activePhases(const PU& pu) From e96036bdb390943f55b20e737459d68ac2a7ff7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 19 Feb 2015 09:07:42 +0100 Subject: [PATCH 2/2] Move helper functions to namespace detail. These were in the anonymous namespace, which was not wrong but lead to false-positive unused function warnings on some compilers, probably due to being used only from within templates. This allows us to keep the warning activated by default. --- .../FullyImplicitBlackoilSolver_impl.hpp | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp index 502a6ea07..020c38099 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver_impl.hpp @@ -81,7 +81,7 @@ typedef Eigen::Array DataBlock; -namespace { +namespace detail { std::vector @@ -129,7 +129,7 @@ namespace { } -} // Anonymous namespace +} // namespace detail template void FullyImplicitBlackoilSolver::SolverParameter:: @@ -198,9 +198,9 @@ namespace { , rock_comp_props_(rock_comp_props) , wells_ (wells) , linsolver_ (linsolver) - , active_(activePhases(fluid.phaseUsage())) - , canph_ (active2Canonical(fluid.phaseUsage())) - , cells_ (buildAllCells(Opm::AutoDiffGrid::numCells(grid))) + , active_(detail::activePhases(fluid.phaseUsage())) + , canph_ (detail::active2Canonical(fluid.phaseUsage())) + , cells_ (detail::buildAllCells(Opm::AutoDiffGrid::numCells(grid))) , ops_ (grid) , wops_ (wells_) , has_disgas_(has_disgas) @@ -996,7 +996,7 @@ namespace { - namespace + namespace detail { double rateToCompare(const ADB& well_phase_flow_rate, const int well, @@ -1069,7 +1069,7 @@ namespace { return broken; } - } // anonymous namespace + } // namespace detail @@ -1106,7 +1106,7 @@ namespace { // inequality constraint, and therefore skipped. continue; } - if (constraintBroken(bhp, well_phase_flow_rate, w, np, wells().type[w], wc, ctrl_index)) { + if (detail::constraintBroken(bhp, well_phase_flow_rate, w, np, wells().type[w], wc, ctrl_index)) { // ctrl_index will be the index of the broken constraint after the loop. break; } @@ -1250,10 +1250,8 @@ namespace { - namespace { - struct Chop01 { - double operator()(double x) const { return std::max(std::min(x, 1.0), 0.0); } - }; + namespace detail + { double infinityNorm( const ADB& a ) { @@ -1265,7 +1263,7 @@ namespace { } } - } + } // namespace detail @@ -1767,7 +1765,7 @@ namespace { const std::vector::const_iterator endMassBalanceIt = residual_.material_balance_eq.end(); for (; massBalanceIt != endMassBalanceIt; ++massBalanceIt) { - const double massBalanceResid = infinityNorm( (*massBalanceIt) ); + const double massBalanceResid = detail::infinityNorm( (*massBalanceIt) ); if (!std::isfinite(massBalanceResid)) { OPM_THROW(Opm::NumericalProblem, "Encountered a non-finite residual"); @@ -1776,14 +1774,14 @@ namespace { } // the following residuals are not used in the oscillation detection now - const double wellFluxResid = infinityNorm( residual_.well_flux_eq ); + const double wellFluxResid = detail::infinityNorm( residual_.well_flux_eq ); if (!std::isfinite(wellFluxResid)) { OPM_THROW(Opm::NumericalProblem, "Encountered a non-finite residual"); } residualNorms.push_back(wellFluxResid); - const double wellResid = infinityNorm( residual_.well_eq ); + const double wellResid = detail::infinityNorm( residual_.well_eq ); if (!std::isfinite(wellResid)) { OPM_THROW(Opm::NumericalProblem, "Encountered a non-finite residual"); @@ -1977,8 +1975,8 @@ namespace { converged_CNV = converged_CNV && (CNV[idx] < tol_cnv); } - const double residualWellFlux = infinityNorm(residual_.well_flux_eq); - const double residualWell = infinityNorm(residual_.well_eq); + const double residualWellFlux = detail::infinityNorm(residual_.well_flux_eq); + const double residualWell = detail::infinityNorm(residual_.well_eq); const bool converged_Well = (residualWellFlux < 1./Opm::unit::day) && (residualWell < Opm::unit::barsa); const bool converged = converged_MB && converged_CNV && converged_Well;