From 01b25f27edff9c03db0eae83811fe3501f00705a Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Mon, 5 Mar 2018 16:40:17 +0100 Subject: [PATCH] Allow to add well contributions to both matrix and preconditioner matrix. matrix_add_well_contributions=true will add to both the preconditioner matrix and the matrix of the linear operator. preconditioner_add_well_contributions=true will only add the contributions to the preconditioner matrix. --- opm/autodiff/BlackoilModelEbos.hpp | 4 ++++ opm/autodiff/BlackoilModelParameters.cpp | 2 ++ opm/autodiff/BlackoilModelParameters.hpp | 5 ++++- opm/autodiff/StandardWell_impl.hpp | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index a45b0375f..d0458913e 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -376,6 +376,10 @@ namespace Opm { auto& ebosJac = ebosSimulator_.model().linearizer().matrix(); if (param_.matrix_add_well_contributions_) { + wellModel().addWellContributions(ebosJac); + } + if ( param_.preconditioner_add_well_contributions_ && + ! param_.matrix_add_well_contributions_ ) { matrix_for_preconditioner_ .reset(new Mat(ebosJac)); wellModel().addWellContributions(*matrix_for_preconditioner_); } diff --git a/opm/autodiff/BlackoilModelParameters.cpp b/opm/autodiff/BlackoilModelParameters.cpp index be87aca67..15c5630b1 100644 --- a/opm/autodiff/BlackoilModelParameters.cpp +++ b/opm/autodiff/BlackoilModelParameters.cpp @@ -66,6 +66,7 @@ namespace Opm use_update_stabilization_ = param.getDefault("use_update_stabilization", use_update_stabilization_); deck_file_name_ = param.template get("deck_filename"); matrix_add_well_contributions_ = param.getDefault("matrix_add_well_contributions", matrix_add_well_contributions_); + preconditioner_add_well_contributions_ = param.getDefault("preconditioner_add_well_contributions", preconditioner_add_well_contributions_); } @@ -95,6 +96,7 @@ namespace Opm use_update_stabilization_ = true; use_multisegment_well_ = false; matrix_add_well_contributions_ = false; + preconditioner_add_well_contributions_ = false; } diff --git a/opm/autodiff/BlackoilModelParameters.hpp b/opm/autodiff/BlackoilModelParameters.hpp index 7b885a4c3..2d15c0308 100644 --- a/opm/autodiff/BlackoilModelParameters.hpp +++ b/opm/autodiff/BlackoilModelParameters.hpp @@ -91,9 +91,12 @@ namespace Opm /// The file name of the deck std::string deck_file_name_; - // Whether to add influences of wells between cells to the matrix + // Whether to add influences of wells between cells to the matrix and preconditioner matrix bool matrix_add_well_contributions_; + // Whether to add influences of wells between cells to the preconditioner matrix only + bool preconditioner_add_well_contributions_; + /// Construct from user parameters or defaults. explicit BlackoilModelParameters( const ParameterGroup& param ); diff --git a/opm/autodiff/StandardWell_impl.hpp b/opm/autodiff/StandardWell_impl.hpp index 8a0d3c79f..15a02d739 100644 --- a/opm/autodiff/StandardWell_impl.hpp +++ b/opm/autodiff/StandardWell_impl.hpp @@ -1599,6 +1599,11 @@ namespace Opm StandardWell:: apply(const BVector& x, BVector& Ax) const { + if ( param_.matrix_add_well_contributions_ ) + { + // Contributions are already in the matrix itself + return; + } assert( Bx_.size() == duneB_.N() ); assert( invDrw_.size() == invDuneD_.N() );