Reference documentation for deal.II version 9.5.1
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
include
deal.II
lac
solver_relaxation.h
Go to the documentation of this file.
1
// ---------------------------------------------------------------------
2
//
3
// Copyright (C) 2010 - 2021 by the deal.II authors
4
//
5
// This file is part of the deal.II library.
6
//
7
// The deal.II library is free software; you can use it, redistribute
8
// it, and/or modify it under the terms of the GNU Lesser General
9
// Public License as published by the Free Software Foundation; either
10
// version 2.1 of the License, or (at your option) any later version.
11
// The full text of the license can be found in the file LICENSE.md at
12
// the top level directory of deal.II.
13
//
14
// ---------------------------------------------------------------------
15
16
#ifndef dealii_solver_relaxation_h
17
#define dealii_solver_relaxation_h
18
19
20
#include <
deal.II/base/config.h
>
21
22
#include <
deal.II/base/logstream.h
>
23
#include <
deal.II/base/subscriptor.h
>
24
25
#include <
deal.II/lac/solver.h
>
26
#include <
deal.II/lac/solver_control.h
>
27
28
DEAL_II_NAMESPACE_OPEN
29
56
template
<
typename
VectorType = Vector<
double
>>
57
class
SolverRelaxation
:
public
SolverBase
<VectorType>
58
{
59
public
:
64
struct
AdditionalData
65
{};
66
70
SolverRelaxation
(
SolverControl
& cn,
71
const
AdditionalData
&data =
AdditionalData
());
72
78
template
<
typename
MatrixType,
class
RelaxationType>
79
void
80
solve
(
const
MatrixType & A,
81
VectorType & x,
82
const
VectorType & b,
83
const
RelaxationType &R);
84
};
85
86
//----------------------------------------------------------------------//
87
88
template
<
class
VectorType>
89
SolverRelaxation<VectorType>::SolverRelaxation
(
SolverControl
&cn,
90
const
AdditionalData
&)
91
:
SolverBase
<VectorType>(cn)
92
{}
93
94
95
96
template
<
class
VectorType>
97
template
<
typename
MatrixType,
class
RelaxationType>
98
void
99
SolverRelaxation<VectorType>::solve
(
const
MatrixType & A,
100
VectorType & x,
101
const
VectorType & b,
102
const
RelaxationType &R)
103
{
104
GrowingVectorMemory<VectorType>
mem;
105
SolverControl::State
conv =
SolverControl::iterate
;
106
107
// Memory allocation
108
typename
VectorMemory<VectorType>::Pointer
Vr(mem);
109
VectorType & r = *Vr;
110
r.reinit(x);
111
typename
VectorMemory<VectorType>::Pointer
Vd(mem);
112
VectorType & d = *Vd;
113
d.reinit(x);
114
115
LogStream::Prefix
prefix(
"Relaxation"
);
116
117
int
iter = 0;
118
// Main loop
119
for
(; conv ==
SolverControl::iterate
; ++iter)
120
{
121
// Compute residual
122
A.vmult(r, x);
123
r.sadd(-1., 1., b);
124
125
// The required norm of the
126
// (preconditioned)
127
// residual is computed in
128
// criterion() and stored
129
// in res.
130
conv = this->iteration_status(iter, r.l2_norm(), x);
131
if
(conv !=
SolverControl::iterate
)
132
break
;
133
R.step(x, b);
134
}
135
136
// in case of failure: throw exception
137
AssertThrow
(conv ==
SolverControl::success
,
138
SolverControl::NoConvergence
(iter, r.l2_norm()));
139
// otherwise exit as normal
140
}
141
142
143
DEAL_II_NAMESPACE_CLOSE
144
145
#endif
GrowingVectorMemory
Definition
vector_memory.h:316
LogStream::Prefix
Definition
logstream.h:102
SolverBase
Definition
solver.h:341
SolverControl::NoConvergence
Definition
solver_control.h:96
SolverControl
Definition
solver_control.h:68
SolverControl::State
State
Definition
solver_control.h:75
SolverControl::iterate
@ iterate
Continue iteration.
Definition
solver_control.h:77
SolverControl::success
@ success
Stop iteration, goal reached.
Definition
solver_control.h:79
SolverRelaxation
Definition
solver_relaxation.h:58
SolverRelaxation::SolverRelaxation
SolverRelaxation(SolverControl &cn, const AdditionalData &data=AdditionalData())
Definition
solver_relaxation.h:89
SolverRelaxation::solve
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const RelaxationType &R)
Definition
solver_relaxation.h:99
VectorMemory::Pointer
Definition
vector_memory.h:191
config.h
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition
config.h:472
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition
config.h:473
AssertThrow
#define AssertThrow(cond, exc)
Definition
exceptions.h:1703
logstream.h
solver.h
solver_control.h
SolverRelaxation::AdditionalData
Definition
solver_relaxation.h:65
subscriptor.h
Generated by
1.10.0