2 #include <lac/sparse_matrix.h>
3 #include <lac/sparsity_pattern.h>
4 #include <lac/vector.h>
5 #include <lac/block_sparse_matrix.h>
13 template <
typename ValueType>
24 int nnz = deal_mat.n_nonzero_elements();
29 ValueType *val = NULL;
35 dealii::BlockSparseMatrix<double>::iterator it = deal_mat.begin(),
36 it_end = deal_mat.end();
39 for (; it!=it_end; ++it) {
41 col[
i] = it.operator*().column();
42 row[
i] = it.operator*().row();
43 val[
i] = it.operator*().value();
61 template <
typename ValueType>
63 const dealii::SparseMatrix<ValueType> &deal_mat,
70 int nnz = deal_mat.n_nonzero_elements();
75 ValueType *val = NULL;
81 dealii::SparsityPatternIterators::Iterator it = sp.begin();
82 dealii::SparsityPatternIterators::Iterator it_end = sp.end();
85 for (; it!=it_end; ++it) {
87 col[
i] = it->column();
89 val[
i] = deal_mat.el(it->row(),it->column());
105 template <
typename ValueType>
111 ValueType *val = NULL;
114 for (
unsigned int i=0;
i<deal_vec.size(); ++
i)
115 val[
i] = deal_vec[
i];
117 vec->
SetDataPtr(&val,
"DealII vector",
int(deal_vec.size()));
130 template <
typename ValueType>
132 dealii::Vector<ValueType> *deal_vec) {
135 assert(
int(vec.
get_size()) ==
int(deal_vec->size()));
138 ValueType *val = NULL;
142 for (
int i=0;
i<size; ++
i)
143 (*deal_vec)[
i] = val[
i];
156 template <
typename ValueType>
162 ValueType *val = NULL;
165 for (
unsigned int i=0;
i<deal_vec.size(); ++
i)
166 val[
i] = deal_vec[
i];
168 vec->
SetDataPtr(&val,
"DealII vector",
int(deal_vec.size()));
181 template <
typename ValueType>
183 dealii::BlockVector<ValueType> *deal_vec) {
186 assert(
int(vec.
get_size()) ==
int(deal_vec->size()));
189 ValueType *val = NULL;
193 for (
int i=0;
i<size; ++
i)
194 (*deal_vec)[
i] = val[
i];
void ConvertToCSR(void)
Convert the matrix to CSR structure.
Definition: local_matrix.cpp:1387
void import_dealii_matrix(dealii::BlockSparseMatrix< ValueType > &deal_mat, paralution::LocalMatrix< ValueType > *mat)
Import (copy) a Deal.II block sparse matrix using its iterator and accessor into a paralution Local M...
Definition: paralution_dealii.hpp:14
void import_dealii_vector(const dealii::Vector< ValueType > &deal_vec, paralution::LocalVector< ValueType > *vec)
Import (copy) a Deal.II vector into a local vector.
Definition: paralution_dealii.hpp:106
virtual int get_size(void) const
Return the size of the vector.
Definition: local_vector.cpp:46
void allocate_host(const int size, DataType **ptr)
Allocate buffer on the host.
Definition: allocate_free.cpp:26
nnz
Definition: pcg_example.m:8
virtual void MoveToHost(void)
Move the object to the Host backend.
Definition: local_vector.cpp:354
void LeaveDataPtr(ValueType **ptr)
Get a pointer from the vector data and free the vector object.
Definition: local_vector.cpp:162
void SetDataPtrCOO(int **row, int **col, ValueType **val, std::string name, const int nnz, const int nrow, const int ncol)
Initialize a COO matrix on the Host with externally allocated data.
Definition: local_matrix.cpp:492
for i
Definition: pcg_example.m:13
Definition: local_matrix.hpp:15
void export_dealii_vector(paralution::LocalVector< ValueType > &vec, dealii::Vector< ValueType > *deal_vec)
Export (copy) a local vector into a Deal.II vector.
Definition: paralution_dealii.hpp:131
Definition: host_vector.hpp:13
void SetDataPtr(ValueType **ptr, std::string name, const int size)
Initialize a vector with externally allocated data.
Definition: local_vector.cpp:146
void free_host(DataType **ptr)
Free buffer on the host.
Definition: allocate_free.cpp:96