48template <
typename VectorType>
52 this->mg_constrained_dofs = &mg_c;
57template <
typename VectorType>
62 this->mg_constrained_dofs = &mg_c;
67template <
typename VectorType>
72 prolongation_matrices.resize(0);
73 prolongation_sparsities.resize(0);
74 interface_dofs.resize(0);
79template <
typename VectorType>
83 const VectorType & src)
const
85 Assert((to_level >= 1) && (to_level <= prolongation_matrices.size()),
86 ExcIndexRange(to_level, 1, prolongation_matrices.size() + 1));
88 if (this->mg_constrained_dofs !=
nullptr &&
89 this->mg_constrained_dofs->get_user_constraint_matrix(to_level - 1)
93 VectorType copy_src(src);
94 this->mg_constrained_dofs->get_user_constraint_matrix(to_level - 1)
95 .distribute(copy_src);
96 prolongation_matrices[to_level - 1]->vmult(dst, copy_src);
100 prolongation_matrices[to_level - 1]->vmult(dst, src);
106template <
typename VectorType>
110 const VectorType & src)
const
112 Assert((from_level >= 1) && (from_level <= prolongation_matrices.size()),
113 ExcIndexRange(from_level, 1, prolongation_matrices.size() + 1));
116 prolongation_matrices[from_level - 1]->Tvmult_add(dst, src);
128 const unsigned int level,
129 std::vector<types::global_dof_index> &dof_indices)
131 if (mg_constrained_dofs !=
nullptr &&
133 for (
auto &ind : dof_indices)
149template <
typename VectorType>
150template <
int dim,
int spacedim>
155 const unsigned int n_levels =
159 this->sizes.resize(n_levels);
160 for (
unsigned int l = 0;
l < n_levels; ++
l)
161 this->sizes[
l] = dof_handler.
n_dofs(
l);
173 prolongation_matrices.resize(0);
174 prolongation_sparsities.resize(0);
175 prolongation_matrices.reserve(n_levels - 1);
176 prolongation_sparsities.reserve(n_levels - 1);
178 for (
unsigned int i = 0; i < n_levels - 1; ++i)
180 prolongation_sparsities.emplace_back(
182 prolongation_matrices.emplace_back(
189 std::vector<types::global_dof_index> dof_indices_parent(dofs_per_cell);
190 std::vector<types::global_dof_index> dof_indices_child(dofs_per_cell);
191 std::vector<types::global_dof_index> entries(dofs_per_cell);
210 level_p1_relevant_dofs);
213 level_p1_relevant_dofs);
216 for (cell = dof_handler.
begin(
level); cell != endc; ++cell)
217 if (cell->has_children() &&
220 cell->level_subdomain_id() ==
223 cell->get_mg_dof_indices(dof_indices_parent);
225 replace(this->mg_constrained_dofs,
level, dof_indices_parent);
227 Assert(cell->n_children() ==
230 for (
unsigned int child = 0; child < cell->n_children(); ++child)
235 child, cell->refinement_case());
237 Assert(prolongation.
n() != 0, ExcNoProlongation());
239 cell->child(child)->get_mg_dof_indices(dof_indices_child);
241 replace(this->mg_constrained_dofs,
248 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
251 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
252 if (prolongation(i, j) != 0)
253 entries.push_back(dof_indices_parent[j]);
261#ifdef DEAL_II_WITH_MPI
263 VectorType>::requires_distributed_sparsity_pattern)
279 *prolongation_matrices[
level],
280 *prolongation_sparsities[
level],
297 for (cell = dof_handler.
begin(
level); cell != endc; ++cell)
298 if (cell->has_children() &&
301 cell->level_subdomain_id() ==
304 cell->get_mg_dof_indices(dof_indices_parent);
306 replace(this->mg_constrained_dofs,
level, dof_indices_parent);
308 Assert(cell->n_children() ==
311 for (
unsigned int child = 0; child < cell->n_children(); ++child)
315 child, cell->refinement_case());
317 if (this->mg_constrained_dofs !=
nullptr &&
319 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
321 level, dof_indices_parent[j]))
322 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
323 prolongation(i, j) = 0.;
325 cell->child(child)->get_mg_dof_indices(dof_indices_child);
327 replace(this->mg_constrained_dofs,
332 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
333 prolongation_matrices[
level]->
set(dof_indices_child[i],
335 dof_indices_parent.data(),
343 this->fill_and_communicate_copy_indices(dof_handler);
348template <
typename VectorType>
349template <
int dim,
int spacedim>
359template <
typename VectorType>
363 for (
unsigned int level = 0;
level < prolongation_matrices.size(); ++
level)
365 os <<
"Level " <<
level << std::endl;
366 prolongation_matrices[
level]->print(os);
373template <
typename VectorType>
378 for (
unsigned int i = 0; i < prolongation_matrices.size(); ++i)
380 prolongation_sparsities[i]->memory_consumption();
387#include "mg_transfer_prebuilt.inst"
const std::vector< std::pair< size_type, number > > * get_constraint_entries(const size_type line_n) const
bool is_identity_constrained(const size_type line_n) const
size_type n_constraints() const
cell_iterator end() const
const FiniteElement< dim, spacedim > & get_fe(const unsigned int index=0) const
const IndexSet & locally_owned_mg_dofs(const unsigned int level) const
const Triangulation< dim, spacedim > & get_triangulation() const
types::global_dof_index n_dofs() const
cell_iterator begin(const unsigned int level=0) const
MPI_Comm get_communicator() const
unsigned int n_dofs_per_cell() const
virtual const FullMatrix< double > & get_prolongation_matrix(const unsigned int child, const RefinementCase< dim > &refinement_case=RefinementCase< dim >::isotropic_refinement) const
bool is_boundary_index(const unsigned int level, const types::global_dof_index index) const
bool have_boundary_indices() const
const AffineConstraints< double > & get_level_constraints(const unsigned int level) const
std::size_t memory_consumption() const
virtual void restrict_and_add(const unsigned int from_level, VectorType &dst, const VectorType &src) const override
void build(const DoFHandler< dim, spacedim > &dof_handler)
void build_matrices(const DoFHandler< dim, spacedim > &dof_handler)
std::size_t memory_consumption() const
MGTransferPrebuilt()=default
virtual void prolongate(const unsigned int to_level, VectorType &dst, const VectorType &src) const override
void print_matrices(std::ostream &os) const
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
virtual types::subdomain_id locally_owned_subdomain() const
virtual unsigned int n_global_levels() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
__global__ void set(Number *val, const Number s, const size_type N)
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
typename ActiveSelector::cell_iterator cell_iterator
void add_entries(const size_type row, ForwardIterator begin, ForwardIterator end, const bool indices_are_unique_and_sorted=false)
const IndexSet & row_index_set() const
void reinit(const size_type m, const size_type n, const IndexSet &rowset=IndexSet())
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
const types::subdomain_id invalid_subdomain_id
static void reinit(Matrix &matrix, Sparsity &sparsity, int level, const SparsityPatternType &sp, const DoFHandler< dim, spacedim > &)