16 #ifndef dealii_mg_transfer_h 17 #define dealii_mg_transfer_h 19 #include <deal.II/base/config.h> 21 #include <deal.II/lac/block_vector.h> 22 #include <deal.II/lac/constraint_matrix.h> 23 #include <deal.II/lac/sparse_matrix.h> 24 #include <deal.II/lac/block_sparsity_pattern.h> 25 #include <deal.II/lac/trilinos_sparse_matrix.h> 26 #include <deal.II/lac/la_parallel_vector.h> 28 #include <deal.II/lac/vector_memory.h> 30 #include <deal.II/multigrid/mg_base.h> 31 #include <deal.II/multigrid/mg_constrained_dofs.h> 32 #include <deal.II/base/mg_level_object.h> 34 #include <deal.II/dofs/dof_handler.h> 39 DEAL_II_NAMESPACE_OPEN
44 template <
typename VectorType>
47 typedef ::SparsityPattern Sparsity;
48 typedef ::SparseMatrix<typename VectorType::value_type> Matrix;
50 template <
typename SparsityPatternType,
typename DoFHandlerType>
51 static void reinit(Matrix &matrix, Sparsity &sparsity,
int level,
const SparsityPatternType &sp,
const DoFHandlerType &)
53 sparsity.copy_from (sp);
59 #ifdef DEAL_II_WITH_TRILINOS 60 template <
typename Number>
61 struct MatrixSelector<
LinearAlgebra::distributed::Vector<Number> >
63 typedef ::TrilinosWrappers::SparsityPattern Sparsity;
64 typedef ::TrilinosWrappers::SparseMatrix Matrix;
66 template <
typename SparsityPatternType,
typename DoFHandlerType>
67 static void reinit(Matrix &matrix, Sparsity &,
int level,
const SparsityPatternType &sp, DoFHandlerType &dh)
71 (&(dh.get_triangulation()));
72 MPI_Comm communicator = dist_tria !=
nullptr ?
76 matrix.reinit(dh.locally_owned_mg_dofs(level+1),
77 dh.locally_owned_mg_dofs(level),
78 sp, communicator,
true);
86 typedef ::TrilinosWrappers::SparsityPattern Sparsity;
87 typedef ::TrilinosWrappers::SparseMatrix Matrix;
89 template <
typename SparsityPatternType,
typename DoFHandlerType>
90 static void reinit(Matrix &matrix, Sparsity &,
int level,
const SparsityPatternType &sp, DoFHandlerType &dh)
94 (&(dh.get_triangulation()));
95 MPI_Comm communicator = dist_tria !=
nullptr ?
98 matrix.reinit(dh.locally_owned_mg_dofs(level+1),
99 dh.locally_owned_mg_dofs(level),
100 sp, communicator,
true);
105 #ifdef DEAL_II_WITH_MPI 109 typedef ::TrilinosWrappers::SparsityPattern Sparsity;
110 typedef ::TrilinosWrappers::SparseMatrix Matrix;
112 template <
typename SparsityPatternType,
typename DoFHandlerType>
113 static void reinit(Matrix &matrix, Sparsity &,
int level,
const SparsityPatternType &sp, DoFHandlerType &dh)
117 (&(dh.get_triangulation()));
118 MPI_Comm communicator = dist_tria !=
nullptr ?
121 matrix.reinit(dh.locally_owned_mg_dofs(level+1),
122 dh.locally_owned_mg_dofs(level),
123 sp, communicator,
true);
130 template <
typename Number>
131 struct MatrixSelector<
LinearAlgebra::distributed::Vector<Number> >
133 typedef ::SparsityPattern Sparsity;
134 typedef ::SparseMatrix<Number> Matrix;
136 template <
typename SparsityPatternType,
typename DoFHandlerType>
137 static void reinit(Matrix &, Sparsity &,
int,
const SparsityPatternType &,
const DoFHandlerType &)
140 "ERROR: MGTransferPrebuilt with LinearAlgebra::distributed::Vector currently " 141 "needs deal.II to be configured with Trilinos."));
164 template <
typename VectorType>
180 template <
int dim,
class InVector,
int spacedim>
184 const InVector &src)
const;
193 template <
int dim,
class OutVector,
int spacedim>
204 template <
int dim,
class OutVector,
int spacedim>
243 template <
int dim,
int spacedim>
249 std::vector<types::global_dof_index>
sizes;
258 std::vector<std::vector<std::pair<types::global_dof_index, types::global_dof_index> > >
268 std::vector<std::vector<std::pair<types::global_dof_index, types::global_dof_index> > >
278 std::vector<std::vector<std::pair<types::global_dof_index, types::global_dof_index> > >
314 template <
typename Number>
330 template <
int dim,
typename Number2,
int spacedim>
343 template <
int dim,
typename Number2,
int spacedim>
354 template <
int dim,
typename Number2,
int spacedim>
394 template <
int dim,
typename Number2,
int spacedim>
399 const bool solution_transfer)
const;
404 template <
int dim,
int spacedim>
410 std::vector<types::global_dof_index>
sizes;
419 std::vector<std::vector<std::pair<unsigned int, unsigned int> > >
426 std::vector<std::vector<std::pair<unsigned int, unsigned int> > >
436 std::vector<std::vector<std::pair<unsigned int, unsigned int> > >
442 std::vector<std::vector<std::pair<unsigned int, unsigned int> > >
452 std::vector<std::vector<std::pair<unsigned int, unsigned int> > >
458 std::vector<std::vector<std::pair<unsigned int, unsigned int> > >
528 template <
typename VectorType>
581 template <
int dim,
int spacedim>
595 virtual void prolongate (
const unsigned int to_level,
597 const VectorType &src)
const;
616 const VectorType &src)
const;
663 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::size_t memory_consumption() const
std::vector< std::shared_ptr< typename internal::MatrixSelector< VectorType >::Matrix > > prolongation_matrices
std::vector< std::vector< std::pair< types::global_dof_index, types::global_dof_index > > > copy_indices
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()
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > solution_copy_indices_global_mine
virtual ~MGTransferPrebuilt()=default
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
std::vector< std::shared_ptr< typename internal::MatrixSelector< VectorType >::Sparsity > > prolongation_sparsities
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
SmartPointer< const MGConstrainedDoFs, MGLevelGlobalTransfer< LinearAlgebra::distributed::Vector< Number > > > mg_constrained_dofs
std::vector< unsigned int > component_to_block_map
SmartPointer< const MGConstrainedDoFs, MGLevelGlobalTransfer< VectorType > > mg_constrained_dofs
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > copy_indices
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
std::vector< std::vector< std::pair< types::global_dof_index, types::global_dof_index > > > copy_indices_global_mine
static ::ExceptionBase & ExcMatricesNotBuilt()
virtual void prolongate(const unsigned int to_level, VectorType &dst, const VectorType &src) const
MGLevelObject< LinearAlgebra::distributed::Vector< Number > > solution_ghosted_level_vector
static ::ExceptionBase & ExcNotImplemented()
std::vector< std::vector< bool > > interface_dofs
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
virtual void restrict_and_add(const unsigned int from_level, VectorType &dst, const VectorType &src) const