ISTLSolver.hpp
Go to the documentation of this file.
1/*
2 Copyright 2016 IRIS AS
3 Copyright 2019, 2020 Equinor ASA
4 Copyright 2020 SINTEF Digital, Mathematics and Cybernetics
5
6 This file is part of the Open Porous Media project (OPM).
7
8 OPM is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 OPM is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with OPM. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#ifndef OPM_ISTLSOLVER_HEADER_INCLUDED
23#define OPM_ISTLSOLVER_HEADER_INCLUDED
24
25#include <dune/istl/owneroverlapcopy.hh>
26#include <dune/istl/solver.hh>
27
28#include <opm/common/CriticalError.hpp>
29#include <opm/common/ErrorMacros.hpp>
30#include <opm/common/Exceptions.hpp>
31#include <opm/common/TimingMacros.hpp>
32
33#include <opm/grid/utility/ElementChunks.hpp>
34
54
55#include <any>
56#include <cstddef>
57#include <functional>
58#include <memory>
59#include <set>
60#include <sstream>
61#include <string>
62#include <tuple>
63#include <vector>
64
65namespace Opm::Properties {
66
67namespace TTag {
69 using InheritsFrom = std::tuple<FlowIstlSolverParams>;
70};
71}
72
73template <class TypeTag, class MyTypeTag>
74struct WellModel;
75
78template<class TypeTag>
79struct SparseMatrixAdapter<TypeTag, TTag::FlowIstlSolver>
80{
81private:
83 enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
85
86public:
88};
89
90} // namespace Opm::Properties
91
92namespace Opm
93{
94
95
96namespace detail
97{
98
99template<class Matrix, class Vector, class Comm>
101{
102 using AbstractSolverType = Dune::InverseOperator<Vector, Vector>;
103 using AbstractOperatorType = Dune::AssembledLinearOperator<Matrix, Vector, Vector>;
105
106 void create(const Matrix& matrix,
107 bool parallel,
108 const PropertyTree& prm,
109 std::size_t pressureIndex,
110 std::function<Vector()> weightCalculator,
111 const bool forceSerial,
112 Comm* comm);
113
114 std::unique_ptr<AbstractSolverType> solver_;
115 std::unique_ptr<AbstractOperatorType> op_;
116 std::unique_ptr<LinearOperatorExtra<Vector,Vector>> wellOperator_;
118 std::size_t interiorCellNum_ = 0;
119};
120
121
122#ifdef HAVE_MPI
124void copyParValues(std::any& parallelInformation, std::size_t size,
125 Dune::OwnerOverlapCopyCommunication<int,int>& comm);
126#endif
127
130template<class Matrix>
131void makeOverlapRowsInvalid(Matrix& matrix,
132 const std::vector<int>& overlapRows);
133
136template<class Matrix, class Grid>
137std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
138 const std::vector<int>& cell_part,
139 std::size_t nonzeroes,
140 const std::vector<std::set<int>>& wellConnectionsGraph);
141}
142
147 template <class TypeTag>
148 class ISTLSolver : public AbstractISTLSolver<TypeTag>
149 {
150 protected:
158 using Matrix = typename SparseMatrixAdapter::IstlMatrix;
161 using AbstractSolverType = Dune::InverseOperator<Vector, Vector>;
162 using AbstractOperatorType = Dune::AssembledLinearOperator<Matrix, Vector, Vector>;
166 using ElementChunksType = ElementChunks<GridView, Dune::Partitions::All>;
167
169
170 enum { enablePolymerMolarWeight = getPropValue<TypeTag, Properties::EnablePolymerMW>() };
172
173#if HAVE_MPI
174 using CommunicationType = Dune::OwnerOverlapCopyCommunication<int,int>;
175#else
176 using CommunicationType = Dune::Communication<int>;
177#endif
178
179 public:
180 using AssembledLinearOperatorType = Dune::AssembledLinearOperator< Matrix, Vector, Vector >;
181
182 static void registerParameters()
183 {
185 }
186
194 ISTLSolver(const Simulator& simulator,
195 const FlowLinearSolverParameters& parameters,
196 bool forceSerial = false)
197 : simulator_(simulator),
198 iterations_( 0 ),
199 matrix_(nullptr),
200 parameters_{parameters},
201 forceSerial_(forceSerial)
202 {
203 initialize();
204 }
205
208 explicit ISTLSolver(const Simulator& simulator)
209 : simulator_(simulator),
210 iterations_( 0 ),
211 solveCount_(0),
212 matrix_(nullptr)
213 {
214 parameters_.resize(1);
215 parameters_[0].init(simulator_.vanguard().eclState().getSimulationConfig().useCPR());
216 initialize();
217 }
218
220 {
221 OPM_TIMEBLOCK(IstlSolver);
222
224 // Polymer injectivity is incompatible with the CPRW linear solver.
225 if (parameters_[0].linsolver_ == "cprw" || parameters_[0].linsolver_ == "hybrid") {
226 OPM_THROW(std::runtime_error,
227 "The polymer injectivity model is incompatible with the CPRW linear solver.\n"
228 "Choose a different option, for example --linear-solver=ilu0");
229 }
230 }
231
232 if (parameters_[0].linsolver_ == "hybrid") {
233 // Experimental hybrid configuration.
234 // When chosen, will set up two solvers, one with CPRW
235 // and the other with ILU0 preconditioner. More general
236 // options may be added later.
237 prm_.clear();
238 parameters_.clear();
239 {
241 para.init(false);
242 para.linsolver_ = "cprw";
243 parameters_.push_back(para);
245 Parameters::IsSet<Parameters::LinearSolverMaxIter>(),
246 Parameters::IsSet<Parameters::LinearSolverReduction>()));
247 }
248 {
250 para.init(false);
251 para.linsolver_ = "ilu0";
252 parameters_.push_back(para);
254 Parameters::IsSet<Parameters::LinearSolverMaxIter>(),
255 Parameters::IsSet<Parameters::LinearSolverReduction>()));
256 }
257 // ------------
258 } else {
259 assert(parameters_.size() == 1);
260 assert(prm_.empty());
261
262 // Do a normal linear solver setup.
263 if (parameters_[0].is_nldd_local_solver_) {
265 Parameters::IsSet<Parameters::NlddLocalLinearSolverMaxIter>(),
266 Parameters::IsSet<Parameters::NlddLocalLinearSolverReduction>()));
267 }
268 else {
270 Parameters::IsSet<Parameters::LinearSolverMaxIter>(),
271 Parameters::IsSet<Parameters::LinearSolverReduction>()));
272 }
273 }
274 flexibleSolver_.resize(prm_.size());
275
276 const bool on_io_rank = (simulator_.gridView().comm().rank() == 0);
277#if HAVE_MPI
278 comm_.reset( new CommunicationType( simulator_.vanguard().grid().comm() ) );
279#endif
280 extractParallelGridInformationToISTL(simulator_.vanguard().grid(), parallelInformation_);
281
282 // For some reason simulator_.model().elementMapper() is not initialized at this stage
283 //const auto& elemMapper = simulator_.model().elementMapper(); //does not work.
284 // Set it up manually
285 ElementMapper elemMapper(simulator_.vanguard().gridView(), Dune::mcmgElementLayout());
287 useWellConn_ = Parameters::Get<Parameters::MatrixAddWellContributions>();
288 const bool ownersFirst = Parameters::Get<Parameters::OwnerCellsFirst>();
289 if (!ownersFirst) {
290 const std::string msg = "The linear solver no longer supports --owner-cells-first=false.";
291 if (on_io_rank) {
292 OpmLog::error(msg);
293 }
294 OPM_THROW_NOLOG(std::runtime_error, msg);
295 }
296
297 const int interiorCellNum_ = detail::numMatrixRowsToUseInSolver(simulator_.vanguard().grid(), true);
298 for (auto& f : flexibleSolver_) {
299 f.interiorCellNum_ = interiorCellNum_;
300 }
301
302#if HAVE_MPI
303 if (isParallel()) {
304 const std::size_t size = simulator_.vanguard().grid().leafGridView().size(0);
306 }
307#endif
308
309 // Print parameters to PRT/DBG logs.
311
312 element_chunks_ = std::make_unique<ElementChunksType>(simulator_.vanguard().gridView(), Dune::Partitions::all, ThreadManager::maxThreads());
313 }
314
315 // nothing to clean here
316 void eraseMatrix() override
317 {
318 }
319
320 void setActiveSolver(const int num) override
321 {
322 if (num > static_cast<int>(prm_.size()) - 1) {
323 OPM_THROW(std::logic_error, "Solver number " + std::to_string(num) + " not available.");
324 }
325 activeSolverNum_ = num;
326 if (simulator_.gridView().comm().rank() == 0) {
327 OpmLog::debug("Active solver = " + std::to_string(activeSolverNum_)
328 + " (" + parameters_[activeSolverNum_].linsolver_ + ")");
329 }
330 }
331
332 int numAvailableSolvers() const override
333 {
334 return flexibleSolver_.size();
335 }
336
337 void initPrepare(const Matrix& M, Vector& b)
338 {
339 const bool firstcall = (matrix_ == nullptr);
340
341 // update matrix entries for solvers.
342 if (firstcall) {
343 // model will not change the matrix object. Hence simply store a pointer
344 // to the original one with a deleter that does nothing.
345 // Outch! We need to be able to scale the linear system! Hence const_cast
346 matrix_ = const_cast<Matrix*>(&M);
347
348 useWellConn_ = Parameters::Get<Parameters::MatrixAddWellContributions>();
349 // setup sparsity pattern for jacobi matrix for preconditioner (only used for openclSolver)
350 } else {
351 // Pointers should not change
352 if ( &M != matrix_ ) {
353 OPM_THROW(std::logic_error,
354 "Matrix objects are expected to be reused when reassembling!");
355 }
356 }
357 rhs_ = &b;
358
359 // TODO: check all solvers, not just one.
360 // We use lower case as the internal canonical representation of solver names
361 std::string type = prm_[activeSolverNum_].template get<std::string>("preconditioner.type", "paroverilu0");
362 std::transform(type.begin(), type.end(), type.begin(), ::tolower);
363 if (isParallel() && type != "paroverilu0") {
365 }
366 }
367
368 void prepare(const SparseMatrixAdapter& M, Vector& b) override
369 {
370 prepare(M.istlMatrix(), b);
371 }
372
373 void prepare(const Matrix& M, Vector& b) override
374 {
375 OPM_TIMEBLOCK(istlSolverPrepare);
376 try {
377 initPrepare(M,b);
378
380 } OPM_CATCH_AND_RETHROW_AS_CRITICAL_ERROR("This is likely due to a faulty linear solver JSON specification. Check for errors related to missing nodes.");
381 }
382
383
384 void setResidual(Vector& /* b */) override
385 {
386 // rhs_ = &b; // Must be handled in prepare() instead.
387 }
388
389 void getResidual(Vector& b) const override
390 {
391 b = *rhs_;
392 }
393
394 void setMatrix(const SparseMatrixAdapter& /* M */) override
395 {
396 // matrix_ = &M.istlMatrix(); // Must be handled in prepare() instead.
397 }
398
399 int getSolveCount() const override {
400 return solveCount_;
401 }
402
404 solveCount_ = 0;
405 }
406
407 bool solve(Vector& x) override
408 {
409 OPM_TIMEBLOCK(istlSolverSolve);
410 ++solveCount_;
411 // Write linear system if asked for.
412 const int verbosity = prm_[activeSolverNum_].get("verbosity", 0);
413 const bool write_matrix = verbosity > 10;
414 if (write_matrix) {
415 Helper::writeSystem(simulator_, //simulator is only used to get names
416 getMatrix(),
417 *rhs_,
418 comm_.get());
419 }
420
421 // Solve system.
423 {
424 OPM_TIMEBLOCK(flexibleSolverApply);
425 assert(flexibleSolver_[activeSolverNum_].solver_);
426 flexibleSolver_[activeSolverNum_].solver_->apply(x, *rhs_, result);
427 }
428
429 iterations_ = result.iterations;
430
431 // Check convergence, iterations etc.
432 return checkConvergence(result);
433 }
434
435
441
443 int iterations () const override { return iterations_; }
444
446 const std::any& parallelInformation() const { return parallelInformation_; }
447
448 const CommunicationType* comm() const override { return comm_.get(); }
449
450 void setDomainIndex(const int index)
451 {
452 domainIndex_ = index;
453 }
454
455 bool isNlddLocalSolver() const
456 {
457 return parameters_[activeSolverNum_].is_nldd_local_solver_;
458 }
459
460 protected:
461#if HAVE_MPI
462 using Comm = Dune::OwnerOverlapCopyCommunication<int, int>;
463#endif
464
466 {
468 }
469
470 bool isParallel() const {
471#if HAVE_MPI
472 return !forceSerial_ && comm_->communicator().size() > 1;
473#else
474 return false;
475#endif
476 }
477
479 {
480 OPM_TIMEBLOCK(flexibleSolverPrepare);
481 if (shouldCreateSolver()) {
482 if (!useWellConn_) {
483 if (isNlddLocalSolver()) {
484 auto wellOp = std::make_unique<DomainWellModelAsLinearOperator<WellModel, Vector, Vector>>(simulator_.problem().wellModel());
485 wellOp->setDomainIndex(domainIndex_);
486 flexibleSolver_[activeSolverNum_].wellOperator_ = std::move(wellOp);
487 }
488 else {
489 auto wellOp = std::make_unique<WellModelOperator>(simulator_.problem().wellModel());
490 flexibleSolver_[activeSolverNum_].wellOperator_ = std::move(wellOp);
491 }
492 }
493 std::function<Vector()> weightCalculator = this->getWeightsCalculator(prm_[activeSolverNum_], getMatrix(), pressureIndex);
494 OPM_TIMEBLOCK(flexibleSolverCreate);
496 isParallel(),
499 weightCalculator,
501 comm_.get());
502 }
503 else
504 {
505 OPM_TIMEBLOCK(flexibleSolverUpdate);
506 flexibleSolver_[activeSolverNum_].pre_->update();
507 }
508 }
509
510
514 {
515 // Decide if we should recreate the solver or just do
516 // a minimal preconditioner update.
517 if (flexibleSolver_.empty()) {
518 return true;
519 }
520 if (!flexibleSolver_[activeSolverNum_].solver_) {
521 return true;
522 }
523
524 if (flexibleSolver_[activeSolverNum_].pre_->hasPerfectUpdate()) {
525 return false;
526 }
527
528 // For AMG based preconditioners, the hierarchy depends on the matrix values
529 // so it is recreated at certain intervals
530 if (this->parameters_[activeSolverNum_].cpr_reuse_setup_ == 0) {
531 // Always recreate solver.
532 return true;
533 }
534 if (this->parameters_[activeSolverNum_].cpr_reuse_setup_ == 1) {
535 // Recreate solver on the first iteration of every timestep.
536 const int newton_iteration = this->simulator_.model().newtonMethod().numIterations();
537 return newton_iteration == 0;
538 }
539 if (this->parameters_[activeSolverNum_].cpr_reuse_setup_ == 2) {
540 // Recreate solver if the last solve used more than 10 iterations.
541 return this->iterations() > 10;
542 }
543 if (this->parameters_[activeSolverNum_].cpr_reuse_setup_ == 3) {
544 // Never recreate the solver
545 return false;
546 }
547 if (this->parameters_[activeSolverNum_].cpr_reuse_setup_ == 4) {
548 // Recreate solver every 'step' solve calls.
549 const int step = this->parameters_[activeSolverNum_].cpr_reuse_interval_;
550 const bool create = ((solveCount_ % step) == 0);
551 return create;
552 }
553 // If here, we have an invalid parameter.
554 const bool on_io_rank = (simulator_.gridView().comm().rank() == 0);
555 std::string msg = "Invalid value: " + std::to_string(this->parameters_[activeSolverNum_].cpr_reuse_setup_)
556 + " for --cpr-reuse-setup parameter, run with --help to see allowed values.";
557 if (on_io_rank) {
558 OpmLog::error(msg);
559 }
560 throw std::runtime_error(msg);
561
562 return false;
563 }
564
565
566 // Weights to make approximate pressure equations.
567 // Calculated from the storage terms (only) of the
568 // conservation equations, ignoring all other terms.
569 std::function<Vector()> getWeightsCalculator(const PropertyTree& prm,
570 const Matrix& matrix,
571 std::size_t pressIndex) const
572 {
573 std::function<Vector()> weightsCalculator;
574
575 using namespace std::string_literals;
576
577 auto preconditionerType = prm.get("preconditioner.type"s, "cpr"s);
578 // We use lower case as the internal canonical representation of solver names
579 std::transform(preconditionerType.begin(), preconditionerType.end(), preconditionerType.begin(), ::tolower);
580 if (preconditionerType == "cpr" || preconditionerType == "cprt"
581 || preconditionerType == "cprw" || preconditionerType == "cprwt") {
582 const bool transpose = preconditionerType == "cprt" || preconditionerType == "cprwt";
583 const auto weightsType = prm.get("preconditioner.weight_type"s, "quasiimpes"s);
584 if (weightsType == "quasiimpes") {
585 // weights will be created as default in the solver
586 // assignment p = pressureIndex prevent compiler warning about
587 // capturing variable with non-automatic storage duration
588 weightsCalculator = [matrix, transpose, pressIndex]() {
589 return Amg::getQuasiImpesWeights<Matrix, Vector>(matrix,
590 pressIndex,
591 transpose);
592 };
593 } else if ( weightsType == "trueimpes" ) {
594 weightsCalculator =
595 [this, pressIndex]
596 {
597 Vector weights(rhs_->size());
598 ElementContext elemCtx(simulator_);
599 Amg::getTrueImpesWeights(pressIndex,
600 weights,
601 elemCtx,
602 simulator_.model(),
604 );
605 return weights;
606 };
607 } else if (weightsType == "trueimpesanalytic" ) {
608 weightsCalculator =
609 [this, pressIndex]
610 {
611 Vector weights(rhs_->size());
612 ElementContext elemCtx(simulator_);
614 weights,
615 elemCtx,
616 simulator_.model(),
618 );
619 return weights;
620 };
621 } else {
622 OPM_THROW(std::invalid_argument,
623 "Weights type " + weightsType +
624 "not implemented for cpr."
625 " Please use quasiimpes, trueimpes or trueimpesanalytic.");
626 }
627 }
628 return weightsCalculator;
629 }
630
631
633 {
634 return *matrix_;
635 }
636
637 const Matrix& getMatrix() const
638 {
639 return *matrix_;
640 }
641
643 mutable int iterations_;
644 mutable int solveCount_;
646
647 // non-const to be able to scale the linear system
650
652 std::vector<detail::FlexibleSolverInfo<Matrix,Vector,CommunicationType>> flexibleSolver_;
653 std::vector<int> overlapRows_;
654 std::vector<int> interiorRows_;
655
656 int domainIndex_ = -1;
657
659
660 std::vector<FlowLinearSolverParameters> parameters_;
661 bool forceSerial_ = false;
662 std::vector<PropertyTree> prm_;
663
664 std::shared_ptr< CommunicationType > comm_;
665 std::unique_ptr<ElementChunksType> element_chunks_;
666 }; // end ISTLSolver
667
668} // namespace Opm
669
670#endif // OPM_ISTLSOLVER_HEADER_INCLUDED
Dune::OwnerOverlapCopyCommunication< int, int > Comm
Definition: FlexibleSolver_impl.hpp:304
Interface class adding the update() method to the preconditioner interface.
Definition: PreconditionerWithUpdate.hpp:32
Abstract interface for ISTL solvers.
Definition: AbstractISTLSolver.hpp:45
GetPropType< TypeTag, Properties::SparseMatrixAdapter > SparseMatrixAdapter
Definition: AbstractISTLSolver.hpp:53
static bool checkConvergence(const Dune::InverseOperatorResult &result, const FlowLinearSolverParameters &parameters)
Check the convergence of the linear solver.
Definition: AbstractISTLSolver.hpp:194
Definition: ISTLSolver.hpp:149
void getResidual(Vector &b) const override
Get the residual vector.
Definition: ISTLSolver.hpp:389
void initialize()
Definition: ISTLSolver.hpp:219
const Matrix & getMatrix() const
Definition: ISTLSolver.hpp:637
ElementChunks< GridView, Dune::Partitions::All > ElementChunksType
Definition: ISTLSolver.hpp:166
ISTLSolver(const Simulator &simulator, const FlowLinearSolverParameters &parameters, bool forceSerial=false)
Definition: ISTLSolver.hpp:194
void setDomainIndex(const int index)
Definition: ISTLSolver.hpp:450
int iterations() const override
Definition: ISTLSolver.hpp:443
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: ISTLSolver.hpp:152
std::shared_ptr< CommunicationType > comm_
Definition: ISTLSolver.hpp:664
static constexpr bool isIncompatibleWithCprw
Definition: ISTLSolver.hpp:171
std::vector< FlowLinearSolverParameters > parameters_
Definition: ISTLSolver.hpp:660
void setActiveSolver(const int num) override
Set the active solver by its index.
Definition: ISTLSolver.hpp:320
GetPropType< TypeTag, Properties::GridView > GridView
Definition: ISTLSolver.hpp:151
Dune::InverseOperator< Vector, Vector > AbstractSolverType
Definition: ISTLSolver.hpp:161
void setMatrix(const SparseMatrixAdapter &) override
Set the matrix for the solver.
Definition: ISTLSolver.hpp:394
void prepare(const Matrix &M, Vector &b) override
Prepare the solver with the given matrix and right-hand side vector.
Definition: ISTLSolver.hpp:373
typename SparseMatrixAdapter::IstlMatrix Matrix
Definition: ISTLSolver.hpp:158
GetPropType< TypeTag, Properties::WellModel > WellModel
Definition: ISTLSolver.hpp:156
int solveCount_
Definition: ISTLSolver.hpp:644
bool isNlddLocalSolver() const
Definition: ISTLSolver.hpp:455
Matrix & getMatrix()
Definition: ISTLSolver.hpp:632
int numAvailableSolvers() const override
Get the number of available solvers.
Definition: ISTLSolver.hpp:332
void prepare(const SparseMatrixAdapter &M, Vector &b) override
Prepare the solver with the given sparse matrix and right-hand side vector.
Definition: ISTLSolver.hpp:368
Dune::OwnerOverlapCopyCommunication< int, int > CommunicationType
Definition: ISTLSolver.hpp:174
int getSolveCount() const override
Get the count of how many times the solver has been called.
Definition: ISTLSolver.hpp:399
Matrix * matrix_
Definition: ISTLSolver.hpp:648
bool useWellConn_
Definition: ISTLSolver.hpp:658
bool shouldCreateSolver() const
Definition: ISTLSolver.hpp:513
bool checkConvergence(const Dune::InverseOperatorResult &result) const
Definition: ISTLSolver.hpp:465
static constexpr std::size_t pressureIndex
Definition: ISTLSolver.hpp:168
void prepareFlexibleSolver()
Definition: ISTLSolver.hpp:478
GetPropType< TypeTag, Properties::ThreadManager > ThreadManager
Definition: ISTLSolver.hpp:159
GetPropType< TypeTag, Properties::ElementMapper > ElementMapper
Definition: ISTLSolver.hpp:165
void resetSolveCount()
Definition: ISTLSolver.hpp:403
GetPropType< TypeTag, Properties::GlobalEqVector > Vector
Definition: ISTLSolver.hpp:154
const std::any & parallelInformation() const
Definition: ISTLSolver.hpp:446
void initPrepare(const Matrix &M, Vector &b)
Definition: ISTLSolver.hpp:337
std::vector< detail::FlexibleSolverInfo< Matrix, Vector, CommunicationType > > flexibleSolver_
Definition: ISTLSolver.hpp:652
void eraseMatrix() override
Signals that the memory for the matrix internally in the solver could be erased.
Definition: ISTLSolver.hpp:316
Dune::AssembledLinearOperator< Matrix, Vector, Vector > AbstractOperatorType
Definition: ISTLSolver.hpp:162
std::function< Vector()> getWeightsCalculator(const PropertyTree &prm, const Matrix &matrix, std::size_t pressIndex) const
Definition: ISTLSolver.hpp:569
Dune::AssembledLinearOperator< Matrix, Vector, Vector > AssembledLinearOperatorType
Definition: ISTLSolver.hpp:180
ISTLSolver(const Simulator &simulator)
Definition: ISTLSolver.hpp:208
int iterations_
Definition: ISTLSolver.hpp:643
int domainIndex_
Definition: ISTLSolver.hpp:656
std::any parallelInformation_
Definition: ISTLSolver.hpp:645
GetPropType< TypeTag, Properties::Simulator > Simulator
Definition: ISTLSolver.hpp:157
Vector * rhs_
Definition: ISTLSolver.hpp:649
int activeSolverNum_
Definition: ISTLSolver.hpp:651
std::vector< int > overlapRows_
Definition: ISTLSolver.hpp:653
std::unique_ptr< ElementChunksType > element_chunks_
Definition: ISTLSolver.hpp:665
GetPropType< TypeTag, Properties::Indices > Indices
Definition: ISTLSolver.hpp:155
const Simulator & simulator_
Definition: ISTLSolver.hpp:642
@ enablePolymerMolarWeight
Definition: ISTLSolver.hpp:170
std::vector< int > interiorRows_
Definition: ISTLSolver.hpp:654
Dune::OwnerOverlapCopyCommunication< int, int > Comm
Definition: ISTLSolver.hpp:462
bool forceSerial_
Definition: ISTLSolver.hpp:661
bool solve(Vector &x) override
Solve the system of equations Ax = b.
Definition: ISTLSolver.hpp:407
static void registerParameters()
Definition: ISTLSolver.hpp:182
std::vector< PropertyTree > prm_
Definition: ISTLSolver.hpp:662
GetPropType< TypeTag, Properties::ElementContext > ElementContext
Definition: ISTLSolver.hpp:160
void setResidual(Vector &) override
Set the residual vector.
Definition: ISTLSolver.hpp:384
const CommunicationType * comm() const override
Get the communication object used by the solver.
Definition: ISTLSolver.hpp:448
bool isParallel() const
Definition: ISTLSolver.hpp:470
A sparse matrix interface backend for BCRSMatrix from dune-istl.
Definition: istlsparsematrixadapter.hh:43
Definition: matrixblock.hh:227
Hierarchical collection of key/value pairs.
Definition: PropertyTree.hpp:39
T get(const std::string &key) const
static unsigned maxThreads()
Return the maximum number of threads of the current process.
Definition: threadmanager.hpp:66
Definition: WellOperators.hpp:70
Declare the properties used by the infrastructure code of the finite volume discretizations.
Defines the common properties required by the porous medium multi-phase models.
void getTrueImpesWeightsAnalytic(int, Vector &weights, const ElementContext &elemCtx, const Model &model, const ElementChunksType &element_chunks)
Definition: getQuasiImpesWeights.hpp:168
void getTrueImpesWeights(int pressureVarIndex, Vector &weights, const ElementContext &elemCtx, const Model &model, const ElementChunksType &element_chunks)
Definition: getQuasiImpesWeights.hpp:104
void writeSystem(const SimulatorType &simulator, const MatrixType &matrix, const VectorType &rhs, const std::string &sysName, const Communicator *comm)
Definition: WriteSystemMatrixHelper.hpp:196
Definition: blackoilmodel.hh:79
std::unique_ptr< Matrix > blockJacobiAdjacency(const Grid &grid, const std::vector< int > &cell_part, std::size_t nonzeroes, const std::vector< std::set< int > > &wellConnectionsGraph)
void copyParValues(std::any &parallelInformation, std::size_t size, Dune::OwnerOverlapCopyCommunication< int, int > &comm)
Copy values in parallel.
std::size_t numMatrixRowsToUseInSolver(const Grid &grid, bool ownerFirst)
If ownerFirst=true, returns the number of interior cells in grid, else just numCells().
Definition: findOverlapRowsAndColumns.hpp:122
void makeOverlapRowsInvalid(Matrix &matrix, const std::vector< int > &overlapRows)
void findOverlapAndInterior(const Grid &grid, const Mapper &mapper, std::vector< int > &overlapRows, std::vector< int > &interiorRows)
Find the rows corresponding to overlap cells.
Definition: findOverlapRowsAndColumns.hpp:92
void printLinearSolverParameters(const FlowLinearSolverParameters &parameters, const VectorOrSingle &prm, const Comm &comm)
Print the linear solver parameters to the log if requested.
Definition: printlinearsolverparameter.hpp:61
Definition: blackoilboundaryratevector.hh:39
Dune::InverseOperatorResult InverseOperatorResult
Definition: GpuBridge.hpp:32
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:233
std::string to_string(const ConvergenceReport::ReservoirFailure::Type t)
PropertyTree setupPropertyTree(FlowLinearSolverParameters p, bool linearSolverMaxIterSet, bool linearSolverReductionSet)
This file provides the infrastructure to retrieve run-time parameters.
The Opm property system, traits with inheritance.
This class carries all parameters for the NewtonIterationBlackoilInterleaved class.
Definition: FlowLinearSolverParameters.hpp:97
void init(bool cprRequestedInDataFile)
std::string linsolver_
Definition: FlowLinearSolverParameters.hpp:112
typename Linear::IstlSparseMatrixAdapter< Block > type
Definition: ISTLSolver.hpp:87
The class that allows to manipulate sparse matrices.
Definition: linalgproperties.hh:50
Definition: ISTLSolver.hpp:68
std::tuple< FlowIstlSolverParams > InheritsFrom
Definition: ISTLSolver.hpp:69
Definition: FlowBaseProblemProperties.hpp:91
Definition: ISTLSolver.hpp:101
std::unique_ptr< AbstractSolverType > solver_
Definition: ISTLSolver.hpp:114
std::size_t interiorCellNum_
Definition: ISTLSolver.hpp:118
Dune::InverseOperator< Vector, Vector > AbstractSolverType
Definition: ISTLSolver.hpp:102
AbstractPreconditionerType * pre_
Definition: ISTLSolver.hpp:117
Dune::AssembledLinearOperator< Matrix, Vector, Vector > AbstractOperatorType
Definition: ISTLSolver.hpp:103
void create(const Matrix &matrix, bool parallel, const PropertyTree &prm, std::size_t pressureIndex, std::function< Vector()> weightCalculator, const bool forceSerial, Comm *comm)
std::unique_ptr< LinearOperatorExtra< Vector, Vector > > wellOperator_
Definition: ISTLSolver.hpp:116
std::unique_ptr< AbstractOperatorType > op_
Definition: ISTLSolver.hpp:115