OGS  v6.4.0
MathLib::EigenLisLinearSolver Class Referencefinal

Detailed Description

Linear solver using Lis library with Eigen matrix and vector objects

Definition at line 29 of file EigenLisLinearSolver.h.

#include <EigenLisLinearSolver.h>

Collaboration diagram for MathLib::EigenLisLinearSolver:

Public Member Functions

 EigenLisLinearSolver (const std::string solver_name, BaseLib::ConfigTree const *const option)
 
void setOption (const LisOption &option)
 
bool solve (EigenMatrix &A, EigenVector &b, EigenVector &x)
 

Private Attributes

LisOption _lis_option
 

Constructor & Destructor Documentation

◆ EigenLisLinearSolver()

MathLib::EigenLisLinearSolver::EigenLisLinearSolver ( const std::string  solver_name,
BaseLib::ConfigTree const *const  option 
)

Constructor

Parameters
solver_nameA name used as a prefix for command line options if there are such options available.
optionA pointer to a linear solver option. In case you omit this argument, default settings follow those of LisOption struct.

Definition at line 26 of file EigenLisLinearSolver.cpp.

29  : _lis_option(option)
30 {
31 }

Member Function Documentation

◆ setOption()

void MathLib::EigenLisLinearSolver::setOption ( const LisOption option)
inline

copy linear solvers options

Definition at line 46 of file EigenLisLinearSolver.h.

46 { _lis_option = option; }

References _lis_option.

◆ solve()

bool MathLib::EigenLisLinearSolver::solve ( EigenMatrix A,
EigenVector b,
EigenVector x 
)

Definition at line 33 of file EigenLisLinearSolver.cpp.

35 {
36  static_assert(EigenMatrix::RawMatrixType::IsRowMajor,
37  "Sparse matrix is required to be in row major storage.");
38  auto &A = A_.getRawMatrix();
39  auto &b = b_.getRawVector();
40  auto &x = x_.getRawVector();
41 
42  if (!A.isCompressed())
43  A.makeCompressed();
44  int nnz = A.nonZeros();
45  int* ptr = A.outerIndexPtr();
46  int* col = A.innerIndexPtr();
47  double* data = A.valuePtr();
48  LisMatrix lisA(A_.getNumberOfRows(), nnz, ptr, col, data);
49  LisVector lisb(b.rows(), b.data());
50  LisVector lisx(x.rows(), x.data());
51 
52  LisLinearSolver lissol; // TODO not always create Lis solver here
53  lissol.setOption(_lis_option);
54  bool const status = lissol.solve(lisA, lisb, lisx);
55 
56  for (std::size_t i=0; i<lisx.size(); i++)
57  x[i] = lisx[i];
58 
59  return status;
60 }

References _lis_option, MathLib::EigenMatrix::getNumberOfRows(), MathLib::EigenMatrix::getRawMatrix(), MathLib::EigenVector::getRawVector(), MathLib::LisLinearSolver::setOption(), MathLib::LisVector::size(), and MathLib::LisLinearSolver::solve().

Member Data Documentation

◆ _lis_option

LisOption MathLib::EigenLisLinearSolver::_lis_option
private

Definition at line 51 of file EigenLisLinearSolver.h.

Referenced by setOption(), and solve().


The documentation for this class was generated from the following files: