ExaDG
Loading...
Searching...
No Matches
block_jacobi_preconditioner.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2021 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_BLOCKJACOBIPRECONDITIONER_H_
23#define INCLUDE_SOLVERS_AND_PRECONDITIONERS_BLOCKJACOBIPRECONDITIONER_H_
24
25#include <exadg/solvers_and_preconditioners/preconditioners/preconditioner_base.h>
26
27namespace ExaDG
28{
29template<typename Operator>
30class BlockJacobiPreconditioner : public PreconditionerBase<typename Operator::value_type>
31{
32public:
33 typedef typename PreconditionerBase<typename Operator::value_type>::VectorType VectorType;
34
35 BlockJacobiPreconditioner(Operator const & underlying_operator_in, bool const initialize)
36 : underlying_operator(underlying_operator_in)
37 {
38 // initialize block Jacobi
39 underlying_operator.initialize_block_diagonal_preconditioner(initialize);
40
41 if(initialize)
42 this->update_needed = false;
43 }
44
45 /*
46 * This function updates the block Jacobi preconditioner.
47 * Make sure that the underlying operator has been updated
48 * when calling this function.
49 */
50 void
51 update() final
52 {
53 underlying_operator.update_block_diagonal_preconditioner();
54
55 this->update_needed = false;
56 }
57
58 /*
59 * This function applies the block Jacobi preconditioner.
60 * Make sure that the block Jacobi preconditioner has been
61 * updated when calling this function.
62 */
63 void
64 vmult(VectorType & dst, VectorType const & src) const final
65 {
66 AssertThrow(
67 not this->update_needed,
68 dealii::ExcMessage(
69 "Block Jacobi preconditioner can not be applied because it needs to be updated."));
70
71 underlying_operator.apply_inverse_block_diagonal(dst, src);
72 }
73
74private:
75 Operator const & underlying_operator;
76};
77
78} // namespace ExaDG
79
80
81#endif /* INCLUDE_SOLVERS_AND_PRECONDITIONERS_BLOCKJACOBIPRECONDITIONER_H_ */
Definition block_jacobi_preconditioner.h:31
Definition preconditioner_base.h:35
Definition driver.cpp:33