19#ifdef DEAL_II_WITH_TRILINOS
20# ifdef DEAL_II_TRILINOS_WITH_MUELU
24# include <MueLu_CreateEpetraPreconditioner.hpp>
25# include <ml_MultiLevelPreconditioner.h>
33 const unsigned int n_cycles,
35 const double aggregation_threshold,
36 const std::vector<std::vector<bool>> &constant_modes,
37 const unsigned int smoother_sweeps,
38 const unsigned int smoother_overlap,
39 const bool output_details,
40 const char * smoother_type,
41 const char * coarse_type)
45 , aggregation_threshold(aggregation_threshold)
46 , constant_modes(constant_modes)
47 , smoother_sweeps(smoother_sweeps)
48 , smoother_overlap(smoother_overlap)
49 , output_details(output_details)
50 , smoother_type(smoother_type)
51 , coarse_type(coarse_type)
60# ifdef DEAL_II_WITH_64BIT_INDICES
61 constexpr bool enabled =
false;
63 constexpr bool enabled =
true;
67 "PreconditionAMGMueLu does not support 64bit-indices!"));
76 initialize(matrix.trilinos_matrix(), additional_data);
86 Teuchos::ParameterList parameter_list;
88 parameter_list.set(
"parameterlist: syntax",
"ml");
90 if (additional_data.
elliptic ==
true)
91 ML_Epetra::SetDefaults(
"SA", parameter_list);
94 ML_Epetra::SetDefaults(
"NSSA", parameter_list);
95 parameter_list.set(
"aggregation: block scaling",
true);
100 parameter_list.set(
"aggregation: type",
"Uncoupled");
102 parameter_list.set(
"smoother: type", additional_data.
smoother_type);
103 parameter_list.set(
"coarse: type", additional_data.
coarse_type);
105 parameter_list.set(
"smoother: sweeps",
107 parameter_list.set(
"cycle applications",
108 static_cast<int>(additional_data.
n_cycles));
109 if (additional_data.
w_cycle ==
true)
110 parameter_list.set(
"prec type",
"MGW");
112 parameter_list.set(
"prec type",
"MGV");
114 parameter_list.set(
"smoother: Chebyshev alpha", 10.);
115 parameter_list.set(
"smoother: ifpack overlap",
117 parameter_list.set(
"aggregation: threshold",
119 parameter_list.set(
"coarse: max size", 2000);
122 parameter_list.set(
"ML output", 10);
124 parameter_list.set(
"ML output", 0);
126 const Epetra_Map &domain_map = matrix.OperatorDomainMap();
128 const size_type constant_modes_dimension =
130 Epetra_MultiVector distributed_constant_modes(
131 domain_map, constant_modes_dimension > 0 ? constant_modes_dimension : 1);
132 std::vector<double> dummy(constant_modes_dimension);
134 if (constant_modes_dimension > 0)
137 const bool constant_modes_are_global =
140 constant_modes_are_global ? n_rows :
142 const size_type my_size = domain_map.NumMyElements();
143 if (constant_modes_are_global ==
false)
144 Assert(n_relevant_rows == my_size,
147 distributed_constant_modes)),
150 distributed_constant_modes)));
152 (void)n_relevant_rows;
157 for (
size_type d = 0; d < constant_modes_dimension; ++d)
158 for (
size_type row = 0; row < my_size; ++row)
161 constant_modes_are_global ?
164 distributed_constant_modes[d][row] =
static_cast<double>(
168 parameter_list.set(
"null space: type",
"pre-computed");
169 parameter_list.set(
"null space: dimension",
170 distributed_constant_modes.NumVectors());
172 parameter_list.set(
"null space: vectors",
173 distributed_constant_modes.Values());
177 parameter_list.set(
"null space: vectors", dummy.data());
187 Teuchos::ParameterList &muelu_parameters)
189 initialize(matrix.trilinos_matrix(), muelu_parameters);
196 Teuchos::ParameterList &muelu_parameters)
198 const auto teuchos_wrapped_matrix =
199 Teuchos::rcp(
const_cast<Epetra_CrsMatrix *
>(&matrix),
false);
200 preconditioner = MueLu::CreateEpetraPreconditioner(teuchos_wrapped_matrix,
206 template <
typename number>
209 const ::SparseMatrix<number> &deal_ii_sparse_matrix,
211 const double drop_tolerance,
212 const ::SparsityPattern * use_this_sparsity)
215 const size_type n_rows = deal_ii_sparse_matrix.m();
220 const unsigned int n_mpi_processes =
communicator.NumProc();
222 distributor.
add_range(my_id * n_rows / n_mpi_processes,
223 (my_id + 1) * n_rows / n_mpi_processes);
230 deal_ii_sparse_matrix,
253 unsigned int memory =
sizeof(*this);
268 const AdditionalData &,
270 const ::SparsityPattern *);
273 const AdditionalData &,
275 const ::SparsityPattern *);
void add_range(const size_type begin, const size_type end)
std::shared_ptr< SparseMatrix > trilinos_matrix
size_type memory_consumption() const
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
Epetra_MpiComm communicator
Teuchos::RCP< Epetra_Operator > preconditioner
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
TrilinosWrappers::types::int_type global_index(const Epetra_BlockMap &map, const ::types::global_dof_index i)
TrilinosWrappers::types::int_type n_global_rows(const Epetra_CrsGraph &graph)
TrilinosWrappers::types::int_type global_length(const Epetra_MultiVector &vector)
double aggregation_threshold
std::vector< std::vector< bool > > constant_modes
AdditionalData(const bool elliptic=true, const unsigned int n_cycles=1, const bool w_cycle=false, const double aggregation_threshold=1e-4, const std::vector< std::vector< bool > > &constant_modes=std::vector< std::vector< bool > >(0), const unsigned int smoother_sweeps=2, const unsigned int smoother_overlap=0, const bool output_details=false, const char *smoother_type="Chebyshev", const char *coarse_type="Amesos-KLU")
unsigned int smoother_sweeps
unsigned int smoother_overlap
const char * smoother_type