31#include "../code_config.hpp"
35#ifdef CODI_FORWARD_TYPE
36#error Cannot use PaStiX with forward mode AD
54template <
class ScalarType>
57 pastix_data_t* state{};
60 vector<pastix_int_t> colptr;
61 vector<pastix_int_t> rowidx;
62 vector<su2mixedfloat> values;
63 vector<pastix_int_t> loc2glb;
64 vector<pastix_int_t> perm;
65 vector<su2mixedfloat> workvec;
67 vector<unsigned long> csr_row_ptr;
68 vector<unsigned long> csr_col_ind;
70 pastix_int_t iparm[IPARM_SIZE];
71 double dparm[DPARM_SIZE];
81 const ScalarType*
d =
nullptr;
82 const ScalarType*
l =
nullptr;
83 const ScalarType*
u =
nullptr;
93 unsigned short verb{};
97 vector<unsigned long> sort_rows;
98 vector<vector<unsigned long>> sort_order;
105 iparm[IPARM_VERBOSE] = (verb > 0) ? PastixVerboseNo : PastixVerboseNot;
106 pastixFinalize(&state);
107 spm.colptr =
nullptr;
108 spm.rowptr =
nullptr;
109 spm.values =
nullptr;
110 if (mpi_size > 1) spm.loc2glob =
nullptr;
112 isfactorized =
false;
113 isinitialized =
false;
125 void AssembleValues();
157 const ScalarType*
l,
const ScalarType*
u) {
171 csr_col_ind.reserve(nnz_domain);
173 csr_row_ptr[i] =
static_cast<unsigned long>(csr_col_ind.size());
174 for (
auto k =
row_ptr_l[i]; k <
row_ptr_l[i + 1]; ++k) csr_col_ind.push_back(col_ind_l[k]);
175 csr_col_ind.push_back(i);
176 for (
auto k =
row_ptr_u[i]; k <
row_ptr_u[i + 1]; ++k) csr_col_ind.push_back(col_ind_u[k]);
178 csr_row_ptr[
nPointDomain] =
static_cast<unsigned long>(csr_col_ind.size());
206 if (iparm[IPARM_FACTORIZATION] == PastixFactLDLT || transpose) {
207 iparm[IPARM_TRANSPOSE_SOLVE] = PastixNoTrans;
209 iparm[IPARM_TRANSPOSE_SOLVE] = PastixTrans;
211 iparm[IPARM_VERBOSE] = PastixVerboseNot;
213 for (
auto i = 0ul; i < matrix.size_rhs(); ++i) workvec[i] = rhs[i];
214 if (pastix_task_solve(state, matrix.size_rhs(), 1, workvec.data(), matrix.size_rhs()) != PASTIX_SUCCESS) {
217 for (
auto i = 0ul; i < matrix.size_rhs(); ++i) sol[i] = workvec[i];
static int GetRank()
Definition mpi_structure.hpp:524
static void Error(const std::string &ErrorMsg, const std::string &FunctionName)
Definition mpi_structure.cpp:131
static int GetSize()
Definition mpi_structure.hpp:526
Main class for defining the problem; basically this class reads the configuration file,...
Definition CConfig.hpp:64
Parent class for defining the geometry of the problem (complete geometry, multigrid agglomerated geom...
Definition CGeometry.hpp:75
Wrapper class that converts between SU2 sparse format and PaStiX format and simplifies calls to the e...
Definition CPastixWrapper.hpp:55
const ScalarType * l
Lower blocks (matrix-owned).
Definition CPastixWrapper.hpp:82
CPastixWrapper(CPastixWrapper &&)=delete
~CPastixWrapper()
Class destructor.
Definition CPastixWrapper.hpp:139
const su2uint * row_ptr_l
LDU lower row pointers (geometry-owned).
Definition CPastixWrapper.hpp:79
void Factorize(CGeometry *geometry, const CConfig *config, unsigned short kind_fact)
Factorize matrix.
Definition CPastixWrapper.cpp:229
bool IsSetup() const
Returns true once SetLDU has been called.
Definition CPastixWrapper.hpp:144
void SetLDU(unsigned long nVar, unsigned long nPoint, unsigned long nPointDomain, const su2uint *row_ptr_l, const su2uint *col_ind_l, const su2uint *row_ptr_u, const su2uint *col_ind_u, const ScalarType *d, const ScalarType *l, const ScalarType *u)
Set LDU structure and value pointers; builds and owns assembled CSR (called once).
Definition CPastixWrapper.hpp:155
void Solve(const T &rhs, T &sol)
Runs the "solve" task for any rhs/sol with operator [].
Definition CPastixWrapper.hpp:202
unsigned long blkSz
Block size (nVar * nVar) for value assembly.
Definition CPastixWrapper.hpp:77
CPastixWrapper(const CPastixWrapper &)=delete
const su2uint * row_ptr_u
LDU upper row pointers (geometry-owned).
Definition CPastixWrapper.hpp:80
unsigned long nVar
Definition CPastixWrapper.hpp:74
unsigned long nPointDomain
Definition CPastixWrapper.hpp:76
unsigned long nPoint
Definition CPastixWrapper.hpp:75
CPastixWrapper & operator=(const CPastixWrapper &)=delete
const ScalarType * d
Diagonal blocks (matrix-owned).
Definition CPastixWrapper.hpp:81
const ScalarType * u
Upper blocks (matrix-owned).
Definition CPastixWrapper.hpp:83
void SetTransposedSolve(bool transposed=true)
Request solves with the transposed matrix.
Definition CPastixWrapper.hpp:194
CPastixWrapper & operator=(CPastixWrapper &&)=delete
uint32_t su2uint
Definition code_config.hpp:121
#define CURRENT_FUNCTION
Definition mpi_structure.hpp:59