16 #ifndef dealii_mg_transfer_matrix_free_h 17 #define dealii_mg_transfer_matrix_free_h 19 #include <deal.II/base/config.h> 21 #include <deal.II/lac/la_parallel_vector.h> 22 #include <deal.II/lac/la_parallel_block_vector.h> 23 #include <deal.II/multigrid/mg_base.h> 24 #include <deal.II/multigrid/mg_constrained_dofs.h> 25 #include <deal.II/base/mg_level_object.h> 26 #include <deal.II/multigrid/mg_transfer.h> 27 #include <deal.II/multigrid/mg_transfer_internal.h> 28 #include <deal.II/base/vectorization.h> 30 #include <deal.II/dofs/dof_handler.h> 33 DEAL_II_NAMESPACE_OPEN
54 template <
int dim,
typename Number>
104 virtual void prolongate (
const unsigned int to_level,
137 template<
typename Number2,
int spacedim>
237 template <
int degree>
245 template <
int degree>
268 template <
int dim,
typename Number>
333 virtual void prolongate (
const unsigned int to_level,
369 template <
typename Number2,
int spacedim>
378 template <
typename Number2,
int spacedim>
387 template <
typename Number2,
int spacedim>
396 template <
typename Number2,
int spacedim>
435 template <
int dim,
typename Number>
436 template <
typename Number2,
int spacedim>
443 const unsigned int min_level = dst.min_level();
444 const unsigned int max_level = dst.max_level();
452 MPI_Comm mpi_communicator = p_tria !=
nullptr ? p_tria->
get_communicator() : MPI_COMM_SELF;
456 for (
unsigned int level = min_level; level <= max_level; ++level)
459 relevant_dofs[level]);
463 relevant_dofs[level],
470 this->copy_to_mg (dof_handler, dst, src,
true);
474 dst[max_level].update_ghost_values();
476 for (
unsigned int level=max_level; level > min_level; --level)
481 relevant_dofs[level],
483 ghosted_vector = dst[level];
489 std::vector<types::global_dof_index> dof_indices(fe.
dofs_per_cell);
492 for ( ; cell != endc; ++cell)
493 if (cell->is_locally_owned_on_level())
498 if (!cell->has_children())
501 std::fill(dof_values_coarse.begin(), dof_values_coarse.end(), 0.);
502 for (
unsigned int child=0; child<cell->n_children(); ++child)
504 cell->child(child)->get_mg_dof_indices(dof_indices);
506 dof_values_fine(i) = ghosted_vector(dof_indices[i]);
510 dof_values_coarse[i] += tmp[i];
511 else if (tmp(i) != 0.)
512 dof_values_coarse[i] = tmp[i];
514 cell->get_mg_dof_indices(dof_indices);
516 dst[level-1](dof_indices[i]) = dof_values_coarse[i];
520 dst[level-1].update_ghost_values();
526 template <
int dim,
typename Number>
527 template <
typename Number2,
int spacedim>
536 ExcMessage(
"This object was initialized with support for usage with one " 537 "DoFHandler for each block, but this method assumes that " 538 "the same DoFHandler is used for all the blocks!"));
539 const std::vector<const DoFHandler<dim, spacedim>*> mg_dofs (src.
n_blocks(),&mg_dof);
541 copy_to_mg(mg_dofs, dst, src);
544 template <
int dim,
typename Number>
545 template <
typename Number2,
int spacedim>
552 const unsigned int n_blocks = src.
n_blocks();
558 const unsigned int min_level = dst.min_level();
559 const unsigned int max_level = dst.max_level();
568 for (
unsigned int i=1; i<n_blocks; ++i)
570 (&(mg_dof[0]->get_triangulation())) == tria),
571 ExcMessage(
"The DoFHandler use different Triangulations!"));
573 for (
unsigned int level = min_level; level <= max_level; ++level)
575 dst[level].reinit(n_blocks);
576 bool collect_size =
false;
577 for (
unsigned int b = 0;
b < n_blocks; ++
b)
583 v.
reinit(mg_dof[b]->locally_owned_mg_dofs(level), tria !=
nullptr ?
591 dst[level].collect_sizes ();
598 for (
unsigned int b = 0;
b < n_blocks; ++
b)
600 for (
unsigned int l = min_level;
l <= max_level; ++
l)
601 dst_non_block[l].reinit(dst[l].block(b));
602 const unsigned int data_block = same_for_all ? 0 :
b;
603 matrix_free_transfer_vector[data_block].copy_to_mg(*mg_dof[b], dst_non_block, src.
block(b));
605 for (
unsigned int l = min_level;
l <= max_level; ++
l)
606 dst[l].block(b) = dst_non_block[
l];
610 template <
int dim,
typename Number>
611 template <
typename Number2,
int spacedim>
619 const std::vector<const DoFHandler<dim, spacedim>*> mg_dofs (dst.
n_blocks(), &mg_dof);
621 copy_from_mg(mg_dofs, dst, src);
624 template <
int dim,
typename Number>
625 template <
typename Number2,
int spacedim>
632 const unsigned int n_blocks = dst.
n_blocks();
638 const unsigned int min_level = src.min_level();
639 const unsigned int max_level = src.max_level();
641 for (
unsigned int l = min_level;
l <= max_level; ++
l)
647 for (
unsigned int b = 0;
b < n_blocks; ++
b)
649 for (
unsigned int l = min_level;
l <= max_level; ++
l)
651 src_non_block[
l].reinit(src[l].block(b));
652 src_non_block[
l] = src[
l].
block(b);
654 const unsigned int data_block = same_for_all ? 0 :
b;
655 matrix_free_transfer_vector[data_block].copy_from_mg(*mg_dof[b], dst.
block(b), src_non_block);
664 DEAL_II_NAMESPACE_CLOSE
void reinit(const size_type size, const bool omit_zeroing_entries=false)
bool restriction_is_additive(const unsigned int index) const
void do_restrict_add(const unsigned int from_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const
#define AssertDimension(dim1, dim2)
std::vector< unsigned int > n_owned_level_cells
cell_iterator begin(const unsigned int level=0) const
AlignedVector< VectorizedArray< Number > > evaluation_data
static ::ExceptionBase & ExcNoProlongation()
virtual void restrict_and_add(const unsigned int from_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const
unsigned int n_components
std::size_t memory_consumption() const
std::vector< std::vector< std::vector< unsigned short > > > dirichlet_indices
void build(const DoFHandler< dim, dim > &mg_dof)
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
cell_iterator end() const
#define AssertThrow(cond, exc)
std::size_t memory_consumption() const
void update_ghost_values() const
std::vector< MGTransferMatrixFree< dim, Number > > matrix_free_transfer_vector
void interpolate_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< LinearAlgebra::distributed::Vector< Number >> &dst, const LinearAlgebra::distributed::Vector< Number2 > &src) const
static ::ExceptionBase & ExcMessage(std::string arg1)
AlignedVector< VectorizedArray< Number > > prolongation_matrix_1d
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > parent_child_connect
virtual size_type size() const override
#define Assert(cond, exc)
virtual const FullMatrix< double > & get_restriction_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
virtual MPI_Comm get_communicator() const
void copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< LinearAlgebra::distributed::BlockVector< Number >> &dst, const LinearAlgebra::distributed::BlockVector< Number2 > &src) const
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) const
#define DeclException0(Exception0)
SmartPointer< const MGConstrainedDoFs, MGLevelGlobalTransfer< LinearAlgebra::distributed::Vector< Number > > > mg_constrained_dofs
std::vector< AlignedVector< VectorizedArray< Number > > > weights_on_refined
size_type local_size() const
virtual void prolongate(const unsigned int to_level, LinearAlgebra::distributed::BlockVector< Number > &dst, const LinearAlgebra::distributed::BlockVector< Number > &src) const
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
bool element_is_continuous
std::vector< std::vector< unsigned int > > level_dof_indices
virtual ~MGTransferMatrixFree()=default
const unsigned int dofs_per_cell
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
static const bool supports_dof_handler_vector
void copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, LinearAlgebra::distributed::BlockVector< Number2 > &dst, const MGLevelObject< LinearAlgebra::distributed::BlockVector< Number >> &src) const
void do_prolongate_add(const unsigned int to_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const
unsigned int n_blocks() const
MGTransferBlockMatrixFree()=default
virtual void restrict_and_add(const unsigned int from_level, LinearAlgebra::distributed::BlockVector< Number > &dst, const LinearAlgebra::distributed::BlockVector< Number > &src) const
unsigned int n_child_cell_dofs
const Triangulation< dim, spacedim > & get_triangulation() const
virtual void prolongate(const unsigned int to_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
BlockType & block(const unsigned int i)
size_type n_elements() const
virtual ~MGTransferBlockMatrixFree()=default
void build(const DoFHandler< dim, dim > &mg_dof)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)