31#include <deal.II/multigrid/mg_transfer_block.templates.h>
33#include <deal.II/multigrid/mg_transfer_component.templates.h>
34#include <deal.II/multigrid/multigrid.templates.h>
47 , mg_constrained_dofs(&mg_c)
52template <
typename number>
54 : memory(nullptr, typeid(*this).name())
58template <
typename number>
61 if (memory !=
nullptr)
66template <
typename number>
76template <
typename number>
82 Assert((to_level >= 1) && (to_level <= prolongation_matrices.size()),
83 ExcIndexRange(to_level, 1, prolongation_matrices.size() + 1));
90 if (this->mg_constrained_dofs !=
nullptr)
91 Assert(this->mg_constrained_dofs->get_user_constraint_matrix(to_level - 1)
100 for (
unsigned int b = 0; b < this->mg_block.size(); ++b)
102 if (this->selected[b])
103 prolongation_matrices[to_level - 1]->block(b, b).vmult(
104 dst.
block(this->mg_block[b]), src.
block(this->mg_block[b]));
109template <
typename number>
115 Assert((from_level >= 1) && (from_level <= prolongation_matrices.size()),
116 ExcIndexRange(from_level, 1, prolongation_matrices.size() + 1));
122 for (
unsigned int b = 0; b < this->mg_block.size(); ++b)
124 if (this->selected[b])
126 if (factors.size() != 0)
131 prolongation_matrices[from_level - 1]->block(b, b).Tvmult(
132 *aux, src.
block(this->mg_block[b]));
134 dst.
block(this->mg_block[b]).add(factors[b], *aux);
139 prolongation_matrices[from_level - 1]->block(b, b).Tvmult_add(
140 dst.
block(this->mg_block[b]), src.
block(this->mg_block[b]));
151 std::size_t result =
sizeof(*this);
176 std::size_t result =
sizeof(*this);
177 result +=
sizeof(
unsigned int) *
sizes.size();
197template <
typename number>
199 : selected_component(0)
200 , mg_selected_component(0)
204template <
typename number>
206 : selected_component(0)
207 , mg_selected_component(0)
213template <
typename number>
219 Assert((to_level >= 1) && (to_level <= prolongation_matrices.size()),
220 ExcIndexRange(to_level, 1, prolongation_matrices.size() + 1));
222 prolongation_matrices[to_level - 1]
223 ->block(mg_target_component[mg_selected_component],
224 mg_target_component[mg_selected_component])
230template <
typename number>
236 Assert((from_level >= 1) && (from_level <= prolongation_matrices.size()),
237 ExcIndexRange(from_level, 1, prolongation_matrices.size() + 1));
239 prolongation_matrices[from_level - 1]
240 ->block(mg_target_component[mg_selected_component],
241 mg_target_component[mg_selected_component])
242 .Tvmult_add(dst, src);
248template <
typename number>
255template <
typename number>
264template <
typename number>
270 Assert((to_level >= 1) && (to_level <= prolongation_matrices.size()),
271 ExcIndexRange(to_level, 1, prolongation_matrices.size() + 1));
274 if (this->mg_constrained_dofs !=
nullptr)
275 Assert(this->mg_constrained_dofs->get_user_constraint_matrix(to_level - 1)
281 prolongation_matrices[to_level - 1]
282 ->block(selected_block, selected_block)
287template <
typename number>
293 Assert((from_level >= 1) && (from_level <= prolongation_matrices.size()),
294 ExcIndexRange(from_level, 1, prolongation_matrices.size() + 1));
296 prolongation_matrices[from_level - 1]
297 ->block(selected_block, selected_block)
298 .Tvmult_add(dst, src);
305#include "multigrid.inst"
unsigned int n_blocks() const
BlockType & block(const unsigned int i)
std::vector< unsigned int > mg_block
std::vector< std::vector< types::global_dof_index > > sizes
std::vector< bool > selected
std::vector< types::global_dof_index > block_start
std::vector< std::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
std::vector< std::shared_ptr< BlockSparsityPattern > > prolongation_sparsities
std::vector< std::vector< types::global_dof_index > > mg_block_start
std::size_t memory_consumption() const
virtual void prolongate(const unsigned int to_level, Vector< number > &dst, const Vector< number > &src) const override
virtual void restrict_and_add(const unsigned int from_level, Vector< number > &dst, const Vector< number > &src) const override
virtual void prolongate(const unsigned int to_level, BlockVector< number > &dst, const BlockVector< number > &src) const override
virtual void restrict_and_add(const unsigned int from_level, BlockVector< number > &dst, const BlockVector< number > &src) const override
virtual ~MGTransferBlock() override
void initialize(const std::vector< number > &factors, VectorMemory< Vector< number > > &memory)
std::vector< unsigned int > mg_target_component
ComponentMask component_mask
std::vector< unsigned int > target_component
std::vector< types::global_dof_index > component_start
std::vector< std::shared_ptr< BlockSparseMatrix< double > > > prolongation_matrices
std::vector< std::vector< types::global_dof_index > > mg_component_start
std::vector< std::shared_ptr< BlockSparsityPattern > > prolongation_sparsities
std::vector< std::vector< types::global_dof_index > > sizes
std::size_t memory_consumption() const
virtual void prolongate(const unsigned int to_level, Vector< number > &dst, const Vector< number > &src) const override
virtual void restrict_and_add(const unsigned int from_level, Vector< number > &dst, const Vector< number > &src) const override
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcIndexRange(std::size_t arg1, std::size_t arg2, std::size_t arg3)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcNotInitialized()
std::enable_if_t< std::is_fundamental< T >::value, std::size_t > memory_consumption(const T &t)