108 using Matrix =
typename SparseMatrixAdapter::IstlMatrix;
111 using AbstractSolverType = Dune::InverseOperator<Vector, Vector>;
112 using AbstractOperatorType = Dune::AssembledLinearOperator<Matrix, Vector, Vector>;
119 using CommunicationType = Dune::OwnerOverlapCopyCommunication<int,int>;
121 using CommunicationType = Dune::CollectiveCommunication<int>;
125 using AssembledLinearOperatorType = Dune::AssembledLinearOperator< Matrix, Vector, Vector >;
149 std::string accelerator_mode =
EWOMS_GET_PARAM(TypeTag, std::string, AcceleratorMode);
151 if ((this->simulator_.vanguard().grid().comm().size() > 1) && (accelerator_mode !=
"none")) {
152 const bool on_io_rank = (this->simulator_.gridView().comm().rank() == 0);
154 OpmLog::warning(
"Cannot use AcceleratorMode feature with MPI, setting AcceleratorMode to 'none'.");
156 accelerator_mode =
"none";
159 if (accelerator_mode ==
"none") {
164 const int platformID = EWOMS_GET_PARAM(TypeTag,
int, OpenclPlatformId);
165 const int deviceID = EWOMS_GET_PARAM(TypeTag,
int, BdaDeviceId);
166 const int maxit = EWOMS_GET_PARAM(TypeTag,
int, LinearSolverMaxIter);
167 const double tolerance = EWOMS_GET_PARAM(TypeTag,
double, LinearSolverReduction);
168 const bool opencl_ilu_parallel = EWOMS_GET_PARAM(TypeTag,
bool, OpenclIluParallel);
169 const int linear_solver_verbosity = this->parameters_[0].linear_solver_verbosity_;
170 std::string linsolver = EWOMS_GET_PARAM(TypeTag, std::string, LinearSolver);
171 bdaBridge_ = std::make_unique<detail::BdaSolverInfo<Matrix,Vector>>(accelerator_mode,
172 linear_solver_verbosity,
181 void prepare(
const Matrix& M, Vector& b)
183 OPM_TIMEBLOCK(prepare);
184 [[maybe_unused]]
const bool firstcall = (this->matrix_ ==
nullptr);
185 ParentType::prepare(M,b);
189 if (firstcall && bdaBridge_) {
194 bdaBridge_->numJacobiBlocks_ = EWOMS_GET_PARAM(TypeTag,
int, NumJacobiBlocks);
195 bdaBridge_->prepare(this->simulator_.vanguard().grid(),
196 this->simulator_.vanguard().cartesianIndexMapper(),
197 this->simulator_.vanguard().schedule().getWellsatEnd(),
198 this->simulator_.vanguard().cellPartition(),
199 this->getMatrix().nonzeroes(), this->useWellConn_);
205 void setResidual(Vector& )
210 void getResidual(Vector& b)
const
215 void setMatrix(
const SparseMatrixAdapter& )
220 bool solve(Vector& x)
223 return ParentType::solve(x);
226 OPM_TIMEBLOCK(istlSolverEbosBdaSolve);
227 this->solveCount_ += 1;
229 const int verbosity = this->prm_[this->activeSolverNum_].template get<int>(
"verbosity", 0);
230 const bool write_matrix = verbosity > 10;
232 Helper::writeSystem(this->simulator_,
239 Dune::InverseOperatorResult result;
241 std::function<void(WellContributions&)> getContribs =
242 [
this](WellContributions& w)
244 this->simulator_.problem().wellModel().getWellContributions(w);
246 if (!bdaBridge_->apply(*(this->rhs_), this->useWellConn_, getContribs,
247 this->simulator_.gridView().comm().rank(),
248 const_cast<Matrix&
>(this->getMatrix()),
251 if(bdaBridge_->gpuActive()){
253 ParentType::prepareFlexibleSolver();
255 assert(this->flexibleSolver_[this->activeSolverNum_].solver_);
256 this->flexibleSolver_[this->activeSolverNum_].solver_->apply(x, *(this->rhs_), result);
260 this->checkConvergence(result);
262 return this->converged_;
266 std::unique_ptr<detail::BdaSolverInfo<Matrix, Vector>> bdaBridge_;