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/base/mg_level_object.h> 22 #include <deal.II/base/vectorization.h> 24 #include <deal.II/dofs/dof_handler.h> 26 #include <deal.II/lac/la_parallel_block_vector.h> 27 #include <deal.II/lac/la_parallel_vector.h> 29 #include <deal.II/multigrid/mg_base.h> 30 #include <deal.II/multigrid/mg_constrained_dofs.h> 31 #include <deal.II/multigrid/mg_transfer.h> 32 #include <deal.II/multigrid/mg_transfer_internal.h> 35 DEAL_II_NAMESPACE_OPEN
56 template <
int dim,
typename Number>
112 const unsigned int to_level,
136 const unsigned int from_level,
147 template <
typename Number2,
int spacedim>
208 std::vector<std::vector<std::pair<unsigned int, unsigned int>>>
251 template <
int degree>
254 const unsigned int to_level,
261 template <
int degree>
285 template <
int dim,
typename Number>
287 :
public MGTransferBase<LinearAlgebra::distributed::BlockVector<Number>>
306 const std::vector<MGConstrainedDoFs> &mg_constrained_dofs);
324 const std::vector<MGConstrainedDoFs> &mg_constrained_dofs);
360 const unsigned int to_level,
384 const unsigned int from_level,
398 template <
typename Number2,
int spacedim>
408 template <
typename Number2,
int spacedim>
418 template <
typename Number2,
int spacedim>
429 template <
typename Number2,
int spacedim>
447 static const bool supports_dof_handler_vector =
true;
470 template <
int dim,
typename Number>
471 template <
typename Number2,
int spacedim>
478 const unsigned int min_level = dst.min_level();
479 const unsigned int max_level = dst.max_level();
488 MPI_Comm mpi_communicator =
493 for (
unsigned int level = min_level; level <= max_level; ++level)
497 relevant_dofs[level]);
498 if (dst[level].size() !=
500 dst[level].local_size() !=
503 relevant_dofs[level],
510 this->
copy_to_mg(dof_handler, dst, src,
true);
515 dst[max_level].update_ghost_values();
517 for (
unsigned int level = max_level; level > min_level; --level)
522 relevant_dofs[level],
524 ghosted_vector = dst[level];
530 std::vector<types::global_dof_index> dof_indices(fe.
dofs_per_cell);
532 dof_handler.
begin(level - 1);
534 for (; cell != endc; ++cell)
535 if (cell->is_locally_owned_on_level())
540 if (!cell->has_children())
543 std::fill(dof_values_coarse.begin(), dof_values_coarse.end(), 0.);
544 for (
unsigned int child = 0; child < cell->n_children(); ++child)
546 cell->child(child)->get_mg_dof_indices(dof_indices);
548 dof_values_fine(i) = ghosted_vector(dof_indices[i]);
550 .vmult(tmp, dof_values_fine);
553 dof_values_coarse[i] += tmp[i];
554 else if (tmp(i) != 0.)
555 dof_values_coarse[i] = tmp[i];
557 cell->get_mg_dof_indices(dof_indices);
559 dst[level - 1](dof_indices[i]) = dof_values_coarse[i];
563 dst[level - 1].update_ghost_values();
569 template <
int dim,
typename Number>
570 template <
typename Number2,
int spacedim>
580 "This object was initialized with support for usage with one " 581 "DoFHandler for each block, but this method assumes that " 582 "the same DoFHandler is used for all the blocks!"));
583 const std::vector<const DoFHandler<dim, spacedim> *> mg_dofs(src.
n_blocks(),
589 template <
int dim,
typename Number>
590 template <
typename Number2,
int spacedim>
597 const unsigned int n_blocks = src.
n_blocks();
603 const unsigned int min_level = dst.min_level();
604 const unsigned int max_level = dst.max_level();
613 for (
unsigned int i = 1; i < n_blocks; ++i)
615 &(mg_dof[0]->get_triangulation())) == tria),
616 ExcMessage(
"The DoFHandler use different Triangulations!"));
618 for (
unsigned int level = min_level; level <= max_level; ++level)
620 dst[level].reinit(n_blocks);
621 bool collect_size =
false;
622 for (
unsigned int b = 0; b < n_blocks; ++b)
629 v.
reinit(mg_dof[b]->locally_owned_mg_dofs(level),
638 dst[level].collect_sizes();
644 min_level, max_level);
646 for (
unsigned int b = 0; b < n_blocks; ++b)
648 for (
unsigned int l = min_level; l <= max_level; ++l)
649 dst_non_block[l].reinit(dst[l].block(b));
650 const unsigned int data_block = same_for_all ? 0 : b;
651 matrix_free_transfer_vector[data_block].copy_to_mg(*mg_dof[b],
655 for (
unsigned int l = min_level; l <= max_level; ++l)
656 dst[l].block(b) = dst_non_block[l];
660 template <
int dim,
typename Number>
661 template <
typename Number2,
int spacedim>
670 const std::vector<const DoFHandler<dim, spacedim> *> mg_dofs(dst.
n_blocks(),
676 template <
int dim,
typename Number>
677 template <
typename Number2,
int spacedim>
685 const unsigned int n_blocks = dst.
n_blocks();
691 const unsigned int min_level = src.min_level();
692 const unsigned int max_level = src.max_level();
694 for (
unsigned int l = min_level; l <= max_level; ++l)
699 min_level, max_level);
701 for (
unsigned int b = 0; b < n_blocks; ++b)
703 for (
unsigned int l = min_level; l <= max_level; ++l)
705 src_non_block[l].reinit(src[l].block(b));
706 src_non_block[l] = src[l].
block(b);
708 const unsigned int data_block = same_for_all ? 0 : b;
709 matrix_free_transfer_vector[data_block].copy_from_mg(*mg_dof[b],
720 DEAL_II_NAMESPACE_CLOSE
void reinit(const size_type size, const bool omit_zeroing_entries=false)
void do_prolongate_add(const unsigned int to_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const
#define AssertDimension(dim1, dim2)
void copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, LinearAlgebra::distributed::BlockVector< Number2 > &dst, const MGLevelObject< LinearAlgebra::distributed::BlockVector< Number >> &src) const
std::vector< unsigned int > n_owned_level_cells
AlignedVector< VectorizedArray< Number > > evaluation_data
static::ExceptionBase & ExcNoProlongation()
unsigned int n_components
std::vector< std::vector< std::vector< unsigned short > > > dirichlet_indices
size_type n_elements() const
unsigned int n_blocks() const
#define AssertThrow(cond, exc)
const Triangulation< dim, spacedim > & get_triangulation() const
size_type local_size() const
void interpolate_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< LinearAlgebra::distributed::Vector< Number >> &dst, const LinearAlgebra::distributed::Vector< Number2 > &src) const
virtual MPI_Comm get_communicator() const
static::ExceptionBase & ExcMessage(std::string arg1)
AlignedVector< VectorizedArray< Number > > prolongation_matrix_1d
void copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< LinearAlgebra::distributed::Vector< Number >> &dst, const LinearAlgebra::distributed::Vector< Number2 > &src) const
virtual size_type size() const override
#define Assert(cond, exc)
void copy_from_mg(const DoFHandler< dim, spacedim > &mg_dof, LinearAlgebra::distributed::Vector< Number2 > &dst, const MGLevelObject< LinearAlgebra::distributed::Vector< Number >> &src) const
static::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
virtual void restrict_and_add(const unsigned int from_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
virtual void prolongate(const unsigned int to_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
std::size_t memory_consumption() const
#define DeclException0(Exception0)
std::vector< AlignedVector< VectorizedArray< Number > > > weights_on_refined
void do_restrict_add(const unsigned int from_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const
bool element_is_continuous
void copy_to_mg(const DoFHandler< dim, spacedim > &mg_dof, MGLevelObject< LinearAlgebra::distributed::BlockVector< Number >> &dst, const LinearAlgebra::distributed::BlockVector< Number2 > &src) const
cell_iterator end() const
std::vector< std::vector< unsigned int > > level_dof_indices
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
const unsigned int dofs_per_cell
bool restriction_is_additive(const unsigned int index) const
SmartPointer< const MGConstrainedDoFs, MGLevelGlobalTransfer< LinearAlgebra::distributed::Vector< Number > > > mg_constrained_dofs
void update_ghost_values() const
cell_iterator begin(const unsigned int level=0) const
virtual const FullMatrix< double > & get_restriction_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > parent_child_connect
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) const
std::vector< MGTransferMatrixFree< dim, Number > > matrix_free_transfer_vector
virtual ~MGTransferMatrixFree() override=default
unsigned int n_child_cell_dofs
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
BlockType & block(const unsigned int i)
void build(const DoFHandler< dim, dim > &mg_dof)