17#ifdef DEAL_II_WITH_TRILINOS
23# include <Epetra_MultiVector.h>
25# include <Ifpack_Chebyshev.h>
26# include <Teuchos_ParameterList.hpp>
27# include <Teuchos_RCP.hpp>
34 : communicator(MPI_COMM_SELF)
57 ExcMessage(
"Trying to dereference a null pointer."));
79 const double min_diagonal,
80 const unsigned int n_sweeps)
82 , min_diagonal(min_diagonal)
95 Ifpack().Create(
"point relaxation",
96 const_cast<Epetra_CrsMatrix *
>(&matrix.trilinos_matrix()),
99 Ifpack_Preconditioner *ifpack =
107 Teuchos::ParameterList parameter_list;
108 parameter_list.set(
"relaxation: sweeps",
109 static_cast<int>(additional_data.
n_sweeps));
110 parameter_list.set(
"relaxation: type",
"Jacobi");
111 parameter_list.set(
"relaxation: damping factor", additional_data.
omega);
112 parameter_list.set(
"relaxation: min diagonal value",
115 ierr = ifpack->SetParameters(parameter_list);
118 ierr = ifpack->Initialize();
121 ierr = ifpack->Compute();
130 const double min_diagonal,
131 const unsigned int overlap,
132 const unsigned int n_sweeps)
134 , min_diagonal(min_diagonal)
147 Ifpack().Create(
"point relaxation",
148 const_cast<Epetra_CrsMatrix *
>(&matrix.trilinos_matrix()),
151 Ifpack_Preconditioner *ifpack =
159 Teuchos::ParameterList parameter_list;
160 parameter_list.set(
"relaxation: sweeps",
161 static_cast<int>(additional_data.
n_sweeps));
162 parameter_list.set(
"relaxation: type",
"symmetric Gauss-Seidel");
163 parameter_list.set(
"relaxation: damping factor", additional_data.
omega);
164 parameter_list.set(
"relaxation: min diagonal value",
166 parameter_list.set(
"schwarz: combine mode",
"Add");
168 ierr = ifpack->SetParameters(parameter_list);
171 ierr = ifpack->Initialize();
174 ierr = ifpack->Compute();
183 const double min_diagonal,
184 const unsigned int overlap,
185 const unsigned int n_sweeps)
187 , min_diagonal(min_diagonal)
200 Ifpack().Create(
"point relaxation",
201 const_cast<Epetra_CrsMatrix *
>(&matrix.trilinos_matrix()),
204 Ifpack_Preconditioner *ifpack =
212 Teuchos::ParameterList parameter_list;
213 parameter_list.set(
"relaxation: sweeps",
214 static_cast<int>(additional_data.
n_sweeps));
215 parameter_list.set(
"relaxation: type",
"Gauss-Seidel");
216 parameter_list.set(
"relaxation: damping factor", additional_data.
omega);
217 parameter_list.set(
"relaxation: min diagonal value",
219 parameter_list.set(
"schwarz: combine mode",
"Add");
221 ierr = ifpack->SetParameters(parameter_list);
224 ierr = ifpack->Initialize();
227 ierr = ifpack->Compute();
236 const unsigned int block_size,
237 const std::string &block_creation_type,
239 const double min_diagonal,
240 const unsigned int n_sweeps)
241 : block_size(block_size)
242 , block_creation_type(block_creation_type)
244 , min_diagonal(min_diagonal)
260 Ifpack().Create((matrix.trilinos_matrix().NumMyRows() == 0) ?
263 const_cast<Epetra_CrsMatrix *
>(&matrix.trilinos_matrix()),
266 Ifpack_Preconditioner *ifpack =
274 Teuchos::ParameterList parameter_list;
275 parameter_list.set(
"relaxation: sweeps",
276 static_cast<int>(additional_data.
n_sweeps));
277 parameter_list.set(
"relaxation: type",
"Jacobi");
278 parameter_list.set(
"relaxation: damping factor", additional_data.
omega);
279 parameter_list.set(
"relaxation: min diagonal value",
281 parameter_list.set(
"partitioner: type",
284 (matrix.trilinos_matrix().NumMyRows() + additional_data.
block_size - 1) /
286 parameter_list.set(
"partitioner: local parts", n_local_parts);
288 ierr = ifpack->SetParameters(parameter_list);
291 ierr = ifpack->Initialize();
294 ierr = ifpack->Compute();
303 const unsigned int block_size,
304 const std::string &block_creation_type,
306 const double min_diagonal,
307 const unsigned int overlap,
308 const unsigned int n_sweeps)
309 : block_size(block_size)
310 , block_creation_type(block_creation_type)
312 , min_diagonal(min_diagonal)
328 Ifpack().Create((matrix.trilinos_matrix().NumMyRows() == 0) ?
331 const_cast<Epetra_CrsMatrix *
>(&matrix.trilinos_matrix()),
334 Ifpack_Preconditioner *ifpack =
342 Teuchos::ParameterList parameter_list;
343 parameter_list.set(
"relaxation: sweeps",
344 static_cast<int>(additional_data.
n_sweeps));
345 parameter_list.set(
"relaxation: type",
"symmetric Gauss-Seidel");
346 parameter_list.set(
"relaxation: damping factor", additional_data.
omega);
347 parameter_list.set(
"relaxation: min diagonal value",
349 parameter_list.set(
"schwarz: combine mode",
"Add");
350 parameter_list.set(
"partitioner: type",
353 (matrix.trilinos_matrix().NumMyRows() + additional_data.
block_size - 1) /
355 parameter_list.set(
"partitioner: local parts", n_local_parts);
357 ierr = ifpack->SetParameters(parameter_list);
360 ierr = ifpack->Initialize();
363 ierr = ifpack->Compute();
372 const unsigned int block_size,
373 const std::string &block_creation_type,
375 const double min_diagonal,
376 const unsigned int overlap,
377 const unsigned int n_sweeps)
378 : block_size(block_size)
379 , block_creation_type(block_creation_type)
381 , min_diagonal(min_diagonal)
397 Ifpack().Create((matrix.trilinos_matrix().NumMyRows() == 0) ?
400 const_cast<Epetra_CrsMatrix *
>(&matrix.trilinos_matrix()),
403 Ifpack_Preconditioner *ifpack =
411 Teuchos::ParameterList parameter_list;
412 parameter_list.set(
"relaxation: sweeps",
413 static_cast<int>(additional_data.
n_sweeps));
414 parameter_list.set(
"relaxation: type",
"Gauss-Seidel");
415 parameter_list.set(
"relaxation: damping factor", additional_data.
omega);
416 parameter_list.set(
"relaxation: min diagonal value",
418 parameter_list.set(
"schwarz: combine mode",
"Add");
419 parameter_list.set(
"partitioner: type",
422 (matrix.trilinos_matrix().NumMyRows() + additional_data.
block_size - 1) /
424 parameter_list.set(
"partitioner: local parts", n_local_parts);
426 ierr = ifpack->SetParameters(parameter_list);
429 ierr = ifpack->Initialize();
432 ierr = ifpack->Compute();
441 const double ic_atol,
442 const double ic_rtol,
443 const unsigned int overlap)
458 Ifpack().Create(
"IC",
459 const_cast<Epetra_CrsMatrix *
>(&matrix.trilinos_matrix()),
462 Ifpack_Preconditioner *ifpack =
470 Teuchos::ParameterList parameter_list;
471 parameter_list.set(
"fact: level-of-fill", additional_data.
ic_fill);
472 parameter_list.set(
"fact: absolute threshold", additional_data.
ic_atol);
473 parameter_list.set(
"fact: relative threshold", additional_data.
ic_rtol);
474 parameter_list.set(
"schwarz: combine mode",
"Add");
476 ierr = ifpack->SetParameters(parameter_list);
479 ierr = ifpack->Initialize();
482 ierr = ifpack->Compute();
491 const double ilu_atol,
492 const double ilu_rtol,
493 const unsigned int overlap)
508 Ifpack().Create(
"ILU",
509 const_cast<Epetra_CrsMatrix *
>(&matrix.trilinos_matrix()),
512 Ifpack_Preconditioner *ifpack =
520 Teuchos::ParameterList parameter_list;
521 parameter_list.set(
"fact: level-of-fill",
522 static_cast<int>(additional_data.
ilu_fill));
523 parameter_list.set(
"fact: absolute threshold", additional_data.
ilu_atol);
524 parameter_list.set(
"fact: relative threshold", additional_data.
ilu_rtol);
525 parameter_list.set(
"schwarz: combine mode",
"Add");
527 ierr = ifpack->SetParameters(parameter_list);
530 ierr = ifpack->Initialize();
533 ierr = ifpack->Compute();
542 const unsigned int ilut_fill,
543 const double ilut_atol,
544 const double ilut_rtol,
545 const unsigned int overlap)
546 : ilut_drop(ilut_drop)
547 , ilut_fill(ilut_fill)
548 , ilut_atol(ilut_atol)
549 , ilut_rtol(ilut_rtol)
561 Ifpack().Create(
"ILUT",
562 const_cast<Epetra_CrsMatrix *
>(&matrix.trilinos_matrix()),
565 Ifpack_Preconditioner *ifpack =
573 Teuchos::ParameterList parameter_list;
574 parameter_list.set(
"fact: drop value", additional_data.
ilut_drop);
575 parameter_list.set(
"fact: level-of-fill",
576 static_cast<int>(additional_data.
ilut_fill));
577 parameter_list.set(
"fact: absolute threshold", additional_data.
ilut_atol);
578 parameter_list.set(
"fact: relative threshold", additional_data.
ilut_rtol);
579 parameter_list.set(
"schwarz: combine mode",
"Add");
581 ierr = ifpack->SetParameters(parameter_list);
584 ierr = ifpack->Initialize();
587 ierr = ifpack->Compute();
596 const unsigned int overlap)
608 Ifpack().Create(
"Amesos",
609 const_cast<Epetra_CrsMatrix *
>(&matrix.trilinos_matrix()),
612 Ifpack_Preconditioner *ifpack =
620 Teuchos::ParameterList parameter_list;
621 parameter_list.set(
"schwarz: combine mode",
"Add");
623 ierr = ifpack->SetParameters(parameter_list);
626 ierr = ifpack->Initialize();
629 ierr = ifpack->Compute();
638 const unsigned int degree,
639 const double max_eigenvalue,
640 const double eigenvalue_ratio,
641 const double min_eigenvalue,
642 const double min_diagonal,
643 const bool nonzero_starting)
645 , max_eigenvalue(max_eigenvalue)
646 , eigenvalue_ratio(eigenvalue_ratio)
647 , min_eigenvalue(min_eigenvalue)
648 , min_diagonal(min_diagonal)
649 , nonzero_starting(nonzero_starting)
659 Teuchos::rcp(
new Ifpack_Chebyshev(&matrix.trilinos_matrix()));
661 Ifpack_Chebyshev *ifpack =
669 Teuchos::ParameterList parameter_list;
670 parameter_list.set(
"chebyshev: ratio eigenvalue",
672 parameter_list.set(
"chebyshev: min eigenvalue",
674 parameter_list.set(
"chebyshev: max eigenvalue",
676 parameter_list.set(
"chebyshev: degree",
677 static_cast<int>(additional_data.
degree));
678 parameter_list.set(
"chebyshev: min diagonal value",
680 parameter_list.set(
"chebyshev: zero starting solution",
683 ierr = ifpack->SetParameters(parameter_list);
686 ierr = ifpack->Initialize();
689 ierr = ifpack->Compute();
713 Ifpack().Create(
"point relaxation",
714 const_cast<Epetra_CrsMatrix *
>(&matrix.trilinos_matrix()),
717 Ifpack_Preconditioner *ifpack =
725 Teuchos::ParameterList parameter_list;
726 parameter_list.set(
"relaxation: sweeps", 1);
727 parameter_list.set(
"relaxation: type",
"Jacobi");
728 parameter_list.set(
"relaxation: damping factor", 1.0);
729 parameter_list.set(
"relaxation: min diagonal value", 0.0);
731 ierr = ifpack->SetParameters(parameter_list);
734 ierr = ifpack->Initialize();
737 ierr = ifpack->Compute();
755 const ::Vector<double> &src)
const
762 const ::Vector<double> &src)
const
IndexSet locally_owned_range_indices() const
Epetra_MpiComm communicator
Epetra_Operator & trilinos_operator() const
Teuchos::RCP< Epetra_Operator > preconditioner
MPI_Comm get_mpi_communicator() const
IndexSet locally_owned_domain_indices() const
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
void vmult(MPI::Vector &dst, const MPI::Vector &src) const override
void Tvmult(MPI::Vector &dst, const MPI::Vector &src) const override
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcTrilinosError(int arg1)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
std::string block_creation_type
AdditionalData(const unsigned int block_size=1, const std::string &block_creation_type="linear", const double omega=1, const double min_diagonal=0, const unsigned int n_sweeps=1)
std::string block_creation_type
AdditionalData(const unsigned int block_size=1, const std::string &block_creation_type="linear", const double omega=1, const double min_diagonal=0, const unsigned int overlap=0, const unsigned int n_sweeps=1)
AdditionalData(const unsigned int block_size=1, const std::string &block_creation_type="linear", const double omega=1, const double min_diagonal=0, const unsigned int overlap=0, const unsigned int n_sweeps=1)
std::string block_creation_type
AdditionalData(const unsigned int overlap=0)
AdditionalData(const unsigned int degree=1, const double max_eigenvalue=10., const double eigenvalue_ratio=30., const double min_eigenvalue=1., const double min_diagonal=1e-12, const bool nonzero_starting=false)
AdditionalData(const unsigned int ic_fill=0, const double ic_atol=0., const double ic_rtol=1., const unsigned int overlap=0)
AdditionalData(const double ilut_drop=0., const unsigned int ilut_fill=0, const double ilut_atol=0., const double ilut_rtol=1., const unsigned int overlap=0)
AdditionalData(const unsigned int ilu_fill=0, const double ilu_atol=0., const double ilu_rtol=1., const unsigned int overlap=0)
AdditionalData(const double omega=1, const double min_diagonal=0, const unsigned int n_sweeps=1)
AdditionalData(const double omega=1, const double min_diagonal=0, const unsigned int overlap=0, const unsigned int n_sweeps=1)
AdditionalData(const double omega=1, const double min_diagonal=0, const unsigned int overlap=0, const unsigned int n_sweeps=1)