16 #include <deal.II/lac/trilinos_index_access.h> 17 #include <deal.II/lac/trilinos_precondition.h> 19 #ifdef DEAL_II_WITH_TRILINOS 20 # if DEAL_II_TRILINOS_VERSION_GTE(11, 14, 0) 21 # include <deal.II/lac/sparse_matrix.h> 22 # include <deal.II/lac/trilinos_sparse_matrix.h> 24 # include <MueLu_CreateEpetraPreconditioner.hpp> 25 # include <ml_MultiLevelPreconditioner.h> 27 DEAL_II_NAMESPACE_OPEN
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)
160 TrilinosWrappers::types::int_type global_row_id =
161 constant_modes_are_global ?
164 distributed_constant_modes[d][row] =
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();
222 static_cast<TrilinosWrappers::types::int_type
>(n_rows), 0,
communicator);
229 deal_ii_sparse_matrix,
251 unsigned int memory =
sizeof(*this);
265 const AdditionalData &,
267 const ::SparsityPattern *);
270 const AdditionalData &,
272 const ::SparsityPattern *);
276 DEAL_II_NAMESPACE_CLOSE
278 # endif // DEAL_II_TRILINOS_VERSION_GTE(11,14,0) 279 #endif // DEAL_II_WITH_TRILINOS unsigned int smoother_sweeps
void initialize(const SparseMatrix &matrix, const AdditionalData &additional_data=AdditionalData())
::types::global_dof_index size_type
TrilinosWrappers::types::int_type global_length(const Epetra_MultiVector &vector)
const char * smoother_type
std::shared_ptr< Epetra_Map > vector_distributor
#define AssertThrow(cond, exc)
size_type memory_consumption() const
static ::ExceptionBase & ExcMessage(std::string arg1)
TrilinosWrappers::types::int_type n_global_rows(const Epetra_CrsGraph &graph)
double aggregation_threshold
#define Assert(cond, exc)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
std::vector< std::vector< bool > > constant_modes
AdditionalData(const bool elliptic=true, const unsigned int n_cycles=1, const bool w_cyle=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")
std::shared_ptr< SparseMatrix > trilinos_matrix
TrilinosWrappers::types::int_type global_index(const Epetra_BlockMap &map, const ::types::global_dof_index i)
unsigned int smoother_overlap
Epetra_MpiComm communicator
Teuchos::RCP< Epetra_Operator > preconditioner