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
52
53#include <any>
54#include <cstddef>
55#include <functional>
56#include <memory>
57#include <set>
58#include <sstream>
59#include <string>
60#include <tuple>
61#include <vector>
62
63namespace Opm::Properties {
64
65namespace TTag {
67 using InheritsFrom = std::tuple<FlowIstlSolverParams>;
68};
69}
70
71template <class TypeTag, class MyTypeTag>
72struct WellModel;
73
76template<class TypeTag>
77struct SparseMatrixAdapter<TypeTag, TTag::FlowIstlSolver>
78{
79private:
81 enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
83
84public:
86};
87
88} // namespace Opm::Properties
89
90namespace Opm
91{
92
93
94namespace detail
95{
96
97template<class Matrix, class Vector, class Comm>
99{
100 using AbstractSolverType = Dune::InverseOperator<Vector, Vector>;
101 using AbstractOperatorType = Dune::AssembledLinearOperator<Matrix, Vector, Vector>;
103
104 void create(const Matrix& matrix,
105 bool parallel,
106 const PropertyTree& prm,
107 std::size_t pressureIndex,
108 std::function<Vector()> weightCalculator,
109 const bool forceSerial,
110 Comm* comm);
111
112 std::unique_ptr<AbstractSolverType> solver_;
113 std::unique_ptr<AbstractOperatorType> op_;
114 std::unique_ptr<LinearOperatorExtra<Vector,Vector>> wellOperator_;
116 std::size_t interiorCellNum_ = 0;
117};
118
119
120#ifdef HAVE_MPI
122void copyParValues(std::any& parallelInformation, std::size_t size,
123 Dune::OwnerOverlapCopyCommunication<int,int>& comm);
124#endif
125
128template<class Matrix>
129void makeOverlapRowsInvalid(Matrix& matrix,
130 const std::vector<int>& overlapRows);
131
134template<class Matrix, class Grid>
135std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
136 const std::vector<int>& cell_part,
137 std::size_t nonzeroes,
138 const std::vector<std::set<int>>& wellConnectionsGraph);
139}
140
145 template <class TypeTag>
146 class ISTLSolver : public AbstractISTLSolver<TypeTag>
147 {
148 protected:
156 using Matrix = typename SparseMatrixAdapter::IstlMatrix;
159 using AbstractSolverType = Dune::InverseOperator<Vector, Vector>;
160 using AbstractOperatorType = Dune::AssembledLinearOperator<Matrix, Vector, Vector>;
165
166 enum { enablePolymerMolarWeight = getPropValue<TypeTag, Properties::EnablePolymerMW>() };
168
169#if HAVE_MPI
170 using CommunicationType = Dune::OwnerOverlapCopyCommunication<int,int>;
171#else
172 using CommunicationType = Dune::Communication<int>;
173#endif
174
175 public:
176 using AssembledLinearOperatorType = Dune::AssembledLinearOperator< Matrix, Vector, Vector >;
177
178 static void registerParameters()
179 {
181 }
182
190 ISTLSolver(const Simulator& simulator,
191 const FlowLinearSolverParameters& parameters,
192 bool forceSerial = false)
193 : simulator_(simulator),
194 iterations_( 0 ),
195 matrix_(nullptr),
196 parameters_{parameters},
197 forceSerial_(forceSerial)
198 {
199 initialize();
200 }
201
204 explicit ISTLSolver(const Simulator& simulator)
205 : simulator_(simulator),
206 iterations_( 0 ),
207 solveCount_(0),
208 matrix_(nullptr)
209 {
210 parameters_.resize(1);
211 parameters_[0].init(simulator_.vanguard().eclState().getSimulationConfig().useCPR());
212 initialize();
213 }
214
216 {
217 OPM_TIMEBLOCK(IstlSolver);
218
220 // Polymer injectivity is incompatible with the CPRW linear solver.
221 if (parameters_[0].linsolver_ == "cprw" || parameters_[0].linsolver_ == "hybrid") {
222 OPM_THROW(std::runtime_error,
223 "The polymer injectivity model is incompatible with the CPRW linear solver.\n"
224 "Choose a different option, for example --linear-solver=ilu0");
225 }
226 }
227
228 if (parameters_[0].linsolver_ == "hybrid") {
229 // Experimental hybrid configuration.
230 // When chosen, will set up two solvers, one with CPRW
231 // and the other with ILU0 preconditioner. More general
232 // options may be added later.
233 prm_.clear();
234 parameters_.clear();
235 {
237 para.init(false);
238 para.linsolver_ = "cprw";
239 parameters_.push_back(para);
241 Parameters::IsSet<Parameters::LinearSolverMaxIter>(),
242 Parameters::IsSet<Parameters::LinearSolverReduction>()));
243 }
244 {
246 para.init(false);
247 para.linsolver_ = "ilu0";
248 parameters_.push_back(para);
250 Parameters::IsSet<Parameters::LinearSolverMaxIter>(),
251 Parameters::IsSet<Parameters::LinearSolverReduction>()));
252 }
253 // ------------
254 } else {
255 assert(parameters_.size() == 1);
256 assert(prm_.empty());
257
258 // Do a normal linear solver setup.
259 if (parameters_[0].is_nldd_local_solver_) {
261 Parameters::IsSet<Parameters::NlddLocalLinearSolverMaxIter>(),
262 Parameters::IsSet<Parameters::NlddLocalLinearSolverReduction>()));
263 }
264 else {
266 Parameters::IsSet<Parameters::LinearSolverMaxIter>(),
267 Parameters::IsSet<Parameters::LinearSolverReduction>()));
268 }
269 }
270 flexibleSolver_.resize(prm_.size());
271
272 const bool on_io_rank = (simulator_.gridView().comm().rank() == 0);
273#if HAVE_MPI
274 comm_.reset( new CommunicationType( simulator_.vanguard().grid().comm() ) );
275#endif
276 extractParallelGridInformationToISTL(simulator_.vanguard().grid(), parallelInformation_);
277
278 // For some reason simulator_.model().elementMapper() is not initialized at this stage
279 //const auto& elemMapper = simulator_.model().elementMapper(); //does not work.
280 // Set it up manually
281 ElementMapper elemMapper(simulator_.vanguard().gridView(), Dune::mcmgElementLayout());
283 useWellConn_ = Parameters::Get<Parameters::MatrixAddWellContributions>();
284 const bool ownersFirst = Parameters::Get<Parameters::OwnerCellsFirst>();
285 if (!ownersFirst) {
286 const std::string msg = "The linear solver no longer supports --owner-cells-first=false.";
287 if (on_io_rank) {
288 OpmLog::error(msg);
289 }
290 OPM_THROW_NOLOG(std::runtime_error, msg);
291 }
292
293 const int interiorCellNum_ = detail::numMatrixRowsToUseInSolver(simulator_.vanguard().grid(), true);
294 for (auto& f : flexibleSolver_) {
295 f.interiorCellNum_ = interiorCellNum_;
296 }
297
298#if HAVE_MPI
299 if (isParallel()) {
300 const std::size_t size = simulator_.vanguard().grid().leafGridView().size(0);
302 }
303#endif
304
305 // Print parameters to PRT/DBG logs.
307 }
308
309 // nothing to clean here
310 void eraseMatrix() override
311 {
312 }
313
314 void setActiveSolver(const int num) override
315 {
316 if (num > static_cast<int>(prm_.size()) - 1) {
317 OPM_THROW(std::logic_error, "Solver number " + std::to_string(num) + " not available.");
318 }
319 activeSolverNum_ = num;
320 if (simulator_.gridView().comm().rank() == 0) {
321 OpmLog::debug("Active solver = " + std::to_string(activeSolverNum_)
322 + " (" + parameters_[activeSolverNum_].linsolver_ + ")");
323 }
324 }
325
326 int numAvailableSolvers() const override
327 {
328 return flexibleSolver_.size();
329 }
330
331 void initPrepare(const Matrix& M, Vector& b)
332 {
333 const bool firstcall = (matrix_ == nullptr);
334
335 // update matrix entries for solvers.
336 if (firstcall) {
337 // model will not change the matrix object. Hence simply store a pointer
338 // to the original one with a deleter that does nothing.
339 // Outch! We need to be able to scale the linear system! Hence const_cast
340 matrix_ = const_cast<Matrix*>(&M);
341
342 useWellConn_ = Parameters::Get<Parameters::MatrixAddWellContributions>();
343 // setup sparsity pattern for jacobi matrix for preconditioner (only used for openclSolver)
344 } else {
345 // Pointers should not change
346 if ( &M != matrix_ ) {
347 OPM_THROW(std::logic_error,
348 "Matrix objects are expected to be reused when reassembling!");
349 }
350 }
351 rhs_ = &b;
352
353 // TODO: check all solvers, not just one.
354 if (isParallel() && prm_[activeSolverNum_].template get<std::string>("preconditioner.type") != "ParOverILU0") {
356 }
357 }
358
359 void prepare(const SparseMatrixAdapter& M, Vector& b) override
360 {
361 prepare(M.istlMatrix(), b);
362 }
363
364 void prepare(const Matrix& M, Vector& b) override
365 {
366 OPM_TIMEBLOCK(istlSolverPrepare);
367 try {
368 initPrepare(M,b);
369
371 } 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.");
372 }
373
374
375 void setResidual(Vector& /* b */) override
376 {
377 // rhs_ = &b; // Must be handled in prepare() instead.
378 }
379
380 void getResidual(Vector& b) const override
381 {
382 b = *rhs_;
383 }
384
385 void setMatrix(const SparseMatrixAdapter& /* M */) override
386 {
387 // matrix_ = &M.istlMatrix(); // Must be handled in prepare() instead.
388 }
389
390 int getSolveCount() const override {
391 return solveCount_;
392 }
393
395 solveCount_ = 0;
396 }
397
398 bool solve(Vector& x) override
399 {
400 OPM_TIMEBLOCK(istlSolverSolve);
401 ++solveCount_;
402 // Write linear system if asked for.
403 const int verbosity = prm_[activeSolverNum_].get("verbosity", 0);
404 const bool write_matrix = verbosity > 10;
405 if (write_matrix) {
406 Helper::writeSystem(simulator_, //simulator is only used to get names
407 getMatrix(),
408 *rhs_,
409 comm_.get());
410 }
411
412 // Solve system.
414 {
415 OPM_TIMEBLOCK(flexibleSolverApply);
416 assert(flexibleSolver_[activeSolverNum_].solver_);
417 flexibleSolver_[activeSolverNum_].solver_->apply(x, *rhs_, result);
418 }
419
420 iterations_ = result.iterations;
421
422 // Check convergence, iterations etc.
423 return checkConvergence(result);
424 }
425
426
432
434 int iterations () const override { return iterations_; }
435
437 const std::any& parallelInformation() const { return parallelInformation_; }
438
439 const CommunicationType* comm() const override { return comm_.get(); }
440
441 void setDomainIndex(const int index)
442 {
443 domainIndex_ = index;
444 }
445
446 bool isNlddLocalSolver() const
447 {
448 return parameters_[activeSolverNum_].is_nldd_local_solver_;
449 }
450
451 protected:
452#if HAVE_MPI
453 using Comm = Dune::OwnerOverlapCopyCommunication<int, int>;
454#endif
455
457 {
459 }
460
461 bool isParallel() const {
462#if HAVE_MPI
463 return !forceSerial_ && comm_->communicator().size() > 1;
464#else
465 return false;
466#endif
467 }
468
470 {
471 OPM_TIMEBLOCK(flexibleSolverPrepare);
472 if (shouldCreateSolver()) {
473 if (!useWellConn_) {
474 if (isNlddLocalSolver()) {
475 auto wellOp = std::make_unique<DomainWellModelAsLinearOperator<WellModel, Vector, Vector>>(simulator_.problem().wellModel());
476 wellOp->setDomainIndex(domainIndex_);
477 flexibleSolver_[activeSolverNum_].wellOperator_ = std::move(wellOp);
478 }
479 else {
480 auto wellOp = std::make_unique<WellModelOperator>(simulator_.problem().wellModel());
481 flexibleSolver_[activeSolverNum_].wellOperator_ = std::move(wellOp);
482 }
483 }
484 std::function<Vector()> weightCalculator = this->getWeightsCalculator(prm_[activeSolverNum_], getMatrix(), pressureIndex);
485 OPM_TIMEBLOCK(flexibleSolverCreate);
487 isParallel(),
490 weightCalculator,
492 comm_.get());
493 }
494 else
495 {
496 OPM_TIMEBLOCK(flexibleSolverUpdate);
497 flexibleSolver_[activeSolverNum_].pre_->update();
498 }
499 }
500
501
505 {
506 // Decide if we should recreate the solver or just do
507 // a minimal preconditioner update.
508 if (flexibleSolver_.empty()) {
509 return true;
510 }
511 if (!flexibleSolver_[activeSolverNum_].solver_) {
512 return true;
513 }
514
515 if (flexibleSolver_[activeSolverNum_].pre_->hasPerfectUpdate()) {
516 return false;
517 }
518
519 // For AMG based preconditioners, the hierarchy depends on the matrix values
520 // so it is recreated at certain intervals
521 if (this->parameters_[activeSolverNum_].cpr_reuse_setup_ == 0) {
522 // Always recreate solver.
523 return true;
524 }
525 if (this->parameters_[activeSolverNum_].cpr_reuse_setup_ == 1) {
526 // Recreate solver on the first iteration of every timestep.
527 const int newton_iteration = this->simulator_.model().newtonMethod().numIterations();
528 return newton_iteration == 0;
529 }
530 if (this->parameters_[activeSolverNum_].cpr_reuse_setup_ == 2) {
531 // Recreate solver if the last solve used more than 10 iterations.
532 return this->iterations() > 10;
533 }
534 if (this->parameters_[activeSolverNum_].cpr_reuse_setup_ == 3) {
535 // Never recreate the solver
536 return false;
537 }
538 if (this->parameters_[activeSolverNum_].cpr_reuse_setup_ == 4) {
539 // Recreate solver every 'step' solve calls.
540 const int step = this->parameters_[activeSolverNum_].cpr_reuse_interval_;
541 const bool create = ((solveCount_ % step) == 0);
542 return create;
543 }
544 // If here, we have an invalid parameter.
545 const bool on_io_rank = (simulator_.gridView().comm().rank() == 0);
546 std::string msg = "Invalid value: " + std::to_string(this->parameters_[activeSolverNum_].cpr_reuse_setup_)
547 + " for --cpr-reuse-setup parameter, run with --help to see allowed values.";
548 if (on_io_rank) {
549 OpmLog::error(msg);
550 }
551 throw std::runtime_error(msg);
552
553 return false;
554 }
555
556
557 // Weights to make approximate pressure equations.
558 // Calculated from the storage terms (only) of the
559 // conservation equations, ignoring all other terms.
560 std::function<Vector()> getWeightsCalculator(const PropertyTree& prm,
561 const Matrix& matrix,
562 std::size_t pressIndex) const
563 {
564 std::function<Vector()> weightsCalculator;
565
566 using namespace std::string_literals;
567
568 auto preconditionerType = prm.get("preconditioner.type"s, "cpr"s);
569 if (preconditionerType == "cpr" || preconditionerType == "cprt"
570 || preconditionerType == "cprw" || preconditionerType == "cprwt") {
571 const bool transpose = preconditionerType == "cprt" || preconditionerType == "cprwt";
572 const auto weightsType = prm.get("preconditioner.weight_type"s, "quasiimpes"s);
573 if (weightsType == "quasiimpes") {
574 // weights will be created as default in the solver
575 // assignment p = pressureIndex prevent compiler warning about
576 // capturing variable with non-automatic storage duration
577 weightsCalculator = [matrix, transpose, pressIndex]() {
578 return Amg::getQuasiImpesWeights<Matrix, Vector>(matrix,
579 pressIndex,
580 transpose);
581 };
582 } else if ( weightsType == "trueimpes" ) {
583 weightsCalculator =
584 [this, pressIndex]
585 {
586 Vector weights(rhs_->size());
587 ElementContext elemCtx(simulator_);
588 Amg::getTrueImpesWeights(pressIndex, weights,
589 simulator_.vanguard().gridView(),
590 elemCtx, simulator_.model(),
592 return weights;
593 };
594 } else if (weightsType == "trueimpesanalytic" ) {
595 weightsCalculator =
596 [this, pressIndex]
597 {
598 Vector weights(rhs_->size());
599 ElementContext elemCtx(simulator_);
600 Amg::getTrueImpesWeightsAnalytic(pressIndex, weights,
601 simulator_.vanguard().gridView(),
602 elemCtx, simulator_.model(),
604 return weights;
605 };
606 } else {
607 OPM_THROW(std::invalid_argument,
608 "Weights type " + weightsType +
609 "not implemented for cpr."
610 " Please use quasiimpes, trueimpes or trueimpesanalytic.");
611 }
612 }
613 return weightsCalculator;
614 }
615
616
618 {
619 return *matrix_;
620 }
621
622 const Matrix& getMatrix() const
623 {
624 return *matrix_;
625 }
626
628 mutable int iterations_;
629 mutable int solveCount_;
631
632 // non-const to be able to scale the linear system
635
637 std::vector<detail::FlexibleSolverInfo<Matrix,Vector,CommunicationType>> flexibleSolver_;
638 std::vector<int> overlapRows_;
639 std::vector<int> interiorRows_;
640
641 int domainIndex_ = -1;
642
644
645 std::vector<FlowLinearSolverParameters> parameters_;
646 bool forceSerial_ = false;
647 std::vector<PropertyTree> prm_;
648
649 std::shared_ptr< CommunicationType > comm_;
650 }; // end ISTLSolver
651
652} // namespace Opm
653
654#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:147
void getResidual(Vector &b) const override
Get the residual vector.
Definition: ISTLSolver.hpp:380
void initialize()
Definition: ISTLSolver.hpp:215
const Matrix & getMatrix() const
Definition: ISTLSolver.hpp:622
ISTLSolver(const Simulator &simulator, const FlowLinearSolverParameters &parameters, bool forceSerial=false)
Definition: ISTLSolver.hpp:190
void setDomainIndex(const int index)
Definition: ISTLSolver.hpp:441
int iterations() const override
Definition: ISTLSolver.hpp:434
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: ISTLSolver.hpp:150
std::shared_ptr< CommunicationType > comm_
Definition: ISTLSolver.hpp:649
static constexpr bool isIncompatibleWithCprw
Definition: ISTLSolver.hpp:167
std::vector< FlowLinearSolverParameters > parameters_
Definition: ISTLSolver.hpp:645
void setActiveSolver(const int num) override
Set the active solver by its index.
Definition: ISTLSolver.hpp:314
GetPropType< TypeTag, Properties::GridView > GridView
Definition: ISTLSolver.hpp:149
Dune::InverseOperator< Vector, Vector > AbstractSolverType
Definition: ISTLSolver.hpp:159
void setMatrix(const SparseMatrixAdapter &) override
Set the matrix for the solver.
Definition: ISTLSolver.hpp:385
void prepare(const Matrix &M, Vector &b) override
Prepare the solver with the given matrix and right-hand side vector.
Definition: ISTLSolver.hpp:364
typename SparseMatrixAdapter::IstlMatrix Matrix
Definition: ISTLSolver.hpp:156
GetPropType< TypeTag, Properties::WellModel > WellModel
Definition: ISTLSolver.hpp:154
int solveCount_
Definition: ISTLSolver.hpp:629
bool isNlddLocalSolver() const
Definition: ISTLSolver.hpp:446
Matrix & getMatrix()
Definition: ISTLSolver.hpp:617
int numAvailableSolvers() const override
Get the number of available solvers.
Definition: ISTLSolver.hpp:326
void prepare(const SparseMatrixAdapter &M, Vector &b) override
Prepare the solver with the given sparse matrix and right-hand side vector.
Definition: ISTLSolver.hpp:359
Dune::OwnerOverlapCopyCommunication< int, int > CommunicationType
Definition: ISTLSolver.hpp:170
int getSolveCount() const override
Get the count of how many times the solver has been called.
Definition: ISTLSolver.hpp:390
Matrix * matrix_
Definition: ISTLSolver.hpp:633
bool useWellConn_
Definition: ISTLSolver.hpp:643
bool shouldCreateSolver() const
Definition: ISTLSolver.hpp:504
bool checkConvergence(const Dune::InverseOperatorResult &result) const
Definition: ISTLSolver.hpp:456
static constexpr std::size_t pressureIndex
Definition: ISTLSolver.hpp:164
void prepareFlexibleSolver()
Definition: ISTLSolver.hpp:469
GetPropType< TypeTag, Properties::ThreadManager > ThreadManager
Definition: ISTLSolver.hpp:157
GetPropType< TypeTag, Properties::ElementMapper > ElementMapper
Definition: ISTLSolver.hpp:163
void resetSolveCount()
Definition: ISTLSolver.hpp:394
GetPropType< TypeTag, Properties::GlobalEqVector > Vector
Definition: ISTLSolver.hpp:152
const std::any & parallelInformation() const
Definition: ISTLSolver.hpp:437
void initPrepare(const Matrix &M, Vector &b)
Definition: ISTLSolver.hpp:331
std::vector< detail::FlexibleSolverInfo< Matrix, Vector, CommunicationType > > flexibleSolver_
Definition: ISTLSolver.hpp:637
void eraseMatrix() override
Signals that the memory for the matrix internally in the solver could be erased.
Definition: ISTLSolver.hpp:310
Dune::AssembledLinearOperator< Matrix, Vector, Vector > AbstractOperatorType
Definition: ISTLSolver.hpp:160
std::function< Vector()> getWeightsCalculator(const PropertyTree &prm, const Matrix &matrix, std::size_t pressIndex) const
Definition: ISTLSolver.hpp:560
Dune::AssembledLinearOperator< Matrix, Vector, Vector > AssembledLinearOperatorType
Definition: ISTLSolver.hpp:176
ISTLSolver(const Simulator &simulator)
Definition: ISTLSolver.hpp:204
int iterations_
Definition: ISTLSolver.hpp:628
int domainIndex_
Definition: ISTLSolver.hpp:641
std::any parallelInformation_
Definition: ISTLSolver.hpp:630
GetPropType< TypeTag, Properties::Simulator > Simulator
Definition: ISTLSolver.hpp:155
Vector * rhs_
Definition: ISTLSolver.hpp:634
int activeSolverNum_
Definition: ISTLSolver.hpp:636
std::vector< int > overlapRows_
Definition: ISTLSolver.hpp:638
GetPropType< TypeTag, Properties::Indices > Indices
Definition: ISTLSolver.hpp:153
const Simulator & simulator_
Definition: ISTLSolver.hpp:627
@ enablePolymerMolarWeight
Definition: ISTLSolver.hpp:166
std::vector< int > interiorRows_
Definition: ISTLSolver.hpp:639
Dune::OwnerOverlapCopyCommunication< int, int > Comm
Definition: ISTLSolver.hpp:453
bool forceSerial_
Definition: ISTLSolver.hpp:646
bool solve(Vector &x) override
Solve the system of equations Ax = b.
Definition: ISTLSolver.hpp:398
static void registerParameters()
Definition: ISTLSolver.hpp:178
std::vector< PropertyTree > prm_
Definition: ISTLSolver.hpp:647
GetPropType< TypeTag, Properties::ElementContext > ElementContext
Definition: ISTLSolver.hpp:158
void setResidual(Vector &) override
Set the residual vector.
Definition: ISTLSolver.hpp:375
const CommunicationType * comm() const override
Get the communication object used by the solver.
Definition: ISTLSolver.hpp:439
bool isParallel() const
Definition: ISTLSolver.hpp:461
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 threadId()
Return the index of the current OpenMP thread.
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 GridView &gridView, ElementContext &elemCtx, const Model &model, std::size_t threadId)
Definition: getQuasiImpesWeights.hpp:137
void getTrueImpesWeights(int pressureVarIndex, Vector &weights, const GridView &gridView, ElementContext &elemCtx, const Model &model, std::size_t threadId)
Definition: getQuasiImpesWeights.hpp:91
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:95
void init(bool cprRequestedInDataFile)
std::string linsolver_
Definition: FlowLinearSolverParameters.hpp:110
typename Linear::IstlSparseMatrixAdapter< Block > type
Definition: ISTLSolver.hpp:85
The class that allows to manipulate sparse matrices.
Definition: linalgproperties.hh:50
Definition: ISTLSolver.hpp:66
std::tuple< FlowIstlSolverParams > InheritsFrom
Definition: ISTLSolver.hpp:67
Definition: FlowBaseProblemProperties.hpp:87
Definition: ISTLSolver.hpp:99
std::unique_ptr< AbstractSolverType > solver_
Definition: ISTLSolver.hpp:112
std::size_t interiorCellNum_
Definition: ISTLSolver.hpp:116
Dune::InverseOperator< Vector, Vector > AbstractSolverType
Definition: ISTLSolver.hpp:100
AbstractPreconditionerType * pre_
Definition: ISTLSolver.hpp:115
Dune::AssembledLinearOperator< Matrix, Vector, Vector > AbstractOperatorType
Definition: ISTLSolver.hpp:101
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:114
std::unique_ptr< AbstractOperatorType > op_
Definition: ISTLSolver.hpp:113