From 615a88ad90eaec5646a05c87a5a8439bdd767cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Fri, 7 Feb 2014 17:15:48 +0100 Subject: [PATCH 01/11] Made Residual struct definition public, and documented. This is in anticipation of implementing CPR preconditioning. --- opm/autodiff/FullyImplicitBlackoilSolver.hpp | 47 ++++++++++++++++---- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/opm/autodiff/FullyImplicitBlackoilSolver.hpp b/opm/autodiff/FullyImplicitBlackoilSolver.hpp index 65d888026..97f013daa 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver.hpp @@ -78,9 +78,45 @@ namespace Opm { BlackoilState& state , WellState& wstate); + /// Typedef used throughout the solver, in the public section + /// since it is used in the definition of Residual. + typedef AutoDiffBlock ADB; + + /// Residual structure of the fully implicit solver. + /// All equations are given as AD types, with multiple + /// jacobian blocks corresponding to the primary unknowns. The + /// primary unknowns are for a three-phase simulation, in order: + /// p (pressure) + /// sw (water saturation) + /// xvar (gas saturation, gas-oil ratio or oil-gas ratio) + /// qs (well outflows by well and phase) + /// bhp (bottom hole pressures) + /// In the above, the xvar variable will have a different + /// meaning from cell to cell, corresponding to the state in + /// that cell (saturated, undersaturated oil or undersaturated + /// gas). In a two-phase simulation, either sw or xvar is not + /// used, depending on which face is missing. + struct Residual { + /// The mass_balance vector has one element for each + /// active phase, each of which has size equal to the + /// number of cells. Each mass balance equation is given + /// in terms of surface volumes. + std::vector mass_balance; + /// The well_flux_eq has size equal to the number of wells + /// times the number of phases. It contains the well flow + /// equations, relating the total well flows to + /// bottom-hole pressures and reservoir conditions. + ADB well_flux_eq; + /// The well_eq has size equal to the number of wells. It + /// contains the well control equations, that is for each + /// well either a rate specification or bottom hole + /// pressure specification. + ADB well_eq; + }; + + private: // Types and enums - typedef AutoDiffBlock ADB; typedef ADB::V V; typedef ADB::M M; typedef Eigen::Array rq_; std::vector phaseCondition_; - // The mass_balance vector has one element for each active phase, - // each of which has size equal to the number of cells. - // The well_eq has size equal to the number of wells. - struct { - std::vector mass_balance; - ADB well_flux_eq; - ADB well_eq; - } residual_; + Residual residual_; // Private methods. SolutionState From 8850868f5050634b7bc999d662ccc92a6427f8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Mon, 10 Feb 2014 10:41:18 +0100 Subject: [PATCH 02/11] Interface and simple implementation of fully implicit system solver. This is done in preparation for adding a cpr-preconditioning solver for the fully implicit black-oil system. The existing implementation that concatenates the whole system and passes it to some linear solver has been moved from a private function of FullyImplicitBlackoilSolver to the class FullyImplicitSolverSimple. To enable this decoupling, the residual struct has been copied out of the FullyImplicitBlackoilSolver class and is now an independent struct: FullyImplicitBlackoilResidual. The opportunity has been used to replace the field mass_balance with material_balance_eq, which is more precise. --- CMakeLists_files.cmake | 4 ++ .../FullyImplicitBlackoilResidual.hpp | 70 +++++++++++++++++++ .../FullyImplicitSystemSolverInterface.hpp | 46 ++++++++++++ .../FullyImplicitSystemSolverSimple.cpp | 68 ++++++++++++++++++ .../FullyImplicitSystemSolverSimple.hpp | 55 +++++++++++++++ 5 files changed, 243 insertions(+) create mode 100644 opm/autodiff/FullyImplicitBlackoilResidual.hpp create mode 100644 opm/autodiff/FullyImplicitSystemSolverInterface.hpp create mode 100644 opm/autodiff/FullyImplicitSystemSolverSimple.cpp create mode 100644 opm/autodiff/FullyImplicitSystemSolverSimple.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index cba690427..26d4e7fad 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -29,6 +29,7 @@ list (APPEND MAIN_SOURCE_FILES opm/autodiff/BlackoilPropsAd.cpp opm/autodiff/BlackoilPropsAdInterface.cpp opm/autodiff/FullyImplicitBlackoilSolver.cpp + opm/autodiff/FullyImplicitSystemSolverSimple.cpp opm/autodiff/ImpesTPFAAD.cpp opm/autodiff/SimulatorCompressibleAd.cpp opm/autodiff/SimulatorFullyImplicitBlackoil.cpp @@ -83,7 +84,10 @@ list (APPEND PUBLIC_HEADER_FILES opm/autodiff/BlackoilPropsAdInterface.hpp opm/autodiff/GeoProps.hpp opm/autodiff/ImpesTPFAAD.hpp + opm/autodiff/FullyImplicitBlackoilResidual.hpp opm/autodiff/FullyImplicitBlackoilSolver.hpp + opm/autodiff/FullyImplicitBlackoilSystemSolverInterface.hpp + opm/autodiff/FullyImplicitBlackoilSystemSolverSimple.hpp opm/autodiff/SimulatorCompressibleAd.hpp opm/autodiff/SimulatorFullyImplicitBlackoil.hpp opm/autodiff/SimulatorIncompTwophaseAd.hpp diff --git a/opm/autodiff/FullyImplicitBlackoilResidual.hpp b/opm/autodiff/FullyImplicitBlackoilResidual.hpp new file mode 100644 index 000000000..757270212 --- /dev/null +++ b/opm/autodiff/FullyImplicitBlackoilResidual.hpp @@ -0,0 +1,70 @@ +/* + Copyright 2014 SINTEF ICT, Applied Mathematics. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#ifndef OPM_FULLYIMPLICITBLACKOILRESIDUAL_HEADER_INCLUDED +#define OPM_FULLYIMPLICITBLACKOILRESIDUAL_HEADER_INCLUDED + +#include + +namespace Opm +{ + + /// Residual structure of the fully implicit solver. + /// All equations are given as AD types, with multiple + /// jacobian blocks corresponding to the primary unknowns. The + /// primary unknowns are for a three-phase simulation, in order: + /// p (pressure) + /// sw (water saturation) + /// xvar (gas saturation, gas-oil ratio or oil-gas ratio) + /// qs (well outflows by well and phase) + /// bhp (bottom hole pressures) + /// In the above, the xvar variable will have a different + /// meaning from cell to cell, corresponding to the state in + /// that cell (saturated, undersaturated oil or undersaturated + /// gas). In a two-phase simulation, either sw or xvar is not + /// used, depending on which face is missing. + /// + /// Note: this class is strongly coupled to the class + /// FullyImplicitBlackoilSolver, and is separated from that + /// class to facilitate the development of linear solver + /// strategies outside that class. + struct FullyImplicitBlackoilResidual { + /// A type alias for the automatic differentiation type. + typedef AutoDiffBlock ADB; + /// The material_balance_eq vector has one element for each + /// active phase, each of which has size equal to the number + /// of cells. Each material balance equation is given in terms + /// of surface volumes. + std::vector material_balance_eq; + /// The well_flux_eq has size equal to the number of wells + /// times the number of phases. It contains the well flow + /// equations, relating the total well flows to + /// bottom-hole pressures and reservoir conditions. + ADB well_flux_eq; + /// The well_eq has size equal to the number of wells. It + /// contains the well control equations, that is for each + /// well either a rate specification or bottom hole + /// pressure specification. + ADB well_eq; + }; + +} // namespace Opm + + +#endif // OPM_FULLYIMPLICITBLACKOILRESIDUAL_HEADER_INCLUDED diff --git a/opm/autodiff/FullyImplicitSystemSolverInterface.hpp b/opm/autodiff/FullyImplicitSystemSolverInterface.hpp new file mode 100644 index 000000000..d3b4b980d --- /dev/null +++ b/opm/autodiff/FullyImplicitSystemSolverInterface.hpp @@ -0,0 +1,46 @@ +/* + Copyright 2014 SINTEF ICT, Applied Mathematics. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#ifndef OPM_FULLYIMPLICITSYSTEMSOLVERINTERFACE_HEADER_INCLUDED +#define OPM_FULLYIMPLICITSYSTEMSOLVERINTERFACE_HEADER_INCLUDED + +#include + +namespace Opm +{ + + /// Interface class for (linear) solvers for the fully implicit black-oil system. + class FullyImplicitSystemSolverInterface + { + public: + /// Return type for linearSolve(). A simple, non-ad vector type. + typedef FullyImplicitBlackoilResidual::ADB::V SolutionVector; + + /// Solve the linear system Ax = b, with A being the + /// combined derivative matrix of the residual and b + /// being the residual itself. + /// \param[in] residual residual object containing A and b. + /// \return the solution x + virtual SolutionVector linearSolve(const FullyImplicitBlackoilResidual& residual) const = 0; + }; + +} // namespace Opm + + +#endif // OPM_FULLYIMPLICITSYSTEMSOLVERINTERFACE_HEADER_INCLUDED diff --git a/opm/autodiff/FullyImplicitSystemSolverSimple.cpp b/opm/autodiff/FullyImplicitSystemSolverSimple.cpp new file mode 100644 index 000000000..ad5a5ec0b --- /dev/null +++ b/opm/autodiff/FullyImplicitSystemSolverSimple.cpp @@ -0,0 +1,68 @@ +/* + Copyright 2014 SINTEF ICT, Applied Mathematics. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + + +#include +#include +#include + +namespace Opm +{ + + /// Construct a system solver. + /// \param[in] linsolver linear solver to use + FullyImplicitSystemSolverSimple::FullyImplicitSystemSolverSimple(const LinearSolverInterface& linsolver) + : linsolver_(linsolver) + { + } + + /// Solve the linear system Ax = b, with A being the + /// combined derivative matrix of the residual and b + /// being the residual itself. + /// \param[in] residual residual object containing A and b. + /// \return the solution x + FullyImplicitSystemSolverSimple::SolutionVector + FullyImplicitSystemSolverSimple::linearSolve(const FullyImplicitBlackoilResidual& residual) const + { + typedef FullyImplicitBlackoilResidual::ADB ADB; + const int np = residual.material_balance_eq.size(); + ADB mass_res = residual.material_balance_eq[0]; + for (int phase = 1; phase < np; ++phase) { + mass_res = vertcat(mass_res, residual.material_balance_eq[phase]); + } + const ADB well_res = vertcat(residual.well_flux_eq, residual.well_eq); + const ADB total_residual = collapseJacs(vertcat(mass_res, well_res)); + + const Eigen::SparseMatrix matr = total_residual.derivative()[0]; + + SolutionVector dx(SolutionVector::Zero(total_residual.size())); + Opm::LinearSolverInterface::LinearSolverReport rep + = linsolver_.solve(matr.rows(), matr.nonZeros(), + matr.outerIndexPtr(), matr.innerIndexPtr(), matr.valuePtr(), + total_residual.value().data(), dx.data()); + if (!rep.converged) { + OPM_THROW(std::runtime_error, + "FullyImplicitBlackoilSolver::solveJacobianSystem(): " + "Linear solver convergence failure."); + } + return dx; + } + +} // namespace Opm + diff --git a/opm/autodiff/FullyImplicitSystemSolverSimple.hpp b/opm/autodiff/FullyImplicitSystemSolverSimple.hpp new file mode 100644 index 000000000..2c2fadd50 --- /dev/null +++ b/opm/autodiff/FullyImplicitSystemSolverSimple.hpp @@ -0,0 +1,55 @@ +/* + Copyright 2014 SINTEF ICT, Applied Mathematics. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#ifndef OPM_FULLYIMPLICITSYSTEMSOLVERSIMPLE_HEADER_INCLUDED +#define OPM_FULLYIMPLICITSYSTEMSOLVERSIMPLE_HEADER_INCLUDED + + +#include +#include + +namespace Opm +{ + + /// This class solves the fully implicit black-oil system by + /// simply concatenating the Jacobian matrices and passing the + /// resulting system to a linear solver. The linear solver used + /// can be passed in as a constructor argument. + class FullyImplicitSystemSolverSimple : public FullyImplicitSystemSolverInterface + { + public: + /// Construct a system solver. + /// \param[in] linsolver linear solver to use + FullyImplicitSystemSolverSimple(const LinearSolverInterface& linsolver); + + /// Solve the linear system Ax = b, with A being the + /// combined derivative matrix of the residual and b + /// being the residual itself. + /// \param[in] residual residual object containing A and b. + /// \return the solution x + virtual SolutionVector linearSolve(const FullyImplicitBlackoilResidual& residual) const; + + private: + const LinearSolverInterface& linsolver_; + }; + +} // namespace Opm + + +#endif // OPM_FULLYIMPLICITSYSTEMSOLVERSIMPLE_HEADER_INCLUDED From a14cff7834696192bbc9a38d2e203bdef8c36175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Mon, 10 Feb 2014 10:47:21 +0100 Subject: [PATCH 03/11] Use new linear solver interface in fully implicit solver. This includes: - Using the class FullyImplicitBlackoilResidual instead of in-class definition for the residual object. - Changing residual field name mass_balance to material_balance_eq. - Letting the simulator and solver classes accept a FullyImplicitSystemSolverInterface instead of a LinearSolverInterface. - In sim_fibo_ad and test_implicit_ad, instantiate class FullyImplicitSystemSolverSimple, replicating existing behaviour. --- examples/sim_fibo_ad.cpp | 4 +- examples/test_implicit_ad.cpp | 4 +- opm/autodiff/FullyImplicitBlackoilSolver.cpp | 57 ++++--------------- opm/autodiff/FullyImplicitBlackoilSolver.hpp | 48 +++------------- .../SimulatorFullyImplicitBlackoil.cpp | 6 +- .../SimulatorFullyImplicitBlackoil.hpp | 4 +- 6 files changed, 30 insertions(+), 93 deletions(-) diff --git a/examples/sim_fibo_ad.cpp b/examples/sim_fibo_ad.cpp index 138c0f69c..d0bfd3994 100644 --- a/examples/sim_fibo_ad.cpp +++ b/examples/sim_fibo_ad.cpp @@ -41,6 +41,7 @@ #include #include +#include #include #include @@ -137,6 +138,7 @@ try // Linear solver. LinearSolverFactory linsolver(param); + FullyImplicitSystemSolverSimple fis_solver(linsolver); // Write parameters used for later reference. bool output = param.getDefault("output", true); @@ -211,7 +213,7 @@ try *new_props, rock_comp->isActive() ? rock_comp.get() : 0, wells, - linsolver, + fis_solver, grav, outputWriter); if (epoch == 0) { diff --git a/examples/test_implicit_ad.cpp b/examples/test_implicit_ad.cpp index 0c1e78580..5afcbeb95 100644 --- a/examples/test_implicit_ad.cpp +++ b/examples/test_implicit_ad.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -103,8 +104,9 @@ try Opm::DerivedGeology geo(*g, props, grav); Opm::LinearSolverFactory linsolver(param); + Opm::FullyImplicitSystemSolverSimple fis_solver(linsolver); - Opm::FullyImplicitBlackoilSolver solver(*g, props, geo, 0, *wells, linsolver); + Opm::FullyImplicitBlackoilSolver solver(*g, props, geo, 0, *wells, fis_solver); Opm::BlackoilState state; initStateBasic(*g, props0, param, 0.0, state); diff --git a/opm/autodiff/FullyImplicitBlackoilSolver.cpp b/opm/autodiff/FullyImplicitBlackoilSolver.cpp index f3f686712..6f8dd8f41 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver.cpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver.cpp @@ -194,7 +194,7 @@ namespace { const DerivedGeology& geo , const RockCompressibility* rock_comp_props, const Wells& wells, - const LinearSolverInterface& linsolver) + const FullyImplicitSystemSolverInterface& linsolver) : grid_ (grid) , fluid_ (fluid) , geo_ (geo) @@ -643,13 +643,13 @@ namespace { // std::cout << "===== rq_[" << phase << "].mflux = \n" << std::endl; // std::cout << rq_[phase].mflux; - residual_.mass_balance[ phaseIdx ] = + residual_.material_balance_eq[ phaseIdx ] = pvdt*(rq_[phaseIdx].accum[1] - rq_[phaseIdx].accum[0]) + ops_.div*rq_[phaseIdx].mflux; // DUMP(ops_.div*rq_[phase].mflux); - // DUMP(residual_.mass_balance[phase]); + // DUMP(residual_.material_balance_eq[phase]); } // -------- Extra (optional) rs and rv contributions to the mass balance equations -------- @@ -663,16 +663,16 @@ namespace { rq_[po].head.value()); const ADB rs_face = upwindOil.select(state.rs); - residual_.mass_balance[ Gas ] += ops_.div * (rs_face * rq_[po].mflux); + residual_.material_balance_eq[ Gas ] += ops_.div * (rs_face * rq_[po].mflux); const int pg = fluid_.phaseUsage().phase_pos[ Gas ]; const UpwindSelector upwindGas(grid_, ops_, rq_[pg].head.value()); const ADB rv_face = upwindGas.select(state.rv); - residual_.mass_balance[ Oil ] += ops_.div * (rv_face * rq_[pg].mflux); + residual_.material_balance_eq[ Oil ] += ops_.div * (rv_face * rq_[pg].mflux); - // DUMP(residual_.mass_balance[ Gas ]); + // DUMP(residual_.material_balance_eq[ Gas ]); } @@ -772,7 +772,7 @@ namespace { // const ADB well_contrib = superset(perf_flux*perf_b, well_cells, nc); well_contribs[phase] = superset(perf_flux*perf_b, well_cells, nc); // DUMP(well_contribs[phase]); - residual_.mass_balance[phase] += well_contribs[phase]; + residual_.material_balance_eq[phase] += well_contribs[phase]; } if (active_[Gas] && active_[Oil]) { const int oilpos = pu.phase_pos[Oil]; @@ -782,8 +782,8 @@ namespace { well_rates_all += superset(wops_.p2w * (well_perf_rates[oilpos]*rs_perf), Span(nw, 1, gaspos*nw), nw*np); well_rates_all += superset(wops_.p2w * (well_perf_rates[gaspos]*rv_perf), Span(nw, 1, oilpos*nw), nw*np); // DUMP(well_contribs[gaspos] + well_contribs[oilpos]*state.rs); - residual_.mass_balance[gaspos] += well_contribs[oilpos]*state.rs; - residual_.mass_balance[oilpos] += well_contribs[gaspos]*state.rv; + residual_.material_balance_eq[gaspos] += well_contribs[oilpos]*state.rs; + residual_.material_balance_eq[oilpos] += well_contribs[gaspos]*state.rv; } // Set the well flux equation @@ -826,40 +826,7 @@ namespace { V FullyImplicitBlackoilSolver::solveJacobianSystem() const { - const int np = fluid_.numPhases(); - ADB mass_res = residual_.mass_balance[0]; - for (int phase = 1; phase < np; ++phase) { - mass_res = vertcat(mass_res, residual_.mass_balance[phase]); - } - const ADB well_res = vertcat(residual_.well_flux_eq, residual_.well_eq); - const ADB total_residual = collapseJacs(vertcat(mass_res, well_res)); - // DUMP(total_residual); - - const Eigen::SparseMatrix matr = total_residual.derivative()[0]; - - V dx(V::Zero(total_residual.size())); - Opm::LinearSolverInterface::LinearSolverReport rep - = linsolver_.solve(matr.rows(), matr.nonZeros(), - matr.outerIndexPtr(), matr.innerIndexPtr(), matr.valuePtr(), - total_residual.value().data(), dx.data()); - /* - std::ofstream filestream("matrix.out"); - filestream << matr; - filestream.close(); - std::ofstream filestream2("sol.out"); - filestream2 << dx; - filestream2.close(); - std::ofstream filestream3("r.out"); - filestream3 << total_residual.value(); - filestream3.close(); */ - - - if (!rep.converged) { - OPM_THROW(std::runtime_error, - "FullyImplicitBlackoilSolver::solveJacobianSystem(): " - "Linear solver convergence failure."); - } - return dx; + return linsolver_.linearSolve(residual_); } @@ -1268,8 +1235,8 @@ namespace { { double r = 0; for (std::vector::const_iterator - b = residual_.mass_balance.begin(), - e = residual_.mass_balance.end(); + b = residual_.material_balance_eq.begin(), + e = residual_.material_balance_eq.end(); b != e; ++b) { r = std::max(r, (*b).value().matrix().norm()); diff --git a/opm/autodiff/FullyImplicitBlackoilSolver.hpp b/opm/autodiff/FullyImplicitBlackoilSolver.hpp index 97f013daa..7b0901a4b 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver.hpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include struct UnstructuredGrid; struct Wells; @@ -31,7 +33,7 @@ namespace Opm { class DerivedGeology; class RockCompressibility; - class LinearSolverInterface; + class FullyImplicitSystemSolverInterface; class BlackoilState; class WellState; @@ -62,7 +64,7 @@ namespace Opm { const DerivedGeology& geo , const RockCompressibility* rock_comp_props, const Wells& wells, - const LinearSolverInterface& linsolver); + const FullyImplicitSystemSolverInterface& linsolver); /// Take a single forward step, modifiying /// state.pressure() @@ -78,45 +80,9 @@ namespace Opm { BlackoilState& state , WellState& wstate); - /// Typedef used throughout the solver, in the public section - /// since it is used in the definition of Residual. - typedef AutoDiffBlock ADB; - - /// Residual structure of the fully implicit solver. - /// All equations are given as AD types, with multiple - /// jacobian blocks corresponding to the primary unknowns. The - /// primary unknowns are for a three-phase simulation, in order: - /// p (pressure) - /// sw (water saturation) - /// xvar (gas saturation, gas-oil ratio or oil-gas ratio) - /// qs (well outflows by well and phase) - /// bhp (bottom hole pressures) - /// In the above, the xvar variable will have a different - /// meaning from cell to cell, corresponding to the state in - /// that cell (saturated, undersaturated oil or undersaturated - /// gas). In a two-phase simulation, either sw or xvar is not - /// used, depending on which face is missing. - struct Residual { - /// The mass_balance vector has one element for each - /// active phase, each of which has size equal to the - /// number of cells. Each mass balance equation is given - /// in terms of surface volumes. - std::vector mass_balance; - /// The well_flux_eq has size equal to the number of wells - /// times the number of phases. It contains the well flow - /// equations, relating the total well flows to - /// bottom-hole pressures and reservoir conditions. - ADB well_flux_eq; - /// The well_eq has size equal to the number of wells. It - /// contains the well control equations, that is for each - /// well either a rate specification or bottom hole - /// pressure specification. - ADB well_eq; - }; - - private: // Types and enums + typedef AutoDiffBlock ADB; typedef ADB::V V; typedef ADB::M M; typedef Eigen::Array true if active const std::vector active_; // Size = # active faces. Maps active -> canonical phase indices. @@ -172,7 +138,7 @@ namespace Opm { std::vector rq_; std::vector phaseCondition_; - Residual residual_; + FullyImplicitBlackoilResidual residual_; // Private methods. SolutionState diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoil.cpp b/opm/autodiff/SimulatorFullyImplicitBlackoil.cpp index bb792173b..c1591cd12 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoil.cpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoil.cpp @@ -71,7 +71,7 @@ namespace Opm const BlackoilPropsAdInterface& props, const RockCompressibility* rock_comp_props, WellsManager& wells_manager, - LinearSolverInterface& linsolver, + FullyImplicitSystemSolverInterface& linsolver, const double* gravity, EclipseWriter &writer); @@ -113,7 +113,7 @@ namespace Opm const BlackoilPropsAdInterface& props, const RockCompressibility* rock_comp_props, WellsManager& wells_manager, - LinearSolverInterface& linsolver, + FullyImplicitSystemSolverInterface& linsolver, const double* gravity, EclipseWriter &eclipseWriter) @@ -261,7 +261,7 @@ namespace Opm const BlackoilPropsAdInterface& props, const RockCompressibility* rock_comp_props, WellsManager& wells_manager, - LinearSolverInterface& linsolver, + FullyImplicitSystemSolverInterface& linsolver, const double* gravity, EclipseWriter &eclipseWriter) : grid_(grid), diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoil.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoil.hpp index f7c0a1b92..df3c8fc0c 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoil.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoil.hpp @@ -34,7 +34,7 @@ namespace Opm class EclipseWriter; class RockCompressibility; class WellsManager; - class LinearSolverInterface; + class FullyImplicitSystemSolverInterface; class SimulatorTimer; class BlackoilState; class WellState; @@ -71,7 +71,7 @@ namespace Opm const BlackoilPropsAdInterface& props, const RockCompressibility* rock_comp_props, WellsManager& wells_manager, - LinearSolverInterface& linsolver, + FullyImplicitSystemSolverInterface& linsolver, const double* gravity, EclipseWriter &writer); From a19344efa9872fa4427ca4302b82e103705845b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 8 Apr 2014 15:28:10 +0200 Subject: [PATCH 04/11] Changed docs/comments after review suggestions. Suggestions from B. Skaflestad and A. Lauser. --- opm/autodiff/FullyImplicitBlackoilResidual.hpp | 4 ++-- opm/autodiff/FullyImplicitSystemSolverSimple.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/opm/autodiff/FullyImplicitBlackoilResidual.hpp b/opm/autodiff/FullyImplicitBlackoilResidual.hpp index 757270212..2c0de63d7 100644 --- a/opm/autodiff/FullyImplicitBlackoilResidual.hpp +++ b/opm/autodiff/FullyImplicitBlackoilResidual.hpp @@ -38,7 +38,7 @@ namespace Opm /// meaning from cell to cell, corresponding to the state in /// that cell (saturated, undersaturated oil or undersaturated /// gas). In a two-phase simulation, either sw or xvar is not - /// used, depending on which face is missing. + /// used, depending on which phase is missing. /// /// Note: this class is strongly coupled to the class /// FullyImplicitBlackoilSolver, and is separated from that @@ -50,7 +50,7 @@ namespace Opm /// The material_balance_eq vector has one element for each /// active phase, each of which has size equal to the number /// of cells. Each material balance equation is given in terms - /// of surface volumes. + /// of surface volumes (in SI units, that is standard m^3). std::vector material_balance_eq; /// The well_flux_eq has size equal to the number of wells /// times the number of phases. It contains the well flow diff --git a/opm/autodiff/FullyImplicitSystemSolverSimple.hpp b/opm/autodiff/FullyImplicitSystemSolverSimple.hpp index 2c2fadd50..db7a252b4 100644 --- a/opm/autodiff/FullyImplicitSystemSolverSimple.hpp +++ b/opm/autodiff/FullyImplicitSystemSolverSimple.hpp @@ -38,7 +38,7 @@ namespace Opm /// \param[in] linsolver linear solver to use FullyImplicitSystemSolverSimple(const LinearSolverInterface& linsolver); - /// Solve the linear system Ax = b, with A being the + /// Solve the system of linear equations Ax = b, with A being the /// combined derivative matrix of the residual and b /// being the residual itself. /// \param[in] residual residual object containing A and b. From 9e7ab6d1d2b090f73df899ef608ecd65ab924a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 8 Apr 2014 15:56:08 +0200 Subject: [PATCH 05/11] Renamed class {FullyImplicit->Linearised}BlackoilResidual. --- opm/autodiff/FullyImplicitBlackoilSolver.hpp | 4 ++-- opm/autodiff/FullyImplicitSystemSolverInterface.hpp | 6 +++--- opm/autodiff/FullyImplicitSystemSolverSimple.cpp | 4 ++-- opm/autodiff/FullyImplicitSystemSolverSimple.hpp | 2 +- ...lackoilResidual.hpp => LinearisedBlackoilResidual.hpp} | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) rename opm/autodiff/{FullyImplicitBlackoilResidual.hpp => LinearisedBlackoilResidual.hpp} (92%) diff --git a/opm/autodiff/FullyImplicitBlackoilSolver.hpp b/opm/autodiff/FullyImplicitBlackoilSolver.hpp index 873308fbd..8cc202ce8 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver.hpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include struct UnstructuredGrid; @@ -139,7 +139,7 @@ namespace Opm { std::vector phaseCondition_; V well_perforation_pressure_diffs_; // Diff to bhp for each well perforation. - FullyImplicitBlackoilResidual residual_; + LinearisedBlackoilResidual residual_; // Private methods. SolutionState diff --git a/opm/autodiff/FullyImplicitSystemSolverInterface.hpp b/opm/autodiff/FullyImplicitSystemSolverInterface.hpp index d3b4b980d..262704ad2 100644 --- a/opm/autodiff/FullyImplicitSystemSolverInterface.hpp +++ b/opm/autodiff/FullyImplicitSystemSolverInterface.hpp @@ -20,7 +20,7 @@ #ifndef OPM_FULLYIMPLICITSYSTEMSOLVERINTERFACE_HEADER_INCLUDED #define OPM_FULLYIMPLICITSYSTEMSOLVERINTERFACE_HEADER_INCLUDED -#include +#include namespace Opm { @@ -30,14 +30,14 @@ namespace Opm { public: /// Return type for linearSolve(). A simple, non-ad vector type. - typedef FullyImplicitBlackoilResidual::ADB::V SolutionVector; + typedef LinearisedBlackoilResidual::ADB::V SolutionVector; /// Solve the linear system Ax = b, with A being the /// combined derivative matrix of the residual and b /// being the residual itself. /// \param[in] residual residual object containing A and b. /// \return the solution x - virtual SolutionVector linearSolve(const FullyImplicitBlackoilResidual& residual) const = 0; + virtual SolutionVector linearSolve(const LinearisedBlackoilResidual& residual) const = 0; }; } // namespace Opm diff --git a/opm/autodiff/FullyImplicitSystemSolverSimple.cpp b/opm/autodiff/FullyImplicitSystemSolverSimple.cpp index ad5a5ec0b..cba3f1828 100644 --- a/opm/autodiff/FullyImplicitSystemSolverSimple.cpp +++ b/opm/autodiff/FullyImplicitSystemSolverSimple.cpp @@ -38,9 +38,9 @@ namespace Opm /// \param[in] residual residual object containing A and b. /// \return the solution x FullyImplicitSystemSolverSimple::SolutionVector - FullyImplicitSystemSolverSimple::linearSolve(const FullyImplicitBlackoilResidual& residual) const + FullyImplicitSystemSolverSimple::linearSolve(const LinearisedBlackoilResidual& residual) const { - typedef FullyImplicitBlackoilResidual::ADB ADB; + typedef LinearisedBlackoilResidual::ADB ADB; const int np = residual.material_balance_eq.size(); ADB mass_res = residual.material_balance_eq[0]; for (int phase = 1; phase < np; ++phase) { diff --git a/opm/autodiff/FullyImplicitSystemSolverSimple.hpp b/opm/autodiff/FullyImplicitSystemSolverSimple.hpp index db7a252b4..2d5070bc5 100644 --- a/opm/autodiff/FullyImplicitSystemSolverSimple.hpp +++ b/opm/autodiff/FullyImplicitSystemSolverSimple.hpp @@ -43,7 +43,7 @@ namespace Opm /// being the residual itself. /// \param[in] residual residual object containing A and b. /// \return the solution x - virtual SolutionVector linearSolve(const FullyImplicitBlackoilResidual& residual) const; + virtual SolutionVector linearSolve(const LinearisedBlackoilResidual& residual) const; private: const LinearSolverInterface& linsolver_; diff --git a/opm/autodiff/FullyImplicitBlackoilResidual.hpp b/opm/autodiff/LinearisedBlackoilResidual.hpp similarity index 92% rename from opm/autodiff/FullyImplicitBlackoilResidual.hpp rename to opm/autodiff/LinearisedBlackoilResidual.hpp index 2c0de63d7..f37983f85 100644 --- a/opm/autodiff/FullyImplicitBlackoilResidual.hpp +++ b/opm/autodiff/LinearisedBlackoilResidual.hpp @@ -17,8 +17,8 @@ along with OPM. If not, see . */ -#ifndef OPM_FULLYIMPLICITBLACKOILRESIDUAL_HEADER_INCLUDED -#define OPM_FULLYIMPLICITBLACKOILRESIDUAL_HEADER_INCLUDED +#ifndef OPM_LINEARISEDBLACKOILRESIDUAL_HEADER_INCLUDED +#define OPM_LINEARISEDBLACKOILRESIDUAL_HEADER_INCLUDED #include @@ -44,7 +44,7 @@ namespace Opm /// FullyImplicitBlackoilSolver, and is separated from that /// class to facilitate the development of linear solver /// strategies outside that class. - struct FullyImplicitBlackoilResidual { + struct LinearisedBlackoilResidual { /// A type alias for the automatic differentiation type. typedef AutoDiffBlock ADB; /// The material_balance_eq vector has one element for each @@ -67,4 +67,4 @@ namespace Opm } // namespace Opm -#endif // OPM_FULLYIMPLICITBLACKOILRESIDUAL_HEADER_INCLUDED +#endif // OPM_LINEARISEDBLACKOILRESIDUAL_HEADER_INCLUDED From a434d39363b370693b952f649bc9c4f6d4d32bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 8 Apr 2014 15:59:14 +0200 Subject: [PATCH 06/11] Modify for renamed file. Forgot this for the initial renaming commit. --- CMakeLists_files.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 3798e759d..bdbef21c0 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -101,10 +101,10 @@ list (APPEND PUBLIC_HEADER_FILES opm/autodiff/BlackoilPropsAdInterface.hpp opm/autodiff/GeoProps.hpp opm/autodiff/ImpesTPFAAD.hpp - opm/autodiff/FullyImplicitBlackoilResidual.hpp opm/autodiff/FullyImplicitBlackoilSolver.hpp opm/autodiff/FullyImplicitBlackoilSystemSolverInterface.hpp opm/autodiff/FullyImplicitBlackoilSystemSolverSimple.hpp + opm/autodiff/LinearisedBlackoilResidual.hpp opm/autodiff/SimulatorCompressibleAd.hpp opm/autodiff/SimulatorFullyImplicitBlackoil.hpp opm/autodiff/SimulatorIncompTwophaseAd.hpp From bd44127bd631ce38804bc93951021137fd1faad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 8 Apr 2014 16:11:08 +0200 Subject: [PATCH 07/11] Renamed more classes. FullyImplicitSystemSolver{Interface, Simple} -> NewtonIterationBlackoil{Interface, Simple}. Change suggested by B. Skaflestad. --- CMakeLists_files.cmake | 6 +++--- examples/sim_fibo_ad.cpp | 4 ++-- examples/test_implicit_ad.cpp | 4 ++-- opm/autodiff/FullyImplicitBlackoilSolver.cpp | 2 +- opm/autodiff/FullyImplicitBlackoilSolver.hpp | 8 ++++---- ...face.hpp => NewtonIterationBlackoilInterface.hpp} | 8 ++++---- ...rSimple.cpp => NewtonIterationBlackoilSimple.cpp} | 8 ++++---- ...rSimple.hpp => NewtonIterationBlackoilSimple.hpp} | 12 ++++++------ opm/autodiff/SimulatorFullyImplicitBlackoil.cpp | 6 +++--- opm/autodiff/SimulatorFullyImplicitBlackoil.hpp | 4 ++-- 10 files changed, 31 insertions(+), 31 deletions(-) rename opm/autodiff/{FullyImplicitSystemSolverInterface.hpp => NewtonIterationBlackoilInterface.hpp} (86%) rename opm/autodiff/{FullyImplicitSystemSolverSimple.cpp => NewtonIterationBlackoilSimple.cpp} (88%) rename opm/autodiff/{FullyImplicitSystemSolverSimple.hpp => NewtonIterationBlackoilSimple.hpp} (79%) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index bdbef21c0..efbfbe77b 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -29,7 +29,7 @@ list (APPEND MAIN_SOURCE_FILES opm/autodiff/BlackoilPropsAd.cpp opm/autodiff/BlackoilPropsAdInterface.cpp opm/autodiff/FullyImplicitBlackoilSolver.cpp - opm/autodiff/FullyImplicitSystemSolverSimple.cpp + opm/autodiff/NewtonIterationBlackoilSimple.cpp opm/autodiff/ImpesTPFAAD.cpp opm/autodiff/SimulatorCompressibleAd.cpp opm/autodiff/SimulatorFullyImplicitBlackoil.cpp @@ -102,8 +102,8 @@ list (APPEND PUBLIC_HEADER_FILES opm/autodiff/GeoProps.hpp opm/autodiff/ImpesTPFAAD.hpp opm/autodiff/FullyImplicitBlackoilSolver.hpp - opm/autodiff/FullyImplicitBlackoilSystemSolverInterface.hpp - opm/autodiff/FullyImplicitBlackoilSystemSolverSimple.hpp + opm/autodiff/NewtonIterationBlackoilInterface.hpp + opm/autodiff/NewtonIterationBlackoilSimple.hpp opm/autodiff/LinearisedBlackoilResidual.hpp opm/autodiff/SimulatorCompressibleAd.hpp opm/autodiff/SimulatorFullyImplicitBlackoil.hpp diff --git a/examples/sim_fibo_ad.cpp b/examples/sim_fibo_ad.cpp index a331c819f..cc59135c5 100644 --- a/examples/sim_fibo_ad.cpp +++ b/examples/sim_fibo_ad.cpp @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include @@ -142,7 +142,7 @@ try // Linear solver. LinearSolverFactory linsolver(param); - FullyImplicitSystemSolverSimple fis_solver(linsolver); + NewtonIterationBlackoilSimple fis_solver(linsolver); // Write parameters used for later reference. bool output = param.getDefault("output", true); diff --git a/examples/test_implicit_ad.cpp b/examples/test_implicit_ad.cpp index 48c586d40..8e45e2177 100644 --- a/examples/test_implicit_ad.cpp +++ b/examples/test_implicit_ad.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include @@ -104,7 +104,7 @@ try Opm::DerivedGeology geo(*g, props, grav); Opm::LinearSolverFactory linsolver(param); - Opm::FullyImplicitSystemSolverSimple fis_solver(linsolver); + Opm::NewtonIterationBlackoilSimple fis_solver(linsolver); Opm::FullyImplicitBlackoilSolver solver(*g, props, geo, 0, *wells, fis_solver); diff --git a/opm/autodiff/FullyImplicitBlackoilSolver.cpp b/opm/autodiff/FullyImplicitBlackoilSolver.cpp index 6201b9be4..d665f9cc1 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver.cpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver.cpp @@ -195,7 +195,7 @@ namespace { const DerivedGeology& geo , const RockCompressibility* rock_comp_props, const Wells& wells, - const FullyImplicitSystemSolverInterface& linsolver) + const NewtonIterationBlackoilInterface& linsolver) : grid_ (grid) , fluid_ (fluid) , geo_ (geo) diff --git a/opm/autodiff/FullyImplicitBlackoilSolver.hpp b/opm/autodiff/FullyImplicitBlackoilSolver.hpp index 8cc202ce8..65a1784d8 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver.hpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver.hpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include struct UnstructuredGrid; struct Wells; @@ -33,7 +33,7 @@ namespace Opm { class DerivedGeology; class RockCompressibility; - class FullyImplicitSystemSolverInterface; + class NewtonIterationBlackoilInterface; class BlackoilState; class WellStateFullyImplicitBlackoil; @@ -64,7 +64,7 @@ namespace Opm { const DerivedGeology& geo , const RockCompressibility* rock_comp_props, const Wells& wells, - const FullyImplicitSystemSolverInterface& linsolver); + const NewtonIterationBlackoilInterface& linsolver); /// Take a single forward step, modifiying /// state.pressure() @@ -125,7 +125,7 @@ namespace Opm { const DerivedGeology& geo_; const RockCompressibility* rock_comp_props_; const Wells& wells_; - const FullyImplicitSystemSolverInterface& linsolver_; + const NewtonIterationBlackoilInterface& linsolver_; // For each canonical phase -> true if active const std::vector active_; // Size = # active faces. Maps active -> canonical phase indices. diff --git a/opm/autodiff/FullyImplicitSystemSolverInterface.hpp b/opm/autodiff/NewtonIterationBlackoilInterface.hpp similarity index 86% rename from opm/autodiff/FullyImplicitSystemSolverInterface.hpp rename to opm/autodiff/NewtonIterationBlackoilInterface.hpp index 262704ad2..7046a7b83 100644 --- a/opm/autodiff/FullyImplicitSystemSolverInterface.hpp +++ b/opm/autodiff/NewtonIterationBlackoilInterface.hpp @@ -17,8 +17,8 @@ along with OPM. If not, see . */ -#ifndef OPM_FULLYIMPLICITSYSTEMSOLVERINTERFACE_HEADER_INCLUDED -#define OPM_FULLYIMPLICITSYSTEMSOLVERINTERFACE_HEADER_INCLUDED +#ifndef OPM_NEWTONITERATIONBLACKOILINTERFACE_HEADER_INCLUDED +#define OPM_NEWTONITERATIONBLACKOILINTERFACE_HEADER_INCLUDED #include @@ -26,7 +26,7 @@ namespace Opm { /// Interface class for (linear) solvers for the fully implicit black-oil system. - class FullyImplicitSystemSolverInterface + class NewtonIterationBlackoilInterface { public: /// Return type for linearSolve(). A simple, non-ad vector type. @@ -43,4 +43,4 @@ namespace Opm } // namespace Opm -#endif // OPM_FULLYIMPLICITSYSTEMSOLVERINTERFACE_HEADER_INCLUDED +#endif // OPM_NEWTONITERATIONBLACKOILINTERFACE_HEADER_INCLUDED diff --git a/opm/autodiff/FullyImplicitSystemSolverSimple.cpp b/opm/autodiff/NewtonIterationBlackoilSimple.cpp similarity index 88% rename from opm/autodiff/FullyImplicitSystemSolverSimple.cpp rename to opm/autodiff/NewtonIterationBlackoilSimple.cpp index cba3f1828..6b5002186 100644 --- a/opm/autodiff/FullyImplicitSystemSolverSimple.cpp +++ b/opm/autodiff/NewtonIterationBlackoilSimple.cpp @@ -18,7 +18,7 @@ */ -#include +#include #include #include @@ -27,7 +27,7 @@ namespace Opm /// Construct a system solver. /// \param[in] linsolver linear solver to use - FullyImplicitSystemSolverSimple::FullyImplicitSystemSolverSimple(const LinearSolverInterface& linsolver) + NewtonIterationBlackoilSimple::NewtonIterationBlackoilSimple(const LinearSolverInterface& linsolver) : linsolver_(linsolver) { } @@ -37,8 +37,8 @@ namespace Opm /// being the residual itself. /// \param[in] residual residual object containing A and b. /// \return the solution x - FullyImplicitSystemSolverSimple::SolutionVector - FullyImplicitSystemSolverSimple::linearSolve(const LinearisedBlackoilResidual& residual) const + NewtonIterationBlackoilSimple::SolutionVector + NewtonIterationBlackoilSimple::linearSolve(const LinearisedBlackoilResidual& residual) const { typedef LinearisedBlackoilResidual::ADB ADB; const int np = residual.material_balance_eq.size(); diff --git a/opm/autodiff/FullyImplicitSystemSolverSimple.hpp b/opm/autodiff/NewtonIterationBlackoilSimple.hpp similarity index 79% rename from opm/autodiff/FullyImplicitSystemSolverSimple.hpp rename to opm/autodiff/NewtonIterationBlackoilSimple.hpp index 2d5070bc5..d4da29daf 100644 --- a/opm/autodiff/FullyImplicitSystemSolverSimple.hpp +++ b/opm/autodiff/NewtonIterationBlackoilSimple.hpp @@ -17,11 +17,11 @@ along with OPM. If not, see . */ -#ifndef OPM_FULLYIMPLICITSYSTEMSOLVERSIMPLE_HEADER_INCLUDED -#define OPM_FULLYIMPLICITSYSTEMSOLVERSIMPLE_HEADER_INCLUDED +#ifndef OPM_NEWTONITERATIONBLACKOILSIMPLE_HEADER_INCLUDED +#define OPM_NEWTONITERATIONBLACKOILSIMPLE_HEADER_INCLUDED -#include +#include #include namespace Opm @@ -31,12 +31,12 @@ namespace Opm /// simply concatenating the Jacobian matrices and passing the /// resulting system to a linear solver. The linear solver used /// can be passed in as a constructor argument. - class FullyImplicitSystemSolverSimple : public FullyImplicitSystemSolverInterface + class NewtonIterationBlackoilSimple : public NewtonIterationBlackoilInterface { public: /// Construct a system solver. /// \param[in] linsolver linear solver to use - FullyImplicitSystemSolverSimple(const LinearSolverInterface& linsolver); + NewtonIterationBlackoilSimple(const LinearSolverInterface& linsolver); /// Solve the system of linear equations Ax = b, with A being the /// combined derivative matrix of the residual and b @@ -52,4 +52,4 @@ namespace Opm } // namespace Opm -#endif // OPM_FULLYIMPLICITSYSTEMSOLVERSIMPLE_HEADER_INCLUDED +#endif // OPM_NEWTONITERATIONBLACKOILSIMPLE_HEADER_INCLUDED diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoil.cpp b/opm/autodiff/SimulatorFullyImplicitBlackoil.cpp index cedfe9b71..53c124513 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoil.cpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoil.cpp @@ -70,7 +70,7 @@ namespace Opm BlackoilPropsAdInterface& props, const RockCompressibility* rock_comp_props, WellsManager& wells_manager, - FullyImplicitSystemSolverInterface& linsolver, + NewtonIterationBlackoilInterface& linsolver, const double* gravity); SimulatorReport run(SimulatorTimer& timer, @@ -110,7 +110,7 @@ namespace Opm BlackoilPropsAdInterface& props, const RockCompressibility* rock_comp_props, WellsManager& wells_manager, - FullyImplicitSystemSolverInterface& linsolver, + NewtonIterationBlackoilInterface& linsolver, const double* gravity) { @@ -257,7 +257,7 @@ namespace Opm BlackoilPropsAdInterface& props, const RockCompressibility* rock_comp_props, WellsManager& wells_manager, - FullyImplicitSystemSolverInterface& linsolver, + NewtonIterationBlackoilInterface& linsolver, const double* gravity) : grid_(grid), props_(props), diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoil.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoil.hpp index 0ce3aa8cf..d5aabee3f 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoil.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoil.hpp @@ -33,7 +33,7 @@ namespace Opm class BlackoilPropsAdInterface; class RockCompressibility; class WellsManager; - class FullyImplicitSystemSolverInterface; + class NewtonIterationBlackoilInterface; class SimulatorTimer; class BlackoilState; class WellStateFullyImplicitBlackoil; @@ -70,7 +70,7 @@ namespace Opm BlackoilPropsAdInterface& props, const RockCompressibility* rock_comp_props, WellsManager& wells_manager, - FullyImplicitSystemSolverInterface& linsolver, + NewtonIterationBlackoilInterface& linsolver, const double* gravity); /// Run the simulation. From 9fec84312facdd033db34c129f1414252eb3e9b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 8 Apr 2014 16:16:54 +0200 Subject: [PATCH 08/11] Rename method linearSolve()->computeNewtonIncrement(). --- opm/autodiff/FullyImplicitBlackoilSolver.cpp | 2 +- opm/autodiff/NewtonIterationBlackoilInterface.hpp | 2 +- opm/autodiff/NewtonIterationBlackoilSimple.cpp | 2 +- opm/autodiff/NewtonIterationBlackoilSimple.hpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/opm/autodiff/FullyImplicitBlackoilSolver.cpp b/opm/autodiff/FullyImplicitBlackoilSolver.cpp index d665f9cc1..4f009be53 100644 --- a/opm/autodiff/FullyImplicitBlackoilSolver.cpp +++ b/opm/autodiff/FullyImplicitBlackoilSolver.cpp @@ -1158,7 +1158,7 @@ namespace { V FullyImplicitBlackoilSolver::solveJacobianSystem() const { - return linsolver_.linearSolve(residual_); + return linsolver_.computeNewtonIncrement(residual_); } diff --git a/opm/autodiff/NewtonIterationBlackoilInterface.hpp b/opm/autodiff/NewtonIterationBlackoilInterface.hpp index 7046a7b83..277b36d9b 100644 --- a/opm/autodiff/NewtonIterationBlackoilInterface.hpp +++ b/opm/autodiff/NewtonIterationBlackoilInterface.hpp @@ -37,7 +37,7 @@ namespace Opm /// being the residual itself. /// \param[in] residual residual object containing A and b. /// \return the solution x - virtual SolutionVector linearSolve(const LinearisedBlackoilResidual& residual) const = 0; + virtual SolutionVector computeNewtonIncrement(const LinearisedBlackoilResidual& residual) const = 0; }; } // namespace Opm diff --git a/opm/autodiff/NewtonIterationBlackoilSimple.cpp b/opm/autodiff/NewtonIterationBlackoilSimple.cpp index 6b5002186..7e71437bc 100644 --- a/opm/autodiff/NewtonIterationBlackoilSimple.cpp +++ b/opm/autodiff/NewtonIterationBlackoilSimple.cpp @@ -38,7 +38,7 @@ namespace Opm /// \param[in] residual residual object containing A and b. /// \return the solution x NewtonIterationBlackoilSimple::SolutionVector - NewtonIterationBlackoilSimple::linearSolve(const LinearisedBlackoilResidual& residual) const + NewtonIterationBlackoilSimple::computeNewtonIncrement(const LinearisedBlackoilResidual& residual) const { typedef LinearisedBlackoilResidual::ADB ADB; const int np = residual.material_balance_eq.size(); diff --git a/opm/autodiff/NewtonIterationBlackoilSimple.hpp b/opm/autodiff/NewtonIterationBlackoilSimple.hpp index d4da29daf..ce17ef8b1 100644 --- a/opm/autodiff/NewtonIterationBlackoilSimple.hpp +++ b/opm/autodiff/NewtonIterationBlackoilSimple.hpp @@ -43,7 +43,7 @@ namespace Opm /// being the residual itself. /// \param[in] residual residual object containing A and b. /// \return the solution x - virtual SolutionVector linearSolve(const LinearisedBlackoilResidual& residual) const; + virtual SolutionVector computeNewtonIncrement(const LinearisedBlackoilResidual& residual) const; private: const LinearSolverInterface& linsolver_; From 148e6e78cbd4915cab47dc5ffde5d51a6adb620e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Thu, 10 Apr 2014 09:37:52 +0200 Subject: [PATCH 09/11] Fix typo in #include (Autodiff -> AutoDiff). --- opm/autodiff/NewtonIterationBlackoilSimple.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/autodiff/NewtonIterationBlackoilSimple.cpp b/opm/autodiff/NewtonIterationBlackoilSimple.cpp index 7e71437bc..9647335aa 100644 --- a/opm/autodiff/NewtonIterationBlackoilSimple.cpp +++ b/opm/autodiff/NewtonIterationBlackoilSimple.cpp @@ -19,7 +19,7 @@ #include -#include +#include #include namespace Opm From dc622c6a7ad0badeae6e440b59044bcbabeecd45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 15 Apr 2014 12:10:43 +0200 Subject: [PATCH 10/11] Add forgotten #include . --- opm/autodiff/NewtonIterationBlackoilSimple.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/opm/autodiff/NewtonIterationBlackoilSimple.cpp b/opm/autodiff/NewtonIterationBlackoilSimple.cpp index 9647335aa..92e885903 100644 --- a/opm/autodiff/NewtonIterationBlackoilSimple.cpp +++ b/opm/autodiff/NewtonIterationBlackoilSimple.cpp @@ -17,6 +17,7 @@ along with OPM. If not, see . */ +#include #include #include From 5acb27f5065d7177856ab96049e5089ff43c0111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 15 Apr 2014 12:11:13 +0200 Subject: [PATCH 11/11] Update CpGrid version to use new classes. --- examples/sim_fibo_ad_cp.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/sim_fibo_ad_cp.cpp b/examples/sim_fibo_ad_cp.cpp index 63856026e..dfa96e3fb 100644 --- a/examples/sim_fibo_ad_cp.cpp +++ b/examples/sim_fibo_ad_cp.cpp @@ -56,6 +56,7 @@ #include #include +#include #include #include @@ -189,6 +190,7 @@ try // Linear solver. LinearSolverFactory linsolver(param); + NewtonIterationBlackoilSimple fis_solver(linsolver); // Write parameters used for later reference. bool output = param.getDefault("output", true); @@ -263,7 +265,7 @@ try *new_props, rock_comp->isActive() ? rock_comp.get() : 0, wells, - linsolver, + fis_solver, grav); SimulatorReport episodeReport = simulator.run(simtimer, state, well_state);