18#ifdef DEAL_II_WITH_TRILINOS
19# ifdef DEAL_II_TRILINOS_WITH_MUELU
23# include <MueLu_CreateEpetraPreconditioner.hpp>
24# include <ml_MultiLevelPreconditioner.h>
32 const unsigned int n_cycles,
34 const double aggregation_threshold,
35 const std::vector<std::vector<bool>> &constant_modes,
36 const unsigned int smoother_sweeps,
37 const unsigned int smoother_overlap,
38 const bool output_details,
39 const char *smoother_type,
40 const char *coarse_type)
44 , aggregation_threshold(aggregation_threshold)
45 , constant_modes(constant_modes)
46 , smoother_sweeps(smoother_sweeps)
47 , smoother_overlap(smoother_overlap)
48 , output_details(output_details)
49 , smoother_type(smoother_type)
50 , coarse_type(coarse_type)
59# ifdef DEAL_II_WITH_64BIT_INDICES
60 constexpr bool enabled =
false;
62 constexpr bool enabled =
true;
66 "PreconditionAMGMueLu does not support 64bit-indices!"));
75 initialize(matrix.trilinos_matrix(), additional_data);
85 Teuchos::ParameterList parameter_list;
87 parameter_list.set(
"parameterlist: syntax",
"ml");
89 if (additional_data.
elliptic ==
true)
90 ML_Epetra::SetDefaults(
"SA", parameter_list);
93 ML_Epetra::SetDefaults(
"NSSA", parameter_list);
94 parameter_list.set(
"aggregation: block scaling",
true);
99 parameter_list.set(
"aggregation: type",
"Uncoupled");
101 parameter_list.set(
"smoother: type", additional_data.
smoother_type);
102 parameter_list.set(
"coarse: type", additional_data.
coarse_type);
104 parameter_list.set(
"smoother: sweeps",
106 parameter_list.set(
"cycle applications",
107 static_cast<int>(additional_data.
n_cycles));
108 if (additional_data.
w_cycle ==
true)
109 parameter_list.set(
"prec type",
"MGW");
111 parameter_list.set(
"prec type",
"MGV");
113 parameter_list.set(
"smoother: Chebyshev alpha", 10.);
114 parameter_list.set(
"smoother: ifpack overlap",
116 parameter_list.set(
"aggregation: threshold",
118 parameter_list.set(
"coarse: max size", 2000);
121 parameter_list.set(
"ML output", 10);
123 parameter_list.set(
"ML output", 0);
125 const Epetra_Map &domain_map = matrix.OperatorDomainMap();
127 const size_type constant_modes_dimension =
129 Epetra_MultiVector distributed_constant_modes(
130 domain_map, constant_modes_dimension > 0 ? constant_modes_dimension : 1);
131 std::vector<double> dummy(constant_modes_dimension);
133 if (constant_modes_dimension > 0)
136 const bool constant_modes_are_global =
139 constant_modes_are_global ? n_rows :
141 const size_type my_size = domain_map.NumMyElements();
142 if (constant_modes_are_global ==
false)
143 Assert(n_relevant_rows == my_size,
146 distributed_constant_modes)),
149 distributed_constant_modes)));
151 (void)n_relevant_rows;
156 for (
size_type d = 0; d < constant_modes_dimension; ++d)
157 for (
size_type row = 0; row < my_size; ++row)
160 constant_modes_are_global ?
163 distributed_constant_modes[d][row] =
static_cast<double>(
167 parameter_list.set(
"null space: type",
"pre-computed");
168 parameter_list.set(
"null space: dimension",
169 distributed_constant_modes.NumVectors());
171 parameter_list.set(
"null space: vectors",
172 distributed_constant_modes.Values());
176 parameter_list.set(
"null space: vectors", dummy.data());
186 Teuchos::ParameterList &muelu_parameters)
188 initialize(matrix.trilinos_matrix(), muelu_parameters);
195 Teuchos::ParameterList &muelu_parameters)
197 const auto teuchos_wrapped_matrix =
198 Teuchos::rcp(
const_cast<Epetra_CrsMatrix *
>(&matrix),
false);
199 preconditioner = MueLu::CreateEpetraPreconditioner(teuchos_wrapped_matrix,
205 template <
typename number>
208 const ::SparseMatrix<number> &deal_ii_sparse_matrix,
210 const double drop_tolerance,
211 const ::SparsityPattern *use_this_sparsity)
214 const size_type n_rows = deal_ii_sparse_matrix.m();
219 const unsigned int n_mpi_processes =
communicator.NumProc();
221 distributor.
add_range(my_id * n_rows / n_mpi_processes,
222 (my_id + 1) * n_rows / n_mpi_processes);
229 deal_ii_sparse_matrix,
252 unsigned int memory =
sizeof(*this);
267 const AdditionalData &,
269 const ::SparsityPattern *);
272 const AdditionalData &,
274 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