Reference documentation for deal.II version GIT relicensing-426-g7976cfd195 2024-04-18 21:10:01+00:00
\(\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
// SPDX-License-Identifier: LGPL-2.1-or-later
4
// Copyright (C) 2010 - 2023 by the deal.II authors
5
//
6
// This file is part of the deal.II library.
7
//
8
// Part of the source code is dual licensed under Apache-2.0 WITH
9
// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10
// governing the source code and code contributions can be found in
11
// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12
//
13
// ------------------------------------------------------------------------
14
15
#ifndef dealii_solver_relaxation_h
16
#define dealii_solver_relaxation_h
17
18
19
#include <
deal.II/base/config.h
>
20
21
#include <
deal.II/base/logstream.h
>
22
#include <
deal.II/base/subscriptor.h
>
23
24
#include <
deal.II/lac/solver.h
>
25
#include <
deal.II/lac/solver_control.h
>
26
27
DEAL_II_NAMESPACE_OPEN
28
55
template
<
typename
VectorType = Vector<
double
>>
56
class
SolverRelaxation
:
public
SolverBase
<VectorType>
57
{
58
public
:
63
struct
AdditionalData
64
{};
65
69
SolverRelaxation
(
SolverControl
&cn,
70
const
AdditionalData
&data =
AdditionalData
());
71
77
template
<
typename
MatrixType,
typename
RelaxationType>
78
void
79
solve
(
const
MatrixType &A,
80
VectorType &x,
81
const
VectorType &b,
82
const
RelaxationType &R);
83
};
84
85
//----------------------------------------------------------------------//
86
87
template
<
typename
VectorType>
88
SolverRelaxation<VectorType>::SolverRelaxation
(
SolverControl
&cn,
89
const
AdditionalData
&)
90
:
SolverBase
<VectorType>(cn)
91
{}
92
93
94
95
template
<
typename
VectorType>
96
template
<
typename
MatrixType,
typename
RelaxationType>
97
void
98
SolverRelaxation<VectorType>::solve
(
const
MatrixType &A,
99
VectorType &x,
100
const
VectorType &b,
101
const
RelaxationType &R)
102
{
103
GrowingVectorMemory<VectorType>
mem;
104
SolverControl::State
conv =
SolverControl::iterate
;
105
106
// Memory allocation
107
typename
VectorMemory<VectorType>::Pointer
Vr(mem);
108
VectorType &r = *Vr;
109
r.reinit(x);
110
typename
VectorMemory<VectorType>::Pointer
Vd(mem);
111
VectorType &d = *Vd;
112
d.reinit(x);
113
114
LogStream::Prefix
prefix(
"Relaxation"
);
115
116
int
iter = 0;
117
// Main loop
118
for
(; conv ==
SolverControl::iterate
; ++iter)
119
{
120
// Compute residual
121
A.vmult(r, x);
122
r.sadd(-1., 1., b);
123
124
// The required norm of the
125
// (preconditioned)
126
// residual is computed in
127
// criterion() and stored
128
// in res.
129
conv = this->iteration_status(iter, r.l2_norm(), x);
130
if
(conv !=
SolverControl::iterate
)
131
break
;
132
R.step(x, b);
133
}
134
135
// in case of failure: throw exception
136
AssertThrow
(conv ==
SolverControl::success
,
137
SolverControl::NoConvergence
(iter, r.l2_norm()));
138
// otherwise exit as normal
139
}
140
141
142
DEAL_II_NAMESPACE_CLOSE
143
144
#endif
GrowingVectorMemory
Definition
vector_memory.h:315
LogStream::Prefix
Definition
logstream.h:101
SolverBase
Definition
solver.h:340
SolverControl::NoConvergence
Definition
solver_control.h:95
SolverControl
Definition
solver_control.h:67
SolverControl::State
State
Definition
solver_control.h:74
SolverControl::iterate
@ iterate
Continue iteration.
Definition
solver_control.h:76
SolverControl::success
@ success
Stop iteration, goal reached.
Definition
solver_control.h:78
SolverRelaxation
Definition
solver_relaxation.h:57
SolverRelaxation::SolverRelaxation
SolverRelaxation(SolverControl &cn, const AdditionalData &data=AdditionalData())
Definition
solver_relaxation.h:88
SolverRelaxation::solve
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const RelaxationType &R)
Definition
solver_relaxation.h:98
VectorMemory::Pointer
Definition
vector_memory.h:190
config.h
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition
config.h:502
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition
config.h:503
AssertThrow
#define AssertThrow(cond, exc)
Definition
exceptions.h:1739
logstream.h
solver.h
solver_control.h
SolverRelaxation::AdditionalData
Definition
solver_relaxation.h:64
subscriptor.h
Generated by
1.9.8