Files
FESADev/src/fesa/solvers/linear/pardiso_session.h
T

61 lines
1.7 KiB
C++

#ifndef FESA_SRC_FESA_SOLVERS_LINEAR_PARDISO_SESSION_H_
#define FESA_SRC_FESA_SOLVERS_LINEAR_PARDISO_SESSION_H_
#include <array>
#include <vector>
#include <mkl.h>
#include "fesa/core/status.h"
namespace fesa {
class SparseMatrix;
class Vector;
namespace pardiso_internal {
/// @brief Retains the two existing CSR and pivot policies.
enum class PardisoMatrixPolicy { kSpdUpper, kUnsymmetricFull };
/// @brief Owns one backend factorization, CSR storage and phase lifecycle.
/// @note No symbolic reuse is performed across Factorize calls.
class PardisoSession final {
public:
explicit PardisoSession(PardisoMatrixPolicy policy);
~PardisoSession();
PardisoSession(const PardisoSession&) = delete;
PardisoSession& operator=(const PardisoSession&) = delete;
Status Factorize(const SparseMatrix& matrix);
Status Solve(const Vector& rhs, Vector& solution);
private:
Status CopyValidatedUpperTriangle(const SparseMatrix& matrix);
Status CopyValidatedFullCsr(const SparseMatrix& matrix);
void CallPardiso(MKL_INT phase, double* rhs, double* solution,
MKL_INT& error);
MKL_INT Release() noexcept;
void ClearOwnedArrays() noexcept;
std::array<void*, 64U> pt_{};
std::array<MKL_INT, 64U> iparm_{};
std::vector<MKL_INT> row_offsets_;
std::vector<MKL_INT> column_indices_;
std::vector<MKL_INT> permutation_;
std::vector<double> values_;
MKL_INT equation_count_{0};
MKL_INT max_factorizations_{1};
MKL_INT matrix_number_{1};
const PardisoMatrixPolicy policy_;
MKL_INT mtype_;
MKL_INT rhs_count_{1};
MKL_INT message_level_{0};
bool owns_pardiso_state_{false};
bool factorized_{false};
};
} // namespace pardiso_internal
} // namespace fesa
#endif // FESA_SRC_FESA_SOLVERS_LINEAR_PARDISO_SESSION_H_