GEOS
MultiscalePreconditioner.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2019 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2019 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2019 Total, S.A
8  * Copyright (c) 2019- GEOS/GEOSX Contributors
9  * All right reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOS_LINEARALGEBRA_MULTISCALE_MULTISCALEPRECONDITIONER_HPP_
20 #define GEOS_LINEARALGEBRA_MULTISCALE_MULTISCALEPRECONDITIONER_HPP_
21 
22 #include "linearAlgebra/common/PreconditionerBase.hpp"
24 #include "mesh/MeshLevel.hpp"
25 
26 #include <memory>
27 
28 namespace geos
29 {
30 
31 namespace multiscale
32 {
33 template< typename LAI >
34 class LevelBuilderBase;
35 }
36 
41 template< typename LAI >
43 {
44 public:
45 
48 
50  using Vector = typename Base::Vector;
51 
53  using Matrix = typename Base::Matrix;
54 
57 
64 
66 
67  virtual void setup( Matrix const & mat ) override;
68 
76  virtual void apply( Vector const & src, Vector & dst ) const override;
77 
78  virtual void clear() override;
79 
80 private:
81 
82  void createLevels( Matrix const & mat );
83 
84  void computeLevel( integer const level ) const;
85 
86  void printLevelInfo() const;
87 
88  void logMessage( integer const minLevel, string const & msg ) const;
89 
90  struct LevelData
91  {
92  std::unique_ptr< multiscale::LevelBuilderBase< LAI > > builder;
93  Matrix const * matrix;
94  mutable Vector rhs;
95  mutable Vector sol;
96  mutable Vector tmp;
97  };
98 
99  LinearSolverParameters m_params;
100 
101  DomainPartition & m_domain;
102 
103  std::vector< LevelData > m_levels;
104 
105  std::unique_ptr< PreconditionerBase< LAI > > m_coarse_solver;
106 
107  bool m_initialized{ false };
108 };
109 
110 } // namespace geos
111 
112 #endif //GEOS_LINEARALGEBRA_MULTISCALE_MULTISCALEPRECONDITIONER_HPP_
Partition of the decomposed physical domain. It also manages the connexion information to its neighbo...
Abstract base class for linear operators.
Multiscale preconditioner for near-elliptic and coupled problems.
virtual void apply(Vector const &src, Vector &dst) const override
Apply operator to a vector, dst = this(src).
virtual void setup(Matrix const &mat) override
Compute the preconditioner from a matrix.
virtual void clear() override
Clean up the preconditioner setup.
MultiscalePreconditioner(LinearSolverParameters params, DomainPartition &domain)
Constructor.
Common interface for preconditioning operators.
Matrix const & matrix() const
Access the matrix the preconditioner was computed from.
typename Base::Vector Vector
Alias for vector type.
typename LAI::ParallelMatrix Matrix
Alias for matrix type.
int integer
Signed integer type.
Definition: DataTypes.hpp:81
Set of parameters for a linear solver or preconditioner.