44 using Scalar =
typename Vector::field_type;
51 const Scalar tolerance,
54 const bool opencl_ilu_parallel,
60 void prepare(
const Grid& grid,
64 const std::vector<int>& cellPartition,
65 const std::size_t nonzeroes,
68 bool apply(Vector& rhs,
74 Dune::InverseOperatorResult&
result);
78 int numJacobiBlocks_ = 0;
84 void blockJacobiAdjacency(
const Grid& grid,
86 std::size_t nonzeroes);
88 void copyMatToBlockJac(
const Matrix& mat, Matrix&
blockJac);
90 std::unique_ptr<Bridge> bridge_;
91 std::string accelerator_mode_;
92 std::unique_ptr<Matrix> blockJacobiForGPUILU0_;
93 std::vector<std::set<int>> wellConnectionsGraph_;
114 using Matrix =
typename SparseMatrixAdapter::IstlMatrix;
117 using AbstractSolverType = Dune::InverseOperator<Vector, Vector>;
118 using AbstractOperatorType = Dune::AssembledLinearOperator<Matrix, Vector, Vector>;
125 using CommunicationType = Dune::OwnerOverlapCopyCommunication<int,int>;
127 using CommunicationType = Dune::Communication<int>;
131 using AssembledLinearOperatorType = Dune::AssembledLinearOperator< Matrix, Vector, Vector >;
155 std::string accelerator_mode = Parameters::Get<Parameters::AcceleratorMode>();
157 if ((this->simulator_.vanguard().grid().comm().size() > 1) && (accelerator_mode !=
"none")) {
158 const bool on_io_rank = (this->simulator_.gridView().comm().rank() == 0);
160 OpmLog::warning(
"Cannot use AcceleratorMode feature with MPI, setting AcceleratorMode to 'none'.");
162 accelerator_mode =
"none";
165 if (accelerator_mode ==
"none") {
170 const int platformID = Parameters::Get<Parameters::OpenclPlatformId>();
171 const int deviceID = Parameters::Get<Parameters::BdaDeviceId>();
172 const int maxit = Parameters::Get<Parameters::LinearSolverMaxIter>();
173 const double tolerance = Parameters::Get<Parameters::LinearSolverReduction>();
174 const bool opencl_ilu_parallel = Parameters::Get<Parameters::OpenclIluParallel>();
176 std::string
linsolver = Parameters::Get<Parameters::LinearSolver>();
177 bdaBridge_ = std::make_unique<detail::BdaSolverInfo<Matrix,Vector>>(accelerator_mode,
187 void prepare(
const Matrix& M, Vector&
b)
195 ParentType::initPrepare(M,
b);
197 ParentType::prepare(M,
b);
200#if HAVE_OPENCL || HAVE_ROCSPARSE || HAVE_CUDA
207 bdaBridge_->numJacobiBlocks_ = Parameters::Get<Parameters::NumJacobiBlocks>();
208 bdaBridge_->prepare(this->simulator_.vanguard().grid(),
209 this->simulator_.vanguard().cartesianIndexMapper(),
210 this->simulator_.vanguard().schedule().getWellsatEnd(),
211 this->simulator_.vanguard().schedule().getPossibleFutureConnections(),
212 this->simulator_.vanguard().cellPartition(),
213 this->getMatrix().nonzeroes(),
this->useWellConn_);
219 void setResidual(Vector& )
224 void getResidual(Vector&
b)
const
229 void setMatrix(
const SparseMatrixAdapter& )
234 bool solve(Vector& x)
237 return ParentType::solve(x);
241 this->solveCount_ += 1;
243 const int verbosity = this->prm_[this->activeSolverNum_].template
get<int>(
"verbosity", 0);
246 Helper::writeSystem(this->simulator_,
253 Dune::InverseOperatorResult
result;
258 this->simulator_.problem().wellModel().getWellContributions(
w);
261 this->simulator_.gridView().comm().rank(),
262 const_cast<Matrix&
>(
this->getMatrix()),
265 if(bdaBridge_->gpuActive()){
267 ParentType::prepareFlexibleSolver();
269 assert(this->flexibleSolver_[this->activeSolverNum_].solver_);
270 this->flexibleSolver_[this->activeSolverNum_].solver_->apply(x, *(this->rhs_),
result);
274 this->checkConvergence(
result);
276 return this->converged_;
280 std::unique_ptr<detail::BdaSolverInfo<Matrix, Vector>> bdaBridge_;
ISTLSolverBda(const Simulator &simulator, const FlowLinearSolverParameters ¶meters)
Construct a system solver.
Definition ISTLSolverBda.hpp:137
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
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:235