5 #ifndef GKO_PUBLIC_CORE_MULTIGRID_PGM_HPP_
6 #define GKO_PUBLIC_CORE_MULTIGRID_PGM_HPP_
11 #include <ginkgo/core/base/composition.hpp>
12 #include <ginkgo/core/base/exception_helpers.hpp>
13 #include <ginkgo/core/base/lin_op.hpp>
14 #include <ginkgo/core/base/types.hpp>
15 #include <ginkgo/core/config/config.hpp>
16 #include <ginkgo/core/config/registry.hpp>
17 #include <ginkgo/core/config/type_descriptor.hpp>
18 #include <ginkgo/core/distributed/matrix.hpp>
19 #include <ginkgo/core/matrix/csr.hpp>
20 #include <ginkgo/core/matrix/sparsity_csr.hpp>
21 #include <ginkgo/core/multigrid/multigrid_level.hpp>
56 template <
typename ValueType = default_precision,
typename IndexType =
int32>
57 class Pgm :
public LinOp,
public EnableMultigridLevel<ValueType> {
58 GKO_ASSERT_SUPPORTED_VALUE_AND_INDEX_TYPE;
61 using value_type = ValueType;
62 using index_type = IndexType;
71 return system_matrix_;
147 bool initialized_ =
false;
148 bool distributed_ =
false;
151 std::shared_ptr<const LinOp> prolong_op_;
152 std::shared_ptr<const LinOp> restrict_op_;
153 std::shared_ptr<const LinOp> coarse_op_;
154 std::shared_ptr<const matrix::SparsityCsr<ValueType, IndexType>>
156 std::shared_ptr<const matrix::SparsityCsr<ValueType, IndexType>>
176 config::make_type_descriptor<ValueType, IndexType>());
193 explicit Pgm(std::shared_ptr<const Executor> exec) :
LinOp(std::move(exec))
196 explicit Pgm(
const Factory* factory,
197 std::shared_ptr<const LinOp> system_matrix)
198 : Pgm(factory, std::move(system_matrix), nullptr)
201 Pgm(
const Factory* factory, std::shared_ptr<const LinOp> system_matrix,
202 reuse_data_type& reuse_data)
203 : Pgm(
factory, std::move(system_matrix), &reuse_data)
206 Pgm(
const Factory* factory, std::shared_ptr<const LinOp> system_matrix,
207 reuse_data_type* reuse_data)
209 EnableMultigridLevel<ValueType>(system_matrix),
210 parameters_{
factory->get_parameters()},
211 system_matrix_{system_matrix},
212 agg_(
factory->get_executor(), system_matrix_->get_size()[0])
216 if (system_matrix_->get_size()[0] != 0) {
218 if (reuse_data && reuse_data->initialized_) {
219 this->generate_from(*reuse_data);
221 this->generate(reuse_data);
232 void generate(reuse_data_type* reuse_data);
238 void generate_from(
const reuse_data_type& reuse_data);
241 static void check_reuse_consistent(
const Factory* factory,
243 const reuse_data_type& reuse_data);
252 std::tuple<std::shared_ptr<LinOp>, std::shared_ptr<LinOp>,
253 std::shared_ptr<LinOp>>
255 std::shared_ptr<
const matrix::Csr<ValueType, IndexType>> local_matrix,
256 std::shared_ptr<
const matrix::SparsityCsr<ValueType, IndexType>>*
270 std::shared_ptr<const matrix::Csr<ValueType, IndexType>>
271 convert_local_fine_op(std::shared_ptr<const LinOp> system_matrix)
const;
282 std::shared_ptr<const LinOp> convert_distributed_fine_op(
283 std::shared_ptr<const LinOp> system_matrix)
const;
298 template <
typename GlobalIndexType>
299 array<GlobalIndexType> communicate_off_diag_agg(
300 std::shared_ptr<
const experimental::distributed::Matrix<
301 ValueType, IndexType, GlobalIndexType>>
304 experimental::distributed::Partition<IndexType, GlobalIndexType>>
306 const array<IndexType>& local_agg);
310 std::shared_ptr<const LinOp> system_matrix_{};
311 array<IndexType> agg_;
315 template <
typename ValueType = default_precision,
typename IndexType =
int32>
316 using AmgxPgm GKO_DEPRECATED(
317 "This class is deprecated and will be removed in the next "
318 "major release. Please use Pgm instead.") = Pgm<ValueType, IndexType>;
325 #endif // GKO_PUBLIC_CORE_MULTIGRID_PGM_HPP_