13#ifndef dealii_mg_transfer_matrix_free_h
14#define dealii_mg_transfer_matrix_free_h
45 class MGTwoLevelTransferImplementation;
50 template <
int dim,
typename VectorType>
55 class MGTwoLevelTransferImplementation;
123template <
int dim,
typename VectorType>
136 "This class is currently only implemented for vectors of "
137 "type LinearAlgebra::distributed::Vector.");
176 virtual std::pair<bool, bool>
178 const std::shared_ptr<const Utilities::MPI::Partitioner>
180 const std::shared_ptr<const Utilities::MPI::Partitioner>
193 virtual std::pair<const DoFHandler<dim> *,
unsigned int>
204 template <
int dim,
typename VectorType>
211 using Number =
typename VectorType::value_type;
236 const VectorType &src)
const = 0;
272 template <std::
size_t w
idth,
typename IndexType>
273 std::pair<bool, bool>
275 const std::shared_ptr<const Utilities::MPI::Partitioner>
277 const std::shared_ptr<const Utilities::MPI::Partitioner>
282 &constraint_info_coarse,
283 std::vector<unsigned int> &dof_indices_fine);
317 std::shared_ptr<const Utilities::MPI::Partitioner>
324 std::shared_ptr<const Utilities::MPI::Partitioner>
368template <
int dim,
typename VectorType>
382 "This class is currently only implemented for vectors of "
383 "type LinearAlgebra::distributed::Vector.");
388 using Number =
typename VectorType::value_type;
466 const unsigned int dof_handler_index_fine,
468 const unsigned int dof_handler_index_coarse);
480 const unsigned int fe_degree_coarse);
486 interpolate(VectorType &dst,
const VectorType &src)
const override;
492 std::pair<bool, bool>
494 const std::shared_ptr<const Utilities::MPI::Partitioner>
508 std::pair<const DoFHandler<dim> *,
unsigned int>
514 const VectorType &src)
const override;
518 const VectorType &src)
const override;
590 internal::MatrixFreeFunctions::
591 ConstraintInfo<dim, VectorizedArrayType, types::global_dof_index>
597 internal::MatrixFreeFunctions::
598 ConstraintInfo<dim, VectorizedArrayType, types::global_dof_index>
682 LinearAlgebra::distributed::Vector<Number, MemorySpace::Default>>;
693template <int dim, typename VectorType>
703 "type LinearAlgebra::distributed::Vector. This class should not be used for host vectors since it would perform redundant transfers. Use MGTwoLevelTransfer instead.");
709 using Number =
typename VectorType::value_type;
740 const unsigned int dof_handler_index_fine,
742 const unsigned int dof_handler_index_coarse);
749 const unsigned int fe_degree_coarse);
767 interpolate(VectorType &dst,
const VectorType &src)
const override;
772 std::pair<bool, bool>
774 const std::shared_ptr<const Utilities::MPI::Partitioner>
788 std::pair<const DoFHandler<dim> *,
unsigned int>
819 friend class internal::MGTwoLevelTransferImplementation;
823 typename VectorType::memory_space>;
831template <int dim, typename VectorType>
840 "This class is currently only implemented for vectors of "
841 "type LinearAlgebra::distributed::Vector.");
843 using Number =
typename VectorType::value_type;
923 interpolate(VectorType &dst,
const VectorType &src)
const override;
929 std::pair<bool, bool>
931 const std::shared_ptr<const Utilities::MPI::Partitioner>
945 std::pair<const DoFHandler<dim> *,
unsigned int>
951 boost::signals2::connection
957 boost::signals2::connection
963 boost::signals2::connection
969 boost::signals2::connection
979 const VectorType &src)
const override;
986 const VectorType &src)
const override;
992 template <
int n_components>
995 const VectorType &src)
const;
1000 template <
int n_components>
1039 internal::MatrixFreeFunctions::
1040 ConstraintInfo<dim, VectorizedArrayType, unsigned int>
1063 typename VectorType::memory_space>;
1100template <int dim, typename Number, typename MemorySpace>
1103 LinearAlgebra::distributed::Vector<Number, MemorySpace>>
1132 template <
typename MGTwoLevelTransferObject>
1135 const std::function<
void(
const unsigned int,
VectorType &)>
1141 template <
typename MGTwoLevelTransferObject>
1155 build(
const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
1203 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
1217 const std::function<
void(
const unsigned int,
VectorType &)>
1260 template <
class InVector>
1264 const InVector &src)
const;
1275 template <
class OutVector>
1299 template <
class InVector>
1303 const InVector &src)
const;
1313 template <
class InVector>
1366 std::pair<const DoFHandler<dim> *,
unsigned int>
1381 template <
typename MGTwoLevelTransferObject>
1394 template <
class InVector>
1398 const InVector &vector_reference,
1399 const bool omit_zeroing_entries,
1400 const bool force_same_partitioner =
false)
const;
1427 std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
1436template <
int dim,
typename Number,
typename TransferType>
1438 :
public MGTransferBase<LinearAlgebra::distributed::BlockVector<Number>>
1461 const unsigned int to_level,
1467 const unsigned int to_level,
1491 const unsigned int from_level,
1505 template <
typename BlockVectorType2>
1510 const BlockVectorType2 &src)
const;
1515 template <
typename BlockVectorType2>
1520 const BlockVectorType2 &src)
const;
1525 template <
typename BlockVectorType2>
1529 BlockVectorType2 &dst,
1536 template <
typename BlockVectorType2>
1540 BlockVectorType2 &dst,
1549 virtual const TransferType &
1572template <
int dim,
typename Number>
1577 MGTransferMatrixFree<dim, Number, ::MemorySpace::Host>>
1585 &transfer_operator);
1603 const std::vector<MGConstrainedDoFs> &mg_constrained_dofs);
1616 const std::vector<MGConstrainedDoFs> &mg_constrained_dofs);
1638 std::vector<MGTransferMatrixFree<dim, Number, ::MemorySpace::Host>>
1656template <
int dim,
typename VectorType>
1663 const unsigned int mg_level_fine,
1664 const unsigned int mg_level_coarse)
1666 host_transfer.
reinit(dof_handler_fine,
1674template <
int dim,
typename VectorType>
1677 const MatrixFree<dim, Number> &matrix_free_fine,
1678 const unsigned int dof_handler_index_fine,
1679 const MatrixFree<dim, Number> &matrix_free_coarse,
1680 const unsigned int dof_handler_index_coarse)
1682 host_transfer.
reinit(matrix_free_fine,
1683 dof_handler_index_fine,
1685 dof_handler_index_coarse);
1689template <
int dim,
typename VectorType>
1693 const unsigned int fe_degree_coarse)
1699template <
int dim,
typename VectorType>
1703 const VectorType &src)
const
1705 if (host_vector_coarse.
size() == 0)
1706 host_vector_coarse.
reinit(src.get_partitioner());
1707 if (host_vector_fine.
size() == 0)
1708 host_vector_fine.
reinit(dst.get_partitioner());
1710 copy_to_host(host_vector_fine, dst);
1711 copy_to_host(host_vector_coarse, src);
1715 copy_from_host(dst, host_vector_fine);
1718template <
int dim,
typename VectorType>
1722 const VectorType &src)
const
1724 if (host_vector_coarse.
size() == 0)
1725 host_vector_coarse.
reinit(dst.get_partitioner());
1726 if (host_vector_fine.
size() == 0)
1727 host_vector_fine.
reinit(src.get_partitioner());
1729 copy_to_host(host_vector_coarse, dst);
1730 copy_to_host(host_vector_fine, src);
1734 copy_from_host(dst, host_vector_coarse);
1737template <
int dim,
typename VectorType>
1741 const VectorType &src)
const
1743 if (host_vector_coarse.
size() == 0)
1744 host_vector_coarse.
reinit(dst.get_partitioner());
1745 if (host_vector_fine.
size() == 0)
1746 host_vector_fine.
reinit(src.get_partitioner());
1748 copy_to_host(host_vector_fine, src);
1750 host_transfer.
interpolate(host_vector_coarse, host_vector_fine);
1752 copy_from_host(dst, host_vector_coarse);
1755template <
int dim,
typename VectorType>
1756std::pair<bool, bool>
1759 const std::shared_ptr<const Utilities::MPI::Partitioner>
1760 &partitioner_coarse,
1761 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_fine)
1767template <
int dim,
typename VectorType>
1774template <
int dim,
typename VectorType>
1775std::pair<const DoFHandler<dim> *,
unsigned int>
1782template <
int dim,
typename VectorType>
1785 VectorTypeHost &dst,
1786 const VectorType &src)
const
1788 LinearAlgebra::ReadWriteVector<Number> rw_vector(
1789 src.get_partitioner()->locally_owned_range());
1795template <
int dim,
typename VectorType>
1799 const VectorTypeHost &src)
const
1801 LinearAlgebra::ReadWriteVector<Number> rw_vector(
1802 src.get_partitioner()->locally_owned_range());
1810template <
int dim,
typename Number,
typename MemorySpace>
1811template <
typename MGTwoLevelTransferObject>
1813 const MGLevelObject<MGTwoLevelTransferObject> &transfer,
1814 const std::function<
void(
const unsigned int, VectorType &)>
1815 &initialize_dof_vector)
1817 this->transfer.
clear();
1818 this->internal_transfer.clear();
1820 this->initialize_transfer_references(transfer);
1821 this->build(initialize_dof_vector);
1826template <
int dim,
typename Number,
typename MemorySpace>
1827template <
typename MGTwoLevelTransferObject>
1830 const MGLevelObject<MGTwoLevelTransferObject> &transfer)
1832 this->initialize_transfer_references(transfer);
1837template <
int dim,
typename Number,
typename MemorySpace>
1838template <
typename MGTwoLevelTransferObject>
1841 const MGLevelObject<MGTwoLevelTransferObject> &transfer)
1843 const unsigned int min_level = transfer.
min_level();
1844 const unsigned int max_level = transfer.
max_level();
1846 this->transfer.
resize(min_level, max_level);
1849 for (
unsigned int l = min_level + 1;
l <= max_level; ++
l)
1850 this->transfer[l] = &
const_cast<MGTwoLevelTransferBase<dim, VectorType> &
>(
1851 static_cast<const MGTwoLevelTransferBase<dim, VectorType> &
>(
1857template <
int dim,
typename Number,
typename MemorySpace>
1858template <
class InVector>
1861 const unsigned int level,
1863 const InVector &vec_reference,
1864 const bool omit_zeroing_entries,
1865 const bool force_same_partitioner)
const
1867 std::shared_ptr<const Utilities::MPI::Partitioner> partitioner;
1869 if (external_partitioners.empty())
1871 partitioner = vec_reference.get_partitioner();
1878 partitioner = external_partitioners[level - transfer.
min_level()];
1884 if (vec.get_partitioner().get() == partitioner.get())
1886 if (omit_zeroing_entries ==
false)
1892 if (!force_same_partitioner && vec.size() == partitioner->size() &&
1893 vec.locally_owned_size() == partitioner->locally_owned_size())
1895 if (omit_zeroing_entries ==
false)
1901 vec.reinit(partitioner, omit_zeroing_entries);
1906template <
int dim,
typename Number,
typename MemorySpace>
1907template <
class InVector>
1910 const DoFHandler<dim> &dof_handler,
1911 MGLevelObject<VectorType> &dst,
1912 const InVector &src)
const
1914 assert_dof_handler(dof_handler);
1918 const bool zero_out_values =
1919 (this->perform_plain_copy ==
false &&
1920 this->perform_renumbered_plain_copy ==
false) ||
1923 this->initialize_dof_vector(level,
1930 if (this->perform_plain_copy)
1932 dst[dst.
max_level()].copy_locally_owned_data_from(src);
1934 else if (this->perform_renumbered_plain_copy)
1938 for (
unsigned int i = 0; i < this->copy_indices.back().n_cols(); ++i)
1939 dst_level.local_element(this->copy_indices.back()(1, i)) =
1940 src.local_element(i);
1944 this->ghosted_global_vector = src;
1945 this->ghosted_global_vector.update_ghost_values();
1951 auto &dst_level = dst[
l];
1953 const auto copy_unknowns = [&](
const auto &indices) {
1954 for (
unsigned int i = 0; i < indices.n_cols(); ++i)
1955 dst_level.local_element(indices(1, i)) =
1956 this->ghosted_global_vector.local_element(indices(0, i));
1959 copy_unknowns(this->copy_indices[l]);
1960 copy_unknowns(this->copy_indices_level_mine[l]);
1969template <
int dim,
typename Number,
typename MemorySpace>
1970template <
class OutVector>
1973 const DoFHandler<dim> &dof_handler,
1975 const MGLevelObject<VectorType> &src)
const
1977 assert_dof_handler(dof_handler);
1979 if (this->perform_plain_copy)
1981 dst.zero_out_ghost_values();
1982 dst.copy_locally_owned_data_from(src[src.
max_level()]);
1984 else if (this->perform_renumbered_plain_copy)
1986 const auto &src_level = src[src.
max_level()];
1987 dst.zero_out_ghost_values();
1988 for (
unsigned int i = 0; i < this->copy_indices.back().n_cols(); ++i)
1989 dst.local_element(i) =
1990 src_level.local_element(this->copy_indices.back()(1, i));
1997 auto &ghosted_vector = this->ghosted_level_vector[
l];
1999 if (this->ghosted_level_vector[l].size() > 0)
2000 ghosted_vector = src[
l];
2002 const auto *
const ghosted_vector_ptr =
2003 (this->ghosted_level_vector[
l].size() > 0) ? &ghosted_vector :
2006 ghosted_vector_ptr->update_ghost_values();
2008 const auto copy_unknowns = [&](
const auto &indices) {
2009 for (
unsigned int i = 0; i < indices.n_cols(); ++i)
2010 dst.local_element(indices(0, i)) =
2011 ghosted_vector_ptr->local_element(indices(1, i));
2014 copy_unknowns(this->copy_indices[l]);
2015 copy_unknowns(this->copy_indices_global_mine[l]);
2023template <
int dim,
typename Number,
typename MemorySpace>
2024template <
class InVector>
2027 MGLevelObject<VectorType> &dst,
2028 const InVector &src)
const
2030 DoFHandler<dim> dof_handler_dummy;
2032 this->interpolate_to_mg(dof_handler_dummy, dst, src);
2037template <
int dim,
typename Number,
typename MemorySpace>
2038template <
class InVector>
2041 const DoFHandler<dim> &dof_handler,
2042 MGLevelObject<VectorType> &dst,
2043 const InVector &src)
const
2045 assert_dof_handler(dof_handler);
2047 const unsigned int min_level = dst.
min_level();
2048 const unsigned int max_level = transfer.
max_level();
2052 for (
unsigned int level = min_level; level <= max_level; ++level)
2054 const bool zero_out_values =
false;
2055 this->initialize_dof_vector(level, dst[level], src, !zero_out_values);
2058 if (this->perform_plain_copy)
2060 dst[max_level].copy_locally_owned_data_from(src);
2062 for (
unsigned int l = max_level;
l > min_level; --
l)
2063 this->transfer[l]->
interpolate(dst[l - 1], dst[l]);
2065 else if (this->perform_renumbered_plain_copy)
2067 auto &dst_level = dst[max_level];
2069 for (
unsigned int i = 0; i < this->solution_copy_indices.back().n_cols();
2071 dst_level.local_element(this->solution_copy_indices.back()(1, i)) =
2072 src.local_element(i);
2074 for (
unsigned int l = max_level;
l > min_level; --
l)
2075 this->transfer[l]->
interpolate(dst[l - 1], dst[l]);
2079 this->solution_ghosted_global_vector = src;
2080 this->solution_ghosted_global_vector.update_ghost_values();
2082 for (
unsigned int l = max_level + 1;
l != min_level;)
2086 auto &dst_level = dst[
l];
2088 const auto copy_unknowns = [&](
const auto &indices) {
2089 for (
unsigned int i = 0; i < indices.n_cols(); ++i)
2090 dst_level.local_element(indices(1, i)) =
2091 this->solution_ghosted_global_vector.local_element(
2095 copy_unknowns(this->solution_copy_indices[l]);
2096 copy_unknowns(this->solution_copy_indices_level_mine[l]);
2101 this->transfer[
l]->interpolate(dst[l - 1], dst[l]);
2108template <
int dim,
typename Number,
typename TransferType>
2109template <
typename BlockVectorType2>
2112 const DoFHandler<dim> &dof_handler,
2113 MGLevelObject<LinearAlgebra::distributed::BlockVector<Number>> &dst,
2114 const BlockVectorType2 &src)
const
2118 "This object was initialized with support for usage with one "
2119 "DoFHandler for each block, but this method assumes that "
2120 "the same DoFHandler is used for all the blocks!"));
2121 const std::vector<const DoFHandler<dim> *> mg_dofs(src.n_blocks(),
2124 copy_to_mg(mg_dofs, dst, src);
2129template <
int dim,
typename Number,
typename TransferType>
2130template <
typename BlockVectorType2>
2133 const std::vector<
const DoFHandler<dim> *> &dof_handler,
2134 MGLevelObject<LinearAlgebra::distributed::BlockVector<Number>> &dst,
2135 const BlockVectorType2 &src)
const
2137 const unsigned int n_blocks = src.n_blocks();
2143 const unsigned int min_level = dst.
min_level();
2144 const unsigned int max_level = dst.
max_level();
2146 for (
unsigned int level = min_level; level <= max_level; ++level)
2147 if (dst[level].
n_blocks() != n_blocks)
2148 dst[level].reinit(n_blocks);
2151 MGLevelObject<LinearAlgebra::distributed::Vector<Number>> dst_non_block(
2152 min_level, max_level);
2156 const unsigned int data_block = same_for_all ? 0 :
b;
2157 get_matrix_free_transfer(data_block)
2158 .copy_to_mg(*dof_handler[b], dst_non_block, src.block(b));
2160 for (
unsigned int l = min_level;
l <= max_level; ++
l)
2161 dst[l].block(b) = dst_non_block[
l];
2164 for (
unsigned int level = min_level; level <= max_level; ++level)
2168template <
int dim,
typename Number,
typename TransferType>
2169template <
typename BlockVectorType2>
2172 const DoFHandler<dim> &dof_handler,
2173 BlockVectorType2 &dst,
2174 const MGLevelObject<LinearAlgebra::distributed::BlockVector<Number>> &src)
2179 "This object was initialized with support for usage with one "
2180 "DoFHandler for each block, but this method assumes that "
2181 "the same DoFHandler is used for all the blocks!"));
2182 const std::vector<const DoFHandler<dim> *> mg_dofs(dst.n_blocks(),
2185 copy_from_mg(mg_dofs, dst, src);
2188template <
int dim,
typename Number,
typename TransferType>
2189template <
typename BlockVectorType2>
2192 const std::vector<
const DoFHandler<dim> *> &dof_handler,
2193 BlockVectorType2 &dst,
2194 const MGLevelObject<LinearAlgebra::distributed::BlockVector<Number>> &src)
2197 const unsigned int n_blocks = dst.n_blocks();
2203 const unsigned int min_level = src.min_level();
2204 const unsigned int max_level = src.max_level();
2206 for (
unsigned int l = min_level;
l <= max_level; ++
l)
2210 MGLevelObject<LinearAlgebra::distributed::Vector<Number>> src_non_block(
2211 min_level, max_level);
2215 for (
unsigned int l = min_level;
l <= max_level; ++
l)
2217 src_non_block[
l].reinit(src[l].block(b));
2218 src_non_block[
l] = src[
l].block(b);
2220 const unsigned int data_block = same_for_all ? 0 :
b;
2221 get_matrix_free_transfer(data_block)
2222 .copy_from_mg(*dof_handler[b], dst.block(b), src_non_block);
friend class ObserverPointer
virtual size_type size() const override
void reinit(const size_type size, const bool omit_zeroing_entries=false)
ObserverPointer< const MGConstrainedDoFs > mg_constrained_dofs
std::function< void(const unsigned int, LinearAlgebra::distributed::Vector< Number, MemorySpace > &)> initialize_dof_vector
void resize(const unsigned int new_minlevel, const unsigned int new_maxlevel, Args &&...args)
unsigned int max_level() const
unsigned int min_level() const
virtual void prolongate(const unsigned int to_level, LinearAlgebra::distributed::BlockVector< Number > &dst, const LinearAlgebra::distributed::BlockVector< Number > &src) const override
virtual void prolongate_and_add(const unsigned int to_level, LinearAlgebra::distributed::BlockVector< Number > &dst, const LinearAlgebra::distributed::BlockVector< Number > &src) const override
virtual const TransferType & get_matrix_free_transfer(const unsigned int b) const =0
void copy_from_mg(const std::vector< const DoFHandler< dim > * > &dof_handler, BlockVectorType2 &dst, const MGLevelObject< LinearAlgebra::distributed::BlockVector< Number > > &src) const
void copy_to_mg(const DoFHandler< dim > &dof_handler, MGLevelObject< LinearAlgebra::distributed::BlockVector< Number > > &dst, const BlockVectorType2 &src) const
virtual void restrict_and_add(const unsigned int from_level, LinearAlgebra::distributed::BlockVector< Number > &dst, const LinearAlgebra::distributed::BlockVector< Number > &src) const override
MGTransferBlockMatrixFreeBase(const bool same_for_all)
void copy_from_mg(const DoFHandler< dim > &dof_handler, BlockVectorType2 &dst, const MGLevelObject< LinearAlgebra::distributed::BlockVector< Number > > &src) const
void copy_to_mg(const std::vector< const DoFHandler< dim > * > &dof_handler, MGLevelObject< LinearAlgebra::distributed::BlockVector< Number > > &dst, const BlockVectorType2 &src) const
const MGTransferMatrixFree< dim, Number, ::MemorySpace::Host > & get_matrix_free_transfer(const unsigned int b) const override
MGTransferBlockMatrixFree(const MGTransferMatrixFree< dim, Number, ::MemorySpace::Host > &transfer_operator)
MGTransferBlockMatrixFree(const MGConstrainedDoFs &mg_constrained_dofs)
std::vector< ObserverPointer< const MGTransferMatrixFree< dim, typename VectorType::value_type, ::MemorySpace::Host > > > transfer_operators
std::vector< MGTransferMatrixFree< dim, typename VectorType::value_type, ::MemorySpace::Host > > transfer_operators_internal
MGTransferBlockMatrixFree(const std::vector< MGConstrainedDoFs > &mg_constrained_dofs)
void build(const DoFHandler< dim > &dof_handler)
MGTransferBlockMatrixFree()=default
void build(const std::vector< const DoFHandler< dim > * > &dof_handler)
void initialize_constraints(const std::vector< MGConstrainedDoFs > &mg_constrained_dofs)
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
void initialize_two_level_transfers(const MGLevelObject< MGTwoLevelTransferObject > &transfer)
void interpolate_to_mg(MGLevelObject< VectorType > &dst, const InVector &src) const
std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > external_partitioners
void interpolate_to_mg(const DoFHandler< dim > &dof_handler, MGLevelObject< VectorType > &dst, const InVector &src) const
void initialize_transfer_references(const MGLevelObject< MGTwoLevelTransferObject > &transfer)
MGLevelObject< MGTwoLevelTransfer< dim, LinearAlgebra::distributed::Vector< Number, ::MemorySpace::Host > > > internal_transfer
void build(const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > &external_partitioners={})
unsigned int max_level() const
void prolongate(const unsigned int to_level, VectorType &dst, const VectorType &src) const override
void initialize_dof_vector(const unsigned int level, VectorType &vector, const InVector &vector_reference, const bool omit_zeroing_entries, const bool force_same_partitioner=false) const
void copy_from_mg(const DoFHandler< dim > &dof_handler, OutVector &dst, const MGLevelObject< VectorType > &src) const
void build(const DoFHandler< dim > &dof_handler, const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > &external_partitioners={})
MGTransferMatrixFree(const MGConstrainedDoFs &mg_constrained_dofs)
void fill_and_communicate_copy_indices_global_coarsening(const DoFHandler< dim > &dof_handler)
void build(const DoFHandler< dim > &dof_handler, const std::function< void(const unsigned int, VectorType &)> &initialize_dof_vector)
void initialize_internal_transfer(const DoFHandler< dim > &dof_handler, const ObserverPointer< const MGConstrainedDoFs > &mg_constrained_dofs)
virtual void restrict_and_add(const unsigned int from_level, VectorType &dst, const VectorType &src) const override
void prolongate_and_add(const unsigned int to_level, VectorType &dst, const VectorType &src) const override
MGLevelObject< ObserverPointer< MGTwoLevelTransferBase< dim, VectorType > > > transfer
void build(const std::function< void(const unsigned int, VectorType &)> &initialize_dof_vector)
MGTransferMatrixFree(const MGLevelObject< MGTwoLevelTransferObject > &transfer, const std::function< void(const unsigned int, VectorType &)> &initialize_dof_vector={})
void initialize_constraints(const MGConstrainedDoFs &mg_constrained_dofs)
unsigned int min_level() const
std::pair< const DoFHandler< dim > *, unsigned int > get_dof_handler_fine() const
LinearAlgebra::distributed::Vector< Number, MemorySpace > VectorType
void copy_to_mg(const DoFHandler< dim > &dof_handler, MGLevelObject< VectorType > &dst, const InVector &src) const
void assert_dof_handler(const DoFHandler< dim > &dof_handler_out) const
std::size_t memory_consumption() const
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner_fine
virtual std::pair< const DoFHandler< dim > *, unsigned int > get_dof_handler_fine() const =0
virtual std::size_t memory_consumption() const =0
virtual void restrict_and_add(VectorType &dst, const VectorType &src) const =0
virtual std::pair< bool, bool > enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine)=0
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner_coarse
virtual void prolongate_and_add(VectorType &dst, const VectorType &src) const =0
virtual void interpolate(VectorType &dst, const VectorType &src) const =0
typename VectorType::value_type Number
std::size_t memory_consumption() const override
MGTwoLevelTransfer< dim, VectorTypeHost > host_transfer
void interpolate(VectorType &dst, const VectorType &src) const override
void reinit(const MatrixFree< dim, Number > &matrix_free_fine, const unsigned int dof_handler_index_fine, const MatrixFree< dim, Number > &matrix_free_coarse, const unsigned int dof_handler_index_coarse)
void restrict_and_add(VectorType &dst, const VectorType &src) const override
LinearAlgebra::distributed::Vector< Number, MemorySpace::Host > VectorTypeHost
bool fast_polynomial_transfer_supported(const unsigned int fe_degree_fine, const unsigned int fe_degree_coarse)
void copy_to_host(VectorTypeHost &dst, const VectorType &src) const
VectorTypeHost host_vector_fine
MGTwoLevelTransferCopyToHost()=default
std::pair< const DoFHandler< dim > *, unsigned int > get_dof_handler_fine() const override
std::pair< bool, bool > enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine) override
void copy_from_host(VectorType &dst, const VectorTypeHost &src) const
void prolongate_and_add(VectorType &dst, const VectorType &src) const override
VectorTypeHost host_vector_coarse
void reinit(const DoFHandler< dim > &dof_handler_fine, const DoFHandler< dim > &dof_handler_coarse, const AffineConstraints< Number > &constraint_fine=AffineConstraints< Number >(), const AffineConstraints< Number > &constraint_coarse=AffineConstraints< Number >(), const unsigned int mg_level_fine=numbers::invalid_unsigned_int, const unsigned int mg_level_coarse=numbers::invalid_unsigned_int)
std::shared_ptr< NonMatching::MappingInfo< dim, dim, Number > > mapping_info
boost::signals2::connection connect_restriction(const std::function< void(const bool)> &slot)
void reinit(const DoFHandler< dim > &dof_handler_fine, const DoFHandler< dim > &dof_handler_coarse, const Mapping< dim > &mapping_fine, const Mapping< dim > &mapping_coarse, const AffineConstraints< Number > &constraint_fine=AffineConstraints< Number >(), const AffineConstraints< Number > &constraint_coarse=AffineConstraints< Number >())
AdditionalData additional_data
std::unique_ptr< FiniteElement< dim > > fe_coarse
std::vector< Number > rpe_input_output
ObserverPointer< const DoFHandler< dim > > dof_handler_fine
void restrict_and_add_internal_comp(VectorType &dst, const VectorType &src) const
boost::signals2::connection connect_prolongation_cell_loop(const std::function< void(const bool)> &slot)
std::vector< Number > rpe_buffer
std::size_t memory_consumption() const override
std::pair< bool, bool > enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine) override
Utilities::MPI::RemotePointEvaluation< dim > rpe
void restrict_and_add_internal(VectorType &dst, const VectorType &src) const override
std::vector< unsigned int > level_dof_indices_fine_ptrs
mg::SignalsNonNested signals_non_nested
internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArrayType, unsigned int > constraint_info
boost::signals2::connection connect_prolongation(const std::function< void(const bool)> &slot)
boost::signals2::connection connect_restriction_cell_loop(const std::function< void(const bool)> &slot)
VectorizedArray< Number, 1 > VectorizedArrayType
void prolongate_and_add_internal_comp(VectorType &dst, const VectorType &src) const
MGTwoLevelTransferNonNested(const AdditionalData &data=AdditionalData())
void interpolate(VectorType &dst, const VectorType &src) const override
std::vector< unsigned int > level_dof_indices_fine
typename VectorType::value_type Number
unsigned int mg_level_fine
void prolongate_and_add_internal(VectorType &dst, const VectorType &src) const override
std::pair< const DoFHandler< dim > *, unsigned int > get_dof_handler_fine() const override
void reinit_geometric_transfer(const DoFHandler< dim > &dof_handler_fine, const DoFHandler< dim > &dof_handler_coarse, const AffineConstraints< Number > &constraint_fine=AffineConstraints< Number >(), const AffineConstraints< Number > &constraint_coarse=AffineConstraints< Number >(), const unsigned int mg_level_fine=numbers::invalid_unsigned_int, const unsigned int mg_level_coarse=numbers::invalid_unsigned_int)
internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArrayType, types::global_dof_index > constraint_info_fine
void reinit(const MatrixFree< dim, Number > &matrix_free_fine, const unsigned int dof_handler_index_fine, const MatrixFree< dim, Number > &matrix_free_coarse, const unsigned int dof_handler_index_coarse)
friend class internal::MGTwoLevelTransferImplementation
std::vector< MGTransferScheme > schemes
ObserverPointer< const DoFHandler< dim > > dof_handler_fine
VectorizedArray< Number > VectorizedArrayType
friend class Portable::internal::MGTwoLevelTransferImplementation
typename VectorType::value_type Number
std::vector< unsigned char > weights_are_compressed
std::pair< const DoFHandler< dim > *, unsigned int > get_dof_handler_fine() const override
void interpolate(VectorType &dst, const VectorType &src) const override
internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArrayType, types::global_dof_index > constraint_info_coarse
std::unique_ptr< MatrixFreeRelatedData > matrix_free_data
static bool fast_polynomial_transfer_supported(const unsigned int fe_degree_fine, const unsigned int fe_degree_coarse)
AlignedVector< VectorizedArrayType > weights
void reinit_polynomial_transfer(const DoFHandler< dim > &dof_handler_fine, const DoFHandler< dim > &dof_handler_coarse, const AffineConstraints< Number > &constraint_fine=AffineConstraints< Number >(), const AffineConstraints< Number > &constraint_coarse=AffineConstraints< Number >(), const unsigned int mg_level_fine=numbers::invalid_unsigned_int, const unsigned int mg_level_coarse=numbers::invalid_unsigned_int)
unsigned int mg_level_fine
std::pair< bool, bool > enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine) override
void restrict_and_add_internal(VectorType &dst, const VectorType &src) const override
unsigned int n_components
std::vector< unsigned int > weights_start
void reinit(const DoFHandler< dim > &dof_handler_fine, const DoFHandler< dim > &dof_handler_coarse, const AffineConstraints< Number > &constraint_fine=AffineConstraints< Number >(), const AffineConstraints< Number > &constraint_coarse=AffineConstraints< Number >(), const unsigned int mg_level_fine=numbers::invalid_unsigned_int, const unsigned int mg_level_coarse=numbers::invalid_unsigned_int)
std::size_t memory_consumption() const override
void prolongate_and_add_internal(VectorType &dst, const VectorType &src) const override
Abstract base class for mapping classes.
Communicate values between a mesh and arbitrary points.
static constexpr std::size_t size()
bool fine_element_is_continuous
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner_fine_embedded
void restrict_and_add(VectorType &dst, const VectorType &src) const override
virtual void restrict_and_add_internal(VectorType &dst, const VectorType &src) const =0
void zero_out_ghost_values(const VectorType &vec) const
AlignedVector< Number > buffer_fine_embedded
AlignedVector< Number > buffer_coarse_embedded
std::pair< bool, bool > internal_enable_inplace_operations_if_possible(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_coarse, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner_fine, bool &vec_fine_needs_ghost_update, internal::MatrixFreeFunctions::ConstraintInfo< dim, VectorizedArray< Number, width >, IndexType > &constraint_info_coarse, std::vector< unsigned int > &dof_indices_fine)
void compress(VectorType &vec, const VectorOperation::values op) const
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner_coarse_embedded
typename VectorType::value_type Number
bool vec_fine_needs_ghost_update
virtual void prolongate_and_add_internal(VectorType &dst, const VectorType &src) const =0
void prolongate_and_add(VectorType &dst, const VectorType &src) const override
void update_ghost_values(const VectorType &vec) const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
std::enable_if_t< IsBlockVector< VectorType >::value, void > collect_sizes(VectorType &vector)
std::enable_if_t< IsBlockVector< VectorType >::value, unsigned int > n_blocks(const VectorType &vector)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
T & get_underlying_value(T &p)
constexpr unsigned int invalid_unsigned_int
bool enforce_all_points_found
AdditionalData(const double tolerance=1e-6, const unsigned int rtree_level=0, const bool enforce_all_points_found=true)
unsigned int degree_coarse
unsigned int n_dofs_per_cell_coarse
unsigned int n_coarse_cells
AlignedVector< double > restriction_matrix
internal::MatrixFreeFunctions::ShapeInfo< double > shape_info_coarse
unsigned int n_dofs_per_cell_fine
AlignedVector< double > prolongation_matrix
boost::signals2::signal< void(const bool before)> prolongation_cell_loop
boost::signals2::signal< void(const bool before)> restriction
boost::signals2::signal< void(const bool before)> restriction_cell_loop
boost::signals2::signal< void(const bool before)> prolongation