18 #include "libmesh/libmesh_common.h"
20 #ifdef LIBMESH_TRILINOS_HAVE_EPETRA
23 #include "libmesh/trilinos_preconditioner.h"
24 #include "libmesh/trilinos_epetra_matrix.h"
25 #include "libmesh/trilinos_epetra_vector.h"
26 #include "libmesh/libmesh_common.h"
27 #include "libmesh/enum_preconditioner_type.h"
29 #include "libmesh/ignore_warnings.h"
30 #ifdef LIBMESH_TRILINOS_HAVE_IFPACK
32 #include "Ifpack_DiagPreconditioner.h"
33 #include "Ifpack_AdditiveSchwarz.h"
34 #include "Ifpack_ILU.h"
35 #include "Ifpack_ILUT.h"
36 #include "Ifpack_IC.h"
37 #include "Ifpack_ICT.h"
40 #ifdef LIBMESH_TRILINOS_HAVE_ML
41 #include "ml_MultiLevelPreconditioner.h"
43 #include "libmesh/restore_warnings.h"
60 libmesh_error_msg_if(!this->_matrix,
"ERROR: No matrix set for PetscPreconditioner, but init() called");
69 set_preconditioner_type(this->_preconditioner_type);
87 #ifdef LIBMESH_TRILINOS_HAVE_IFPACK
88 Ifpack_Preconditioner * ifpack =
nullptr;
91 #ifdef LIBMESH_TRILINOS_HAVE_ML
92 ML_Epetra::MultiLevelPreconditioner * ml =
nullptr;
95 switch (this->_preconditioner_type)
97 #ifdef LIBMESH_TRILINOS_HAVE_IFPACK
101 ifpack =
dynamic_cast<Ifpack_Preconditioner *
>(_prec);
106 #ifdef LIBMESH_TRILINOS_HAVE_ML
109 ml =
dynamic_cast<ML_Epetra::MultiLevelPreconditioner *
>(_prec);
110 ml->ComputePreconditioner();
117 libmesh_error_msg(
"ERROR: No valid TrilinosPreconditioners available!");
123 template <
typename T>
127 #ifdef LIBMESH_TRILINOS_HAVE_IFPACK
128 Ifpack_Preconditioner * pc =
nullptr;
131 #ifdef LIBMESH_TRILINOS_HAVE_ML
132 ML_Epetra::MultiLevelPreconditioner * ml =
nullptr;
135 switch (preconditioner_type)
137 case IDENTITY_PRECOND:
141 case CHOLESKY_PRECOND:
147 #ifdef LIBMESH_TRILINOS_HAVE_IFPACK
149 pc =
new Ifpack_ILU(_mat);
150 pc->SetParameters(_param_list);
165 case BLOCK_JACOBI_PRECOND:
171 case EISENSTAT_PRECOND:
174 #ifdef LIBMESH_TRILINOS_HAVE_ML
176 ml =
new ML_Epetra::MultiLevelPreconditioner(*_mat, _param_list,
false);;
182 libmesh_error_msg(
"ERROR: Unsupported Trilinos Preconditioner: " << preconditioner_type <<
"\nContinuing with Trilinos defaults");
188 template <
typename T>
192 return _prec->SetUseTranspose(UseTranspose);
195 template <
typename T>
199 return _prec->Apply(X, Y);
202 template <
typename T>
206 return _prec->ApplyInverse(r, z);
209 template <
typename T>
213 return _prec->NormInf();
216 template <
typename T>
220 return _prec->Label();
223 template <
typename T>
227 return _prec->UseTranspose();
230 template <
typename T>
234 return _prec->HasNormInf();
237 template <
typename T>
241 return _prec->Comm();
244 template <
typename T>
248 return _prec->OperatorDomainMap();
251 template <
typename T>
255 return _prec->OperatorRangeMap();
264 #endif // LIBMESH_TRILINOS_HAVE_EPETRA
void set_params(Teuchos::ParameterList &list)
存储 ParameterList list 的副本。
virtual void init() override
初始化预条件器。
virtual bool HasNormInf() const override
virtual void apply(const NumericVector< T > &x, NumericVector< T > &y) override
应用预条件器。
void set_preconditioner_type(const PreconditionerType &preconditioner_type)
根据 libMesh PreconditionerType 设置 Trilinos 预条件器。
这个类提供了一个接口,用于使用Trilinos提供的预条件器套件。 所有重写的虚拟函数在preconditioner.h中有文档说明。
这是一个通用的稀疏矩阵类。该类包含了必须在派生类中覆盖的纯虚拟成员。 使用一个公共的基类允许从不同的求解器包中以不同的格式统一访问稀疏矩阵。
bool _is_initialized
Flag that tells if init() has been called.
void compute()
计算预条件器。在 Trilinos 中,我们需要显式调用此函数。
virtual const Epetra_Map & OperatorDomainMap() const override
virtual bool UseTranspose() const override
virtual double NormInf() const override
virtual int SetUseTranspose(bool UseTranspose) override
virtual const char * Label() const override
virtual const Epetra_Map & OperatorRangeMap() const override
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const override
virtual const Epetra_Comm & Comm() const override
virtual int ApplyInverse(const Epetra_MultiVector &r, Epetra_MultiVector &z) const override
Epetra_FECrsMatrix * mat()
获取原始Epetra_FECrsMatrix指针。
此类提供了对Epetra数据结构的并行、稀疏矩阵的友好接口。所有重写的虚拟函数在sparse_matrix.h中都有文档。