From: Peter Munch Date: Sun, 23 Jul 2023 08:22:24 +0000 (+0200) Subject: Replace MGTransferMG usages in tests/matrix_free X-Git-Tag: relicensing~646^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F15784%2Fhead;p=dealii.git Replace MGTransferMG usages in tests/matrix_free --- diff --git a/tests/matrix_free/multigrid_dg_periodic.cc b/tests/matrix_free/multigrid_dg_periodic.cc index 2d3e3c2e39..028ca25bd6 100644 --- a/tests/matrix_free/multigrid_dg_periodic.cc +++ b/tests/matrix_free/multigrid_dg_periodic.cc @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include @@ -165,6 +165,12 @@ public: return inverse_diagonal_entries; } + const std::shared_ptr & + get_vector_partitioner() const + { + return data.get_vector_partitioner(); + } + private: void @@ -493,38 +499,6 @@ public: -template -class MGTransferMF - : public MGTransferPrebuilt< - LinearAlgebra::distributed::Vector> -{ -public: - MGTransferMF(const MGLevelObject &laplace) - : laplace_operator(laplace){}; - - /** - * Overload copy_to_mg from MGTransferPrebuilt - */ - template - void - copy_to_mg(const DoFHandler & mg_dof, - MGLevelObject> &dst, - const InVector & src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - laplace_operator[level].initialize_dof_vector(dst[level]); - MGTransferPrebuilt>::copy_to_mg(mg_dof, dst, src); - } - -private: - const MGLevelObject &laplace_operator; -}; - - - template void do_test(const DoFHandler &dof, const unsigned int n_q_points_1d) @@ -581,8 +555,14 @@ do_test(const DoFHandler &dof, const unsigned int n_q_points_1d) } mg_smoother.initialize(mg_matrices, smoother_data); - MGTransferMF mg_transfer(mg_matrices); - mg_transfer.build(dof); + std::vector> partitioners; + for (unsigned int level = mg_matrices.min_level(); + level <= mg_matrices.max_level(); + ++level) + partitioners.push_back(mg_matrices[level].get_vector_partitioner()); + + MGTransferMatrixFree mg_transfer; + mg_transfer.build(dof, partitioners); mg::Matrix> mg_matrix(mg_matrices); @@ -590,7 +570,7 @@ do_test(const DoFHandler &dof, const unsigned int n_q_points_1d) mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother); PreconditionMG, - MGTransferMF> + MGTransferMatrixFree> preconditioner(dof, mg, mg_transfer); { diff --git a/tests/matrix_free/multigrid_dg_sip_01.cc b/tests/matrix_free/multigrid_dg_sip_01.cc index bcb67a2342..f2dad019e6 100644 --- a/tests/matrix_free/multigrid_dg_sip_01.cc +++ b/tests/matrix_free/multigrid_dg_sip_01.cc @@ -500,40 +500,6 @@ public: -template -class MGTransferMF - : public MGTransferMatrixFree -{ -public: - MGTransferMF(const MGLevelObject &laplace, - const MGConstrainedDoFs & mg_constrained_dofs) - : MGTransferMatrixFree( - mg_constrained_dofs) - , laplace_operator(laplace){}; - - /** - * Overload copy_to_mg from MGTransferPrebuilt - */ - template - void - copy_to_mg(const DoFHandler & mg_dof_handler, - MGLevelObject> &dst, - const InVector & src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - laplace_operator[level].initialize_dof_vector(dst[level]); - MGTransferMatrixFree::copy_to_mg( - mg_dof_handler, dst, src); - } - -private: - const MGLevelObject &laplace_operator; -}; - - - template void do_test(const DoFHandler &dof, const unsigned n_q_points_1d) diff --git a/tests/matrix_free/multigrid_dg_sip_02.cc b/tests/matrix_free/multigrid_dg_sip_02.cc index fb5ac5cc66..2accd6dcff 100644 --- a/tests/matrix_free/multigrid_dg_sip_02.cc +++ b/tests/matrix_free/multigrid_dg_sip_02.cc @@ -177,6 +177,12 @@ public: return inverse_diagonal_entries; } + const std::shared_ptr & + get_vector_partitioner() const + { + return data.get_vector_partitioner(); + } + private: void @@ -408,40 +414,6 @@ public: -template -class MGTransferMF - : public MGTransferMatrixFree -{ -public: - MGTransferMF(const MGLevelObject &laplace, - const MGConstrainedDoFs & mg_constrained_dofs) - : MGTransferMatrixFree( - mg_constrained_dofs) - , laplace_operator(laplace){}; - - /** - * Overload copy_to_mg from MGTransferPrebuilt - */ - template - void - copy_to_mg(const DoFHandler & mg_dof_handler, - MGLevelObject> &dst, - const InVector & src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - laplace_operator[level].initialize_dof_vector(dst[level]); - MGTransferMatrixFree::copy_to_mg( - mg_dof_handler, dst, src); - } - -private: - const MGLevelObject &laplace_operator; -}; - - - template void do_test(const DoFHandler &dof, const unsigned int n_q_points_1d) @@ -503,9 +475,14 @@ do_test(const DoFHandler &dof, const unsigned int n_q_points_1d) mg_constrained_dofs.initialize(dof); mg_constrained_dofs.make_zero_boundary_constraints(dof, {0}); - MGTransferMF mg_transfer(mg_matrices, - mg_constrained_dofs); - mg_transfer.build(dof); + std::vector> partitioners; + for (unsigned int level = mg_matrices.min_level(); + level <= mg_matrices.max_level(); + ++level) + partitioners.push_back(mg_matrices[level].get_vector_partitioner()); + + MGTransferMatrixFree mg_transfer(mg_constrained_dofs); + mg_transfer.build(dof, partitioners); mg::Matrix> mg_matrix(mg_matrices); @@ -513,7 +490,7 @@ do_test(const DoFHandler &dof, const unsigned int n_q_points_1d) mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother); PreconditionMG, - MGTransferMF> + MGTransferMatrixFree> preconditioner(dof, mg, mg_transfer); { diff --git a/tests/matrix_free/parallel_multigrid.cc b/tests/matrix_free/parallel_multigrid.cc index bcc1b56df8..fb94f0ec16 100644 --- a/tests/matrix_free/parallel_multigrid.cc +++ b/tests/matrix_free/parallel_multigrid.cc @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include @@ -196,6 +196,12 @@ public: return inverse_diagonal_entries; } + const std::shared_ptr & + get_vector_partitioner() const + { + return data.get_vector_partitioner(); + } + private: void @@ -274,37 +280,6 @@ private: -template -class MGTransferPrebuiltMF - : public MGTransferPrebuilt> -{ -public: - MGTransferPrebuiltMF(const MGLevelObject &laplace) - : laplace_operator(laplace){}; - - /** - * Overload copy_to_mg from MGTransferPrebuilt to get the vectors compatible - * with MatrixFree and bypass the crude initialization in MGTransferPrebuilt - */ - template - void - copy_to_mg(const DoFHandler & mg_dof, - MGLevelObject> &dst, - const InVector &src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - laplace_operator[level].initialize_dof_vector(dst[level]); - MGTransferPrebuilt>::copy_to_mg( - mg_dof, dst, src); - } - -private: - const MGLevelObject &laplace_operator; -}; - - - template class MGCoarseIterative : public MGCoarseGridBase> @@ -375,8 +350,14 @@ do_test(const DoFHandler &dof) mg_matrices[level].initialize(mapping, dof, dirichlet_boundaries, level); } - MGTransferPrebuiltMF mg_transfer(mg_matrices); - mg_transfer.build(dof); + std::vector> partitioners; + for (unsigned int level = mg_matrices.min_level(); + level <= mg_matrices.max_level(); + ++level) + partitioners.push_back(mg_matrices[level].get_vector_partitioner()); + + MGTransferMatrixFree mg_transfer; + mg_transfer.build(dof, partitioners); MGCoarseIterative mg_coarse; mg_coarse.initialize(mg_matrices[0]); @@ -411,7 +392,7 @@ do_test(const DoFHandler &dof) mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother); PreconditionMG, - MGTransferPrebuiltMF> + MGTransferMatrixFree> preconditioner(dof, mg, mg_transfer); { diff --git a/tests/matrix_free/parallel_multigrid_adaptive_01.cc b/tests/matrix_free/parallel_multigrid_adaptive_01.cc index ce5cfd3e16..b58785c16a 100644 --- a/tests/matrix_free/parallel_multigrid_adaptive_01.cc +++ b/tests/matrix_free/parallel_multigrid_adaptive_01.cc @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include @@ -304,6 +304,12 @@ public: return inverse_diagonal_entries; } + const std::shared_ptr & + get_vector_partitioner() const + { + return data.get_vector_partitioner(); + } + private: void @@ -426,42 +432,6 @@ private: -template -class MGTransferMF - : public MGTransferPrebuilt> -{ -public: - MGTransferMF(const MGLevelObject &laplace, - const MGConstrainedDoFs & mg_constrained_dofs) - : MGTransferPrebuilt>( - mg_constrained_dofs) - , laplace_operator(laplace) - {} - - /** - * Overload copy_to_mg from MGTransferPrebuilt to get the vectors compatible - * with MatrixFree and bypass the crude vector initialization in - * MGTransferPrebuilt - */ - template - void - copy_to_mg(const DoFHandler &mg_dof_handler, - MGLevelObject> &dst, - const InVector &src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - laplace_operator[level].initialize_dof_vector(dst[level]); - MGTransferPrebuilt>::copy_to_mg( - mg_dof_handler, dst, src); - } - -private: - const MGLevelObject &laplace_operator; -}; - - - template class MGCoarseIterative : public MGCoarseGridBase> @@ -560,8 +530,14 @@ do_test(const DoFHandler &dof) ++level) mg_interface_matrices[level].initialize(mg_matrices[level]); - MGTransferMF mg_transfer(mg_matrices, mg_constrained_dofs); - mg_transfer.build(dof); + std::vector> partitioners; + for (unsigned int level = mg_matrices.min_level(); + level <= mg_matrices.max_level(); + ++level) + partitioners.push_back(mg_matrices[level].get_vector_partitioner()); + + MGTransferMatrixFree mg_transfer(mg_constrained_dofs); + mg_transfer.build(dof, partitioners); MGCoarseIterative mg_coarse; mg_coarse.initialize(mg_matrices[0]); @@ -599,7 +575,7 @@ do_test(const DoFHandler &dof) mg.set_edge_matrices(mg_interface, mg_interface); PreconditionMG, - MGTransferMF> + MGTransferMatrixFree> preconditioner(dof, mg, mg_transfer); { diff --git a/tests/matrix_free/parallel_multigrid_adaptive_02.cc b/tests/matrix_free/parallel_multigrid_adaptive_02.cc index 0851366674..3ae1c09498 100644 --- a/tests/matrix_free/parallel_multigrid_adaptive_02.cc +++ b/tests/matrix_free/parallel_multigrid_adaptive_02.cc @@ -53,43 +53,6 @@ using namespace dealii::MatrixFreeOperators; -template -class MGTransferMF - : public MGTransferMatrixFree -{ -public: - MGTransferMF(const MGLevelObject &laplace, - const MGConstrainedDoFs & mg_constrained_dofs) - : MGTransferMatrixFree( - mg_constrained_dofs) - , laplace_operator(laplace) - {} - - /** - * Overload copy_to_mg from MGTransferPrebuilt to get the vectors compatible - * with MatrixFree and bypass the crude vector initialization in - * MGTransferPrebuilt - */ - template - void - copy_to_mg(const DoFHandler & mg_dof_handler, - MGLevelObject> &dst, - const InVector & src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - laplace_operator[level].initialize_dof_vector(dst[level]); - MGTransferMatrixFree::copy_to_mg( - mg_dof_handler, dst, src); - } - -private: - const MGLevelObject &laplace_operator; -}; - - - template class MGCoarseIterative : public MGCoarseGridBase> @@ -249,9 +212,14 @@ do_test(const DoFHandler &dof) ++level) mg_interface_matrices[level].initialize(mg_matrices[level]); - MGTransferMF mg_transfer(mg_matrices, - mg_constrained_dofs); - mg_transfer.build(dof); + std::vector> partitioners; + for (unsigned int level = mg_matrices.min_level(); + level <= mg_matrices.max_level(); + ++level) + partitioners.push_back(mg_level_data[level].get_vector_partitioner()); + + MGTransferMatrixFree mg_transfer(mg_constrained_dofs); + mg_transfer.build(dof, partitioners); MGCoarseIterative mg_coarse; mg_coarse.initialize(mg_matrices[0]); @@ -287,7 +255,7 @@ do_test(const DoFHandler &dof) mg.set_edge_matrices(mg_interface, mg_interface); PreconditionMG, - MGTransferMF> + MGTransferMatrixFree> preconditioner(dof, mg, mg_transfer); { diff --git a/tests/matrix_free/parallel_multigrid_adaptive_03.cc b/tests/matrix_free/parallel_multigrid_adaptive_03.cc index d932c4211c..3bef0b0a02 100644 --- a/tests/matrix_free/parallel_multigrid_adaptive_03.cc +++ b/tests/matrix_free/parallel_multigrid_adaptive_03.cc @@ -311,6 +311,12 @@ public: return inverse_diagonal_entries; } + const std::shared_ptr & + get_vector_partitioner() const + { + return data.get_vector_partitioner(); + } + private: void @@ -438,45 +444,6 @@ private: -template -class MGTransferMF - : public MGTransferMatrixFree -{ -public: - MGTransferMF(const MGLevelObject &laplace, - const MGConstrainedDoFs & mg_constrained_dofs) - : MGTransferMatrixFree( - mg_constrained_dofs) - , laplace_operator(laplace) - {} - - /** - * Overload copy_to_mg from MGTransferPrebuilt to get the vectors compatible - * with MatrixFree and bypass the crude vector initialization in - * MGTransferPrebuilt - */ - template - void - copy_to_mg(const DoFHandler & mg_dof_handler, - MGLevelObject> &dst, - const InVector & src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - laplace_operator[level].initialize_dof_vector(dst[level]); - MGLevelGlobalTransfer>::copy_to_mg(mg_dof_handler, - dst, - src); - } - -private: - const MGLevelObject &laplace_operator; -}; - - - template class MGCoarseIterative : public MGCoarseGridBase> @@ -569,9 +536,14 @@ do_test(const DoFHandler &dof, const bool threaded) ++level) mg_interface_matrices[level].initialize(mg_matrices[level]); - MGTransferMF mg_transfer(mg_matrices, - mg_constrained_dofs); - mg_transfer.build(dof); + std::vector> partitioners; + for (unsigned int level = mg_matrices.min_level(); + level <= mg_matrices.max_level(); + ++level) + partitioners.push_back(mg_matrices[level].get_vector_partitioner()); + + MGTransferMatrixFree mg_transfer(mg_constrained_dofs); + mg_transfer.build(dof, partitioners); MGCoarseIterative mg_coarse; mg_coarse.initialize(mg_matrices[0]); @@ -610,7 +582,7 @@ do_test(const DoFHandler &dof, const bool threaded) mg.set_edge_matrices(mg_interface, mg_interface); PreconditionMG, - MGTransferMF> + MGTransferMatrixFree> preconditioner(dof, mg, mg_transfer); { diff --git a/tests/matrix_free/parallel_multigrid_adaptive_04.cc b/tests/matrix_free/parallel_multigrid_adaptive_04.cc index fe43ae0af2..b275ce1ab5 100644 --- a/tests/matrix_free/parallel_multigrid_adaptive_04.cc +++ b/tests/matrix_free/parallel_multigrid_adaptive_04.cc @@ -53,43 +53,6 @@ using namespace dealii::MatrixFreeOperators; -template -class MGTransferMF - : public MGTransferMatrixFree -{ -public: - MGTransferMF(const MGLevelObject &laplace, - const MGConstrainedDoFs & mg_constrained_dofs) - : MGTransferMatrixFree( - mg_constrained_dofs) - , laplace_operator(laplace) - {} - - /** - * Overload copy_to_mg from MGTransferPrebuilt to get the vectors compatible - * with MatrixFree and bypass the crude vector initialization in - * MGTransferPrebuilt - */ - template - void - copy_to_mg(const DoFHandler & mg_dof_handler, - MGLevelObject> &dst, - const InVector & src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - laplace_operator[level].initialize_dof_vector(dst[level]); - MGTransferMatrixFree::copy_to_mg( - mg_dof_handler, dst, src); - } - -private: - const MGLevelObject &laplace_operator; -}; - - - template class MGCoarseIterative : public MGCoarseGridBase> @@ -249,9 +212,14 @@ do_test(const DoFHandler &dof) ++level) mg_interface_matrices[level].initialize(mg_matrices[level]); - MGTransferMF mg_transfer(mg_matrices, - mg_constrained_dofs); - mg_transfer.build(dof); + std::vector> partitioners; + for (unsigned int level = mg_matrices.min_level(); + level <= mg_matrices.max_level(); + ++level) + partitioners.push_back(mg_level_data[level].get_vector_partitioner()); + + MGTransferMatrixFree mg_transfer(mg_constrained_dofs); + mg_transfer.build(dof, partitioners); MGCoarseIterative mg_coarse; mg_coarse.initialize(mg_matrices[0]); @@ -285,7 +253,7 @@ do_test(const DoFHandler &dof) mg.set_edge_matrices(mg_interface, mg_interface); PreconditionMG, - MGTransferMF> + MGTransferMatrixFree> preconditioner(dof, mg, mg_transfer); { diff --git a/tests/matrix_free/parallel_multigrid_adaptive_05.cc b/tests/matrix_free/parallel_multigrid_adaptive_05.cc index 96b5394ad9..86dcbaa8f6 100644 --- a/tests/matrix_free/parallel_multigrid_adaptive_05.cc +++ b/tests/matrix_free/parallel_multigrid_adaptive_05.cc @@ -308,6 +308,12 @@ public: return inverse_diagonal_entries; } + const std::shared_ptr & + get_vector_partitioner() const + { + return data.get_vector_partitioner(); + } + private: void @@ -435,45 +441,6 @@ private: -template -class MGTransferMF - : public MGTransferMatrixFree -{ -public: - MGTransferMF(const MGLevelObject &laplace, - const MGConstrainedDoFs & mg_constrained_dofs) - : MGTransferMatrixFree( - mg_constrained_dofs) - , laplace_operator(laplace) - {} - - /** - * Overload copy_to_mg from MGTransferPrebuilt to get the vectors compatible - * with MatrixFree and bypass the crude vector initialization in - * MGTransferPrebuilt - */ - template - void - copy_to_mg(const DoFHandler & mg_dof_handler, - MGLevelObject> &dst, - const InVector & src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - laplace_operator[level].initialize_dof_vector(dst[level]); - MGLevelGlobalTransfer>::copy_to_mg(mg_dof_handler, - dst, - src); - } - -private: - const MGLevelObject &laplace_operator; -}; - - - template class MGCoarseIterative : public MGCoarseGridBase> @@ -566,9 +533,14 @@ do_test(const DoFHandler &dof, const bool threaded) ++level) mg_interface_matrices[level].initialize(mg_matrices[level]); - MGTransferMF mg_transfer(mg_matrices, - mg_constrained_dofs); - mg_transfer.build(dof); + std::vector> partitioners; + for (unsigned int level = mg_matrices.min_level(); + level <= mg_matrices.max_level(); + ++level) + partitioners.push_back(mg_matrices[level].get_vector_partitioner()); + + MGTransferMatrixFree mg_transfer(mg_constrained_dofs); + mg_transfer.build(dof, partitioners); MGCoarseIterative mg_coarse; mg_coarse.initialize(mg_matrices[0]); @@ -607,7 +579,7 @@ do_test(const DoFHandler &dof, const bool threaded) mg.set_edge_matrices(mg_interface, mg_interface); PreconditionMG, - MGTransferMF> + MGTransferMatrixFree> preconditioner(dof, mg, mg_transfer); { diff --git a/tests/matrix_free/parallel_multigrid_adaptive_06ref.cc b/tests/matrix_free/parallel_multigrid_adaptive_06ref.cc index ee23793237..8915d65f94 100644 --- a/tests/matrix_free/parallel_multigrid_adaptive_06ref.cc +++ b/tests/matrix_free/parallel_multigrid_adaptive_06ref.cc @@ -54,43 +54,6 @@ using namespace dealii::MatrixFreeOperators; -template -class MGTransferMF - : public MGTransferMatrixFree -{ -public: - MGTransferMF(const MGLevelObject &laplace, - const MGConstrainedDoFs & mg_constrained_dofs) - : MGTransferMatrixFree( - mg_constrained_dofs) - , laplace_operator(laplace) - {} - - /** - * Overload copy_to_mg from MGTransferPrebuilt to get the vectors compatible - * with MatrixFree and bypass the crude vector initialization in - * MGTransferPrebuilt - */ - template - void - copy_to_mg(const DoFHandler & mg_dof_handler, - MGLevelObject> &dst, - const InVector & src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - laplace_operator[level].initialize_dof_vector(dst[level]); - MGTransferMatrixFree::copy_to_mg( - mg_dof_handler, dst, src); - } - -private: - const MGLevelObject &laplace_operator; -}; - - - template class MGCoarseIterative : public MGCoarseGridBase> @@ -250,9 +213,14 @@ do_test(const DoFHandler &dof) ++level) mg_interface_matrices[level].initialize(mg_matrices[level]); - MGTransferMF mg_transfer(mg_matrices, - mg_constrained_dofs); - mg_transfer.build(dof); + std::vector> partitioners; + for (unsigned int level = mg_matrices.min_level(); + level <= mg_matrices.max_level(); + ++level) + partitioners.push_back(mg_level_data[level].get_vector_partitioner()); + + MGTransferMatrixFree mg_transfer(mg_constrained_dofs); + mg_transfer.build(dof, partitioners); MGCoarseIterative mg_coarse; mg_coarse.initialize(mg_matrices[0]); @@ -274,7 +242,7 @@ do_test(const DoFHandler &dof) mg.set_edge_matrices(mg_interface, mg_interface); PreconditionMG, - MGTransferMF> + MGTransferMatrixFree> preconditioner(dof, mg, mg_transfer); { diff --git a/tests/matrix_free/parallel_multigrid_fullydistributed.cc b/tests/matrix_free/parallel_multigrid_fullydistributed.cc index fdb129600e..c9f48979fe 100644 --- a/tests/matrix_free/parallel_multigrid_fullydistributed.cc +++ b/tests/matrix_free/parallel_multigrid_fullydistributed.cc @@ -201,6 +201,12 @@ public: return inverse_diagonal_entries; } + const std::shared_ptr & + get_vector_partitioner() const + { + return data.get_vector_partitioner(); + } + private: void @@ -279,42 +285,6 @@ private: -template -class MGTransferPrebuiltMF - : public MGTransferMatrixFree -{ -public: - MGTransferPrebuiltMF(const MGLevelObject &laplace, - const MGConstrainedDoFs & mg_constrained_dofs) - : MGTransferMatrixFree( - mg_constrained_dofs) - , laplace_operator(laplace){}; - - /** - * Overload copy_to_mg from MGTransferPrebuilt to get the vectors compatible - * with MatrixFree and bypass the crude initialization in MGTransferPrebuilt - */ - template - void - copy_to_mg( - const DoFHandler &mg_dof, - MGLevelObject< - LinearAlgebra::distributed::Vector> &dst, - const InVector &src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - laplace_operator[level].initialize_dof_vector(dst[level]); - MGLevelGlobalTransfer>::copy_to_mg(mg_dof, dst, src); - } - -private: - const MGLevelObject &laplace_operator; -}; - - - template class MGCoarseIterative : public MGCoarseGridBase> @@ -382,9 +352,14 @@ do_test(const DoFHandler &dof) mg_constrained_dofs.initialize(dof); mg_constrained_dofs.make_zero_boundary_constraints(dof, {0}); - MGTransferPrebuiltMF mg_transfer(mg_matrices, - mg_constrained_dofs); - mg_transfer.build(dof); + std::vector> partitioners; + for (unsigned int level = mg_matrices.min_level(); + level <= mg_matrices.max_level(); + ++level) + partitioners.push_back(mg_matrices[level].get_vector_partitioner()); + + MGTransferMatrixFree mg_transfer(mg_constrained_dofs); + mg_transfer.build(dof, partitioners); MGCoarseIterative mg_coarse; mg_coarse.initialize(mg_matrices[0]); @@ -422,7 +397,7 @@ do_test(const DoFHandler &dof) mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother); PreconditionMG, - MGTransferPrebuiltMF> + MGTransferMatrixFree> preconditioner(dof, mg, mg_transfer); { diff --git a/tests/matrix_free/parallel_multigrid_interleave.cc b/tests/matrix_free/parallel_multigrid_interleave.cc index 8e85f40c4a..b8de2d3c4f 100644 --- a/tests/matrix_free/parallel_multigrid_interleave.cc +++ b/tests/matrix_free/parallel_multigrid_interleave.cc @@ -220,6 +220,12 @@ public: return inverse_diagonal_entries; } + const std::shared_ptr & + get_vector_partitioner() const + { + return data.get_vector_partitioner(); + } + private: void @@ -300,42 +306,6 @@ private: -template -class MGTransferPrebuiltMF - : public MGTransferMatrixFree -{ -public: - MGTransferPrebuiltMF(const MGLevelObject &laplace, - const MGConstrainedDoFs & mg_constrained_dofs) - : MGTransferMatrixFree( - mg_constrained_dofs) - , laplace_operator(laplace){}; - - /** - * Overload copy_to_mg from MGTransferPrebuilt to get the vectors compatible - * with MatrixFree and bypass the crude initialization in MGTransferPrebuilt - */ - template - void - copy_to_mg( - const DoFHandler &mg_dof, - MGLevelObject< - LinearAlgebra::distributed::Vector> &dst, - const InVector &src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - laplace_operator[level].initialize_dof_vector(dst[level]); - MGLevelGlobalTransfer>::copy_to_mg(mg_dof, dst, src); - } - -private: - const MGLevelObject &laplace_operator; -}; - - - template void do_test(const DoFHandler &dof) @@ -383,9 +353,14 @@ do_test(const DoFHandler &dof) mg_constrained_dofs.initialize(dof); mg_constrained_dofs.make_zero_boundary_constraints(dof, {0}); - MGTransferPrebuiltMF mg_transfer(mg_matrices, - mg_constrained_dofs); - mg_transfer.build(dof); + std::vector> partitioners; + for (unsigned int level = mg_matrices.min_level(); + level <= mg_matrices.max_level(); + ++level) + partitioners.push_back(mg_matrices[level].get_vector_partitioner()); + + MGTransferMatrixFree mg_transfer(mg_constrained_dofs); + mg_transfer.build(dof, partitioners); using SMOOTHER = PreconditionChebyshev &dof) mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother); PreconditionMG, - MGTransferPrebuiltMF> + MGTransferMatrixFree> preconditioner(dof, mg, mg_transfer); { diff --git a/tests/matrix_free/parallel_multigrid_interleave_renumber.cc b/tests/matrix_free/parallel_multigrid_interleave_renumber.cc index 96c27dcfda..dbf5f7e122 100644 --- a/tests/matrix_free/parallel_multigrid_interleave_renumber.cc +++ b/tests/matrix_free/parallel_multigrid_interleave_renumber.cc @@ -261,6 +261,12 @@ public: return inverse_diagonal_entries; } + const std::shared_ptr & + get_vector_partitioner() const + { + return data.get_vector_partitioner(); + } + private: void @@ -341,42 +347,6 @@ private: -template -class MGTransferPrebuiltMF - : public MGTransferMatrixFree -{ -public: - MGTransferPrebuiltMF(const MGLevelObject &laplace, - const MGConstrainedDoFs & mg_constrained_dofs) - : MGTransferMatrixFree( - mg_constrained_dofs) - , laplace_operator(laplace){}; - - /** - * Overload copy_to_mg from MGTransferPrebuilt to get the vectors compatible - * with MatrixFree and bypass the crude initialization in MGTransferPrebuilt - */ - template - void - copy_to_mg( - const DoFHandler &mg_dof, - MGLevelObject< - LinearAlgebra::distributed::Vector> &dst, - const InVector &src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - laplace_operator[level].initialize_dof_vector(dst[level]); - MGLevelGlobalTransfer>::copy_to_mg(mg_dof, dst, src); - } - -private: - const MGLevelObject &laplace_operator; -}; - - - template void do_test(DoFHandler &dof) @@ -424,9 +394,14 @@ do_test(DoFHandler &dof) mg_constrained_dofs.initialize(dof); mg_constrained_dofs.make_zero_boundary_constraints(dof, {0}); - MGTransferPrebuiltMF mg_transfer(mg_matrices, - mg_constrained_dofs); - mg_transfer.build(dof); + std::vector> partitioners; + for (unsigned int level = mg_matrices.min_level(); + level <= mg_matrices.max_level(); + ++level) + partitioners.push_back(mg_matrices[level].get_vector_partitioner()); + + MGTransferMatrixFree mg_transfer(mg_constrained_dofs); + mg_transfer.build(dof, partitioners); using SMOOTHER = PreconditionChebyshev &dof) mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother); PreconditionMG, - MGTransferPrebuiltMF> + MGTransferMatrixFree> preconditioner(dof, mg, mg_transfer); { diff --git a/tests/matrix_free/parallel_multigrid_mf.cc b/tests/matrix_free/parallel_multigrid_mf.cc index ba94935293..f5aca044ba 100644 --- a/tests/matrix_free/parallel_multigrid_mf.cc +++ b/tests/matrix_free/parallel_multigrid_mf.cc @@ -196,6 +196,12 @@ public: return inverse_diagonal_entries; } + const std::shared_ptr & + get_vector_partitioner() const + { + return data.get_vector_partitioner(); + } + private: void @@ -274,42 +280,6 @@ private: -template -class MGTransferPrebuiltMF - : public MGTransferMatrixFree -{ -public: - MGTransferPrebuiltMF(const MGLevelObject &laplace, - const MGConstrainedDoFs & mg_constrained_dofs) - : MGTransferMatrixFree( - mg_constrained_dofs) - , laplace_operator(laplace){}; - - /** - * Overload copy_to_mg from MGTransferPrebuilt to get the vectors compatible - * with MatrixFree and bypass the crude initialization in MGTransferPrebuilt - */ - template - void - copy_to_mg( - const DoFHandler &mg_dof, - MGLevelObject< - LinearAlgebra::distributed::Vector> &dst, - const InVector &src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - laplace_operator[level].initialize_dof_vector(dst[level]); - MGLevelGlobalTransfer>::copy_to_mg(mg_dof, dst, src); - } - -private: - const MGLevelObject &laplace_operator; -}; - - - template class MGCoarseIterative : public MGCoarseGridBase> @@ -377,9 +347,14 @@ do_test(const DoFHandler &dof) mg_constrained_dofs.initialize(dof); mg_constrained_dofs.make_zero_boundary_constraints(dof, {0}); - MGTransferPrebuiltMF mg_transfer(mg_matrices, - mg_constrained_dofs); - mg_transfer.build(dof); + std::vector> partitioners; + for (unsigned int level = mg_matrices.min_level(); + level <= mg_matrices.max_level(); + ++level) + partitioners.push_back(mg_matrices[level].get_vector_partitioner()); + + MGTransferMatrixFree mg_transfer(mg_constrained_dofs); + mg_transfer.build(dof, partitioners); MGCoarseIterative mg_coarse; mg_coarse.initialize(mg_matrices[0]); @@ -417,7 +392,7 @@ do_test(const DoFHandler &dof) mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother); PreconditionMG, - MGTransferPrebuiltMF> + MGTransferMatrixFree> preconditioner(dof, mg, mg_transfer); { diff --git a/tests/performance/timing_step_37.cc b/tests/performance/timing_step_37.cc index ef03bb8639..bbfd99a1d3 100644 --- a/tests/performance/timing_step_37.cc +++ b/tests/performance/timing_step_37.cc @@ -265,41 +265,6 @@ LaplaceOperator::local_compute_diagonal( -template -class MGTransferMF - : public MGTransferMatrixFree -{ -public: - void - setup(const MGLevelObject &laplace, - const MGConstrainedDoFs & mg_constrained_dofs) - { - this->MGTransferMatrixFree:: - initialize_constraints(mg_constrained_dofs); - laplace_operator = &laplace; - } - - template - void - copy_to_mg( - const DoFHandler &mg_dof, - MGLevelObject< - LinearAlgebra::distributed::Vector> &dst, - const InVector &src) const - { - for (unsigned int level = dst.min_level(); level <= dst.max_level(); - ++level) - (*laplace_operator)[level].initialize_dof_vector(dst[level]); - MGLevelGlobalTransfer>::copy_to_mg(mg_dof, dst, src); - } - -private: - const MGLevelObject *laplace_operator; -}; - - - template class LaplaceProblem { @@ -343,7 +308,8 @@ private: LinearAlgebra::distributed::Vector solution; LinearAlgebra::distributed::Vector system_rhs; - MGTransferMF mg_transfer; + MGTransferMatrixFree> + mg_transfer; using SmootherType = PreconditionChebyshev void LaplaceProblem::setup_transfer() { - mg_transfer.setup(mg_matrices, mg_constrained_dofs); + mg_transfer.initialize_constraints(mg_constrained_dofs); std::vector> partitioners( dof_handler.get_triangulation().n_global_levels()); for (unsigned int level = 0; level < partitioners.size(); ++level) @@ -601,9 +567,10 @@ LaplaceProblem::solve() mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother); mg.set_edge_matrices(mg_interface, mg_interface); - PreconditionMG, - MGTransferMF> + PreconditionMG< + dim, + LinearAlgebra::distributed::Vector, + MGTransferMatrixFree>> preconditioner(dof_handler, mg, mg_transfer);