1 #ifndef XGC_CORE_CPP_COL_GRID_MATRIX_HPP_
2 #define XGC_CORE_CPP_COL_GRID_MATRIX_HPP_
7 #include <Kokkos_DualView.hpp>
12 #include <ginkgo/ginkgo.hpp>
22 template <
typename Device>
31 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
33 Kokkos::View<
const value_type***, Kokkos::LayoutRight, Device,
34 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
35 using vector_view_t = Kokkos::View<value_type****, Kokkos::LayoutRight, Device>;
37 using vector_h_view_t = Kokkos::View<value_type****, Kokkos::LayoutRight, host_type>;
84 template <
typename Device>
145 template <
typename Device>
161 using mtx_type = gko::batch::matrix::Ell<value_type, index_type>;
163 static constexpr
int max_nnz_per_row = 9;
165 ELLMatrix(std::shared_ptr<const gko::Executor> exec,
size_type n_matrices,
166 index_type num_species,
int nvr,
int nvz,
167 double ginkgo_residual_reduction,
int ginkgo_max_iterations)
168 : exec_{exec},
GridMatrix<Device>(n_matrices, num_species), nvr_{nvr},
169 nvz_{nvz}, ginkgo_residual_reduction_{ginkgo_residual_reduction},
170 ginkgo_max_iterations_{ginkgo_max_iterations}
175 const_values_array_t get_const_values()
const override;
177 values_array_t get_values()
override;
179 void subtract_from_identity()
override;
181 void add_identity_multiply(const_vector_view_t dist_col,
182 vector_view_t dist_iter)
const override;
184 void apply_solve(const_vector_h_view_t b_h, vector_h_view_t x_h, const_vector_view_t b, vector_view_t x)
const override;
193 std::shared_ptr<const gko::Executor> exec_;
194 std::shared_ptr<mtx_type> mtx_;
199 double ginkgo_residual_reduction_;
200 int ginkgo_max_iterations_;
202 void setup_sparsity();
207 template <
typename Device>
213 std::string mtx_type =
"unknown";
217 what_ = mtx_type +
" matrix type not supported!";
220 virtual const char*
what() const noexcept
override {
return what_.c_str(); }
233 std::unique_ptr<GridMatrix<DeviceType>>
create_matrix(
int n_matrices,
235 double ginkgo_residual_reduction,
int ginkgo_max_iterations,
236 std::string format =
"default");
Definition: col_grid_matrix.hpp:86
typename GridMatrix< Device >::vector_view_t vector_view_t
Definition: col_grid_matrix.hpp:95
typename GridMatrix< Device >::index_type index_type
Definition: col_grid_matrix.hpp:88
void setup_sparsity()
Definition: col_grid_matrix.cpp:7
Kokkos::View< int *, host_type > LU_colptr_
Definition: col_grid_matrix.hpp:138
typename GridMatrix< Device >::vector_h_view_t vector_h_view_t
Definition: col_grid_matrix.hpp:97
typename GridMatrix< Device >::values_array_t values_array_t
Definition: col_grid_matrix.hpp:92
Kokkos::DualView< value_type ***, Kokkos::LayoutRight, Device > internal_values_array_t
Definition: col_grid_matrix.hpp:94
const_values_array_t get_const_values() const override
Definition: col_grid_matrix.cpp:226
CSCMatrix(size_type n_nodes, index_type num_species, int nvr, int nvz)
Definition: col_grid_matrix.hpp:102
values_array_t get_values() override
Definition: col_grid_matrix.cpp:216
internal_values_array_t values_
Definition: col_grid_matrix.hpp:135
Kokkos::View< index_type *, device > central_locs_
Definition: col_grid_matrix.hpp:136
void subtract_from_identity() override
Definition: col_grid_matrix.cpp:239
index_type nvz_
Definition: col_grid_matrix.hpp:132
typename GridMatrix< Device >::const_vector_h_view_t const_vector_h_view_t
Definition: col_grid_matrix.hpp:98
typename GridMatrix< Device >::const_vector_view_t const_vector_view_t
Definition: col_grid_matrix.hpp:96
typename GridMatrix< Device >::const_values_array_t const_values_array_t
Definition: col_grid_matrix.hpp:93
Kokkos::View< int *, host_type > LU_rowindx_
Definition: col_grid_matrix.hpp:137
index_type nvr_
Definition: col_grid_matrix.hpp:133
void apply_solve(const_vector_h_view_t b_h, vector_h_view_t x_h, const_vector_view_t b, vector_view_t x) const override
Definition: col_grid_matrix.cpp:321
void add_identity_multiply(const_vector_view_t dist_col, vector_view_t dist_iter) const override
Definition: col_grid_matrix.cpp:264
Definition: col_grid_matrix.hpp:24
virtual const_values_array_t get_const_values() const =0
Kokkos::View< index_type **, device >::HostMirror host_index_map_LU()
Definition: col_grid_matrix.hpp:48
Kokkos::View< const value_type ****, Kokkos::LayoutRight, Device > const_vector_view_t
Definition: col_grid_matrix.hpp:36
virtual void add_identity_multiply(const_vector_view_t dist_col, vector_view_t dist_iter) const =0
Kokkos::DualView< value_type ****, Kokkos::LayoutRight, Device > vector_dualview_t
Definition: col_grid_matrix.hpp:39
Kokkos::View< const value_type ***, Kokkos::LayoutRight, Device, Kokkos::MemoryTraits< Kokkos::Unmanaged > > const_values_array_t
Definition: col_grid_matrix.hpp:34
const size_type batch_size_
Definition: col_grid_matrix.hpp:78
int index_type
Definition: col_grid_matrix.hpp:26
virtual void apply_solve(const_vector_h_view_t b_h, vector_h_view_t x_h, const_vector_view_t b, vector_view_t x) const =0
Kokkos::View< value_type ***, Kokkos::LayoutRight, Device, Kokkos::MemoryTraits< Kokkos::Unmanaged > > values_array_t
Definition: col_grid_matrix.hpp:31
Kokkos::DualView< index_type **, device > index_map_
Definition: col_grid_matrix.hpp:72
Kokkos::View< const value_type ****, Kokkos::LayoutRight, host_type > const_vector_h_view_t
Definition: col_grid_matrix.hpp:38
Kokkos::DualView< const value_type ****, Kokkos::LayoutRight, Device > const_vector_dualview_t
Definition: col_grid_matrix.hpp:40
Kokkos::View< value_type ****, Kokkos::LayoutRight, host_type > vector_h_view_t
Definition: col_grid_matrix.hpp:37
GridMatrix(size_type n_nodes, int n_species)
Definition: col_grid_matrix.hpp:42
virtual values_array_t get_values()=0
index_type num_rows_
Definition: col_grid_matrix.hpp:79
Kokkos::View< value_type ****, Kokkos::LayoutRight, Device > vector_view_t
Definition: col_grid_matrix.hpp:35
index_type get_num_nonzeros() const
Definition: col_grid_matrix.hpp:68
Device device
Definition: col_grid_matrix.hpp:28
index_type get_num_rows() const
Definition: col_grid_matrix.hpp:69
Kokkos::View< index_type **, device > device_index_map_LU() const
Definition: col_grid_matrix.hpp:52
HostType host_type
Definition: col_grid_matrix.hpp:27
double value_type
Definition: col_grid_matrix.hpp:29
index_type nnz_
Definition: col_grid_matrix.hpp:80
virtual ~GridMatrix()
Definition: col_grid_matrix.hpp:46
virtual void subtract_from_identity()=0
const index_type num_nodes_
Definition: col_grid_matrix.hpp:77
const index_type num_species_
Definition: col_grid_matrix.hpp:76
Definition: col_grid_matrix.hpp:209
virtual const char * what() const noexcept override
Definition: col_grid_matrix.hpp:220
std::string what_
Definition: col_grid_matrix.hpp:223
InvalidMatrixType(const GridMatrix< Device > *const mtx)
Definition: col_grid_matrix.hpp:211
Definition: col_grid_matrix.cpp:4
LinAlgBackend
Definition: col_grid_matrix.hpp:227
int size_type
Definition: col_grid_matrix.hpp:19
std::unique_ptr< GridMatrix< DeviceType > > create_matrix(const int n_matrices_in, int nvr, int nvz, const int num_species, const LinAlgBackend labackend, const double ginkgo_residual_reduction, const int ginkgo_max_iterations, const std::string format)
Definition: col_grid_matrix.cpp:652
Kokkos::Device< HostExSpace, HostMemSpace > HostType
Definition: space_settings.hpp:57