Reference documentation for deal.II version 9.2.0
\(\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\}}\)
solver_relaxation.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2010 - 2020 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>
24 
25 #include <deal.II/lac/solver.h>
27 
29 
58 template <typename VectorType = Vector<double>>
59 class SolverRelaxation : public SolverBase<VectorType>
60 {
61 public:
67  {};
68 
73  const AdditionalData &data = AdditionalData());
74 
80  template <typename MatrixType, class RelaxationType>
81  void
82  solve(const MatrixType & A,
83  VectorType & x,
84  const VectorType & b,
85  const RelaxationType &R);
86 };
87 
88 //----------------------------------------------------------------------//
89 
90 template <class VectorType>
92  const AdditionalData &)
93  : SolverBase<VectorType>(cn)
94 {}
95 
96 
97 
98 template <class VectorType>
99 template <typename MatrixType, class RelaxationType>
100 void
102  VectorType & x,
103  const VectorType & b,
104  const RelaxationType &R)
105 {
108 
109  // Memory allocation
110  typename VectorMemory<VectorType>::Pointer Vr(mem);
111  VectorType & r = *Vr;
112  r.reinit(x);
113  typename VectorMemory<VectorType>::Pointer Vd(mem);
114  VectorType & d = *Vd;
115  d.reinit(x);
116 
117  LogStream::Prefix prefix("Relaxation");
118 
119  int iter = 0;
120  // Main loop
121  for (; conv == SolverControl::iterate; iter++)
122  {
123  // Compute residual
124  A.vmult(r, x);
125  r.sadd(-1., 1., b);
126 
127  // The required norm of the
128  // (preconditioned)
129  // residual is computed in
130  // criterion() and stored
131  // in res.
132  conv = this->iteration_status(iter, r.l2_norm(), x);
133  if (conv != SolverControl::iterate)
134  break;
135  R.step(x, b);
136  }
137 
138  // in case of failure: throw exception
140  SolverControl::NoConvergence(iter, r.l2_norm()));
141  // otherwise exit as normal
142 }
143 
144 
146 
147 #endif
RelaxationType
solver.h
LogStream::Prefix
Definition: logstream.h:103
SolverControl::State
State
Definition: solver_control.h:74
SolverControl::NoConvergence
Definition: solver_control.h:96
SolverRelaxation::SolverRelaxation
SolverRelaxation(SolverControl &cn, const AdditionalData &data=AdditionalData())
Definition: solver_relaxation.h:91
VectorType
Physics::Elasticity::Kinematics::d
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
SolverBase
Definition: solver.h:333
GrowingVectorMemory
Definition: vector_memory.h:320
SolverControl::iterate
@ iterate
Continue iteration.
Definition: solver_control.h:77
SolverRelaxation::solve
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const RelaxationType &R)
Definition: solver_relaxation.h:101
subscriptor.h
VectorMemory::Pointer
Definition: vector_memory.h:192
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
Physics::Elasticity::Kinematics::b
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
SolverRelaxation::AdditionalData
Definition: solver_relaxation.h:66
LAPACKSupport::A
static const char A
Definition: lapack_support.h:155
SolverControl::success
@ success
Stop iteration, goal reached.
Definition: solver_control.h:79
config.h
SolverControl
Definition: solver_control.h:67
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
logstream.h
SolverRelaxation
Definition: solver_relaxation.h:59
AssertThrow
#define AssertThrow(cond, exc)
Definition: exceptions.h:1531
solver_control.h