MFEM  v4.4.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
sparsesmoothers.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2022, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef MFEM_SPARSEMATSMOOTHERS
13 #define MFEM_SPARSEMATSMOOTHERS
14 
15 #include "../config/config.hpp"
16 #include "sparsemat.hpp"
17 
18 namespace mfem
19 {
20 
22 {
23 protected:
25 
26 public:
27  SparseSmoother() { oper = NULL; }
28 
30  : MatrixInverse(a) { oper = &a; }
31 
32  virtual void SetOperator(const Operator &a);
33 };
34 
35 /// Data type for Gauss-Seidel smoother of sparse matrix
36 class GSSmoother : public SparseSmoother
37 {
38 protected:
39  int type; // 0, 1, 2 - symmetric, forward, backward
41 
42 public:
43  /// Create GSSmoother.
44  GSSmoother(int t = 0, int it = 1) { type = t; iterations = it; }
45 
46  /// Create GSSmoother.
47  GSSmoother(const SparseMatrix &a, int t = 0, int it = 1)
48  : SparseSmoother(a) { type = t; iterations = it; }
49 
50  /// Matrix vector multiplication with GS Smoother.
51  virtual void Mult(const Vector &x, Vector &y) const;
52 };
53 
54 /// Data type for scaled Jacobi-type smoother of sparse matrix
55 class DSmoother : public SparseSmoother
56 {
57 protected:
58  int type; // 0, 1, 2 - scaled Jacobi, scaled l1-Jacobi, scaled lumped-Jacobi
59  double scale;
61  /// Uses abs values of the diagonal entries. Relevant only when type = 0.
62  bool use_abs_diag = false;
63 
64  mutable Vector z;
65 
66 public:
67  /// Create Jacobi smoother.
68  DSmoother(int t = 0, double s = 1., int it = 1)
69  { type = t; scale = s; iterations = it; }
70 
71  /// Create Jacobi smoother.
72  DSmoother(const SparseMatrix &a, int t = 0, double s = 1., int it = 1);
73 
74  /// Replace diag entries with their abs values. Relevant only when type = 0.
75  void SetPositiveDiagonal(bool pos_diag = true) { use_abs_diag = pos_diag; }
76 
77  /// Matrix vector multiplication with Jacobi smoother.
78  virtual void Mult(const Vector &x, Vector &y) const;
79 };
80 
81 }
82 
83 #endif
GSSmoother(const SparseMatrix &a, int t=0, int it=1)
Create GSSmoother.
Data type for scaled Jacobi-type smoother of sparse matrix.
virtual void SetOperator(const Operator &a)
Set/update the solver for the given operator.
bool use_abs_diag
Uses abs values of the diagonal entries. Relevant only when type = 0.
Abstract data type for matrix inverse.
Definition: matrix.hpp:62
Data type for Gauss-Seidel smoother of sparse matrix.
GSSmoother(int t=0, int it=1)
Create GSSmoother.
Data type sparse matrix.
Definition: sparsemat.hpp:46
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication with Jacobi smoother.
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication with GS Smoother.
double a
Definition: lissajous.cpp:41
DSmoother(int t=0, double s=1., int it=1)
Create Jacobi smoother.
RefCoord t[3]
SparseSmoother(const SparseMatrix &a)
Vector data type.
Definition: vector.hpp:60
RefCoord s[3]
Abstract operator.
Definition: operator.hpp:24
const SparseMatrix * oper
void SetPositiveDiagonal(bool pos_diag=true)
Replace diag entries with their abs values. Relevant only when type = 0.