16 #ifndef dealii_multigrid_h 17 #define dealii_multigrid_h 74 boost::signals2::signal<void(const bool before, const unsigned int level)>
82 boost::signals2::signal<void(const bool before, const unsigned int level)>
90 boost::signals2::signal<void(const bool before, const unsigned int level)>
98 boost::signals2::signal<void(const bool before, const unsigned int level)>
107 boost::signals2::signal<void(const bool before, const unsigned int level)>
136 template <
typename VectorType>
170 const unsigned int minlevel = 0,
172 Cycle cycle = v_cycle);
178 reinit(
const unsigned int minlevel,
const unsigned int maxlevel);
236 get_maxlevel()
const;
242 get_minlevel()
const;
250 set_maxlevel(
const unsigned int);
268 set_minlevel(
const unsigned int level,
bool relative =
false);
273 void set_cycle(
Cycle);
278 boost::signals2::connection
279 connect_coarse_solve(
280 const std::function<
void(
const bool,
const unsigned int)> &slot);
285 boost::signals2::connection
287 const std::function<
void(
const bool,
const unsigned int)> &slot);
292 boost::signals2::connection
293 connect_prolongation(
294 const std::function<
void(
const bool,
const unsigned int)> &slot);
299 boost::signals2::connection
300 connect_pre_smoother_step(
301 const std::function<
void(
const bool,
const unsigned int)> &slot);
306 boost::signals2::connection
307 connect_post_smoother_step(
308 const std::function<
void(
const bool,
const unsigned int)> &slot);
323 level_v_step(
const unsigned int level);
333 level_step(
const unsigned int level,
Cycle cycle);
432 template <
int dim,
class OtherVectorType,
class TRANSFER>
453 template <
int dim,
typename VectorType,
class TRANSFER>
463 const TRANSFER & transfer);
471 const TRANSFER & transfer);
485 template <
class OtherVectorType>
487 vmult(OtherVectorType &dst,
const OtherVectorType &src)
const;
493 template <
class OtherVectorType>
495 vmult_add(OtherVectorType &dst,
const OtherVectorType &src)
const;
502 template <
class OtherVectorType>
504 Tvmult(OtherVectorType &dst,
const OtherVectorType &src)
const;
511 template <
class OtherVectorType>
513 Tvmult_add(OtherVectorType &dst,
const OtherVectorType &src)
const;
522 locally_owned_range_indices(
const unsigned int block = 0)
const;
531 locally_owned_domain_indices(
const unsigned int block = 0)
const;
537 get_mpi_communicator()
const;
542 boost::signals2::connection
543 connect_transfer_to_mg(
const std::function<
void(
bool)> &slot);
548 boost::signals2::connection
549 connect_transfer_to_global(
const std::function<
void(
bool)> &slot);
555 std::vector<SmartPointer<const DoFHandler<dim>,
595 template <
typename VectorType>
601 const unsigned int min_level,
602 const unsigned int max_level,
605 , matrix(&matrix, typeid(*this).name())
606 , coarse(&coarse, typeid(*this).name())
607 , transfer(&transfer, typeid(*this).name())
608 , pre_smooth(&pre_smooth, typeid(*this).name())
609 , post_smooth(&post_smooth, typeid(*this).name())
610 , edge_out(nullptr, typeid(*this).name())
611 , edge_in(nullptr, typeid(*this).name())
612 , edge_down(nullptr, typeid(*this).name())
613 , edge_up(nullptr, typeid(*this).name())
618 maxlevel = max_level;
619 reinit(min_level, maxlevel);
624 template <
typename VectorType>
633 template <
typename VectorType>
646 namespace PreconditionMGImplementation
651 typename OtherVectorType>
652 typename std::enable_if<TRANSFER::supports_dof_handler_vector>::type
657 OtherVectorType & dst,
658 const OtherVectorType & src,
660 const typename ::mg::Signals &
signals,
663 signals.transfer_to_mg(
true);
664 if (uses_dof_handler_vector)
668 signals.transfer_to_mg(
false);
672 signals.transfer_to_global(
true);
673 if (uses_dof_handler_vector)
677 signals.transfer_to_global(
false);
683 typename OtherVectorType>
688 const TRANSFER & transfer,
689 OtherVectorType & dst,
690 const OtherVectorType & src,
691 const bool uses_dof_handler_vector,
692 const typename ::mg::Signals &signals,
695 (void)uses_dof_handler_vector;
698 signals.transfer_to_mg(
true);
700 signals.transfer_to_mg(
false);
704 signals.transfer_to_global(
true);
706 signals.transfer_to_global(
false);
712 typename OtherVectorType>
713 typename std::enable_if<TRANSFER::supports_dof_handler_vector>::type
717 const TRANSFER & 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)
729 signals.transfer_to_mg(
false);
733 signals.transfer_to_global(
true);
734 if (uses_dof_handler_vector)
740 signals.transfer_to_global(
false);
746 typename OtherVectorType>
751 const TRANSFER & transfer,
752 OtherVectorType & dst,
753 const OtherVectorType & src,
754 const bool uses_dof_handler_vector,
755 const typename ::mg::Signals &signals,
758 (void)uses_dof_handler_vector;
761 signals.transfer_to_mg(
true);
763 signals.transfer_to_mg(
false);
767 signals.transfer_to_global(
true);
771 signals.transfer_to_global(
false);
776 template <
int dim,
typename VectorType,
class TRANSFER>
788 template <
int dim,
typename VectorType,
class TRANSFER>
792 const TRANSFER & transfer)
799 for (
unsigned int i = 0; i < dof_handler.size(); ++i)
806 template <
int dim,
typename VectorType,
class TRANSFER>
813 template <
int dim,
typename VectorType,
class TRANSFER>
814 template <
class OtherVectorType>
817 OtherVectorType & dst,
818 const OtherVectorType &src)
const 831 template <
int dim,
typename VectorType,
class TRANSFER>
834 const unsigned int block)
const 841 template <
int dim,
typename VectorType,
class TRANSFER>
844 const unsigned int block)
const 852 template <
int dim,
typename VectorType,
class TRANSFER>
867 template <
int dim,
typename VectorType,
class TRANSFER>
868 boost::signals2::connection
870 const std::function<
void(
bool)> &slot)
877 template <
int dim,
typename VectorType,
class TRANSFER>
878 boost::signals2::connection
880 const std::function<
void(
bool)> &slot)
887 template <
int dim,
typename VectorType,
class TRANSFER>
888 template <
class OtherVectorType>
891 OtherVectorType & dst,
892 const OtherVectorType &src)
const 905 template <
int dim,
typename VectorType,
class TRANSFER>
906 template <
class OtherVectorType>
909 const OtherVectorType &)
const 915 template <
int dim,
typename VectorType,
class TRANSFER>
916 template <
class OtherVectorType>
920 const OtherVectorType &)
const boost::signals2::signal< void(const bool before, const unsigned int level)> coarse_solve
boost::signals2::connection connect_transfer_to_global(const std::function< void(bool)> &slot)
SmartPointer< const MGMatrixBase< VectorType >, Multigrid< VectorType > > matrix
static const unsigned int invalid_unsigned_int
void reinit(MatrixBlock< MatrixType > &v, const BlockSparsityPattern &p)
SmartPointer< const MGMatrixBase< VectorType >, Multigrid< VectorType > > edge_down
SmartPointer< const MGMatrixBase< VectorType > > edge_in
void vmult(OtherVectorType &dst, const OtherVectorType &src) const
Contents is actually a matrix.
unsigned int get_maxlevel() const
boost::signals2::signal< void(const bool before, const unsigned int level)> prolongation
#define AssertIndexRange(index, range)
SmartPointer< const MGCoarseGridBase< VectorType >, Multigrid< VectorType > > coarse
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)> restriction
MGLevelObject< VectorType > t
const bool uses_dof_handler_vector
IndexSet locally_owned_range_indices(const unsigned int block=0) const
#define Assert(cond, exc)
void Tvmult(OtherVectorType &dst, const OtherVectorType &src) const
unsigned int get_minlevel() const
#define DEAL_II_NAMESPACE_CLOSE
SmartPointer< Multigrid< VectorType >, PreconditionMG< dim, VectorType, TRANSFER > > multigrid
boost::signals2::signal< void(const bool before)> transfer_to_mg
const MPI_Comm & get_mpi_communicator() const
SmartPointer< const MGMatrixBase< VectorType > > edge_out
void vmult_add(OtherVectorType &dst, const OtherVectorType &src) const
boost::signals2::signal< void(const bool before, const unsigned int level)> pre_smoother_step
virtual const MPI_Comm & get_communicator() const
boost::signals2::connection connect_transfer_to_mg(const std::function< void(bool)> &slot)
void Tvmult_add(OtherVectorType &dst, const OtherVectorType &src) const
SmartPointer< const TRANSFER, PreconditionMG< dim, VectorType, TRANSFER > > transfer
MGLevelObject< VectorType > solution
std::vector< SmartPointer< const DoFHandler< dim >, PreconditionMG< dim, VectorType, TRANSFER > > > dof_handler_vector
virtual unsigned int get_maxlevel() const =0
SmartPointer< const MGSmootherBase< VectorType >, Multigrid< VectorType > > post_smooth
IndexSet locally_owned_domain_indices(const unsigned int block=0) const
#define DEAL_II_NAMESPACE_OPEN
std::vector< const DoFHandler< dim > * > dof_handler_vector_raw
static ::ExceptionBase & ExcNotImplemented()
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 > defect2
MGLevelObject< VectorType > defect
PreconditionMG(const DoFHandler< dim > &dof_handler, Multigrid< VectorType > &mg, const TRANSFER &transfer)
SmartPointer< const MGTransferBase< VectorType >, Multigrid< VectorType > > transfer
SmartPointer< const MGMatrixBase< VectorType >, Multigrid< VectorType > > edge_up
SmartPointer< const MGSmootherBase< VectorType >, Multigrid< VectorType > > pre_smooth
static ::ExceptionBase & ExcInternalError()