27 #ifndef EWOMS_PARALLEL_BICGSTAB_BACKEND_HH
28 #define EWOMS_PARALLEL_BICGSTAB_BACKEND_HH
38 template <
class TypeTag>
43 namespace Properties {
52 SET_SCALAR_PROP(ParallelBiCGStabLinearSolver, LinearSolverMaxError, 1e7);
83 template <
class TypeTag>
84 class ParallelBiCGStabSolverBackend :
public ParallelBaseBackend<TypeTag>
86 typedef ParallelBaseBackend<TypeTag> ParentType;
88 typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
89 typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
91 typedef typename ParentType::ParallelOperator ParallelOperator;
92 typedef typename ParentType::OverlappingVector OverlappingVector;
93 typedef typename ParentType::ParallelPreconditioner ParallelPreconditioner;
94 typedef typename ParentType::ParallelScalarProduct ParallelScalarProduct;
96 typedef BiCGStabSolver<ParallelOperator,
98 ParallelPreconditioner> RawLinearSolver;
101 ParallelBiCGStabSolverBackend(const Simulator& simulator)
102 : ParentType(simulator)
105 static void registerParameters()
110 "The maximum residual error which the linear solver tolerates"
111 " without giving up");
117 std::shared_ptr<RawLinearSolver> prepareSolver_(ParallelOperator& parOperator,
118 ParallelScalarProduct& parScalarProduct,
119 ParallelPreconditioner& parPreCond)
121 const auto& gridView = this->simulator_.
gridView();
122 typedef CombinedCriterion<OverlappingVector, decltype(gridView.comm())> CCC;
124 Scalar linearSolverTolerance =
EWOMS_GET_PARAM(TypeTag, Scalar, LinearSolverTolerance);
125 Scalar linearSolverAbsTolerance = this->simulator_.
model().newtonMethod().tolerance() / 10.0;
127 convCrit_.reset(
new CCC(gridView.comm(),
128 linearSolverTolerance,
129 linearSolverAbsTolerance,
132 auto bicgstabSolver =
133 std::make_shared<RawLinearSolver>(parPreCond, *convCrit_, parScalarProduct);
136 if (parOperator.overlap().myRank() == 0)
138 bicgstabSolver->setVerbosity(verbosity);
139 bicgstabSolver->setMaxIterations(
EWOMS_GET_PARAM(TypeTag,
int, LinearSolverMaxIterations));
140 bicgstabSolver->setLinearOperator(&parOperator);
141 bicgstabSolver->setRhs(this->overlappingb_);
143 return bicgstabSolver;
146 bool runSolver_(std::shared_ptr<RawLinearSolver> solver)
147 {
return solver->apply(*this->overlappingx_); }
149 void cleanupSolver_()
152 std::unique_ptr<ConvergenceCriterion<OverlappingVector> > convCrit_;
Model & model()
Return the physical model used in the simulation.
Definition: simulator.hh:189
#define NEW_TYPE_TAG(...)
Define a new type tag.
Definition: propertysystem.hh:169
#define INHERITS_FROM(...)
Syntactic sugar for NEW_TYPE_TAG.
Definition: propertysystem.hh:230
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:68
Implements a generic linear solver abstraction.
Definition: parallelbicgstabbackend.hh:39
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:99
static void registerParameters()
Register all run-time parameters for the linear solver.
Definition: parallelbasebackend.hh:187
Implements a preconditioned stabilized BiCG linear solver.
#define NEW_PROP_TAG(PTagName)
Define a property tag.
Definition: propertysystem.hh:247
#define SET_TYPE_PROP(EffTypeTagName, PropTagName,...)
Set a property which defines a type.
Definition: propertysystem.hh:377
const GridView & gridView() const
Return the grid view for which the simulation is done.
Definition: simulator.hh:183
#define SET_SCALAR_PROP(EffTypeTagName, PropTagName,...)
Set a property to a simple constant scalar value.
Definition: propertysystem.hh:394
Provides the common code which is required by most linear solvers.