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,
class OtherVectorType,
class TRANSFER>
500 template <
int dim,
typename VectorType,
class TRANSFER>
532 template <
class OtherVectorType>
534 vmult(OtherVectorType &dst,
const OtherVectorType &src)
const;
540 template <
class OtherVectorType>
542 vmult_add(OtherVectorType &dst,
const OtherVectorType &src)
const;
549 template <
class OtherVectorType>
551 Tvmult(OtherVectorType &dst,
const OtherVectorType &src)
const;
558 template <
class 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>,
654 template <
typename VectorType>
660 const unsigned int min_level,
661 const unsigned int max_level,
665 , coarse(&coarse, typeid(*this).name())
666 , transfer(&transfer, typeid(*this).name())
667 , pre_smooth(&pre_smooth, typeid(*this).name())
668 , post_smooth(&post_smooth, typeid(*this).name())
669 , edge_out(nullptr, typeid(*this).name())
670 , edge_in(nullptr, typeid(*this).name())
671 , edge_down(nullptr, typeid(*this).name())
672 , edge_up(nullptr, typeid(*this).name())
675 maxlevel =
matrix.get_maxlevel();
677 maxlevel = max_level;
678 reinit(min_level, maxlevel);
683 template <
typename VectorType>
692 template <
typename VectorType>
705 namespace PreconditionMGImplementation
710 typename OtherVectorType>
711 std::enable_if_t<TRANSFER::supports_dof_handler_vector>
713 const std::vector<const ::DoFHandler<dim> *> &dof_handler_vector,
715 const TRANSFER & transfer,
716 OtherVectorType & dst,
717 const OtherVectorType & src,
718 const bool uses_dof_handler_vector,
719 const typename ::mg::Signals &signals,
722 signals.transfer_to_mg(
true);
723 if (uses_dof_handler_vector)
724 transfer.copy_to_mg(dof_handler_vector, multigrid.
defect, src);
726 transfer.copy_to_mg(*dof_handler_vector[0], multigrid.
defect, src);
727 signals.transfer_to_mg(
false);
731 signals.transfer_to_global(
true);
732 if (uses_dof_handler_vector)
733 transfer.copy_from_mg(dof_handler_vector, dst, multigrid.
solution);
735 transfer.copy_from_mg(*dof_handler_vector[0], dst, multigrid.
solution);
736 signals.transfer_to_global(
false);
742 typename OtherVectorType>
745 const std::vector<const ::DoFHandler<dim> *> &dof_handler_vector,
747 const TRANSFER & 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);
771 typename OtherVectorType>
772 std::enable_if_t<TRANSFER::supports_dof_handler_vector>
774 const std::vector<const ::DoFHandler<dim> *> &dof_handler_vector,
776 const TRANSFER & 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);
805 typename OtherVectorType>
808 const std::vector<const ::DoFHandler<dim> *> &dof_handler_vector,
810 const TRANSFER & transfer,
811 OtherVectorType & dst,
812 const OtherVectorType & src,
813 const bool uses_dof_handler_vector,
814 const typename ::mg::Signals &signals,
817 (void)uses_dof_handler_vector;
820 signals.transfer_to_mg(
true);
821 transfer.copy_to_mg(*dof_handler_vector[0], multigrid.
defect, src);
822 signals.transfer_to_mg(
false);
826 signals.transfer_to_global(
true);
827 transfer.copy_from_mg_add(*dof_handler_vector[0],
830 signals.transfer_to_global(
false);
835 template <
int dim,
typename VectorType,
class TRANSFER>
839 const TRANSFER & transfer)
840 : dof_handler_vector(1, &dof_handler)
841 , dof_handler_vector_raw(1, &dof_handler)
843 , transfer(&transfer)
844 , uses_dof_handler_vector(false)
847 template <
int dim,
typename VectorType,
class TRANSFER>
851 const TRANSFER & transfer)
852 : dof_handler_vector(dof_handler.size())
853 , dof_handler_vector_raw(dof_handler.size())
855 , transfer(&transfer)
856 , uses_dof_handler_vector(true)
858 for (
unsigned int i = 0; i < dof_handler.size(); ++i)
865 template <
int dim,
typename VectorType,
class TRANSFER>
872 template <
int dim,
typename VectorType,
class TRANSFER>
873 template <
class OtherVectorType>
876 OtherVectorType & dst,
877 const OtherVectorType &src)
const
879 internal::PreconditionMGImplementation::vmult(dof_handler_vector_raw,
884 uses_dof_handler_vector,
890 template <
int dim,
typename VectorType,
class TRANSFER>
893 const unsigned int block)
const
896 return dof_handler_vector[block]->locally_owned_dofs();
900 template <
int dim,
typename VectorType,
class TRANSFER>
903 const unsigned int block)
const
906 return dof_handler_vector[block]->locally_owned_dofs();
911 template <
int dim,
typename VectorType,
class TRANSFER>
926 template <
int dim,
typename VectorType,
class TRANSFER>
927 boost::signals2::connection
929 const std::function<
void(
bool)> &slot)
931 return this->signals.transfer_to_mg.connect(slot);
936 template <
int dim,
typename VectorType,
class TRANSFER>
937 boost::signals2::connection
939 const std::function<
void(
bool)> &slot)
941 return this->signals.transfer_to_global.connect(slot);
946 template <
int dim,
typename VectorType,
class TRANSFER>
947 template <
class OtherVectorType>
950 OtherVectorType & dst,
951 const OtherVectorType &src)
const
953 internal::PreconditionMGImplementation::vmult_add(dof_handler_vector_raw,
958 uses_dof_handler_vector,
964 template <
int dim,
typename VectorType,
class TRANSFER>
965 template <
class OtherVectorType>
968 const OtherVectorType &)
const
974 template <
int dim,
typename VectorType,
class TRANSFER>
975 template <
class OtherVectorType>
979 const OtherVectorType &)
const
985 template <
int dim,
typename VectorType,
class TRANSFER>
989 return *this->multigrid;
993 template <
int dim,
typename VectorType,
class TRANSFER>
997 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)
SmartPointer< Multigrid< VectorType >, PreconditionMG< dim, VectorType, TRANSFER > > multigrid
void vmult_add(OtherVectorType &dst, const OtherVectorType &src) const
void vmult(OtherVectorType &dst, const OtherVectorType &src) const
IndexSet locally_owned_range_indices(const unsigned int block=0) const
SmartPointer< const TRANSFER, PreconditionMG< dim, VectorType, TRANSFER > > transfer
PreconditionMG(const std::vector< const DoFHandler< dim > * > &dof_handler, Multigrid< VectorType > &mg, const TRANSFER &transfer)
std::vector< SmartPointer< const DoFHandler< dim >, PreconditionMG< dim, VectorType, TRANSFER > > > dof_handler_vector
void Tvmult_add(OtherVectorType &dst, const OtherVectorType &src) const
void Tvmult(OtherVectorType &dst, const OtherVectorType &src) const
boost::signals2::connection connect_transfer_to_mg(const std::function< void(bool)> &slot)
const Multigrid< VectorType > & get_multigrid() const
PreconditionMG(const DoFHandler< dim > &dof_handler, Multigrid< VectorType > &mg, const TRANSFER &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)
const bool uses_dof_handler_vector
MPI_Comm get_mpi_communicator() const
Multigrid< VectorType > & get_multigrid()
std::vector< const DoFHandler< dim > * > dof_handler_vector_raw
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