16 #ifndef dealii_mg_transfer_h
17 #define dealii_mg_transfer_h
19 #include <deal.II/base/config.h>
21 #include <deal.II/base/mg_level_object.h>
23 #include <deal.II/dofs/dof_handler.h>
25 #include <deal.II/lac/affine_constraints.h>
26 #include <deal.II/lac/block_sparsity_pattern.h>
27 #include <deal.II/lac/block_vector.h>
28 #include <deal.II/lac/la_parallel_vector.h>
29 #include <deal.II/lac/petsc_sparse_matrix.h>
30 #include <deal.II/lac/petsc_vector.h>
31 #include <deal.II/lac/sparse_matrix.h>
32 #include <deal.II/lac/trilinos_sparse_matrix.h>
33 #include <deal.II/lac/vector_memory.h>
35 #include <deal.II/multigrid/mg_base.h>
36 #include <deal.II/multigrid/mg_constrained_dofs.h>
41 DEAL_II_NAMESPACE_OPEN
46 template <
typename VectorType>
52 static const bool requires_distributed_sparsity_pattern =
false;
54 template <
typename SparsityPatternType,
typename DoFHandlerType>
56 reinit(Matrix & matrix,
59 const SparsityPatternType &sp,
60 const DoFHandlerType &)
62 sparsity.copy_from(sp);
68 #ifdef DEAL_II_WITH_TRILINOS
69 template <
typename Number>
75 static const bool requires_distributed_sparsity_pattern =
false;
77 template <
typename SparsityPatternType,
typename DoFHandlerType>
79 reinit(Matrix &matrix,
82 const SparsityPatternType &sp,
86 DoFHandlerType::space_dimension>
87 *dist_tria =
dynamic_cast<
89 DoFHandlerType::space_dimension
> *>(
90 &(dh.get_triangulation()));
91 MPI_Comm communicator =
94 matrix.reinit(dh.locally_owned_mg_dofs(level + 1),
95 dh.locally_owned_mg_dofs(level),
108 static const bool requires_distributed_sparsity_pattern =
false;
110 template <
typename SparsityPatternType,
typename DoFHandlerType>
112 reinit(Matrix &matrix,
115 const SparsityPatternType &sp,
119 DoFHandlerType::space_dimension>
120 *dist_tria =
dynamic_cast<
122 DoFHandlerType::space_dimension
> *>(
123 &(dh.get_triangulation()));
124 MPI_Comm communicator =
126 matrix.reinit(dh.locally_owned_mg_dofs(level + 1),
127 dh.locally_owned_mg_dofs(level),
134 # ifdef DEAL_II_WITH_MPI
135 # ifdef DEAL_II_TRILINOS_WITH_TPETRA
136 template <
typename Number>
142 static const bool requires_distributed_sparsity_pattern =
false;
144 template <
typename SparsityPatternType,
typename DoFHandlerType>
146 reinit(Matrix &matrix,
149 const SparsityPatternType &sp,
153 DoFHandlerType::space_dimension>
154 *dist_tria =
dynamic_cast<
156 DoFHandlerType::space_dimension
> *>(
157 &(dh.get_triangulation()));
158 MPI_Comm communicator =
160 matrix.reinit(dh.locally_owned_mg_dofs(level + 1),
161 dh.locally_owned_mg_dofs(level),
175 static const bool requires_distributed_sparsity_pattern =
false;
177 template <
typename SparsityPatternType,
typename DoFHandlerType>
179 reinit(Matrix &matrix,
182 const SparsityPatternType &sp,
186 DoFHandlerType::space_dimension>
187 *dist_tria =
dynamic_cast<
189 DoFHandlerType::space_dimension
> *>(
190 &(dh.get_triangulation()));
191 MPI_Comm communicator =
193 matrix.reinit(dh.locally_owned_mg_dofs(level + 1),
194 dh.locally_owned_mg_dofs(level),
204 template <
typename Number>
210 static const bool requires_distributed_sparsity_pattern =
false;
212 template <
typename SparsityPatternType,
typename DoFHandlerType>
217 const SparsityPatternType &,
218 const DoFHandlerType &)
223 "ERROR: MGTransferPrebuilt with LinearAlgebra::distributed::Vector currently "
224 "needs deal.II to be configured with Trilinos."));
230 #ifdef DEAL_II_WITH_PETSC
237 static const bool requires_distributed_sparsity_pattern =
true;
239 template <
typename SparsityPatternType,
typename DoFHandlerType>
241 reinit(Matrix &matrix,
244 const SparsityPatternType &sp,
245 const DoFHandlerType & dh)
248 DoFHandlerType::space_dimension>
249 *dist_tria =
dynamic_cast<
251 DoFHandlerType::space_dimension
> *>(
252 &(dh.get_triangulation()));
253 MPI_Comm communicator =
256 matrix.reinit(dh.locally_owned_mg_dofs(level + 1),
257 dh.locally_owned_mg_dofs(level),
281 template <
typename VectorType>
297 template <
int dim,
class InVector,
int spacedim>
301 const InVector & src)
const;
310 template <
int dim,
class OutVector,
int spacedim>
321 template <
int dim,
class OutVector,
int spacedim>
361 template <
int dim,
int spacedim>
368 std::vector<types::global_dof_index>
sizes;
378 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
389 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
400 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
437 template <
typename Number>
439 :
public MGTransferBase<LinearAlgebra::distributed::Vector<Number>>
454 template <
int dim,
typename Number2,
int spacedim>
467 template <
int dim,
typename Number2,
int spacedim>
479 template <
int dim,
typename Number2,
int spacedim>
521 template <
int dim,
typename Number2,
int spacedim>
526 const bool solution_transfer)
const;
531 template <
int dim,
int spacedim>
538 std::vector<types::global_dof_index>
sizes;
547 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
copy_indices;
553 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
563 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
569 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
579 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
585 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
660 template <
typename VectorType>
716 template <
int dim,
int spacedim>
734 const VectorType & src)
const override;
754 const VectorType & src)
const override;
783 std::shared_ptr<typename internal::MatrixSelector<VectorType>::Sparsity>>
792 std::shared_ptr<typename internal::MatrixSelector<VectorType>::Matrix>>
806 DEAL_II_NAMESPACE_CLOSE