18#ifdef DEAL_II_WITH_TRILINOS
24# include <Epetra_MultiVector.h>
26# include <Ifpack_Chebyshev.h>
27# include <Teuchos_ParameterList.hpp>
28# include <Teuchos_RCP.hpp>
35# ifdef DEAL_II_WITH_MPI
36 : communicator(MPI_COMM_SELF)
44 , preconditioner(base.preconditioner)
46# ifdef DEAL_II_WITH_MPI
47 communicator(base.communicator)
50 vector_distributor(new Epetra_Map(*base.vector_distributor))
59# ifdef DEAL_II_WITH_MPI
69# ifdef DEAL_II_WITH_MPI
81 ExcMessage(
"Trying to dereference a null pointer."));
103 const double min_diagonal,
104 const unsigned int n_sweeps)
106 , min_diagonal(min_diagonal)
119 Ifpack().Create(
"point relaxation",
120 const_cast<Epetra_CrsMatrix *
>(&
matrix.trilinos_matrix()),
123 Ifpack_Preconditioner *ifpack =
131 Teuchos::ParameterList parameter_list;
132 parameter_list.set(
"relaxation: sweeps",
133 static_cast<int>(additional_data.
n_sweeps));
134 parameter_list.set(
"relaxation: type",
"Jacobi");
135 parameter_list.set(
"relaxation: damping factor", additional_data.
omega);
136 parameter_list.set(
"relaxation: min diagonal value",
139 ierr = ifpack->SetParameters(parameter_list);
142 ierr = ifpack->Initialize();
145 ierr = ifpack->Compute();
154 const double min_diagonal,
155 const unsigned int overlap,
156 const unsigned int n_sweeps)
158 , min_diagonal(min_diagonal)
171 Ifpack().Create(
"point relaxation",
172 const_cast<Epetra_CrsMatrix *
>(&
matrix.trilinos_matrix()),
175 Ifpack_Preconditioner *ifpack =
183 Teuchos::ParameterList parameter_list;
184 parameter_list.set(
"relaxation: sweeps",
185 static_cast<int>(additional_data.
n_sweeps));
186 parameter_list.set(
"relaxation: type",
"symmetric Gauss-Seidel");
187 parameter_list.set(
"relaxation: damping factor", additional_data.
omega);
188 parameter_list.set(
"relaxation: min diagonal value",
190 parameter_list.set(
"schwarz: combine mode",
"Add");
192 ierr = ifpack->SetParameters(parameter_list);
195 ierr = ifpack->Initialize();
198 ierr = ifpack->Compute();
207 const double min_diagonal,
208 const unsigned int overlap,
209 const unsigned int n_sweeps)
211 , min_diagonal(min_diagonal)
224 Ifpack().Create(
"point relaxation",
225 const_cast<Epetra_CrsMatrix *
>(&
matrix.trilinos_matrix()),
228 Ifpack_Preconditioner *ifpack =
236 Teuchos::ParameterList parameter_list;
237 parameter_list.set(
"relaxation: sweeps",
238 static_cast<int>(additional_data.
n_sweeps));
239 parameter_list.set(
"relaxation: type",
"Gauss-Seidel");
240 parameter_list.set(
"relaxation: damping factor", additional_data.
omega);
241 parameter_list.set(
"relaxation: min diagonal value",
243 parameter_list.set(
"schwarz: combine mode",
"Add");
245 ierr = ifpack->SetParameters(parameter_list);
248 ierr = ifpack->Initialize();
251 ierr = ifpack->Compute();
261 const std::string &block_creation_type,
263 const double min_diagonal,
264 const unsigned int n_sweeps)
266 , block_creation_type(block_creation_type)
268 , min_diagonal(min_diagonal)
284 Ifpack().Create((
matrix.trilinos_matrix().NumMyRows() == 0) ?
287 const_cast<Epetra_CrsMatrix *
>(&
matrix.trilinos_matrix()),
290 Ifpack_Preconditioner *ifpack =
298 Teuchos::ParameterList parameter_list;
299 parameter_list.set(
"relaxation: sweeps",
300 static_cast<int>(additional_data.
n_sweeps));
301 parameter_list.set(
"relaxation: type",
"Jacobi");
302 parameter_list.set(
"relaxation: damping factor", additional_data.
omega);
303 parameter_list.set(
"relaxation: min diagonal value",
305 parameter_list.set(
"partitioner: type",
310 parameter_list.set(
"partitioner: local parts", n_local_parts);
312 ierr = ifpack->SetParameters(parameter_list);
315 ierr = ifpack->Initialize();
318 ierr = ifpack->Compute();
328 const std::string &block_creation_type,
330 const double min_diagonal,
331 const unsigned int overlap,
332 const unsigned int n_sweeps)
334 , block_creation_type(block_creation_type)
336 , min_diagonal(min_diagonal)
352 Ifpack().Create((
matrix.trilinos_matrix().NumMyRows() == 0) ?
355 const_cast<Epetra_CrsMatrix *
>(&
matrix.trilinos_matrix()),
358 Ifpack_Preconditioner *ifpack =
366 Teuchos::ParameterList parameter_list;
367 parameter_list.set(
"relaxation: sweeps",
368 static_cast<int>(additional_data.
n_sweeps));
369 parameter_list.set(
"relaxation: type",
"symmetric Gauss-Seidel");
370 parameter_list.set(
"relaxation: damping factor", additional_data.
omega);
371 parameter_list.set(
"relaxation: min diagonal value",
373 parameter_list.set(
"schwarz: combine mode",
"Add");
374 parameter_list.set(
"partitioner: type",
379 parameter_list.set(
"partitioner: local parts", n_local_parts);
381 ierr = ifpack->SetParameters(parameter_list);
384 ierr = ifpack->Initialize();
387 ierr = ifpack->Compute();
397 const std::string &block_creation_type,
399 const double min_diagonal,
400 const unsigned int overlap,
401 const unsigned int n_sweeps)
403 , block_creation_type(block_creation_type)
405 , min_diagonal(min_diagonal)
421 Ifpack().Create((
matrix.trilinos_matrix().NumMyRows() == 0) ?
424 const_cast<Epetra_CrsMatrix *
>(&
matrix.trilinos_matrix()),
427 Ifpack_Preconditioner *ifpack =
435 Teuchos::ParameterList parameter_list;
436 parameter_list.set(
"relaxation: sweeps",
437 static_cast<int>(additional_data.
n_sweeps));
438 parameter_list.set(
"relaxation: type",
"Gauss-Seidel");
439 parameter_list.set(
"relaxation: damping factor", additional_data.
omega);
440 parameter_list.set(
"relaxation: min diagonal value",
442 parameter_list.set(
"schwarz: combine mode",
"Add");
443 parameter_list.set(
"partitioner: type",
448 parameter_list.set(
"partitioner: local parts", n_local_parts);
450 ierr = ifpack->SetParameters(parameter_list);
453 ierr = ifpack->Initialize();
456 ierr = ifpack->Compute();
465 const double ic_atol,
466 const double ic_rtol,
467 const unsigned int overlap)
482 Ifpack().Create(
"IC",
483 const_cast<Epetra_CrsMatrix *
>(&
matrix.trilinos_matrix()),
486 Ifpack_Preconditioner *ifpack =
494 Teuchos::ParameterList parameter_list;
495 parameter_list.set(
"fact: level-of-fill", additional_data.
ic_fill);
496 parameter_list.set(
"fact: absolute threshold", additional_data.
ic_atol);
497 parameter_list.set(
"fact: relative threshold", additional_data.
ic_rtol);
498 parameter_list.set(
"schwarz: combine mode",
"Add");
500 ierr = ifpack->SetParameters(parameter_list);
503 ierr = ifpack->Initialize();
506 ierr = ifpack->Compute();
515 const double ilu_atol,
516 const double ilu_rtol,
517 const unsigned int overlap)
532 Ifpack().Create(
"ILU",
533 const_cast<Epetra_CrsMatrix *
>(&
matrix.trilinos_matrix()),
536 Ifpack_Preconditioner *ifpack =
544 Teuchos::ParameterList parameter_list;
545 parameter_list.set(
"fact: level-of-fill",
546 static_cast<int>(additional_data.
ilu_fill));
547 parameter_list.set(
"fact: absolute threshold", additional_data.
ilu_atol);
548 parameter_list.set(
"fact: relative threshold", additional_data.
ilu_rtol);
549 parameter_list.set(
"schwarz: combine mode",
"Add");
551 ierr = ifpack->SetParameters(parameter_list);
554 ierr = ifpack->Initialize();
557 ierr = ifpack->Compute();
566 const unsigned int ilut_fill,
567 const double ilut_atol,
568 const double ilut_rtol,
569 const unsigned int overlap)
570 : ilut_drop(ilut_drop)
571 , ilut_fill(ilut_fill)
572 , ilut_atol(ilut_atol)
573 , ilut_rtol(ilut_rtol)
585 Ifpack().Create(
"ILUT",
586 const_cast<Epetra_CrsMatrix *
>(&
matrix.trilinos_matrix()),
589 Ifpack_Preconditioner *ifpack =
597 Teuchos::ParameterList parameter_list;
598 parameter_list.set(
"fact: drop value", additional_data.
ilut_drop);
599 parameter_list.set(
"fact: level-of-fill",
600 static_cast<int>(additional_data.
ilut_fill));
601 parameter_list.set(
"fact: absolute threshold", additional_data.
ilut_atol);
602 parameter_list.set(
"fact: relative threshold", additional_data.
ilut_rtol);
603 parameter_list.set(
"schwarz: combine mode",
"Add");
605 ierr = ifpack->SetParameters(parameter_list);
608 ierr = ifpack->Initialize();
611 ierr = ifpack->Compute();
620 const unsigned int overlap)
632 Ifpack().Create(
"Amesos",
633 const_cast<Epetra_CrsMatrix *
>(&
matrix.trilinos_matrix()),
636 Ifpack_Preconditioner *ifpack =
644 Teuchos::ParameterList parameter_list;
645 parameter_list.set(
"schwarz: combine mode",
"Add");
647 ierr = ifpack->SetParameters(parameter_list);
650 ierr = ifpack->Initialize();
653 ierr = ifpack->Compute();
662 const unsigned int degree,
663 const double max_eigenvalue,
664 const double eigenvalue_ratio,
665 const double min_eigenvalue,
666 const double min_diagonal,
667 const bool nonzero_starting)
669 , max_eigenvalue(max_eigenvalue)
670 , eigenvalue_ratio(eigenvalue_ratio)
671 , min_eigenvalue(min_eigenvalue)
672 , min_diagonal(min_diagonal)
673 , nonzero_starting(nonzero_starting)
683 Teuchos::rcp(
new Ifpack_Chebyshev(&
matrix.trilinos_matrix()));
685 Ifpack_Chebyshev *ifpack =
693 Teuchos::ParameterList parameter_list;
694 parameter_list.set(
"chebyshev: ratio eigenvalue",
696 parameter_list.set(
"chebyshev: min eigenvalue",
698 parameter_list.set(
"chebyshev: max eigenvalue",
700 parameter_list.set(
"chebyshev: degree",
701 static_cast<int>(additional_data.
degree));
702 parameter_list.set(
"chebyshev: min diagonal value",
704 parameter_list.set(
"chebyshev: zero starting solution",
707 ierr = ifpack->SetParameters(parameter_list);
710 ierr = ifpack->Initialize();
713 ierr = ifpack->Compute();
737 Ifpack().Create(
"point relaxation",
738 const_cast<Epetra_CrsMatrix *
>(&
matrix.trilinos_matrix()),
741 Ifpack_Preconditioner *ifpack =
749 Teuchos::ParameterList parameter_list;
750 parameter_list.set(
"relaxation: sweeps", 1);
751 parameter_list.set(
"relaxation: type",
"Jacobi");
752 parameter_list.set(
"relaxation: damping factor", 1.0);
753 parameter_list.set(
"relaxation: min diagonal value", 0.0);
755 ierr = ifpack->SetParameters(parameter_list);
758 ierr = ifpack->Initialize();
761 ierr = ifpack->Compute();
779 const ::Vector<double> &src)
const
786 const ::Vector<double> &src)
const
#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)
IndexSet locally_owned_range_indices() const
AdditionalData(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
Epetra_MpiComm communicator
void vmult(MPI::Vector &dst, const MPI::Vector &src) const override
std::string block_creation_type
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
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)
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
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)
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
AdditionalData(const double omega=1, const double min_diagonal=0, const unsigned int overlap=0, const unsigned int n_sweeps=1)
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 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 ilu_fill=0, const double ilu_atol=0., const double ilu_rtol=1., const unsigned int overlap=0)
Epetra_Operator & trilinos_operator() const
std::shared_ptr< Epetra_Map > vector_distributor
Teuchos::RCP< Epetra_Operator > preconditioner
AdditionalData(const unsigned int ic_fill=0, const double ic_atol=0., const double ic_rtol=1., const unsigned int overlap=0)
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
std::string block_creation_type
AdditionalData(const unsigned int overlap=0)
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
AdditionalData(const double omega=1, const double min_diagonal=0, const unsigned int n_sweeps=1)
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)
MPI_Comm get_mpi_communicator() const
void Tvmult(MPI::Vector &dst, const MPI::Vector &src) const override
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())
@ matrix
Contents is actually a matrix.