97 using OverlappingVector =
typename ParentType::OverlappingVector;
102 using VectorBlock = Dune::FieldVector<LinearSolverScalar, numEq>;
103 using MatrixBlock =
typename SparseMatrixAdapter::MatrixBlock;
104 using IstlMatrix =
typename SparseMatrixAdapter::IstlMatrix;
106 using Vector = Dune::BlockVector<VectorBlock>;
110 using SequentialSmoother = Dune::SeqSOR<IstlMatrix, Vector, Vector>;
117 using FineOperator = Dune::OverlappingSchwarzOperator<IstlMatrix,
121 using FineScalarProduct = Dune::OverlappingSchwarzScalarProduct<Vector,
123 using ParallelSmoother = Dune::BlockPreconditioner<Vector,
127 using AMG = Dune::Amg::AMG<FineOperator,
132 using FineOperator = Dune::MatrixAdapter<IstlMatrix, Vector, Vector>;
133 using FineScalarProduct = Dune::SeqScalarProduct<Vector>;
134 using ParallelSmoother = SequentialSmoother;
135 using AMG = Dune::Amg::AMG<FineOperator, Vector, ParallelSmoother>;
142 static_assert(std::is_same<SparseMatrixAdapter, IstlSparseMatrixAdapter<MatrixBlock> >::value,
143 "The ParallelAmgBackend linear solver backend requires the IstlSparseMatrixAdapter");
147 : ParentType(simulator)
150 static void registerParameters()
152 ParentType::registerParameters();
154 Parameters::Register<Parameters::LinearSolverMaxError<Scalar>>
155 (
"The maximum residual error which the linear solver tolerates "
156 "without giving up");
157 Parameters::Register<Parameters::AmgCoarsenTarget>
158 (
"The coarsening target for the agglomerations of "
159 "the AMG preconditioner");
165 std::shared_ptr<AMG> preparePreconditioner_()
177 fineOperator_ = std::make_shared<FineOperator>(*this->overlappingMatrix_, *
istlComm_);
179 fineOperator_ = std::make_shared<FineOperator>(*this->overlappingMatrix_);
187 void cleanupPreconditioner_()
190 std::shared_ptr<RawLinearSolver> prepareSolver_(ParallelOperator&
parOperator,
194 const auto& gridView = this->simulator_.gridView();
203 convCrit_.reset(
new CCC(gridView.comm(),
206 Parameters::Get<Parameters::LinearSolverMaxError<Scalar>>()));
213 verbosity = Parameters::Get<Parameters::LinearSolverVerbosity>();
215 bicgstabSolver->setMaxIterations(Parameters::Get<Parameters::LinearSolverMaxIterations>());
222 std::pair<bool,int> runSolver_(std::shared_ptr<RawLinearSolver>
solver)
224 bool converged =
solver->apply(*this->overlappingx_);
225 return std::make_pair(converged,
int(
solver->report().iterations()));
228 void cleanupSolver_()
232 template <
class ParallelIndexSet>
242 overlap.iAmMasterOf(
curIdx)
243 ? GridAttributes::owner
244 : GridAttributes::copy;
252 Dune::ParallelLocalIndex<GridAttributeSet>(
static_cast<size_t>(
curIdx),
261 template <
typename C>
266 template <
typename C>
267 void setUseFixedOrder(C, ...)
278 if (this->simulator_.vanguard().gridView().comm().rank() == 0)
279 verbosity = Parameters::Get<Parameters::LinearSolverVerbosity>();
281 using SmootherArgs =
typename Dune::Amg::SmootherTraits<ParallelSmoother>::Arguments;
293 CoarsenCriterion<Dune::Amg::SymmetricCriterion<IstlMatrix, Dune::Amg::FrobeniusNorm> >;
294 int coarsenTarget = Parameters::Get<Parameters::AmgCoarsenTarget>();
318 std::unique_ptr<ConvergenceCriterion<OverlappingVector> > convCrit_;
320 std::shared_ptr<FineOperator> fineOperator_;
321 std::shared_ptr<AMG> amg_;
324 std::shared_ptr<OwnerOverlapCopyCommunication>
istlComm_;