From b1b9c171b3ea23d44b289bc4bdba5f2f585daf0f Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Thu, 27 Aug 2015 16:58:44 +0200 Subject: [PATCH] update scaling factors for mass balance equations. --- opm/autodiff/BlackoilModelBase.hpp | 3 ++ opm/autodiff/BlackoilModelBase_impl.hpp | 29 ++++++++++++++++++- opm/autodiff/BlackoilModelParameters.cpp | 2 ++ opm/autodiff/BlackoilModelParameters.hpp | 3 ++ opm/autodiff/LinearisedBlackoilResidual.hpp | 2 ++ opm/autodiff/NewtonIterationBlackoilCPR.cpp | 3 +- .../NewtonIterationBlackoilInterleaved.cpp | 3 +- 7 files changed, 40 insertions(+), 5 deletions(-) diff --git a/opm/autodiff/BlackoilModelBase.hpp b/opm/autodiff/BlackoilModelBase.hpp index 0f6229d3d..970f0f8f3 100644 --- a/opm/autodiff/BlackoilModelBase.hpp +++ b/opm/autodiff/BlackoilModelBase.hpp @@ -208,6 +208,9 @@ namespace Opm { /// The number of active phases in the model. int numPhases() const; + /// Update the scaling factors for mass balance equations + void updateEquationsScaling(); + protected: // --------- Types and enums --------- diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index cdea87705..969437075 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -176,7 +176,8 @@ namespace detail { , isSg_(V::Zero(AutoDiffGrid::numCells(grid))) , residual_ ( { std::vector(fluid.numPhases(), ADB::null()), ADB::null(), - ADB::null() } ) + ADB::null(), + { 1.1169, 1.0031, 0.0031 }} ) // the default magic numbers , terminal_output_ (terminal_output) { #if HAVE_MPI @@ -910,6 +911,32 @@ namespace detail { // OPM_AD_DUMP(residual_.material_balance_eq[ Gas ]); } + + + if (param_.update_equations_scaling_) { + updateEquationsScaling(); + } + + } + + + + + + template + void + BlackoilModelBase::updateEquationsScaling() { + ADB::V B; + const Opm::PhaseUsage& pu = fluid_.phaseUsage(); + for ( int idx=0; idx matbalscale; + /// The size of the non-linear system. int sizeNonLinear() const; }; diff --git a/opm/autodiff/NewtonIterationBlackoilCPR.cpp b/opm/autodiff/NewtonIterationBlackoilCPR.cpp index 27d1902dd..a0ed42034 100644 --- a/opm/autodiff/NewtonIterationBlackoilCPR.cpp +++ b/opm/autodiff/NewtonIterationBlackoilCPR.cpp @@ -104,9 +104,8 @@ namespace Opm } // Scale material balance equations. - const double matbalscale[3] = { 1.1169, 1.0031, 0.0031 }; // HACK hardcoded instead of computed. for (int phase = 0; phase < np; ++phase) { - eqs[phase] = eqs[phase] * matbalscale[phase]; + eqs[phase] = eqs[phase] * residual.matbalscale[phase]; } // Add material balance equations (or other manipulations) to diff --git a/opm/autodiff/NewtonIterationBlackoilInterleaved.cpp b/opm/autodiff/NewtonIterationBlackoilInterleaved.cpp index 8b1451ef2..298136521 100644 --- a/opm/autodiff/NewtonIterationBlackoilInterleaved.cpp +++ b/opm/autodiff/NewtonIterationBlackoilInterleaved.cpp @@ -102,9 +102,8 @@ namespace Opm } // Scale material balance equations. - const double matbalscale[3] = { 1.1169, 1.0031, 0.0031 }; // HACK hardcoded instead of computed. for (int phase = 0; phase < np; ++phase) { - eqs[phase] = eqs[phase] * matbalscale[phase]; + eqs[phase] = eqs[phase] * residual.matbalscale[phase]; } // calculating the size for b