42 template <
int dim,
typename Number>
45 , element_is_continuous(false)
47 , n_child_cell_dofs(0)
52 template <
int dim,
typename Number>
65 template <
int dim,
typename Number>
75 template <
int dim,
typename Number>
95 template <
int dim,
typename Number>
99 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
100 &external_partitioners)
112 std::vector<std::vector<Number>> weights_unvectorized;
116 internal::MGTransfer::setup_transfer<dim, Number>(
119 external_partitioners,
125 weights_unvectorized,
148 for (
unsigned int i = 0; i < elem_info.prolongation_matrix_1d.size(); i++)
153 const unsigned int n_levels =
154 dof_handler.get_triangulation().n_global_levels();
156 const unsigned int n_weights_per_cell = Utilities::fixed_power<dim>(3);
158 for (
unsigned int level = 1; level < n_levels; ++
level)
161 ((n_owned_level_cells[level - 1] + vec_size - 1) / vec_size) *
164 for (
unsigned int c = 0; c < n_owned_level_cells[level - 1]; ++c)
166 const unsigned int comp = c / vec_size;
167 const unsigned int v = c % vec_size;
168 for (
unsigned int i = 0; i < n_weights_per_cell; ++i)
171 weights_unvectorized[level - 1][c * n_weights_per_cell + i];
181 template <
int dim,
typename Number>
184 const unsigned int to_level,
193 if (src_inplace ==
false)
203 const bool dst_inplace =
205 if (dst_inplace ==
false)
228 do_prolongate_add<0>(to_level, dst_vec, src_vec);
230 do_prolongate_add<1>(to_level, dst_vec, src_vec);
232 do_prolongate_add<2>(to_level, dst_vec, src_vec);
234 do_prolongate_add<3>(to_level, dst_vec, src_vec);
236 do_prolongate_add<4>(to_level, dst_vec, src_vec);
238 do_prolongate_add<5>(to_level, dst_vec, src_vec);
240 do_prolongate_add<6>(to_level, dst_vec, src_vec);
242 do_prolongate_add<7>(to_level, dst_vec, src_vec);
244 do_prolongate_add<8>(to_level, dst_vec, src_vec);
246 do_prolongate_add<9>(to_level, dst_vec, src_vec);
248 do_prolongate_add<10>(to_level, dst_vec, src_vec);
253 if (dst_inplace ==
false)
256 if (src_inplace ==
true)
262 template <
int dim,
typename Number>
265 const unsigned int from_level,
272 const bool src_inplace =
274 if (src_inplace ==
false)
285 if (dst_inplace ==
false)
304 do_restrict_add<0>(from_level, dst_vec, src_vec);
306 do_restrict_add<1>(from_level, dst_vec, src_vec);
308 do_restrict_add<2>(from_level, dst_vec, src_vec);
310 do_restrict_add<3>(from_level, dst_vec, src_vec);
312 do_restrict_add<4>(from_level, dst_vec, src_vec);
314 do_restrict_add<5>(from_level, dst_vec, src_vec);
316 do_restrict_add<6>(from_level, dst_vec, src_vec);
318 do_restrict_add<7>(from_level, dst_vec, src_vec);
320 do_restrict_add<8>(from_level, dst_vec, src_vec);
322 do_restrict_add<9>(from_level, dst_vec, src_vec);
324 do_restrict_add<10>(from_level, dst_vec, src_vec);
330 if (dst_inplace ==
false)
333 if (src_inplace ==
true)
341 template <
int dim,
int degree,
typename Number>
350 const int loop_length = degree != -1 ? 2 * degree + 1 : 2 * fe_degree + 1;
351 unsigned int degree_to_3[100];
353 for (
int i = 1; i < loop_length - 1; ++i)
355 degree_to_3[loop_length - 1] = 2;
357 for (
int k = 0; k < (dim > 2 ? loop_length : 1); ++k)
358 for (
int j = 0; j < (dim > 1 ? loop_length : 1); ++j)
360 const unsigned int shift = 9 * degree_to_3[k] + 3 * degree_to_3[j];
361 data[0] *= weights[
shift];
364 for (
int i = 1; i < loop_length - 1; ++i)
365 data[i] *= weights[shift + 1];
366 data[loop_length - 1] *= weights[shift + 2];
374 template <
int dim,
typename Number>
375 template <
int degree>
378 const unsigned int to_level,
383 const unsigned int degree_size = (degree > -1 ? degree :
fe_degree) + 1;
385 const unsigned int n_scalar_cell_dofs =
386 Utilities::fixed_power<dim>(n_child_dofs_1d);
416 const unsigned int n_lanes =
417 cell + vec_size > n_owned_level_cells[to_level - 1] ?
418 n_owned_level_cells[to_level - 1] - cell :
422 for (
unsigned int v = 0; v < n_lanes; ++v)
424 const unsigned int shift =
425 internal::MGTransfer::compute_shift_within_children<dim>(
429 const unsigned int *indices =
437 for (
unsigned int k = 0; k < (dim > 2 ? degree_size : 1); ++k)
438 for (
unsigned int j = 0; j < (dim > 1 ? degree_size : 1); ++j)
439 for (
unsigned int i = 0; i < degree_size; ++i, ++m)
441 indices[c * n_scalar_cell_dofs +
442 k * n_child_dofs_1d * n_child_dofs_1d +
443 j * n_child_dofs_1d + i]);
446 for (std::vector<unsigned short>::const_iterator i =
455 degree_size * n_child_dofs_1d);
457 if (element_is_continuous)
471 c * Utilities::fixed_power<dim>(degree_size),
475 weight_dofs_on_child<dim, degree, Number>(
493 c * Utilities::fixed_power<dim>(degree_size),
500 const unsigned int *indices =
502 for (
unsigned int v = 0; v < n_lanes; ++v)
513 template <
int dim,
typename Number>
514 template <
int degree>
517 const unsigned int from_level,
522 const unsigned int degree_size = (degree > -1 ? degree :
fe_degree) + 1;
524 const unsigned int n_scalar_cell_dofs =
525 Utilities::fixed_power<dim>(n_child_dofs_1d);
531 const unsigned int n_lanes =
532 cell + vec_size > n_owned_level_cells[from_level - 1] ?
533 n_owned_level_cells[from_level - 1] - cell :
538 const unsigned int *indices =
540 for (
unsigned int v = 0; v < n_lanes; ++v)
549 degree_size * n_child_dofs_1d);
551 if (element_is_continuous)
553 weight_dofs_on_child<dim, degree, Number>(
555 [(cell / vec_size) * three_to_dim],
571 c * Utilities::fixed_power<dim>(degree_size),
589 c * Utilities::fixed_power<dim>(degree_size),
595 for (
unsigned int v = 0; v < n_lanes; ++v)
597 const unsigned int shift =
598 internal::MGTransfer::compute_shift_within_children<dim>(
607 const unsigned int *indices =
616 for (std::vector<unsigned short>::const_iterator i =
622 for (
unsigned int k = 0; k < (dim > 2 ? degree_size : 1); ++k)
623 for (
unsigned int j = 0; j < (dim > 1 ? degree_size : 1); ++j)
624 for (
unsigned int i = 0; i < degree_size; ++i, ++m)
626 indices[c * n_scalar_cell_dofs +
627 k * n_child_dofs_1d * n_child_dofs_1d +
628 j * n_child_dofs_1d + i]) +=
637 template <
int dim,
typename Number>
655 template <
int dim,
typename Number>
665 template <
int dim,
typename Number>
667 const std::vector<MGConstrainedDoFs> &mg_c)
670 for (
const auto &constrained_block_dofs : mg_c)
676 template <
int dim,
typename Number>
682 ExcMessage(
"This object was initialized with support for usage with " 683 "one DoFHandler for each block, but this method assumes " 684 "that the same DoFHandler is used for all the blocks!"));
692 template <
int dim,
typename Number>
695 const std::vector<MGConstrainedDoFs> &mg_c)
698 ExcMessage(
"This object was initialized with support for using " 699 "the same DoFHandler for all the blocks, but this " 700 "method assumes that there is a separate DoFHandler " 704 for (
unsigned int i = 0; i < mg_c.size(); ++i)
710 template <
int dim,
typename Number>
719 template <
int dim,
typename Number>
730 template <
int dim,
typename Number>
736 for (
unsigned int i = 0; i < dof_handler.size(); ++i)
742 template <
int dim,
typename Number>
745 const unsigned int to_level,
766 template <
int dim,
typename Number>
769 const unsigned int from_level,
790 template <
int dim,
typename Number>
794 std::size_t total_memory_consumption = 0;
796 total_memory_consumption += el.memory_consumption();
797 return total_memory_consumption;
803 #include "mg_transfer_matrix_free.inst" unsigned int max_level() const
const Triangulation< dim, spacedim > & get_triangulation() const
size_type local_size() const
std::vector< Table< 2, unsigned int > > copy_indices_global_mine
void reinit(MatrixBlock< MatrixType > &v, const BlockSparsityPattern &p)
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
void build(const DoFHandler< dim, dim > &dof_handler, const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner >> &external_partitioners=std::vector< std::shared_ptr< const Utilities::MPI::Partitioner >>())
AlignedVector< VectorizedArray< Number > > evaluation_data
unsigned int n_components
std::size_t memory_consumption() const
void build(const DoFHandler< dim, dim > &dof_handler)
std::vector< std::vector< std::vector< unsigned short > > > dirichlet_indices
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
#define AssertIndexRange(index, range)
void reinit(const size_type size, const bool omit_zeroing_entries=false)
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
void zero_out_ghosts() const
void resize(const size_type size_in)
std::size_t memory_consumption() const
void update_ghost_values() const
constexpr T pow(const T base, const int iexp)
Number local_element(const size_type local_index) const
static ::ExceptionBase & ExcMessage(std::string arg1)
AlignedVector< VectorizedArray< Number > > prolongation_matrix_1d
#define Assert(cond, exc)
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 restrict_and_add(const unsigned int from_level, LinearAlgebra::distributed::BlockVector< Number > &dst, const LinearAlgebra::distributed::BlockVector< 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
#define DEAL_II_NAMESPACE_CLOSE
std::vector< AlignedVector< VectorizedArray< Number > > > weights_on_refined
std::enable_if< IsBlockVector< VectorType >::value, unsigned int >::type n_blocks(const VectorType &vector)
static constexpr std::size_t size()
void fill_and_communicate_copy_indices(const DoFHandler< dim, spacedim > &dof_handler)
bool element_is_continuous
std::vector< std::vector< unsigned int > > level_dof_indices
const IndexSet & get_local_lines() const
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
void do_prolongate_add(const unsigned int to_level, LinearAlgebra::distributed::Vector< Number > &dst, const LinearAlgebra::distributed::Vector< Number > &src) const
SmartPointer< const MGConstrainedDoFs, MGLevelGlobalTransfer< LinearAlgebra::distributed::Vector< Number > > > mg_constrained_dofs
unsigned int n_blocks() const
void distribute(VectorType &vec) const
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > parent_child_connect
virtual void prolongate(const unsigned int to_level, LinearAlgebra::distributed::BlockVector< Number > &dst, const LinearAlgebra::distributed::BlockVector< Number > &src) const override
#define DEAL_II_NAMESPACE_OPEN
VectorType::value_type * begin(VectorType &V)
std::vector< MGTransferMatrixFree< dim, Number > > matrix_free_transfer_vector
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_partitioner() const
MGTransferBlockMatrixFree()=default
static ::ExceptionBase & ExcNotImplemented()
unsigned int n_child_cell_dofs
void resize(const unsigned int new_minlevel, const unsigned int new_maxlevel)
unsigned int n_components(const DoFHandler< dim, spacedim > &dh)
MGLevelObject< std::shared_ptr< const Utilities::MPI::Partitioner > > vector_partitioners
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
const AffineConstraints< double > & get_user_constraint_matrix(const unsigned int level) const
BlockType & block(const unsigned int i)
MGLevelObject< LinearAlgebra::distributed::Vector< Number > > ghosted_level_vector
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)