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/dense.hpp>
21 #include <ginkgo/core/matrix/sparsity_csr.hpp>
22 #include <ginkgo/core/multigrid/multigrid_level.hpp>
57 template <
typename ValueType = default_precision,
typename IndexType =
int32>
58 class Pgm :
public LinOp,
public EnableMultigridLevel<ValueType> {
59 GKO_ASSERT_SUPPORTED_VALUE_AND_INDEX_TYPE;
62 using value_type = ValueType;
63 using index_type = IndexType;
72 return system_matrix_;
148 bool initialized_ =
false;
149 bool distributed_ =
false;
152 std::shared_ptr<const LinOp> prolong_op_;
153 std::shared_ptr<const LinOp> restrict_op_;
154 std::shared_ptr<const LinOp> coarse_op_;
155 std::shared_ptr<const matrix::SparsityCsr<ValueType, IndexType>>
157 std::shared_ptr<const matrix::SparsityCsr<ValueType, IndexType>>
177 config::make_type_descriptor<ValueType, IndexType>());
180 void apply_impl(
const LinOp* b,
LinOp* x)
const override
186 LinOp* x)
const override
191 explicit Pgm(std::shared_ptr<const Executor> exec) :
LinOp(std::move(exec))
194 explicit Pgm(
const Factory* factory,
195 std::shared_ptr<const LinOp> system_matrix)
196 : Pgm(factory, std::move(system_matrix), nullptr)
199 Pgm(
const Factory* factory, std::shared_ptr<const LinOp> system_matrix,
200 reuse_data_type& reuse_data)
201 : Pgm(
factory, std::move(system_matrix), &reuse_data)
204 Pgm(
const Factory* factory, std::shared_ptr<const LinOp> system_matrix,
205 reuse_data_type* reuse_data)
207 EnableMultigridLevel<ValueType>(system_matrix),
208 parameters_{
factory->get_parameters()},
209 system_matrix_{system_matrix},
210 agg_(
factory->get_executor(), system_matrix_->get_size()[0])
214 if (system_matrix_->get_size()[0] != 0) {
216 if (reuse_data && reuse_data->initialized_) {
217 this->generate_from(*reuse_data);
219 this->generate(reuse_data);
230 void generate(reuse_data_type* reuse_data);
236 void generate_from(
const reuse_data_type& reuse_data);
239 static void check_reuse_consistent(
const Factory* factory,
241 const reuse_data_type& reuse_data);
250 std::tuple<std::shared_ptr<LinOp>, std::shared_ptr<LinOp>,
251 std::shared_ptr<LinOp>>
253 std::shared_ptr<
const matrix::Csr<ValueType, IndexType>> local_matrix,
254 std::shared_ptr<
const matrix::SparsityCsr<ValueType, IndexType>>*
268 std::shared_ptr<const matrix::Csr<ValueType, IndexType>>
269 convert_local_fine_op(std::shared_ptr<const LinOp> system_matrix)
const;
280 std::shared_ptr<const LinOp> convert_distributed_fine_op(
281 std::shared_ptr<const LinOp> system_matrix)
const;
296 template <
typename GlobalIndexType>
297 array<GlobalIndexType> communicate_off_diag_agg(
298 std::shared_ptr<
const experimental::distributed::Matrix<
299 ValueType, IndexType, GlobalIndexType>>
302 experimental::distributed::Partition<IndexType, GlobalIndexType>>
304 const array<IndexType>& local_agg);
308 std::shared_ptr<const LinOp> system_matrix_{};
309 array<IndexType> agg_;
313 template <
typename ValueType = default_precision,
typename IndexType =
int32>
314 using AmgxPgm GKO_DEPRECATED(
315 "This class is deprecated and will be removed in the next "
316 "major release. Please use Pgm instead.") = Pgm<ValueType, IndexType>;
323 #endif // GKO_PUBLIC_CORE_MULTIGRID_PGM_HPP_