15#ifndef dealii_multigrid_h
16#define dealii_multigrid_h
40 "The name 'signals' is already defined. You are most likely using the QT library \
41and using the 'signals' keyword. You can either #include the Qt headers (or any conflicting headers) \
42*after* the deal.II headers or you can define the 'QT_NO_KEYWORDS' macro and use the 'Q_SIGNALS' macro."
86 boost::signals2::signal<void(
const bool before,
const unsigned int level)>
97 boost::signals2::signal<void(
const bool before,
const unsigned int level)>
105 boost::signals2::signal<void(
const bool before,
const unsigned int level)>
116 boost::signals2::signal<void(
const bool before,
const unsigned int level)>
124 boost::signals2::signal<void(
const bool before,
const unsigned int level)>
132 boost::signals2::signal<void(
const bool before,
const unsigned int level)>
139 boost::signals2::signal<void(
const bool before,
const unsigned int level)>
161template <
typename VectorType>
312 boost::signals2::connection
314 const std::function<
void(
const bool,
const unsigned int)> &slot);
319 boost::signals2::connection
321 const std::function<
void(
const bool,
const unsigned int)> &slot);
326 boost::signals2::connection
328 const std::function<
void(
const bool,
const unsigned int)> &slot);
333 boost::signals2::connection
335 const std::function<
void(
const bool,
const unsigned int)> &slot);
340 boost::signals2::connection
342 const std::function<
void(
const bool,
const unsigned int)> &slot);
347 boost::signals2::connection
349 const std::function<
void(
const bool,
const unsigned int)> &slot);
354 boost::signals2::connection
356 const std::function<
void(
const bool,
const unsigned int)> &slot);
482 template <
int dim,
typename OtherVectorType,
typename TransferType>
501template <
int dim,
typename VectorType,
typename TransferType>
533 template <
typename OtherVectorType>
535 vmult(OtherVectorType &dst,
const OtherVectorType &src)
const;
541 template <
typename OtherVectorType>
543 vmult_add(OtherVectorType &dst,
const OtherVectorType &src)
const;
550 template <
typename OtherVectorType>
552 Tvmult(OtherVectorType &dst,
const OtherVectorType &src)
const;
559 template <
typename OtherVectorType>
561 Tvmult_add(OtherVectorType &dst,
const OtherVectorType &src)
const;
590 boost::signals2::connection
596 boost::signals2::connection
615 std::vector<ObserverPointer<const DoFHandler<dim>,
657template <
typename VectorType>
663 const unsigned int min_level,
664 const unsigned int max_level,
667 , matrix(&matrix, typeid(*this).name())
668 , coarse(&coarse, typeid(*this).name())
669 , transfer(&transfer, typeid(*this).name())
670 , pre_smooth(&pre_smooth, typeid(*this).name())
671 , post_smooth(&post_smooth, typeid(*this).name())
672 , edge_out(nullptr, typeid(*this).name())
673 , edge_in(nullptr, typeid(*this).name())
674 , edge_down(nullptr, typeid(*this).name())
675 , edge_up(nullptr, typeid(*this).name())
678 maxlevel = matrix.get_maxlevel();
680 maxlevel = max_level;
681 reinit(min_level, maxlevel);
686template <
typename VectorType>
695template <
typename VectorType>
708 namespace PreconditionMGImplementation
712 typename TransferType,
713 typename OtherVectorType>
714 std::enable_if_t<TransferType::supports_dof_handler_vector>
717 const TransferType &transfer,
718 OtherVectorType &dst,
719 const OtherVectorType &src,
720 const bool uses_dof_handler_vector,
721 const typename ::mg::Signals &signals,
724 signals.transfer_to_mg(
true);
725 if (uses_dof_handler_vector)
726 transfer.copy_to_mg(dof_handler_vector, multigrid.
defect, src);
728 transfer.copy_to_mg(*dof_handler_vector[0], multigrid.
defect, src);
729 signals.transfer_to_mg(
false);
733 signals.transfer_to_global(
true);
734 if (uses_dof_handler_vector)
735 transfer.copy_from_mg(dof_handler_vector, dst, multigrid.
solution);
737 transfer.copy_from_mg(*dof_handler_vector[0], dst, multigrid.
solution);
738 signals.transfer_to_global(
false);
743 typename TransferType,
744 typename OtherVectorType>
748 const TransferType &transfer,
749 OtherVectorType &dst,
750 const OtherVectorType &src,
751 const bool uses_dof_handler_vector,
752 const typename ::mg::Signals &signals,
755 (void)uses_dof_handler_vector;
758 signals.transfer_to_mg(
true);
759 transfer.copy_to_mg(*dof_handler_vector[0], multigrid.
defect, src);
760 signals.transfer_to_mg(
false);
764 signals.transfer_to_global(
true);
765 transfer.copy_from_mg(*dof_handler_vector[0], dst, multigrid.
solution);
766 signals.transfer_to_global(
false);
771 typename TransferType,
772 typename OtherVectorType>
773 std::enable_if_t<TransferType::supports_dof_handler_vector>
774 vmult_add(
const std::vector<
const DoFHandler<dim> *> &dof_handler_vector,
776 const TransferType &transfer,
777 OtherVectorType &dst,
778 const OtherVectorType &src,
779 const bool uses_dof_handler_vector,
780 const typename ::mg::Signals &signals,
783 signals.transfer_to_mg(
true);
784 if (uses_dof_handler_vector)
785 transfer.copy_to_mg(dof_handler_vector, multigrid.
defect, src);
787 transfer.copy_to_mg(*dof_handler_vector[0], multigrid.
defect, src);
788 signals.transfer_to_mg(
false);
792 signals.transfer_to_global(
true);
793 if (uses_dof_handler_vector)
794 transfer.copy_from_mg_add(dof_handler_vector, dst, multigrid.
solution);
796 transfer.copy_from_mg_add(*dof_handler_vector[0],
799 signals.transfer_to_global(
false);
804 typename TransferType,
805 typename OtherVectorType>
807 vmult_add(
const std::vector<
const DoFHandler<dim> *> &dof_handler_vector,
809 const TransferType &transfer,
810 OtherVectorType &dst,
811 const OtherVectorType &src,
812 const bool uses_dof_handler_vector,
813 const typename ::mg::Signals &signals,
816 (void)uses_dof_handler_vector;
819 signals.transfer_to_mg(
true);
820 transfer.copy_to_mg(*dof_handler_vector[0], multigrid.
defect, src);
821 signals.transfer_to_mg(
false);
825 signals.transfer_to_global(
true);
826 transfer.copy_from_mg_add(*dof_handler_vector[0],
829 signals.transfer_to_global(
false);
834template <
int dim,
typename VectorType,
typename TransferType>
838 const TransferType &transfer)
839 : dof_handler_vector(1, &dof_handler)
840 , dof_handler_vector_raw(1, &dof_handler)
842 , transfer(&transfer)
843 , uses_dof_handler_vector(false)
846template <
int dim,
typename VectorType,
typename TransferType>
850 const TransferType &transfer)
851 : dof_handler_vector(dof_handler.
size())
852 , dof_handler_vector_raw(dof_handler.
size())
854 , transfer(&transfer)
855 , uses_dof_handler_vector(true)
857 for (
unsigned int i = 0; i < dof_handler.size(); ++i)
864template <
int dim,
typename VectorType,
typename TransferType>
871template <
int dim,
typename VectorType,
typename TransferType>
872template <
typename OtherVectorType>
875 OtherVectorType &dst,
876 const OtherVectorType &src)
const
878 internal::PreconditionMGImplementation::vmult(dof_handler_vector_raw,
883 uses_dof_handler_vector,
889template <
int dim,
typename VectorType,
typename TransferType>
892 const unsigned int block)
const
895 return dof_handler_vector[block]->locally_owned_dofs();
899template <
int dim,
typename VectorType,
typename TransferType>
902 const unsigned int block)
const
905 return dof_handler_vector[block]->locally_owned_dofs();
910template <
int dim,
typename VectorType,
typename TransferType>
925template <
int dim,
typename VectorType,
typename TransferType>
926boost::signals2::connection
928 const std::function<
void(
bool)> &slot)
930 return this->signals.transfer_to_mg.connect(slot);
935template <
int dim,
typename VectorType,
typename TransferType>
936boost::signals2::connection
938 const std::function<
void(
bool)> &slot)
940 return this->signals.transfer_to_global.connect(slot);
945template <
int dim,
typename VectorType,
typename TransferType>
946template <
typename OtherVectorType>
949 OtherVectorType &dst,
950 const OtherVectorType &src)
const
952 internal::PreconditionMGImplementation::vmult_add(dof_handler_vector_raw,
957 uses_dof_handler_vector,
963template <
int dim,
typename VectorType,
typename TransferType>
964template <
typename OtherVectorType>
968 const OtherVectorType &)
const
974template <
int dim,
typename VectorType,
typename TransferType>
975template <
typename OtherVectorType>
979 const OtherVectorType &)
const
985template <
int dim,
typename VectorType,
typename TransferType>
989 return *this->multigrid;
993template <
int dim,
typename VectorType,
typename TransferType>
997 return *this->multigrid;
ObserverPointer< const MGMatrixBase< VectorType > > edge_out
MGLevelObject< VectorType > defect2
void set_edge_flux_matrices(const MGMatrixBase< VectorType > &edge_down, const MGMatrixBase< VectorType > &edge_up)
MGLevelObject< VectorType > solution
ObserverPointer< const MGSmootherBase< VectorType >, Multigrid< VectorType > > post_smooth
boost::signals2::connection connect_edge_prolongation(const std::function< void(const bool, const unsigned int)> &slot)
ObserverPointer< const MGMatrixBase< VectorType > > edge_in
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
ObserverPointer< const MGCoarseGridBase< VectorType >, Multigrid< VectorType > > coarse
ObserverPointer< const MGSmootherBase< VectorType >, Multigrid< VectorType > > pre_smooth
const VectorType const_vector_type
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)
ObserverPointer< const MGMatrixBase< VectorType >, Multigrid< VectorType > > matrix
boost::signals2::connection connect_prolongation(const std::function< void(const bool, const unsigned int)> &slot)
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
ObserverPointer< const MGMatrixBase< VectorType >, Multigrid< VectorType > > edge_down
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)
ObserverPointer< const MGMatrixBase< VectorType >, Multigrid< VectorType > > edge_up
boost::signals2::connection connect_pre_smoother_step(const std::function< void(const bool, const unsigned int)> &slot)
ObserverPointer< const MGTransferBase< VectorType >, Multigrid< VectorType > > transfer
std::vector< const DoFHandler< dim > * > dof_handler_vector_raw
void Tvmult(OtherVectorType &dst, const OtherVectorType &src) const
IndexSet locally_owned_domain_indices(const unsigned int block=0) const
ObserverPointer< Multigrid< VectorType >, PreconditionMG< dim, VectorType, TransferType > > multigrid
const Multigrid< VectorType > & get_multigrid() 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)
ObserverPointer< const TransferType, PreconditionMG< dim, VectorType, 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
std::vector< ObserverPointer< const DoFHandler< dim >, PreconditionMG< dim, VectorType, TransferType > > > dof_handler_vector
PreconditionMG(const std::vector< const DoFHandler< dim > * > &dof_handler, Multigrid< VectorType > &mg, const TransferType &transfer)
Multigrid< VectorType > & get_multigrid()
void Tvmult_add(OtherVectorType &dst, const OtherVectorType &src) const
void vmult(OtherVectorType &dst, const OtherVectorType &src) const
Triangulation< dim, spacedim > & get_triangulation()
virtual MPI_Comm get_mpi_communicator() const override
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
#define DEAL_II_NOT_IMPLEMENTED()
Tpetra::Vector< Number, LO, GO, NodeType< MemorySpace > > VectorType
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