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);
64 matrix.reinit(sparsity);
68 #ifdef DEAL_II_WITH_TRILINOS 69 template <
typename Number>
70 struct MatrixSelector<
LinearAlgebra::distributed::Vector<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 141 static const bool requires_distributed_sparsity_pattern =
false;
143 template <
typename SparsityPatternType,
typename DoFHandlerType>
145 reinit(Matrix &matrix,
148 const SparsityPatternType &sp,
152 DoFHandlerType::space_dimension>
153 *dist_tria =
dynamic_cast< 155 DoFHandlerType::space_dimension
> *>(
156 &(dh.get_triangulation()));
157 MPI_Comm communicator =
159 matrix.reinit(dh.locally_owned_mg_dofs(level + 1),
160 dh.locally_owned_mg_dofs(level),
170 template <
typename Number>
171 struct MatrixSelector<
LinearAlgebra::distributed::Vector<Number>>
176 static const bool requires_distributed_sparsity_pattern =
false;
178 template <
typename SparsityPatternType,
typename DoFHandlerType>
183 const SparsityPatternType &,
184 const DoFHandlerType &)
189 "ERROR: MGTransferPrebuilt with LinearAlgebra::distributed::Vector currently " 190 "needs deal.II to be configured with Trilinos."));
196 #ifdef DEAL_II_WITH_PETSC 203 static const bool requires_distributed_sparsity_pattern =
true;
205 template <
typename SparsityPatternType,
typename DoFHandlerType>
207 reinit(Matrix &matrix,
210 const SparsityPatternType &sp,
211 const DoFHandlerType & dh)
214 DoFHandlerType::space_dimension>
215 *dist_tria =
dynamic_cast< 217 DoFHandlerType::space_dimension
> *>(
218 &(dh.get_triangulation()));
219 MPI_Comm communicator =
222 matrix.reinit(dh.locally_owned_mg_dofs(level + 1),
223 dh.locally_owned_mg_dofs(level),
247 template <
typename VectorType>
263 template <
int dim,
class InVector,
int spacedim>
267 const InVector & src)
const;
276 template <
int dim,
class OutVector,
int spacedim>
287 template <
int dim,
class OutVector,
int spacedim>
309 set_component_to_block_map(
const std::vector<unsigned int> &map);
315 memory_consumption()
const;
321 print_indices(std::ostream &os)
const;
327 template <
int dim,
int spacedim>
334 std::vector<types::global_dof_index>
sizes;
344 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
355 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
366 std::vector<std::pair<types::global_dof_index, types::global_dof_index>>>
403 template <
typename Number>
405 :
public MGTransferBase<LinearAlgebra::distributed::Vector<Number>>
420 template <
int dim,
typename Number2,
int spacedim>
433 template <
int dim,
typename Number2,
int spacedim>
445 template <
int dim,
typename Number2,
int spacedim>
468 set_component_to_block_map(
const std::vector<unsigned int> &map);
474 memory_consumption()
const;
480 print_indices(std::ostream &os)
const;
487 template <
int dim,
typename Number2,
int spacedim>
492 const bool solution_transfer)
const;
497 template <
int dim,
int spacedim>
504 std::vector<types::global_dof_index>
sizes;
513 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
copy_indices;
519 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
529 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
535 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
545 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
551 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
626 template <
typename VectorType>
655 virtual ~MGTransferPrebuilt()
override =
default;
682 template <
int dim,
int spacedim>
698 prolongate(
const unsigned int to_level,
700 const VectorType & src)
const override;
718 restrict_and_add(
const unsigned int from_level,
720 const VectorType & src)
const override;
736 memory_consumption()
const;
742 print_matrices(std::ostream &os)
const;
749 std::shared_ptr<typename internal::MatrixSelector<VectorType>::Sparsity>>
758 std::shared_ptr<typename internal::MatrixSelector<VectorType>::Matrix>>
772 DEAL_II_NAMESPACE_CLOSE
std::vector< std::vector< std::pair< types::global_dof_index, types::global_dof_index > > > copy_indices
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > copy_indices_global_mine
LinearAlgebra::distributed::Vector< Number > solution_ghosted_global_vector
std::vector< types::global_dof_index > sizes
#define AssertThrow(cond, exc)
std::vector< unsigned int > component_to_block_map
LinearAlgebra::distributed::Vector< Number > ghosted_global_vector
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > solution_copy_indices_global_mine
virtual MPI_Comm get_communicator() const
std::vector< std::vector< std::pair< types::global_dof_index, types::global_dof_index > > > copy_indices_level_mine
#define DeclException0(Exception0)
bool perform_renumbered_plain_copy
std::vector< unsigned int > component_to_block_map
std::vector< std::vector< std::pair< types::global_dof_index, types::global_dof_index > > > copy_indices_global_mine
SmartPointer< const MGConstrainedDoFs, MGLevelGlobalTransfer< VectorType > > mg_constrained_dofs
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > copy_indices
std::vector< std::shared_ptr< typename internal::MatrixSelector< VectorType >::Sparsity > > prolongation_sparsities
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > solution_copy_indices_level_mine
std::vector< types::global_dof_index > sizes
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > solution_copy_indices
SmartPointer< const MGConstrainedDoFs, MGLevelGlobalTransfer< LinearAlgebra::distributed::Vector< Number > > > mg_constrained_dofs
MGLevelObject< LinearAlgebra::distributed::Vector< Number > > solution_ghosted_level_vector
static::ExceptionBase & ExcNotImplemented()
std::vector< std::vector< bool > > interface_dofs
std::vector< std::shared_ptr< typename internal::MatrixSelector< VectorType >::Matrix > > prolongation_matrices
MGLevelObject< LinearAlgebra::distributed::Vector< Number > > ghosted_level_vector
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > copy_indices_level_mine