libmesh解析
本工作只是尝试解析原libmesh的代码,供学习使用
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 
preconditioner.h
浏览该文件的文档.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2023 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_PRECONDITIONER_H
21 #define LIBMESH_PRECONDITIONER_H
22 
23 
24 // Local includes
25 #include "libmesh/libmesh_common.h"
26 #include "libmesh/reference_counted_object.h"
27 #include "libmesh/libmesh.h"
28 #include "libmesh/parallel_object.h"
29 
30 // C++ includes
31 #include <cstddef>
32 
33 namespace libMesh
34 {
35 
36 // forward declarations
37 template <typename T> class SparseMatrix;
38 template <typename T> class NumericVector;
39 template <typename T> class ShellMatrix;
40 enum SolverPackage : int;
41 enum PreconditionerType : int;
42 
51 template <typename T>
52 class Preconditioner : public ReferenceCountedObject<Preconditioner<T>>,
53  public ParallelObject
54 {
55 public:
56 
63  Preconditioner (const libMesh::Parallel::Communicator & comm);
64 
70  virtual ~Preconditioner ();
71 
80  static std::unique_ptr<Preconditioner<T>>
81  build_preconditioner(const libMesh::Parallel::Communicator & comm,
82  const SolverPackage solver_package = libMesh::default_solver_package());
83 
87  bool initialized () const { return _is_initialized; }
88 
96  virtual void apply(const NumericVector<T> & x, NumericVector<T> & y) = 0;
97 
103  virtual void clear () {}
104 
111  virtual void init () {}
112 
120  virtual void setup () {}
121 
128  void set_matrix(SparseMatrix<Number> & mat);
129 
133  PreconditionerType type () const { return _preconditioner_type; }
134 
141  void set_type (const PreconditionerType pct);
142 
143 protected:
144 
149 
153  PreconditionerType _preconditioner_type;
154 
159 };
160 
161 
162 
163 
164 /*----------------------- inline functions ----------------------------------*/
165 template <typename T>
166 inline
168 {
169  this->clear ();
170 }
171 
172 template <typename T>
173 void
175 {
176  //如果矩阵发生变化,那么(可能)需要重新初始化。
177  _is_initialized = false;
178  _matrix = &mat;
179 }
180 
181 template <typename T>
182 void
183 Preconditioner<T>::set_type (const PreconditionerType pct)
184 {
185  //如果前置条件类型改变,我们(可能)需要重新初始化。
186  _is_initialized = false;
187  _preconditioner_type = pct;
188 }
189 
190 } // namespace libMesh
191 
192 
193 #endif // LIBMESH_PRECONDITIONER_H
virtual void clear()
释放所有内存并清除数据结构。
PreconditionerType type() const
virtual void apply(const NumericVector< T > &x, NumericVector< T > &y)=0
计算基于输入向量 x 的预处理向量 y。通常通过解 来实现此操作,以获得 的作用。
PreconditionerType _preconditioner_type
枚举类型,表示要使用的预处理器类型。
提供了不同线性代数库的向量存储方案的统一接口。
Definition: dof_map.h:67
void set_matrix(SparseMatrix< Number > &mat)
设置要进行预处理的矩阵。
这是一个通用的稀疏矩阵类。该类包含了必须在派生类中覆盖的纯虚拟成员。 使用一个公共的基类允许从不同的求解器包中以不同的格式统一访问稀疏矩阵。
Definition: dof_map.h:66
SolverPackage default_solver_package()
Definition: libmesh.C:967
该类提供了一个统一的接口,用于预处理器。此基类可继承,以包装来自不同软件包(如 PETSc 或 Trilinos)的预处理器。
Preconditioner(const libMesh::Parallel::Communicator &comm)
构造函数。初始化 Preconditioner 的数据结构。
bool _is_initialized
Flag that tells if init() has been called.
Definition: libmesh.C:242
This class implements reference counting.
bool _is_initialized
指示数据结构是否已初始化的标志。
void set_type(const PreconditionerType pct)
设置要使用的预处理器类型。
static std::unique_ptr< Preconditioner< T > > build_preconditioner(const libMesh::Parallel::Communicator &comm, const SolverPackage solver_package=libMesh::default_solver_package())
构建一个 Preconditioner,使用由 solver_package 指定的线性求解器软件包, 并以 std::unique_ptr 包装结果以确保安全性。 ...
virtual void init()
如果尚未初始化数据结构,则初始化数据结构。
bool initialized() const
virtual void setup()
每当 &quot;操作可能已更改&quot; 时都会调用此函数。
virtual ~Preconditioner()
析构函数。
SparseMatrix< T > * _matrix
要进行预处理的矩阵 P...