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)
147 #ifdef LIBMESH_TRILINOS_HAVE_IFPACK 149 pc =
new Ifpack_ILU(_mat);
150 pc->SetParameters(_param_list);
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)
Stores a copy of the ParameterList list internally.
virtual void init() override
Initialize data structures if not done so already.
virtual bool HasNormInf() const override
virtual void apply(const NumericVector< T > &x, NumericVector< T > &y) override
Computes the preconditioned vector y based on input vector x.
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
The libMesh namespace provides an interface to certain functionality in the library.
void set_preconditioner_type(const PreconditionerType &preconditioner_type)
Sets the Trilinos preconditioner to use based on the libMesh PreconditionerType.
This class provides an interface to the suite of preconditioners available from Trilinos.
bool _is_initialized
Flag that tells if init() has been called.
void compute()
Compute the preconditioner.
virtual const Epetra_Map & OperatorDomainMap() const override
virtual bool UseTranspose() const override
virtual double NormInf() const override
PreconditionerType
Defines an enum for preconditioner types.
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()
This class provides a nice interface to the Epetra data structures for parallel, sparse matrices...