ExaDG
Loading...
Searching...
No Matches
additive_schwarz_preconditioner.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2023 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef INCLUDE_SOLVERS_AND_PRECONDITIONERS_ADDITIVESCHWARZPRECONDITIONER_H_
23#define INCLUDE_SOLVERS_AND_PRECONDITIONERS_ADDITIVESCHWARZPRECONDITIONER_H_
24
25#include <deal.II/lac/sparse_matrix.h>
26
27#include <exadg/solvers_and_preconditioners/preconditioners/preconditioner_base.h>
28
29namespace ExaDG
30{
31template<typename Operator>
32class AdditiveSchwarzPreconditioner : public PreconditionerBase<typename Operator::value_type>
33{
34public:
35 typedef typename PreconditionerBase<typename Operator::value_type>::VectorType VectorType;
36
37 AdditiveSchwarzPreconditioner(Operator const & underlying_operator_in, bool const initialize)
38 : underlying_operator(underlying_operator_in)
39 {
40 if(initialize)
41 {
42 this->update();
43 }
44 }
45
46 /*
47 * This function applies the additive Schwarz preconditioner.
48 * Make sure that the additive Schwarz preconditioner has been
49 * updated when calling this function.
50 */
51 void
52 vmult(VectorType & dst, VectorType const & src) const final
53 {
54 AssertThrow(
55 not this->update_needed,
56 dealii::ExcMessage(
57 "Additive Schwarz preconditioner can not be applied because it needs to be updated."));
58
59 underlying_operator.apply_inverse_additive_schwarz_matrices(dst, src);
60 }
61
62 /*
63 * This function updates the additive Schwarz preconditioner.
64 * Make sure that the underlying operator has been updated
65 * when calling this function.
66 */
67 void
68 update() final
69 {
70 underlying_operator.compute_factorized_additive_schwarz_matrices();
71 this->update_needed = false;
72 }
73
74private:
75 Operator const & underlying_operator;
76};
77
78} // namespace ExaDG
79
80
81#endif /* INCLUDE_SOLVERS_AND_PRECONDITIONERS_ADDITIVESCHWARZPRECONDITIONER_H_ */
Definition additive_schwarz_preconditioner.h:33
Definition preconditioner_base.h:35
Definition driver.cpp:33