35#include <deal.II/multigrid/mg_transfer_matrix_free.templates.h>
42template <
int dim,
typename Number>
52template <
int dim,
typename Number>
65template <
int dim,
typename Number>
75template <
int dim,
typename Number>
96template <
int dim,
typename Number>
100 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
101 &external_partitioners)
105 "The underlying DoFHandler object has not had its "
106 "distribute_mg_dofs() function called, but this is a prerequisite "
107 "for multigrid transfers. You will need to call this function, "
108 "probably close to where you already call distribute_dofs()."));
109 if (external_partitioners.size() > 0)
112 ExcMessage(
"An initialize_dof_vector function has already "
113 "been registered in the constructor!"));
116 [external_partitioners](
117 const unsigned int level,
119 vec.reinit(external_partitioners[level]);
133 std::vector<std::vector<Number>> weights_unvectorized;
140 external_partitioners,
146 weights_unvectorized,
174 const unsigned int n_levels =
179 for (
unsigned int level = 1; level < n_levels; ++level)
187 const unsigned int comp = c / vec_size;
188 const unsigned int v = c % vec_size;
189 for (
unsigned int i = 0; i < n_weights_per_cell; ++i)
192 weights_unvectorized[level - 1][c * n_weights_per_cell + i];
202template <
int dim,
typename Number>
206 const std::function<
void(
const unsigned int,
212 const unsigned int n_levels =
215 std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
216 external_partitioners(n_levels);
218 for (
unsigned int level = 0; level < n_levels; ++level)
225 build(dof_handler, external_partitioners);
235template <
int dim,
typename Number>
238 const unsigned int to_level,
248template <
int dim,
typename Number>
251 const unsigned int to_level,
260 if (src_inplace ==
false)
270 const bool dst_inplace =
272 if (dst_inplace ==
false)
318 if (dst_inplace ==
false)
321 if (src_inplace ==
true)
327template <
int dim,
typename Number>
330 const unsigned int from_level,
337 const bool src_inplace =
339 if (src_inplace ==
false)
350 if (dst_inplace ==
false)
396 if (dst_inplace ==
false)
399 if (src_inplace ==
true)
405template <
int dim,
typename Number>
409 const unsigned int to_level,
414 const unsigned int degree_size = (degree > -1 ? degree :
fe_degree) + 1;
416 const unsigned int n_scalar_cell_dofs =
434 .distribute(copy_src);
447 const unsigned int n_lanes =
453 for (
unsigned int v = 0; v < n_lanes; ++v)
455 const unsigned int shift =
460 const unsigned int *indices =
468 for (
unsigned int k = 0; k < (dim > 2 ? degree_size : 1); ++k)
469 for (
unsigned int j = 0; j < (dim > 1 ? degree_size : 1); ++j)
470 for (
unsigned int i = 0; i < degree_size; ++i, ++m)
472 indices[c * n_scalar_cell_dofs +
473 k * n_child_dofs_1d * n_child_dofs_1d +
474 j * n_child_dofs_1d + i]);
477 for (std::vector<unsigned short>::const_iterator i =
486 degree_size * n_child_dofs_1d);
498 2 * degree + 1>::do_forward(1,
504 c * n_scalar_cell_dofs,
508 degree != -1 ? 2 * degree + 1 :
524 2 * degree + 2>::do_forward(1,
530 c * n_scalar_cell_dofs,
536 const unsigned int *indices =
538 for (
unsigned int v = 0; v < n_lanes; ++v)
549template <
int dim,
typename Number>
553 const unsigned int from_level,
558 const unsigned int degree_size = (degree > -1 ? degree :
fe_degree) + 1;
560 const unsigned int n_scalar_cell_dofs =
567 const unsigned int n_lanes =
574 const unsigned int *indices =
576 for (
unsigned int v = 0; v < n_lanes; ++v)
585 degree_size * n_child_dofs_1d);
590 degree != -1 ? 2 * degree + 1 :
594 [(cell / vec_size) * three_to_dim],
604 2 * degree + 1>::do_backward(1,
608 c * n_scalar_cell_dofs,
623 2 * degree + 2>::do_backward(1,
627 c * n_scalar_cell_dofs,
636 for (
unsigned int v = 0; v < n_lanes; ++v)
638 const unsigned int shift =
648 const unsigned int *indices =
657 for (std::vector<unsigned short>::const_iterator i =
663 for (
unsigned int k = 0; k < (dim > 2 ? degree_size : 1); ++k)
664 for (
unsigned int j = 0; j < (dim > 1 ? degree_size : 1); ++j)
665 for (
unsigned int i = 0; i < degree_size; ++i, ++m)
667 indices[c * n_scalar_cell_dofs +
668 k * n_child_dofs_1d * n_child_dofs_1d +
669 j * n_child_dofs_1d + i]) +=
678template <
int dim,
typename Number>
696template <
int dim,
typename Number>
708template <
int dim,
typename Number>
710 const std::vector<MGConstrainedDoFs> &mg_c)
715 for (
const auto &constrained_block_dofs : mg_c)
721template <
int dim,
typename Number>
727 ExcMessage(
"This object was initialized with support for usage with "
728 "one DoFHandler for each block, but this method assumes "
729 "that the same DoFHandler is used for all the blocks!"));
737template <
int dim,
typename Number>
740 const std::vector<MGConstrainedDoFs> &mg_c)
743 ExcMessage(
"This object was initialized with support for using "
744 "the same DoFHandler for all the blocks, but this "
745 "method assumes that there is a separate DoFHandler "
749 for (
unsigned int i = 0; i < mg_c.size(); ++i)
755template <
int dim,
typename Number>
766template <
int dim,
typename Number>
772 for (
unsigned int i = 0; i < dof_handler.size(); ++i)
778template <
int dim,
typename Number>
782 std::size_t total_memory_consumption = 0;
784 total_memory_consumption += el.memory_consumption();
785 return total_memory_consumption;
790template <
int dim,
typename Number>
793 const unsigned int b)
const
800template <
int dim,
typename Number>
810#include "mg_transfer_matrix_free.inst"
const Triangulation< dim, spacedim > & get_triangulation() const
bool has_level_dofs() const
void zero_out_ghost_values() const
Number local_element(const size_type local_index) const
void update_ghost_values() const
size_type locally_owned_size() const
void compress(VectorOperation::values operation)
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_partitioner() const
void reinit(const size_type size, const bool omit_zeroing_entries=false)
MGLevelObject< LinearAlgebra::distributed::Vector< Number > > ghosted_level_vector
std::vector< Table< 2, unsigned int > > copy_indices_global_mine
void fill_and_communicate_copy_indices(const DoFHandler< dim, spacedim > &dof_handler)
std::function< void(const unsigned int, LinearAlgebra::distributed::Vector< Number > &)> initialize_dof_vector
SmartPointer< const MGConstrainedDoFs > mg_constrained_dofs
MGTransferBlockMatrixFreeBase(const bool same_for_all)
std::vector< MGTransferMatrixFree< dim, Number > > matrix_free_transfer_vector
void build(const DoFHandler< dim > &dof_handler)
std::size_t memory_consumption() const
MGTransferBlockMatrixFree()=default
const MGTransferMatrixFree< dim, Number > & get_matrix_free_transfer(const unsigned int b) const override
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
void do_restrict_add(const unsigned int from_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const
void do_prolongate_add(const unsigned int to_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const
std::vector< std::vector< unsigned int > > level_dof_indices
unsigned int n_components
virtual void prolongate(const unsigned int to_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
unsigned int n_child_cell_dofs
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
std::vector< std::vector< std::vector< unsigned short > > > dirichlet_indices
MGLevelObject< std::shared_ptr< const Utilities::MPI::Partitioner > > vector_partitioners
AlignedVector< VectorizedArray< Number > > evaluation_data
void build(const DoFHandler< dim > &dof_handler, const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > &external_partitioners=std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > >())
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > parent_child_connect
virtual void prolongate_and_add(const unsigned int to_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
std::size_t memory_consumption() const
std::vector< AlignedVector< VectorizedArray< Number > > > weights_on_refined
std::vector< unsigned int > n_owned_level_cells
AlignedVector< VectorizedArray< Number > > prolongation_matrix_1d
bool element_is_continuous
virtual void restrict_and_add(const unsigned int from_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const override
virtual unsigned int n_global_levels() const
static constexpr std::size_t size()
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcIndexRange(std::size_t arg1, std::size_t arg2, std::size_t arg3)
static ::ExceptionBase & ExcMessage(std::string arg1)
std::enable_if_t< std::is_fundamental_v< T >, std::size_t > memory_consumption(const T &t)
constexpr T fixed_power(const T t)
constexpr T pow(const T base, const int iexp)
unsigned int compute_shift_within_children(const unsigned int child, const unsigned int fe_shift_1d, const unsigned int fe_degree)
void setup_transfer(const DoFHandler< dim > &dof_handler, const MGConstrainedDoFs *mg_constrained_dofs, const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > &external_partitioners, ElementInfo< Number > &elem_info, std::vector< std::vector< unsigned int > > &level_dof_indices, std::vector< std::vector< std::pair< unsigned int, unsigned int > > > &parent_child_connect, std::vector< unsigned int > &n_owned_level_cells, std::vector< std::vector< std::vector< unsigned short > > > &dirichlet_indices, std::vector< std::vector< Number > > &weights_on_refined, std::vector< Table< 2, unsigned int > > ©_indices_global_mine, MGLevelObject< std::shared_ptr< const Utilities::MPI::Partitioner > > &vector_partitioners)
void weight_fe_q_dofs_by_entity(const Number *weights, const unsigned int n_components, const int n_points_1d_non_template, Number *data)
std::vector< Number > prolongation_matrix_1d
unsigned int n_child_cell_dofs
bool element_is_continuous
unsigned int n_components