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>
278 boost::signals2::connection
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
294 const std::function<
void(
const bool,
const unsigned int)> &slot);
299 boost::signals2::connection
301 const std::function<
void(
const bool,
const unsigned int)> &slot);
306 boost::signals2::connection
308 const std::function<
void(
const bool,
const unsigned int)> &slot);
432 template <
int dim,
class OtherVectorType,
class TRANSFER>
453 template <
int dim,
typename VectorType,
class 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;
542 boost::signals2::connection
548 boost::signals2::connection
555 std::vector<SmartPointer<const DoFHandler<dim>,
595 template <
typename VectorType>
601 const unsigned int min_level,
602 const unsigned int max_level,
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())
616 maxlevel =
matrix.get_maxlevel();
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
654 const std::vector<const ::DoFHandler<dim> *> &dof_handler_vector,
656 const TRANSFER & transfer,
657 OtherVectorType & dst,
658 const OtherVectorType & src,
659 const bool uses_dof_handler_vector,
660 const typename ::mg::Signals &signals,
663 signals.transfer_to_mg(
true);
664 if (uses_dof_handler_vector)
665 transfer.copy_to_mg(dof_handler_vector, multigrid.
defect, src);
667 transfer.copy_to_mg(*dof_handler_vector[0], multigrid.
defect, src);
668 signals.transfer_to_mg(
false);
672 signals.transfer_to_global(
true);
673 if (uses_dof_handler_vector)
674 transfer.copy_from_mg(dof_handler_vector, dst, multigrid.
solution);
676 transfer.copy_from_mg(*dof_handler_vector[0], dst, multigrid.
solution);
677 signals.transfer_to_global(
false);
683 typename OtherVectorType>
686 const std::vector<const ::DoFHandler<dim> *> &dof_handler_vector,
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);
699 transfer.copy_to_mg(*dof_handler_vector[0], multigrid.
defect, src);
700 signals.transfer_to_mg(
false);
704 signals.transfer_to_global(
true);
705 transfer.copy_from_mg(*dof_handler_vector[0], dst, multigrid.
solution);
706 signals.transfer_to_global(
false);
712 typename OtherVectorType>
713 typename std::enable_if<TRANSFER::supports_dof_handler_vector>::type
715 const std::vector<const ::DoFHandler<dim> *> &dof_handler_vector,
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)
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_add(dof_handler_vector, dst, multigrid.
solution);
737 transfer.copy_from_mg_add(*dof_handler_vector[0],
740 signals.transfer_to_global(
false);
746 typename OtherVectorType>
749 const std::vector<const ::DoFHandler<dim> *> &dof_handler_vector,
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);
762 transfer.copy_to_mg(*dof_handler_vector[0], multigrid.
defect, src);
763 signals.transfer_to_mg(
false);
767 signals.transfer_to_global(
true);
768 transfer.copy_from_mg_add(*dof_handler_vector[0],
771 signals.transfer_to_global(
false);
776 template <
int dim,
typename VectorType,
class TRANSFER>
780 const TRANSFER & transfer)
781 : dof_handler_vector(1, &dof_handler)
782 , dof_handler_vector_raw(1, &dof_handler)
784 , transfer(&transfer)
785 , uses_dof_handler_vector(false)
788 template <
int dim,
typename VectorType,
class TRANSFER>
792 const TRANSFER & transfer)
793 : dof_handler_vector(dof_handler.size())
794 , dof_handler_vector_raw(dof_handler.size())
796 , transfer(&transfer)
797 , uses_dof_handler_vector(true)
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
820 internal::PreconditionMGImplementation::vmult(dof_handler_vector_raw,
825 uses_dof_handler_vector,
831 template <
int dim,
typename VectorType,
class TRANSFER>
834 const unsigned int block)
const
837 return dof_handler_vector[block]->locally_owned_dofs();
841 template <
int dim,
typename VectorType,
class TRANSFER>
844 const unsigned int block)
const
847 return dof_handler_vector[block]->locally_owned_dofs();
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)
872 return this->signals.transfer_to_mg.connect(slot);
877 template <
int dim,
typename VectorType,
class TRANSFER>
878 boost::signals2::connection
880 const std::function<
void(
bool)> &slot)
882 return this->signals.transfer_to_global.connect(slot);
887 template <
int dim,
typename VectorType,
class TRANSFER>
888 template <
class OtherVectorType>
891 OtherVectorType & dst,
892 const OtherVectorType &src)
const
894 internal::PreconditionMGImplementation::vmult_add(dof_handler_vector_raw,
899 uses_dof_handler_vector,
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