16 #ifndef inverse_opeator_h
17 #define inverse_opeator_h
116 const std::string &default_solver =
"cg",
136 template <
typename Domain,
138 typename PreconditionerType,
139 typename Range = Domain>
140 dealii::LinearOperator<Domain, Range, Payload>
141 operator()(
const dealii::LinearOperator<Range, Domain, Payload> &op,
142 const PreconditionerType &prec,
143 const double abs_tol = 0.0,
144 const std::string &prefix =
"")
const;
155 template <
typename Range,
157 dealii::internal::LinearOperatorImplementation::EmptyPayload,
158 typename Domain = Range,
160 typename PreconditionerType>
161 dealii::LinearOperator<Range, Domain, Payload>
163 const PreconditionerType &prec,
164 const double abs_tol = 0.0,
165 const std::string &prefix =
"")
const;
174 template <
typename MatrixType,
175 typename PreconditionerType,
179 const PreconditionerType &preconditioner,
180 const VectorType &src,
182 const double abs_tol = 0.0)
const;
196 std::unique_ptr<dealii::SolverControl>
204 template <
typename Range,
typename Payload>
205 std::shared_ptr<dealii::SolverBase<Range>>
217 mutable std::unique_ptr<dealii::SolverControl>
control;
268 template <
typename MatrixType,
269 typename PreconditionerType,
273 const PreconditionerType &preconditioner,
274 const VectorType &src,
276 const double abs_tol)
const
282 solver.solve(matrix, dst, src, preconditioner);
287 solver.solve(matrix, dst, src, preconditioner);
292 solver.solve(matrix, dst, src, preconditioner);
297 solver.solve(matrix, dst, src, preconditioner);
302 solver.solve(matrix, dst, src, preconditioner);
307 solver.solve(matrix, dst, src, preconditioner);
312 solver.solve(matrix, dst, src, preconditioner);
322 template <
typename Range,
326 typename PreconditionerType>
327 dealii::LinearOperator<Range, Domain, Payload>
329 const PreconditionerType &prec,
330 const double abs_tol,
331 const std::string &prefix)
const
338 using SolverType = std::shared_ptr<dealii::SolverBase<Range>>;
339 auto &
solver =
storage.template get_or_add_object_with_name<SolverType>(
342 dealii::LinearOperator<Range, Domain, Payload> inverse;
344 auto initialize_solver = [&](
auto *s) {
351 initialize_solver(
new dealii::SolverCG<Range>(*
control));
355 initialize_solver(
new dealii::SolverBicgstab<Range>(*
control));
359 initialize_solver(
new dealii::SolverGMRES<Range>(*
control));
363 initialize_solver(
new dealii::SolverFGMRES<Range>(*
control));
367 initialize_solver(
new dealii::SolverMinRes<Range>(*
control));
371 initialize_solver(
new dealii::SolverQMRS<Range>(*
control));
375 initialize_solver(
new dealii::SolverRichardson<Range>(*
control));
387 template <
typename Domain,
389 typename PreconditionerType,
391 dealii::LinearOperator<Domain, Range, Payload>
393 const dealii::LinearOperator<Range, Domain, Payload> &op,
394 const PreconditionerType &prec,
395 const double abs_tol,
396 const std::string &prefix)
const
398 return solver<Range, Payload>(op, prec, abs_tol, prefix);
const std::string section_name
A factory that can generate inverse operators according to parameter files.
bool log_result
Log the final result.
void solve(const MatrixType &matrix, const PreconditionerType &preconditioner, const VectorType &src, VectorType &dst, const double abs_tol=0.0) const
Solve using the specified solver, preconditioner, and tolerance.
double tolerance
Default reduction required to succesfully complete a solution step.
std::string get_solver_name() const
Get the solver name.
InverseOperator(const std::string §ion_name="", const std::string &default_solver="cg", const SolverControlType &control_type=SolverControlType::tolerance, const unsigned int max_iterations=1000, const double tolerance=1e-12, const double reduction=1e-6, const unsigned int consecutive_iterations=2, const bool &log_history=false, const bool &log_result=false)
Store and parse the parameters that will be needed to create a linear operator that computes the inve...
std::string solver_name
Solver name.
unsigned int consecutive_iterations
Number of consecutive iterations (used only for ConsecutiveControl).
bool log_history
Log the solver history.
double reduction
Default reduction required to succesfully complete a solution step.
LinearOperator< Domain, Range, Payload > operator()(const LinearOperator< Range, Domain, Payload > &op, const PreconditionerType &prec, const double abs_tol=0.0, const std::string &prefix="") const
Create an inverse operator according to the parameters given in the parameter file.
SolverControlType control_type
Defines the behaviour of the solver control.
LinearOperator< Range, Domain, Payload > solver(const MatrixType &op, const PreconditionerType &prec, const double abs_tol=0.0, const std::string &prefix="") const
Create a solver.
std::unique_ptr< SolverControl > setup_new_solver_control(const double abs_tol=0.0) const
Create a new solver control according to the parameters.
std::shared_ptr< SolverBase< Range > > setup_new_solver(const double abs_tol=0.0) const
Create a new solver according to the parameters.
unsigned int max_iterations
Default number of maximum iterations required to succesfully complete a solution step.
GeneralDataStorage storage
Local storage for the actual solver object.
std::unique_ptr< SolverControl > control
Used internally by the solver.
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
LinearOperator< Domain, Range, Payload > inverse_operator(const LinearOperator< Range, Domain, Payload > &op, Solver &solver, const Preconditioner &preconditioner)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
SolverControlType
An enum class used to identify different classes derived from SolverControl.
@ iteration_number
Use IterationNumberControl.
@ tolerance
Use SolverControl.
@ reduction
Use ReductionControl.
@ consecutive_iterations
Use ConsecutiveControl.