ExaDG
Toggle main menu visibility
Loading...
Searching...
No Matches
include
exadg
solvers_and_preconditioners
preconditioners
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 EXADG_SOLVERS_AND_PRECONDITIONERS_PRECONDITIONERS_JACOBI_PRECONDITIONER_H_
23
#define EXADG_SOLVERS_AND_PRECONDITIONERS_PRECONDITIONERS_JACOBI_PRECONDITIONER_H_
24
25
// deal.II
26
#include <deal.II/lac/la_parallel_vector.h>
27
28
// ExaDG
29
#include <exadg/solvers_and_preconditioners/preconditioners/preconditioner_base.h>
30
31
namespace
ExaDG
32
{
33
template
<
typename
Operator>
34
class
JacobiPreconditioner :
public
PreconditionerBase<typename Operator::value_type>
35
{
36
public
:
37
typedef
typename
PreconditionerBase<typename Operator::value_type>::VectorType VectorType;
38
39
JacobiPreconditioner(Operator
const
& underlying_operator_in,
bool
const
initialize)
40
: underlying_operator(underlying_operator_in)
41
{
42
underlying_operator.initialize_dof_vector(inverse_diagonal);
43
44
if
(initialize)
45
{
46
this->update();
47
}
48
}
49
50
void
51
vmult(VectorType & dst, VectorType
const
& src)
const
final
52
{
53
if
(dealii::PointerComparison::equal(&dst, &src))
54
{
55
dst.scale(inverse_diagonal);
56
}
57
else
58
{
59
for
(
unsigned
int
i = 0; i < dst.locally_owned_size(); ++i)
60
dst.local_element(i) = inverse_diagonal.local_element(i) * src.local_element(i);
61
}
62
}
63
64
unsigned
int
65
get_size_of_diagonal()
66
{
67
return
inverse_diagonal.size();
68
}
69
70
void
71
update()
final
72
{
73
underlying_operator.calculate_inverse_diagonal(inverse_diagonal);
74
75
this->update_needed =
false
;
76
}
77
78
private
:
79
Operator
const
& underlying_operator;
80
81
VectorType inverse_diagonal;
82
};
83
84
}
// namespace ExaDG
85
86
#endif
/* EXADG_SOLVERS_AND_PRECONDITIONERS_PRECONDITIONERS_JACOBI_PRECONDITIONER_H_ */
ExaDG
Definition
driver.cpp:33
Generated by
1.17.0