Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_SpMatUtil.H
Go to the documentation of this file.
1#ifndef AMREX_SPMAT_UTIL_H_
2#define AMREX_SPMAT_UTIL_H_
3#include <AMReX_Config.H>
4
5#include <AMReX_SpMatrix.H>
6
7namespace amrex {
8
9template <typename T, template <typename> class V>
10CSR<T,V> transpose (CSR<T,V> const& csr, Long ncols)
11{
12 Long nnz = csr.nnz;
13
14 CSR<T,V> csrt;
15 csrt.mat.resize(nnz);
16 csrt.col_index.resize(nnz);
17 csrt.row_offset.resize(ncols+1);
18 csrt.nnz = nnz;
19
20 detail::transpose(csrt.view(), csr.const_view());
21
22 return csrt;
23}
24
25template <typename T, template<typename> class Allocator>
27 AlgPartition col_partition)
28{
29 const_cast<SpMatrix<T,Allocator>&>(A).startComm_tr(col_partition);
30
32 AT.m_row_begin = col_partition[ParallelDescriptor::MyProc()];
33 AT.m_row_end = col_partition[ParallelDescriptor::MyProc()+1];
34 AT.m_partition = std::move(col_partition);
35 AT.m_nnz = A.m_csr.nnz;
36
37 // transpose the diagonal part
38 auto at_csr = transpose(A.m_csr, AT.numLocalRows());
39 AT.m_csr = std::move(at_csr);
40
41 const_cast<SpMatrix<T,Allocator>&>(A).finishComm_tr(AT);
42
43 return AT;
44}
45
46}
47
48#endif
Definition AMReX_AlgPartition.H:14
Definition AMReX_SpMatrix.H:52
Long numLocalRows() const
Definition AMReX_SpMatrix.H:178
amrex_long Long
Definition AMReX_INT.H:30
int MyProc() noexcept
Definition AMReX_ParallelDescriptor.H:128
Definition AMReX_Amr.cpp:49
CSR< T, V > transpose(CSR< T, V > const &csr, Long ncols)
Definition AMReX_SpMatUtil.H:10
Definition AMReX_CSR.H:30
V< Long > row_offset
Definition AMReX_CSR.H:33
Long nnz
Definition AMReX_CSR.H:34
CsrView< T > view()
Definition AMReX_CSR.H:47
CsrView< T const > const_view() const
Definition AMReX_CSR.H:57
V< Long > col_index
Definition AMReX_CSR.H:32
V< T > mat
Definition AMReX_CSR.H:31