ExaDG
Toggle main menu visibility
Loading...
Searching...
No Matches
include
exadg
solvers_and_preconditioners
multigrid
smoothers
cg_smoother.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_MULTIGRID_SMOOTHERS_CG_SMOOTHER_H_
23
#define EXADG_SOLVERS_AND_PRECONDITIONERS_MULTIGRID_SMOOTHERS_CG_SMOOTHER_H_
24
25
// deal.II
26
#include <deal.II/lac/solver_cg.h>
27
28
// ExaDG
29
#include <exadg/solvers_and_preconditioners/multigrid/multigrid_parameters.h>
30
#include <exadg/solvers_and_preconditioners/multigrid/smoothers/smoother_base.h>
31
#include <exadg/solvers_and_preconditioners/preconditioners/block_jacobi_preconditioner.h>
32
#include <exadg/solvers_and_preconditioners/preconditioners/jacobi_preconditioner.h>
33
34
namespace
ExaDG
35
{
36
template
<
typename
Operator,
typename
VectorType>
37
class
CGSmoother :
public
SmootherBase
<VectorType>
38
{
39
public
:
40
CGSmoother() : underlying_operator(
nullptr
), preconditioner(
nullptr
)
41
{
42
}
43
44
~CGSmoother()
45
{
46
delete
preconditioner;
47
preconditioner =
nullptr
;
48
}
49
50
CGSmoother(CGSmoother
const
&) =
delete
;
51
52
CGSmoother &
53
operator=(CGSmoother
const
&) =
delete
;
54
55
struct
AdditionalData
56
{
60
AdditionalData
() : preconditioner(PreconditionerSmoother::None), number_of_iterations(5)
61
{
62
}
63
64
// preconditioner
65
PreconditionerSmoother preconditioner;
66
67
// number of CG iterations per smoothing step
68
unsigned
int
number_of_iterations;
69
};
70
71
void
72
setup(Operator
const
& operator_in,
73
bool
const
initialize_preconditioner,
74
AdditionalData
const
& additional_data_in)
75
{
76
underlying_operator = &operator_in;
77
data = additional_data_in;
78
79
if
(data.preconditioner == PreconditionerSmoother::PointJacobi)
80
{
81
preconditioner =
82
new
JacobiPreconditioner<Operator>
(*underlying_operator, initialize_preconditioner);
83
}
84
else
if
(data.preconditioner == PreconditionerSmoother::BlockJacobi)
85
{
86
preconditioner =
87
new
BlockJacobiPreconditioner<Operator>(*underlying_operator, initialize_preconditioner);
88
}
89
else
90
{
91
AssertThrow(data.preconditioner == PreconditionerSmoother::None,
92
dealii::ExcMessage(
"Specified preconditioner not implemented for CG smoother"
));
93
}
94
}
95
96
void
97
update() final
98
{
99
if
(preconditioner !=
nullptr
)
100
preconditioner->update();
101
}
102
103
// same as step(), but sets dst-vector to zero
104
void
105
vmult(VectorType & dst, VectorType
const
& src)
const
final
106
{
107
dst = 0.0;
108
step(dst, src);
109
}
110
111
void
112
step(VectorType & dst, VectorType
const
& src)
const
final
113
{
114
dealii::IterationNumberControl control(data.number_of_iterations, 1.e-20);
115
116
dealii::SolverCG<VectorType> solver(control);
117
118
if
(preconditioner !=
nullptr
)
119
solver.solve(*underlying_operator, dst, src, *preconditioner);
120
else
121
solver.solve(*underlying_operator, dst, src, dealii::PreconditionIdentity());
122
}
123
124
private
:
125
Operator
const
* underlying_operator;
126
AdditionalData
data;
127
128
PreconditionerBase<typename Operator::value_type> * preconditioner;
129
};
130
131
}
// namespace ExaDG
132
133
#endif
/* EXADG_SOLVERS_AND_PRECONDITIONERS_MULTIGRID_SMOOTHERS_CG_SMOOTHER_H_ */
ExaDG::JacobiPreconditioner
Definition
jacobi_preconditioner.h:35
ExaDG::SmootherBase
Definition
smoother_base.h:29
ExaDG
Definition
driver.cpp:33
ExaDG::CGSmoother::AdditionalData
Definition
cg_smoother.h:56
ExaDG::CGSmoother::AdditionalData::AdditionalData
AdditionalData()
Definition
cg_smoother.h:60
Generated by
1.17.0