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 


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.

28  : lis_option_(option)
29 {
30 }

Member Function Documentation

◆ setOption()

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

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 32 of file EigenLisLinearSolver.cpp.

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

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

Referenced by ProcessLib::ComponentTransport::ComponentTransportProcess::solveReactionEquation().

Member Data Documentation

◆ lis_option_

LisOption MathLib::EigenLisLinearSolver::lis_option_

Definition at line 51 of file EigenLisLinearSolver.h.

Referenced by setOption(), and solve().

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