Skip to content

Commit 4be866b

Browse files
hnilbska
authored andcommitted
-- setting for hypre
-- added handling of changing matrix for linear solver
1 parent 49c4d69 commit 4be866b

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

opm/simulators/linalg/ISTLSolver.hpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,12 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
337337
void initPrepare(const Matrix& M, Vector& b)
338338
{
339339
const bool firstcall = (matrix_ == nullptr);
340-
340+
const bool matrix_changed = &M != matrix_;
341+
if(matrix_changed){
342+
force_recreate_ = true;
343+
}
341344
// update matrix entries for solvers.
342-
if (firstcall) {
345+
if (firstcall || matrix_changed) {
343346
// model will not change the matrix object. Hence simply store a pointer
344347
// to the original one with a deleter that does nothing.
345348
// Outch! We need to be able to scale the linear system! Hence const_cast
@@ -506,14 +509,23 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
506509
flexibleSolver_[activeSolverNum_].pre_->update();
507510
}
508511
}
509-
510-
512+
public:
513+
void setForceReCreate(){
514+
force_recreate_ = false;
515+
}
516+
517+
protected:
511518
/// Return true if we should (re)create the whole solver,
512519
/// instead of just calling update() on the preconditioner.
513-
bool shouldCreateSolver() const
520+
bool shouldCreateSolver() //const
514521
{
515522
// Decide if we should recreate the solver or just do
516523
// a minimal preconditioner update.
524+
if(force_recreate_){
525+
force_recreate_ = false;
526+
return true;
527+
}
528+
517529
if (flexibleSolver_.empty()) {
518530
return true;
519531
}
@@ -663,6 +675,7 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
663675

664676
std::shared_ptr< CommunicationType > comm_;
665677
std::unique_ptr<ElementChunksType> element_chunks_;
678+
bool force_recreate_ = false;
666679
}; // end ISTLSolver
667680

668681
} // namespace Opm

0 commit comments

Comments
 (0)