Reference documentation for deal.II version 9.1.0-pre
relaxation_block.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2010 - 2018 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_relaxation_block_h
17 #define dealii_relaxation_block_h
18 
19 #include <deal.II/base/smartpointer.h>
20 #include <deal.II/base/subscriptor.h>
21 
22 #include <deal.II/lac/precondition_block_base.h>
23 #include <deal.II/lac/sparsity_pattern.h>
24 #include <deal.II/lac/vector.h>
25 
26 #include <set>
27 #include <vector>
28 
29 DEAL_II_NAMESPACE_OPEN
30 
54 template <typename MatrixType,
55  typename InverseNumberType = typename MatrixType::value_type,
56  typename VectorType = Vector<double>>
57 class RelaxationBlock : protected PreconditionBlockBase<InverseNumberType>
58 {
59 private:
63  using number = typename MatrixType::value_type;
64 
68  using value_type = InverseNumberType;
69 
70 public:
75 
82  class AdditionalData : public Subscriptor
83  {
84  public:
89  const double relaxation = 1.,
90  const bool invert_diagonal = true,
91  const bool same_diagonal = false,
94  const double threshold = 0.,
95  VectorType * temp_ghost_vector = nullptr);
96 
102 
106  double relaxation;
107 
115 
125 
130 
140  double threshold = 0.;
141 
151  unsigned int kernel_size = 0;
152 
173  std::vector<std::vector<unsigned int>> order;
174 
183  mutable VectorType *temp_ghost_vector;
184 
188  std::size_t
189  memory_consumption() const;
190  };
191 
201  void
202  initialize(const MatrixType &A, const AdditionalData &parameters);
203 
209  void
210  clear();
211 
227  void
229 
230 protected:
239  void
240  do_step(VectorType & dst,
241  const VectorType &prev,
242  const VectorType &src,
243  const bool backward) const;
244 
251  SmartPointer<const MatrixType,
253  A;
254 
261 
262 private:
266  void
267  block_kernel(const size_type block_begin, const size_type block_end);
268 };
269 
270 
286 template <typename MatrixType,
287  typename InverseNumberType = typename MatrixType::value_type,
288  typename VectorType = Vector<double>>
290  : public virtual Subscriptor,
291  protected RelaxationBlock<MatrixType, InverseNumberType, VectorType>
292 {
293 public:
297  // RelaxationBlockJacobi();
298 
302  using number = typename MatrixType::value_type;
303 
309 
314 
319 
344  void
345  step(VectorType &dst, const VectorType &rhs) const;
346 
350  void
351  Tstep(VectorType &dst, const VectorType &rhs) const;
352 
357  void
358  vmult(VectorType &dst, const VectorType &rhs) const;
359 
364  void
365  Tvmult(VectorType &dst, const VectorType &rhs) const;
366 };
367 
368 
384 template <typename MatrixType,
385  typename InverseNumberType = typename MatrixType::value_type,
386  typename VectorType = Vector<double>>
388  : public virtual Subscriptor,
389  protected RelaxationBlock<MatrixType, InverseNumberType, VectorType>
390 {
391 public:
395  // RelaxationBlockSOR();
396 
400  using number = typename MatrixType::value_type;
401 
407 
412 
417 
442  void
443  step(VectorType &dst, const VectorType &rhs) const;
444 
448  void
449  Tstep(VectorType &dst, const VectorType &rhs) const;
450 
455  void
456  vmult(VectorType &dst, const VectorType &rhs) const;
457 
462  void
463  Tvmult(VectorType &dst, const VectorType &rhs) const;
464 };
465 
466 
482 template <typename MatrixType,
483  typename InverseNumberType = typename MatrixType::value_type,
484  typename VectorType = Vector<double>>
486  : public virtual Subscriptor,
487  protected RelaxationBlock<MatrixType, InverseNumberType, VectorType>
488 {
489 public:
493  using number = typename MatrixType::value_type;
494 
500 
505 
510 
535  void
536  step(VectorType &dst, const VectorType &rhs) const;
537 
541  void
542  Tstep(VectorType &dst, const VectorType &rhs) const;
543 
548  void
549  vmult(VectorType &dst, const VectorType &rhs) const;
550 
555  void
556  Tvmult(VectorType &dst, const VectorType &rhs) const;
557 };
558 
559 
560 DEAL_II_NAMESPACE_CLOSE
561 
562 #endif
SmartPointer< const MatrixType, RelaxationBlock< MatrixType, InverseNumberType, VectorType > > A
SmartPointer< const AdditionalData, RelaxationBlock< MatrixType, InverseNumberType, VectorType > > additional_data
void do_step(VectorType &dst, const VectorType &prev, const VectorType &src, const bool backward) const
PreconditionBlockBase< InverseNumberType >::Inversion inversion
typename MatrixType::value_type number
void block_kernel(const size_type block_begin, const size_type block_end)
unsigned long long int global_dof_index
Definition: types.h:72
std::size_t memory_consumption() const
AdditionalData(const double relaxation=1., const bool invert_diagonal=true, const bool same_diagonal=false, const typename PreconditionBlockBase< InverseNumberType >::Inversion inversion=PreconditionBlockBase< InverseNumberType >::gauss_jordan, const double threshold=0., VectorType *temp_ghost_vector=nullptr)
InverseNumberType value_type
std::vector< std::vector< unsigned int > > order
void invert_diagblocks()
types::global_dof_index size_type
Householder< InverseNumberType > & inverse_householder(size_type i)
void initialize(const MatrixType &A, const AdditionalData &parameters)