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
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
MGTransferPrebuilt()=default
void copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, OutVector &dst, const MGLevelObject< VectorType > &src) const
std::vector< std::vector< std::pair< types::global_dof_index, types::global_dof_index > > > copy_indices
std::size_t memory_consumption() const
Contents is actually a matrix.
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > copy_indices_global_mine
void build_matrices(const DoFHandler< dim, spacedim > &mg_dof)
void copy_from_mg_add(const DoFHandler< dim, spacedim > &mg_dof, OutVector &dst, const MGLevelObject< VectorType > &src) const
LinearAlgebra::distributed::Vector< Number > solution_ghosted_global_vector
void copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< VectorType > &dst, const InVector &src) const
std::vector< types::global_dof_index > sizes
#define AssertThrow(cond, exc)
std::vector< unsigned int > component_to_block_map
void print_indices(std::ostream &os) const
LinearAlgebra::distributed::Vector< Number > ghosted_global_vector
static ::ExceptionBase & ExcNoProlongation()
LinearAlgebra::distributed::Vector< Number > Vector
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > solution_copy_indices_global_mine
virtual ~MGTransferPrebuilt() override=default
virtual void restrict_and_add(const unsigned int from_level, VectorType &dst, const VectorType &src) const override
void print_matrices(std::ostream &os) const
std::size_t memory_consumption() const
std::vector< std::vector< std::pair< types::global_dof_index, types::global_dof_index > > > copy_indices_level_mine
void fill_and_communicate_copy_indices(const DoFHandler< dim, spacedim > &mg_dof)
virtual MPI_Comm get_communicator() const
#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
virtual void prolongate(const unsigned int to_level, VectorType &dst, const VectorType &src) const override
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > solution_copy_indices
SmartPointer< const MGConstrainedDoFs, MGLevelGlobalTransfer< LinearAlgebra::distributed::Vector< Number > > > mg_constrained_dofs
static ::ExceptionBase & ExcMatricesNotBuilt()
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
void set_component_to_block_map(const std::vector< unsigned int > &map)
MGLevelObject< LinearAlgebra::distributed::Vector< Number > > ghosted_level_vector
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > copy_indices_level_mine