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>
16 namespace Collisions {
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>;
82 template <
typename Device>
121 using GridMatrix<Device>::index_map_;
122 using GridMatrix<Device>::num_nodes_;
123 using GridMatrix<Device>::num_rows_;
124 using GridMatrix<Device>::nnz_;
125 using GridMatrix<Device>::batch_size_;
126 using GridMatrix<Device>::num_species_;
141 template <
typename Device>
155 using mtx_type = gko::batch::matrix::Ell<value_type, index_type>;
157 static constexpr
int max_nnz_per_row = 9;
159 ELLMatrix(std::shared_ptr<const gko::Executor> exec,
size_type n_matrices,
160 index_type num_species,
int nvr,
int nvz,
161 double ginkgo_residual_reduction,
int ginkgo_max_iterations)
162 : exec_{exec}, GridMatrix<Device>(n_matrices, num_species), nvr_{nvr},
163 nvz_{nvz}, ginkgo_residual_reduction_{ginkgo_residual_reduction},
164 ginkgo_max_iterations_{ginkgo_max_iterations}
169 const_values_array_t get_const_values()
const override;
171 values_array_t get_values()
override;
173 void subtract_from_identity()
override;
175 void add_identity_multiply(const_vector_view_t dist_col,
176 vector_view_t dist_iter)
const override;
178 void apply_solve(const_vector_dualview_t b, vector_dualview_t x)
const override;
181 using GridMatrix<Device>::index_map_;
182 using GridMatrix<Device>::num_nodes_;
183 using GridMatrix<Device>::num_rows_;
184 using GridMatrix<Device>::nnz_;
185 using GridMatrix<Device>::batch_size_;
186 using GridMatrix<Device>::num_species_;
187 std::shared_ptr<const gko::Executor> exec_;
188 std::shared_ptr<mtx_type> mtx_;
193 double ginkgo_residual_reduction_;
194 int ginkgo_max_iterations_;
196 void setup_sparsity();
201 template <
typename Device>
207 std::string mtx_type =
"unknown";
211 what_ = mtx_type +
" matrix type not supported!";
214 virtual const char*
what() const noexcept
override {
return what_.c_str(); }
227 template <
typename Device>
230 double ginkgo_residual_reduction,
int ginkgo_max_iterations,
231 std::string format =
"default");
Definition: col_grid_matrix.hpp:23
Definition: col_grid_matrix.hpp:83
typename GridMatrix< Device >::const_vector_view_t const_vector_view_t
Definition: col_grid_matrix.hpp:94
index_type num_rows_
Definition: col_grid_matrix.hpp:77
typename GridMatrix< Device >::vector_view_t vector_view_t
Definition: col_grid_matrix.hpp:93
index_type nnz_
Definition: col_grid_matrix.hpp:78
Kokkos::DualView< const value_type ****, Kokkos::LayoutRight, Device > const_vector_dualview_t
Definition: col_grid_matrix.hpp:38
const_values_array_t get_const_values() const override
Definition: col_grid_matrix.tpp:224
Kokkos::Device< HostExSpace, HostMemSpace > HostType
Definition: space_settings.hpp:57
virtual void apply_solve(const_vector_dualview_t b, vector_dualview_t x) const =0
Kokkos::View< index_type **, device > device_index_map_LU() const
Definition: col_grid_matrix.hpp:50
Kokkos::View< value_type ***, Kokkos::LayoutRight, Device, Kokkos::MemoryTraits< Kokkos::Unmanaged >> values_array_t
Definition: col_grid_matrix.hpp:31
virtual const char * what() const noexceptoverride
Definition: col_grid_matrix.hpp:214
void subtract_from_identity() override
Definition: col_grid_matrix.tpp:237
Kokkos::View< int *, host_type > LU_rowindx_
Definition: col_grid_matrix.hpp:133
values_array_t get_values() override
Definition: col_grid_matrix.tpp:214
void setup_sparsity()
Definition: col_grid_matrix.tpp:5
Definition: col_grid_matrix.hpp:202
HostType host_type
Definition: col_grid_matrix.hpp:27
Kokkos::DualView< value_type ***, Kokkos::LayoutRight, Device > internal_values_array_t
Definition: col_grid_matrix.hpp:92
int size_type
Definition: col_grid_matrix.hpp:19
const index_type num_species_
Definition: col_grid_matrix.hpp:74
virtual ~GridMatrix()
Definition: col_grid_matrix.hpp:44
typename GridMatrix< Device >::values_array_t values_array_t
Definition: col_grid_matrix.hpp:90
Kokkos::View< const value_type ***, Kokkos::LayoutRight, Device, Kokkos::MemoryTraits< Kokkos::Unmanaged >> const_values_array_t
Definition: col_grid_matrix.hpp:34
index_type nvr_
Definition: col_grid_matrix.hpp:129
GridMatrix(size_type n_nodes, int n_species)
Definition: col_grid_matrix.hpp:40
index_type nvz_
Definition: col_grid_matrix.hpp:128
Kokkos::View< index_type *, device > central_locs_
Definition: col_grid_matrix.hpp:132
Kokkos::DualView< index_type **, device > index_map_
Definition: col_grid_matrix.hpp:70
std::unique_ptr< GridMatrix< Device > > create_matrix(size_type n_matrices, int nvr, int nvz, int num_species, LinAlgBackend labackend, double ginkgo_residual_reduction, int ginkgo_max_iterations, std::string format="default")
Definition: col_grid_matrix.tpp:663
typename GridMatrix< Device >::const_values_array_t const_values_array_t
Definition: col_grid_matrix.hpp:91
index_type get_num_nonzeros() const
Definition: col_grid_matrix.hpp:66
virtual const_values_array_t get_const_values() const =0
double value_type
Definition: col_grid_matrix.hpp:29
Kokkos::DualView< value_type ****, Kokkos::LayoutRight, Device > vector_dualview_t
Definition: col_grid_matrix.hpp:37
internal_values_array_t values_
Definition: col_grid_matrix.hpp:131
void add_identity_multiply(const_vector_view_t dist_col, vector_view_t dist_iter) const override
Definition: col_grid_matrix.tpp:262
Kokkos::View< value_type ****, Kokkos::LayoutRight, Device > vector_view_t
Definition: col_grid_matrix.hpp:35
const size_type batch_size_
Definition: col_grid_matrix.hpp:76
InvalidMatrixType(const GridMatrix< Device > *const mtx)
Definition: col_grid_matrix.hpp:205
Kokkos::View< const value_type ****, Kokkos::LayoutRight, Device > const_vector_view_t
Definition: col_grid_matrix.hpp:36
int index_type
Definition: col_grid_matrix.hpp:26
typename GridMatrix< Device >::vector_dualview_t vector_dualview_t
Definition: col_grid_matrix.hpp:95
LinAlgBackend
Definition: col_grid_matrix.hpp:221
typename GridMatrix< Device >::const_vector_dualview_t const_vector_dualview_t
Definition: col_grid_matrix.hpp:96
Kokkos::View< index_type **, device >::HostMirror host_index_map_LU()
Definition: col_grid_matrix.hpp:46
index_type get_num_rows() const
Definition: col_grid_matrix.hpp:67
CSCMatrix(size_type n_nodes, index_type num_species, int nvr, int nvz)
Definition: col_grid_matrix.hpp:98
const index_type num_nodes_
Definition: col_grid_matrix.hpp:75
virtual void add_identity_multiply(const_vector_view_t dist_col, vector_view_t dist_iter) const =0
typename GridMatrix< Device >::index_type index_type
Definition: col_grid_matrix.hpp:86
std::string what_
Definition: col_grid_matrix.hpp:217
Device device
Definition: col_grid_matrix.hpp:28
virtual values_array_t get_values()=0
Kokkos::View< int *, host_type > LU_colptr_
Definition: col_grid_matrix.hpp:134
void apply_solve(const_vector_dualview_t b, vector_dualview_t x) const override
Definition: col_grid_matrix.tpp:319
virtual void subtract_from_identity()=0