16 #ifndef dealii_multigrid_h
17 #define dealii_multigrid_h
41 "The name 'signals' is already defined. You are most likely using the QT library \
42 and using the 'signals' keyword. You can either #include the Qt headers (or any conflicting headers) \
43 *after* the deal.II headers or you can define the 'QT_NO_KEYWORDS' macro and use the 'Q_SIGNALS' macro."
87 boost::signals2::signal<void(
const bool before,
const unsigned int level)>
98 boost::signals2::signal<void(
const bool before,
const unsigned int level)>
106 boost::signals2::signal<void(
const bool before,
const unsigned int level)>
117 boost::signals2::signal<void(
const bool before,
const unsigned int level)>
125 boost::signals2::signal<void(
const bool before,
const unsigned int level)>
133 boost::signals2::signal<void(
const bool before,
const unsigned int level)>
140 boost::signals2::signal<void(
const bool before,
const unsigned int level)>
162 template <
typename VectorType>
313 boost::signals2::connection
315 const std::function<
void(
const bool,
const unsigned int)> &slot);
320 boost::signals2::connection
322 const std::function<
void(
const bool,
const unsigned int)> &slot);
327 boost::signals2::connection
329 const std::function<
void(
const bool,
const unsigned int)> &slot);
334 boost::signals2::connection
336 const std::function<
void(
const bool,
const unsigned int)> &slot);
341 boost::signals2::connection
343 const std::function<
void(
const bool,
const unsigned int)> &slot);
348 boost::signals2::connection
350 const std::function<
void(
const bool,
const unsigned int)> &slot);
355 boost::signals2::connection
357 const std::function<
void(
const bool,
const unsigned int)> &slot);
481 template <
int dim,
typename OtherVectorType,
typename TransferType>
500 template <
int dim,
typename VectorType,
typename TransferType>
532 template <
typename OtherVectorType>
534 vmult(OtherVectorType &dst,
const OtherVectorType &src)
const;
540 template <
typename OtherVectorType>
542 vmult_add(OtherVectorType &dst,
const OtherVectorType &src)
const;
549 template <
typename OtherVectorType>
551 Tvmult(OtherVectorType &dst,
const OtherVectorType &src)
const;
558 template <
typename OtherVectorType>
560 Tvmult_add(OtherVectorType &dst,
const OtherVectorType &src)
const;
589 boost::signals2::connection
595 boost::signals2::connection
614 std::vector<SmartPointer<const DoFHandler<dim>,
656 template <
typename VectorType>
662 const unsigned int min_level,
663 const unsigned int max_level,
667 , coarse(&coarse, typeid(*this).name())
668 , transfer(&transfer, typeid(*this).name())
669 , pre_smooth(&pre_smooth, typeid(*this).name())
670 , post_smooth(&post_smooth, typeid(*this).name())
671 , edge_out(nullptr, typeid(*this).name())
672 , edge_in(nullptr, typeid(*this).name())
673 , edge_down(nullptr, typeid(*this).name())
674 , edge_up(nullptr, typeid(*this).name())
677 maxlevel =
matrix.get_maxlevel();
679 maxlevel = max_level;
680 reinit(min_level, maxlevel);
685 template <
typename VectorType>
694 template <
typename VectorType>
707 namespace PreconditionMGImplementation
711 typename TransferType,
712 typename OtherVectorType>
713 std::enable_if_t<TransferType::supports_dof_handler_vector>
716 const TransferType &transfer,
717 OtherVectorType &dst,
718 const OtherVectorType &src,
719 const bool uses_dof_handler_vector,
720 const typename ::mg::Signals &signals,
723 signals.transfer_to_mg(
true);
724 if (uses_dof_handler_vector)
725 transfer.copy_to_mg(dof_handler_vector, multigrid.
defect, src);
727 transfer.copy_to_mg(*dof_handler_vector[0], multigrid.
defect, src);
728 signals.transfer_to_mg(
false);
732 signals.transfer_to_global(
true);
733 if (uses_dof_handler_vector)
734 transfer.copy_from_mg(dof_handler_vector, dst, multigrid.
solution);
736 transfer.copy_from_mg(*dof_handler_vector[0], dst, multigrid.
solution);
737 signals.transfer_to_global(
false);
742 typename TransferType,
743 typename OtherVectorType>
747 const TransferType &transfer,
748 OtherVectorType &dst,
749 const OtherVectorType &src,
750 const bool uses_dof_handler_vector,
751 const typename ::mg::Signals &signals,
754 (void)uses_dof_handler_vector;
757 signals.transfer_to_mg(
true);
758 transfer.copy_to_mg(*dof_handler_vector[0], multigrid.
defect, src);
759 signals.transfer_to_mg(
false);
763 signals.transfer_to_global(
true);
764 transfer.copy_from_mg(*dof_handler_vector[0], dst, multigrid.
solution);
765 signals.transfer_to_global(
false);
770 typename TransferType,
771 typename OtherVectorType>
772 std::enable_if_t<TransferType::supports_dof_handler_vector>
773 vmult_add(
const std::vector<
const DoFHandler<dim> *> &dof_handler_vector,
775 const TransferType &transfer,
776 OtherVectorType &dst,
777 const OtherVectorType &src,
778 const bool uses_dof_handler_vector,
779 const typename ::mg::Signals &signals,
782 signals.transfer_to_mg(
true);
783 if (uses_dof_handler_vector)
784 transfer.copy_to_mg(dof_handler_vector, multigrid.
defect, src);
786 transfer.copy_to_mg(*dof_handler_vector[0], multigrid.
defect, src);
787 signals.transfer_to_mg(
false);
791 signals.transfer_to_global(
true);
792 if (uses_dof_handler_vector)
793 transfer.copy_from_mg_add(dof_handler_vector, dst, multigrid.
solution);
795 transfer.copy_from_mg_add(*dof_handler_vector[0],
798 signals.transfer_to_global(
false);
803 typename TransferType,
804 typename OtherVectorType>
806 vmult_add(
const std::vector<
const DoFHandler<dim> *> &dof_handler_vector,
808 const TransferType &transfer,
809 OtherVectorType &dst,
810 const OtherVectorType &src,
811 const bool uses_dof_handler_vector,
812 const typename ::mg::Signals &signals,
815 (void)uses_dof_handler_vector;
818 signals.transfer_to_mg(
true);
819 transfer.copy_to_mg(*dof_handler_vector[0], multigrid.
defect, src);
820 signals.transfer_to_mg(
false);
824 signals.transfer_to_global(
true);
825 transfer.copy_from_mg_add(*dof_handler_vector[0],
828 signals.transfer_to_global(
false);
833 template <
int dim,
typename VectorType,
typename TransferType>
837 const TransferType &transfer)
838 : dof_handler_vector(1, &dof_handler)
839 , dof_handler_vector_raw(1, &dof_handler)
841 , transfer(&transfer)
842 , uses_dof_handler_vector(false)
845 template <
int dim,
typename VectorType,
typename TransferType>
849 const TransferType &transfer)
850 : dof_handler_vector(dof_handler.size())
851 , dof_handler_vector_raw(dof_handler.size())
853 , transfer(&transfer)
854 , uses_dof_handler_vector(true)
856 for (
unsigned int i = 0; i < dof_handler.size(); ++i)
863 template <
int dim,
typename VectorType,
typename TransferType>
870 template <
int dim,
typename VectorType,
typename TransferType>
871 template <
typename OtherVectorType>
874 OtherVectorType &dst,
875 const OtherVectorType &src)
const
877 internal::PreconditionMGImplementation::vmult(dof_handler_vector_raw,
882 uses_dof_handler_vector,
888 template <
int dim,
typename VectorType,
typename TransferType>
891 const unsigned int block)
const
894 return dof_handler_vector[block]->locally_owned_dofs();
898 template <
int dim,
typename VectorType,
typename TransferType>
901 const unsigned int block)
const
904 return dof_handler_vector[block]->locally_owned_dofs();
909 template <
int dim,
typename VectorType,
typename TransferType>
924 template <
int dim,
typename VectorType,
typename TransferType>
925 boost::signals2::connection
927 const std::function<
void(
bool)> &slot)
929 return this->signals.transfer_to_mg.connect(slot);
934 template <
int dim,
typename VectorType,
typename TransferType>
935 boost::signals2::connection
937 const std::function<
void(
bool)> &slot)
939 return this->signals.transfer_to_global.connect(slot);
944 template <
int dim,
typename VectorType,
typename TransferType>
945 template <
typename OtherVectorType>
948 OtherVectorType &dst,
949 const OtherVectorType &src)
const
951 internal::PreconditionMGImplementation::vmult_add(dof_handler_vector_raw,
956 uses_dof_handler_vector,
962 template <
int dim,
typename VectorType,
typename TransferType>
963 template <
typename OtherVectorType>
967 const OtherVectorType &)
const
973 template <
int dim,
typename VectorType,
typename TransferType>
974 template <
typename OtherVectorType>
978 const OtherVectorType &)
const
984 template <
int dim,
typename VectorType,
typename TransferType>
988 return *this->multigrid;
992 template <
int dim,
typename VectorType,
typename TransferType>
996 return *this->multigrid;
MGLevelObject< VectorType > defect2
void set_edge_flux_matrices(const MGMatrixBase< VectorType > &edge_down, const MGMatrixBase< VectorType > &edge_up)
SmartPointer< const MGTransferBase< VectorType >, Multigrid< VectorType > > transfer
SmartPointer< const MGMatrixBase< VectorType >, Multigrid< VectorType > > edge_up
SmartPointer< const MGMatrixBase< VectorType > > edge_in
SmartPointer< const MGMatrixBase< VectorType > > edge_out
MGLevelObject< VectorType > solution
boost::signals2::connection connect_edge_prolongation(const std::function< void(const bool, const unsigned int)> &slot)
SmartPointer< const MGMatrixBase< VectorType >, Multigrid< VectorType > > matrix
void set_maxlevel(const unsigned int)
unsigned int get_minlevel() const
void set_edge_matrices(const MGMatrixBase< VectorType > &edge_out, const MGMatrixBase< VectorType > &edge_in)
boost::signals2::connection connect_residual_step(const std::function< void(const bool, const unsigned int)> &slot)
void level_step(const unsigned int level, Cycle cycle)
unsigned int get_maxlevel() const
const VectorType const_vector_type
SmartPointer< const MGSmootherBase< VectorType >, Multigrid< VectorType > > pre_smooth
SmartPointer< const MGSmootherBase< VectorType >, Multigrid< VectorType > > post_smooth
boost::signals2::connection connect_post_smoother_step(const std::function< void(const bool, const unsigned int)> &slot)
boost::signals2::connection connect_coarse_solve(const std::function< void(const bool, const unsigned int)> &slot)
SmartPointer< const MGCoarseGridBase< VectorType >, Multigrid< VectorType > > coarse
boost::signals2::connection connect_prolongation(const std::function< void(const bool, const unsigned int)> &slot)
SmartPointer< const MGMatrixBase< VectorType >, Multigrid< VectorType > > edge_down
void set_edge_in_matrix(const MGMatrixBase< VectorType > &edge_in)
MGLevelObject< VectorType > t
void set_minlevel(const unsigned int level, bool relative=false)
void level_v_step(const unsigned int level)
Multigrid(const MGMatrixBase< VectorType > &matrix, const MGCoarseGridBase< VectorType > &coarse, const MGTransferBase< VectorType > &transfer, const MGSmootherBase< VectorType > &pre_smooth, const MGSmootherBase< VectorType > &post_smooth, const unsigned int minlevel=0, const unsigned int maxlevel=numbers::invalid_unsigned_int, Cycle cycle=v_cycle)
MGLevelObject< VectorType > defect
boost::signals2::connection connect_restriction(const std::function< void(const bool, const unsigned int)> &slot)
void reinit(const unsigned int minlevel, const unsigned int maxlevel)
boost::signals2::connection connect_pre_smoother_step(const std::function< void(const bool, const unsigned int)> &slot)
std::vector< const DoFHandler< dim > * > dof_handler_vector_raw
void Tvmult(OtherVectorType &dst, const OtherVectorType &src) const
SmartPointer< const TransferType, PreconditionMG< dim, VectorType, TransferType > > transfer
IndexSet locally_owned_domain_indices(const unsigned int block=0) const
boost::signals2::connection connect_transfer_to_global(const std::function< void(bool)> &slot)
boost::signals2::connection connect_transfer_to_mg(const std::function< void(bool)> &slot)
PreconditionMG(const DoFHandler< dim > &dof_handler, Multigrid< VectorType > &mg, const TransferType &transfer)
MPI_Comm get_mpi_communicator() const
const bool uses_dof_handler_vector
void vmult_add(OtherVectorType &dst, const OtherVectorType &src) const
IndexSet locally_owned_range_indices(const unsigned int block=0) const
const Multigrid< VectorType > & get_multigrid() const
SmartPointer< Multigrid< VectorType >, PreconditionMG< dim, VectorType, TransferType > > multigrid
PreconditionMG(const std::vector< const DoFHandler< dim > * > &dof_handler, Multigrid< VectorType > &mg, const TransferType &transfer)
std::vector< SmartPointer< const DoFHandler< dim >, PreconditionMG< dim, VectorType, TransferType > > > dof_handler_vector
void Tvmult_add(OtherVectorType &dst, const OtherVectorType &src) const
void vmult(OtherVectorType &dst, const OtherVectorType &src) const
Multigrid< VectorType > & get_multigrid()
Triangulation< dim, spacedim > & get_triangulation()
virtual MPI_Comm get_communicator() const override
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcInternalError()
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotImplemented()
#define AssertIndexRange(index, range)
@ matrix
Contents is actually a matrix.
void reinit(MatrixBlock< MatrixType > &v, const BlockSparsityPattern &p)
static const unsigned int invalid_unsigned_int
boost::signals2::signal< void(const bool before, const unsigned int level)> prolongation
boost::signals2::signal< void(const bool before, const unsigned int level)> pre_smoother_step
boost::signals2::signal< void(const bool before, const unsigned int level)> coarse_solve
boost::signals2::signal< void(const bool before, const unsigned int level)> edge_prolongation
boost::signals2::signal< void(const bool before, const unsigned int level)> post_smoother_step
boost::signals2::signal< void(const bool before)> transfer_to_global
boost::signals2::signal< void(const bool before, const unsigned int level)> residual_step
boost::signals2::signal< void(const bool before, const unsigned int level)> restriction
boost::signals2::signal< void(const bool before)> transfer_to_mg
const ::Triangulation< dim, spacedim > & tria