#include <deal.II/multigrid/mg_matrix.h>
#include <deal.II/multigrid/mg_smoother.h>
#include <deal.II/multigrid/mg_tools.h>
-#include <deal.II/multigrid/mg_transfer.h>
+#include <deal.II/multigrid/mg_transfer_matrix_free.h>
#include <deal.II/multigrid/multigrid.h>
#include <deal.II/numerics/vector_tools.h>
return inverse_diagonal_entries;
}
+ const std::shared_ptr<const Utilities::MPI::Partitioner> &
+ get_vector_partitioner() const
+ {
+ return data.get_vector_partitioner();
+ }
+
private:
void
-template <typename LAPLACEOPERATOR>
-class MGTransferMF
- : public MGTransferPrebuilt<
- LinearAlgebra::distributed::Vector<typename LAPLACEOPERATOR::value_type>>
-{
-public:
- MGTransferMF(const MGLevelObject<LAPLACEOPERATOR> &laplace)
- : laplace_operator(laplace){};
-
- /**
- * Overload copy_to_mg from MGTransferPrebuilt
- */
- template <int dim, class InVector, int spacedim>
- void
- copy_to_mg(const DoFHandler<dim, spacedim> & mg_dof,
- MGLevelObject<LinearAlgebra::distributed::Vector<
- typename LAPLACEOPERATOR::value_type>> &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<LinearAlgebra::distributed::Vector<
- typename LAPLACEOPERATOR::value_type>>::copy_to_mg(mg_dof, dst, src);
- }
-
-private:
- const MGLevelObject<LAPLACEOPERATOR> &laplace_operator;
-};
-
-
-
template <int dim, typename number>
void
do_test(const DoFHandler<dim> &dof, const unsigned int n_q_points_1d)
}
mg_smoother.initialize(mg_matrices, smoother_data);
- MGTransferMF<LevelMatrixType> mg_transfer(mg_matrices);
- mg_transfer.build(dof);
+ std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> 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<dim, double> mg_transfer;
+ mg_transfer.build(dof, partitioners);
mg::Matrix<LinearAlgebra::distributed::Vector<double>> mg_matrix(mg_matrices);
mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother);
PreconditionMG<dim,
LinearAlgebra::distributed::Vector<double>,
- MGTransferMF<LevelMatrixType>>
+ MGTransferMatrixFree<dim, double>>
preconditioner(dof, mg, mg_transfer);
{
-template <int dim, typename LAPLACEOPERATOR>
-class MGTransferMF
- : public MGTransferMatrixFree<dim, typename LAPLACEOPERATOR::value_type>
-{
-public:
- MGTransferMF(const MGLevelObject<LAPLACEOPERATOR> &laplace,
- const MGConstrainedDoFs & mg_constrained_dofs)
- : MGTransferMatrixFree<dim, typename LAPLACEOPERATOR::value_type>(
- mg_constrained_dofs)
- , laplace_operator(laplace){};
-
- /**
- * Overload copy_to_mg from MGTransferPrebuilt
- */
- template <class InVector, int spacedim>
- void
- copy_to_mg(const DoFHandler<dim, spacedim> & mg_dof_handler,
- MGLevelObject<LinearAlgebra::distributed::Vector<
- typename LAPLACEOPERATOR::value_type>> &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<dim, typename LAPLACEOPERATOR::value_type>::copy_to_mg(
- mg_dof_handler, dst, src);
- }
-
-private:
- const MGLevelObject<LAPLACEOPERATOR> &laplace_operator;
-};
-
-
-
template <int dim, typename number>
void
do_test(const DoFHandler<dim> &dof, const unsigned n_q_points_1d)
return inverse_diagonal_entries;
}
+ const std::shared_ptr<const Utilities::MPI::Partitioner> &
+ get_vector_partitioner() const
+ {
+ return data.get_vector_partitioner();
+ }
+
private:
void
-template <int dim, typename LAPLACEOPERATOR>
-class MGTransferMF
- : public MGTransferMatrixFree<dim, typename LAPLACEOPERATOR::value_type>
-{
-public:
- MGTransferMF(const MGLevelObject<LAPLACEOPERATOR> &laplace,
- const MGConstrainedDoFs & mg_constrained_dofs)
- : MGTransferMatrixFree<dim, typename LAPLACEOPERATOR::value_type>(
- mg_constrained_dofs)
- , laplace_operator(laplace){};
-
- /**
- * Overload copy_to_mg from MGTransferPrebuilt
- */
- template <class InVector, int spacedim>
- void
- copy_to_mg(const DoFHandler<dim, spacedim> & mg_dof_handler,
- MGLevelObject<LinearAlgebra::distributed::Vector<
- typename LAPLACEOPERATOR::value_type>> &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<dim, typename LAPLACEOPERATOR::value_type>::copy_to_mg(
- mg_dof_handler, dst, src);
- }
-
-private:
- const MGLevelObject<LAPLACEOPERATOR> &laplace_operator;
-};
-
-
-
template <int dim, typename number>
void
do_test(const DoFHandler<dim> &dof, const unsigned int n_q_points_1d)
mg_constrained_dofs.initialize(dof);
mg_constrained_dofs.make_zero_boundary_constraints(dof, {0});
- MGTransferMF<dim, LevelMatrixType> mg_transfer(mg_matrices,
- mg_constrained_dofs);
- mg_transfer.build(dof);
+ std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> 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<dim, double> mg_transfer(mg_constrained_dofs);
+ mg_transfer.build(dof, partitioners);
mg::Matrix<LinearAlgebra::distributed::Vector<double>> mg_matrix(mg_matrices);
mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother);
PreconditionMG<dim,
LinearAlgebra::distributed::Vector<double>,
- MGTransferMF<dim, LevelMatrixType>>
+ MGTransferMatrixFree<dim, double>>
preconditioner(dof, mg, mg_transfer);
{
#include <deal.II/multigrid/mg_matrix.h>
#include <deal.II/multigrid/mg_smoother.h>
#include <deal.II/multigrid/mg_tools.h>
-#include <deal.II/multigrid/mg_transfer.h>
+#include <deal.II/multigrid/mg_transfer_matrix_free.h>
#include <deal.II/multigrid/multigrid.h>
#include <deal.II/numerics/vector_tools.h>
return inverse_diagonal_entries;
}
+ const std::shared_ptr<const Utilities::MPI::Partitioner> &
+ get_vector_partitioner() const
+ {
+ return data.get_vector_partitioner();
+ }
+
private:
void
-template <typename MatrixType>
-class MGTransferPrebuiltMF
- : public MGTransferPrebuilt<LinearAlgebra::distributed::Vector<double>>
-{
-public:
- MGTransferPrebuiltMF(const MGLevelObject<MatrixType> &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 <int dim, class InVector, int spacedim>
- void
- copy_to_mg(const DoFHandler<dim, spacedim> & mg_dof,
- MGLevelObject<LinearAlgebra::distributed::Vector<double>> &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<LinearAlgebra::distributed::Vector<double>>::copy_to_mg(
- mg_dof, dst, src);
- }
-
-private:
- const MGLevelObject<MatrixType> &laplace_operator;
-};
-
-
-
template <typename MatrixType, typename Number>
class MGCoarseIterative
: public MGCoarseGridBase<LinearAlgebra::distributed::Vector<Number>>
mg_matrices[level].initialize(mapping, dof, dirichlet_boundaries, level);
}
- MGTransferPrebuiltMF<LevelMatrixType> mg_transfer(mg_matrices);
- mg_transfer.build(dof);
+ std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> 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<dim, double> mg_transfer;
+ mg_transfer.build(dof, partitioners);
MGCoarseIterative<LevelMatrixType, number> mg_coarse;
mg_coarse.initialize(mg_matrices[0]);
mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother);
PreconditionMG<dim,
LinearAlgebra::distributed::Vector<double>,
- MGTransferPrebuiltMF<LevelMatrixType>>
+ MGTransferMatrixFree<dim, double>>
preconditioner(dof, mg, mg_transfer);
{
#include <deal.II/multigrid/mg_matrix.h>
#include <deal.II/multigrid/mg_smoother.h>
#include <deal.II/multigrid/mg_tools.h>
-#include <deal.II/multigrid/mg_transfer.h>
+#include <deal.II/multigrid/mg_transfer_matrix_free.h>
#include <deal.II/multigrid/multigrid.h>
#include <deal.II/numerics/vector_tools.h>
return inverse_diagonal_entries;
}
+ const std::shared_ptr<const Utilities::MPI::Partitioner> &
+ get_vector_partitioner() const
+ {
+ return data.get_vector_partitioner();
+ }
+
private:
void
-template <typename LAPLACEOPERATOR>
-class MGTransferMF
- : public MGTransferPrebuilt<LinearAlgebra::distributed::Vector<double>>
-{
-public:
- MGTransferMF(const MGLevelObject<LAPLACEOPERATOR> &laplace,
- const MGConstrainedDoFs & mg_constrained_dofs)
- : MGTransferPrebuilt<LinearAlgebra::distributed::Vector<double>>(
- 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 <int dim, class InVector, int spacedim>
- void
- copy_to_mg(const DoFHandler<dim, spacedim> &mg_dof_handler,
- MGLevelObject<LinearAlgebra::distributed::Vector<double>> &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<LinearAlgebra::distributed::Vector<double>>::copy_to_mg(
- mg_dof_handler, dst, src);
- }
-
-private:
- const MGLevelObject<LAPLACEOPERATOR> &laplace_operator;
-};
-
-
-
template <typename MatrixType, typename Number>
class MGCoarseIterative
: public MGCoarseGridBase<LinearAlgebra::distributed::Vector<Number>>
++level)
mg_interface_matrices[level].initialize(mg_matrices[level]);
- MGTransferMF<LevelMatrixType> mg_transfer(mg_matrices, mg_constrained_dofs);
- mg_transfer.build(dof);
+ std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> 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<dim, double> mg_transfer(mg_constrained_dofs);
+ mg_transfer.build(dof, partitioners);
MGCoarseIterative<LevelMatrixType, number> mg_coarse;
mg_coarse.initialize(mg_matrices[0]);
mg.set_edge_matrices(mg_interface, mg_interface);
PreconditionMG<dim,
LinearAlgebra::distributed::Vector<double>,
- MGTransferMF<LevelMatrixType>>
+ MGTransferMatrixFree<dim, double>>
preconditioner(dof, mg, mg_transfer);
{
using namespace dealii::MatrixFreeOperators;
-template <int dim, typename LAPLACEOPERATOR>
-class MGTransferMF
- : public MGTransferMatrixFree<dim, typename LAPLACEOPERATOR::value_type>
-{
-public:
- MGTransferMF(const MGLevelObject<LAPLACEOPERATOR> &laplace,
- const MGConstrainedDoFs & mg_constrained_dofs)
- : MGTransferMatrixFree<dim, typename LAPLACEOPERATOR::value_type>(
- 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 <class InVector, int spacedim>
- void
- copy_to_mg(const DoFHandler<dim, spacedim> & mg_dof_handler,
- MGLevelObject<LinearAlgebra::distributed::Vector<
- typename LAPLACEOPERATOR::value_type>> &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<dim, typename LAPLACEOPERATOR::value_type>::copy_to_mg(
- mg_dof_handler, dst, src);
- }
-
-private:
- const MGLevelObject<LAPLACEOPERATOR> &laplace_operator;
-};
-
-
-
template <typename MatrixType, typename Number>
class MGCoarseIterative
: public MGCoarseGridBase<LinearAlgebra::distributed::Vector<Number>>
++level)
mg_interface_matrices[level].initialize(mg_matrices[level]);
- MGTransferMF<dim, LevelMatrixType> mg_transfer(mg_matrices,
- mg_constrained_dofs);
- mg_transfer.build(dof);
+ std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> 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<dim, double> mg_transfer(mg_constrained_dofs);
+ mg_transfer.build(dof, partitioners);
MGCoarseIterative<LevelMatrixType, number> mg_coarse;
mg_coarse.initialize(mg_matrices[0]);
mg.set_edge_matrices(mg_interface, mg_interface);
PreconditionMG<dim,
LinearAlgebra::distributed::Vector<double>,
- MGTransferMF<dim, LevelMatrixType>>
+ MGTransferMatrixFree<dim, double>>
preconditioner(dof, mg, mg_transfer);
{
return inverse_diagonal_entries;
}
+ const std::shared_ptr<const Utilities::MPI::Partitioner> &
+ get_vector_partitioner() const
+ {
+ return data.get_vector_partitioner();
+ }
+
private:
void
-template <int dim, typename LAPLACEOPERATOR>
-class MGTransferMF
- : public MGTransferMatrixFree<dim, typename LAPLACEOPERATOR::value_type>
-{
-public:
- MGTransferMF(const MGLevelObject<LAPLACEOPERATOR> &laplace,
- const MGConstrainedDoFs & mg_constrained_dofs)
- : MGTransferMatrixFree<dim, typename LAPLACEOPERATOR::value_type>(
- 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 <class InVector, int spacedim>
- void
- copy_to_mg(const DoFHandler<dim, spacedim> & mg_dof_handler,
- MGLevelObject<LinearAlgebra::distributed::Vector<
- typename LAPLACEOPERATOR::value_type>> &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<LinearAlgebra::distributed::Vector<
- typename LAPLACEOPERATOR::value_type>>::copy_to_mg(mg_dof_handler,
- dst,
- src);
- }
-
-private:
- const MGLevelObject<LAPLACEOPERATOR> &laplace_operator;
-};
-
-
-
template <typename MatrixType, typename Number>
class MGCoarseIterative
: public MGCoarseGridBase<LinearAlgebra::distributed::Vector<Number>>
++level)
mg_interface_matrices[level].initialize(mg_matrices[level]);
- MGTransferMF<dim, LevelMatrixType> mg_transfer(mg_matrices,
- mg_constrained_dofs);
- mg_transfer.build(dof);
+ std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> 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<dim, number> mg_transfer(mg_constrained_dofs);
+ mg_transfer.build(dof, partitioners);
MGCoarseIterative<LevelMatrixType, number> mg_coarse;
mg_coarse.initialize(mg_matrices[0]);
mg.set_edge_matrices(mg_interface, mg_interface);
PreconditionMG<dim,
LinearAlgebra::distributed::Vector<number>,
- MGTransferMF<dim, LevelMatrixType>>
+ MGTransferMatrixFree<dim, number>>
preconditioner(dof, mg, mg_transfer);
{
using namespace dealii::MatrixFreeOperators;
-template <int dim, typename LAPLACEOPERATOR>
-class MGTransferMF
- : public MGTransferMatrixFree<dim, typename LAPLACEOPERATOR::value_type>
-{
-public:
- MGTransferMF(const MGLevelObject<LAPLACEOPERATOR> &laplace,
- const MGConstrainedDoFs & mg_constrained_dofs)
- : MGTransferMatrixFree<dim, typename LAPLACEOPERATOR::value_type>(
- 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 <class InVector, int spacedim>
- void
- copy_to_mg(const DoFHandler<dim, spacedim> & mg_dof_handler,
- MGLevelObject<LinearAlgebra::distributed::Vector<
- typename LAPLACEOPERATOR::value_type>> &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<dim, typename LAPLACEOPERATOR::value_type>::copy_to_mg(
- mg_dof_handler, dst, src);
- }
-
-private:
- const MGLevelObject<LAPLACEOPERATOR> &laplace_operator;
-};
-
-
-
template <typename MatrixType, typename Number>
class MGCoarseIterative
: public MGCoarseGridBase<LinearAlgebra::distributed::Vector<Number>>
++level)
mg_interface_matrices[level].initialize(mg_matrices[level]);
- MGTransferMF<dim, LevelMatrixType> mg_transfer(mg_matrices,
- mg_constrained_dofs);
- mg_transfer.build(dof);
+ std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> 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<dim, double> mg_transfer(mg_constrained_dofs);
+ mg_transfer.build(dof, partitioners);
MGCoarseIterative<LevelMatrixType, number> mg_coarse;
mg_coarse.initialize(mg_matrices[0]);
mg.set_edge_matrices(mg_interface, mg_interface);
PreconditionMG<dim,
LinearAlgebra::distributed::Vector<double>,
- MGTransferMF<dim, LevelMatrixType>>
+ MGTransferMatrixFree<dim, double>>
preconditioner(dof, mg, mg_transfer);
{
return inverse_diagonal_entries;
}
+ const std::shared_ptr<const Utilities::MPI::Partitioner> &
+ get_vector_partitioner() const
+ {
+ return data.get_vector_partitioner();
+ }
+
private:
void
-template <int dim, typename LAPLACEOPERATOR>
-class MGTransferMF
- : public MGTransferMatrixFree<dim, typename LAPLACEOPERATOR::value_type>
-{
-public:
- MGTransferMF(const MGLevelObject<LAPLACEOPERATOR> &laplace,
- const MGConstrainedDoFs & mg_constrained_dofs)
- : MGTransferMatrixFree<dim, typename LAPLACEOPERATOR::value_type>(
- 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 <class InVector, int spacedim>
- void
- copy_to_mg(const DoFHandler<dim, spacedim> & mg_dof_handler,
- MGLevelObject<LinearAlgebra::distributed::Vector<
- typename LAPLACEOPERATOR::value_type>> &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<LinearAlgebra::distributed::Vector<
- typename LAPLACEOPERATOR::value_type>>::copy_to_mg(mg_dof_handler,
- dst,
- src);
- }
-
-private:
- const MGLevelObject<LAPLACEOPERATOR> &laplace_operator;
-};
-
-
-
template <typename MatrixType, typename Number>
class MGCoarseIterative
: public MGCoarseGridBase<LinearAlgebra::distributed::Vector<Number>>
++level)
mg_interface_matrices[level].initialize(mg_matrices[level]);
- MGTransferMF<dim, LevelMatrixType> mg_transfer(mg_matrices,
- mg_constrained_dofs);
- mg_transfer.build(dof);
+ std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> 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<dim, double> mg_transfer(mg_constrained_dofs);
+ mg_transfer.build(dof, partitioners);
MGCoarseIterative<LevelMatrixType, number> mg_coarse;
mg_coarse.initialize(mg_matrices[0]);
mg.set_edge_matrices(mg_interface, mg_interface);
PreconditionMG<dim,
LinearAlgebra::distributed::Vector<number>,
- MGTransferMF<dim, LevelMatrixType>>
+ MGTransferMatrixFree<dim, double>>
preconditioner(dof, mg, mg_transfer);
{
using namespace dealii::MatrixFreeOperators;
-template <int dim, typename LAPLACEOPERATOR>
-class MGTransferMF
- : public MGTransferMatrixFree<dim, typename LAPLACEOPERATOR::value_type>
-{
-public:
- MGTransferMF(const MGLevelObject<LAPLACEOPERATOR> &laplace,
- const MGConstrainedDoFs & mg_constrained_dofs)
- : MGTransferMatrixFree<dim, typename LAPLACEOPERATOR::value_type>(
- 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 <class InVector, int spacedim>
- void
- copy_to_mg(const DoFHandler<dim, spacedim> & mg_dof_handler,
- MGLevelObject<LinearAlgebra::distributed::Vector<
- typename LAPLACEOPERATOR::value_type>> &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<dim, typename LAPLACEOPERATOR::value_type>::copy_to_mg(
- mg_dof_handler, dst, src);
- }
-
-private:
- const MGLevelObject<LAPLACEOPERATOR> &laplace_operator;
-};
-
-
-
template <typename MatrixType, typename Number>
class MGCoarseIterative
: public MGCoarseGridBase<LinearAlgebra::distributed::Vector<Number>>
++level)
mg_interface_matrices[level].initialize(mg_matrices[level]);
- MGTransferMF<dim, LevelMatrixType> mg_transfer(mg_matrices,
- mg_constrained_dofs);
- mg_transfer.build(dof);
+ std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> 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<dim, double> mg_transfer(mg_constrained_dofs);
+ mg_transfer.build(dof, partitioners);
MGCoarseIterative<LevelMatrixType, number> mg_coarse;
mg_coarse.initialize(mg_matrices[0]);
mg.set_edge_matrices(mg_interface, mg_interface);
PreconditionMG<dim,
LinearAlgebra::distributed::Vector<double>,
- MGTransferMF<dim, LevelMatrixType>>
+ MGTransferMatrixFree<dim, double>>
preconditioner(dof, mg, mg_transfer);
{
return inverse_diagonal_entries;
}
+ const std::shared_ptr<const Utilities::MPI::Partitioner> &
+ get_vector_partitioner() const
+ {
+ return data.get_vector_partitioner();
+ }
+
private:
void
-template <int dim, typename MatrixType>
-class MGTransferPrebuiltMF
- : public MGTransferMatrixFree<dim, typename MatrixType::value_type>
-{
-public:
- MGTransferPrebuiltMF(const MGLevelObject<MatrixType> &laplace,
- const MGConstrainedDoFs & mg_constrained_dofs)
- : MGTransferMatrixFree<dim, typename MatrixType::value_type>(
- 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 <class InVector, int spacedim>
- void
- copy_to_mg(
- const DoFHandler<dim, spacedim> &mg_dof,
- MGLevelObject<
- LinearAlgebra::distributed::Vector<typename MatrixType::value_type>> &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<LinearAlgebra::distributed::Vector<
- typename MatrixType::value_type>>::copy_to_mg(mg_dof, dst, src);
- }
-
-private:
- const MGLevelObject<MatrixType> &laplace_operator;
-};
-
-
-
template <typename MatrixType, typename Number>
class MGCoarseIterative
: public MGCoarseGridBase<LinearAlgebra::distributed::Vector<Number>>
mg_constrained_dofs.initialize(dof);
mg_constrained_dofs.make_zero_boundary_constraints(dof, {0});
- MGTransferPrebuiltMF<dim, LevelMatrixType> mg_transfer(mg_matrices,
- mg_constrained_dofs);
- mg_transfer.build(dof);
+ std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> 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<dim, number> mg_transfer(mg_constrained_dofs);
+ mg_transfer.build(dof, partitioners);
MGCoarseIterative<LevelMatrixType, number> mg_coarse;
mg_coarse.initialize(mg_matrices[0]);
mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother);
PreconditionMG<dim,
LinearAlgebra::distributed::Vector<number>,
- MGTransferPrebuiltMF<dim, LevelMatrixType>>
+ MGTransferMatrixFree<dim, number>>
preconditioner(dof, mg, mg_transfer);
{
return inverse_diagonal_entries;
}
+ const std::shared_ptr<const Utilities::MPI::Partitioner> &
+ get_vector_partitioner() const
+ {
+ return data.get_vector_partitioner();
+ }
+
private:
void
-template <int dim, typename MatrixType>
-class MGTransferPrebuiltMF
- : public MGTransferMatrixFree<dim, typename MatrixType::value_type>
-{
-public:
- MGTransferPrebuiltMF(const MGLevelObject<MatrixType> &laplace,
- const MGConstrainedDoFs & mg_constrained_dofs)
- : MGTransferMatrixFree<dim, typename MatrixType::value_type>(
- 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 <class InVector, int spacedim>
- void
- copy_to_mg(
- const DoFHandler<dim, spacedim> &mg_dof,
- MGLevelObject<
- LinearAlgebra::distributed::Vector<typename MatrixType::value_type>> &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<LinearAlgebra::distributed::Vector<
- typename MatrixType::value_type>>::copy_to_mg(mg_dof, dst, src);
- }
-
-private:
- const MGLevelObject<MatrixType> &laplace_operator;
-};
-
-
-
template <int dim, typename number>
void
do_test(const DoFHandler<dim> &dof)
mg_constrained_dofs.initialize(dof);
mg_constrained_dofs.make_zero_boundary_constraints(dof, {0});
- MGTransferPrebuiltMF<dim, LevelMatrixType> mg_transfer(mg_matrices,
- mg_constrained_dofs);
- mg_transfer.build(dof);
+ std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> 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<dim, number> mg_transfer(mg_constrained_dofs);
+ mg_transfer.build(dof, partitioners);
using SMOOTHER =
PreconditionChebyshev<LevelMatrixType,
mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother);
PreconditionMG<dim,
LinearAlgebra::distributed::Vector<number>,
- MGTransferPrebuiltMF<dim, LevelMatrixType>>
+ MGTransferMatrixFree<dim, number>>
preconditioner(dof, mg, mg_transfer);
{
return inverse_diagonal_entries;
}
+ const std::shared_ptr<const Utilities::MPI::Partitioner> &
+ get_vector_partitioner() const
+ {
+ return data.get_vector_partitioner();
+ }
+
private:
void
-template <int dim, typename MatrixType>
-class MGTransferPrebuiltMF
- : public MGTransferMatrixFree<dim, typename MatrixType::value_type>
-{
-public:
- MGTransferPrebuiltMF(const MGLevelObject<MatrixType> &laplace,
- const MGConstrainedDoFs & mg_constrained_dofs)
- : MGTransferMatrixFree<dim, typename MatrixType::value_type>(
- 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 <class InVector, int spacedim>
- void
- copy_to_mg(
- const DoFHandler<dim, spacedim> &mg_dof,
- MGLevelObject<
- LinearAlgebra::distributed::Vector<typename MatrixType::value_type>> &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<LinearAlgebra::distributed::Vector<
- typename MatrixType::value_type>>::copy_to_mg(mg_dof, dst, src);
- }
-
-private:
- const MGLevelObject<MatrixType> &laplace_operator;
-};
-
-
-
template <int dim, typename number>
void
do_test(DoFHandler<dim> &dof)
mg_constrained_dofs.initialize(dof);
mg_constrained_dofs.make_zero_boundary_constraints(dof, {0});
- MGTransferPrebuiltMF<dim, LevelMatrixType> mg_transfer(mg_matrices,
- mg_constrained_dofs);
- mg_transfer.build(dof);
+ std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> 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<dim, number> mg_transfer(mg_constrained_dofs);
+ mg_transfer.build(dof, partitioners);
using SMOOTHER =
PreconditionChebyshev<LevelMatrixType,
mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother);
PreconditionMG<dim,
LinearAlgebra::distributed::Vector<number>,
- MGTransferPrebuiltMF<dim, LevelMatrixType>>
+ MGTransferMatrixFree<dim, number>>
preconditioner(dof, mg, mg_transfer);
{
return inverse_diagonal_entries;
}
+ const std::shared_ptr<const Utilities::MPI::Partitioner> &
+ get_vector_partitioner() const
+ {
+ return data.get_vector_partitioner();
+ }
+
private:
void
-template <int dim, typename MatrixType>
-class MGTransferPrebuiltMF
- : public MGTransferMatrixFree<dim, typename MatrixType::value_type>
-{
-public:
- MGTransferPrebuiltMF(const MGLevelObject<MatrixType> &laplace,
- const MGConstrainedDoFs & mg_constrained_dofs)
- : MGTransferMatrixFree<dim, typename MatrixType::value_type>(
- 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 <class InVector, int spacedim>
- void
- copy_to_mg(
- const DoFHandler<dim, spacedim> &mg_dof,
- MGLevelObject<
- LinearAlgebra::distributed::Vector<typename MatrixType::value_type>> &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<LinearAlgebra::distributed::Vector<
- typename MatrixType::value_type>>::copy_to_mg(mg_dof, dst, src);
- }
-
-private:
- const MGLevelObject<MatrixType> &laplace_operator;
-};
-
-
-
template <typename MatrixType, typename Number>
class MGCoarseIterative
: public MGCoarseGridBase<LinearAlgebra::distributed::Vector<Number>>
mg_constrained_dofs.initialize(dof);
mg_constrained_dofs.make_zero_boundary_constraints(dof, {0});
- MGTransferPrebuiltMF<dim, LevelMatrixType> mg_transfer(mg_matrices,
- mg_constrained_dofs);
- mg_transfer.build(dof);
+ std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> 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<dim, number> mg_transfer(mg_constrained_dofs);
+ mg_transfer.build(dof, partitioners);
MGCoarseIterative<LevelMatrixType, number> mg_coarse;
mg_coarse.initialize(mg_matrices[0]);
mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother);
PreconditionMG<dim,
LinearAlgebra::distributed::Vector<number>,
- MGTransferPrebuiltMF<dim, LevelMatrixType>>
+ MGTransferMatrixFree<dim, number>>
preconditioner(dof, mg, mg_transfer);
{
-template <int dim, typename MatrixType>
-class MGTransferMF
- : public MGTransferMatrixFree<dim, typename MatrixType::value_type>
-{
-public:
- void
- setup(const MGLevelObject<MatrixType> &laplace,
- const MGConstrainedDoFs & mg_constrained_dofs)
- {
- this->MGTransferMatrixFree<dim, typename MatrixType::value_type>::
- initialize_constraints(mg_constrained_dofs);
- laplace_operator = &laplace;
- }
-
- template <class InVector, int spacedim>
- void
- copy_to_mg(
- const DoFHandler<dim, spacedim> &mg_dof,
- MGLevelObject<
- LinearAlgebra::distributed::Vector<typename MatrixType::value_type>> &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<LinearAlgebra::distributed::Vector<
- typename MatrixType::value_type>>::copy_to_mg(mg_dof, dst, src);
- }
-
-private:
- const MGLevelObject<MatrixType> *laplace_operator;
-};
-
-
-
template <int dim>
class LaplaceProblem
{
LinearAlgebra::distributed::Vector<double> solution;
LinearAlgebra::distributed::Vector<double> system_rhs;
- MGTransferMF<dim, LevelMatrixType> mg_transfer;
+ MGTransferMatrixFree<dim, LinearAlgebra::distributed::Vector<float>>
+ mg_transfer;
using SmootherType =
PreconditionChebyshev<LevelMatrixType,
void
LaplaceProblem<dim>::setup_transfer()
{
- mg_transfer.setup(mg_matrices, mg_constrained_dofs);
+ mg_transfer.initialize_constraints(mg_constrained_dofs);
std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>> partitioners(
dof_handler.get_triangulation().n_global_levels());
for (unsigned int level = 0; level < partitioners.size(); ++level)
mg_matrix, mg_coarse, mg_transfer, mg_smoother, mg_smoother);
mg.set_edge_matrices(mg_interface, mg_interface);
- PreconditionMG<dim,
- LinearAlgebra::distributed::Vector<float>,
- MGTransferMF<dim, LevelMatrixType>>
+ PreconditionMG<
+ dim,
+ LinearAlgebra::distributed::Vector<float>,
+ MGTransferMatrixFree<dim, LinearAlgebra::distributed::Vector<float>>>
preconditioner(dof_handler, mg, mg_transfer);