NUMCXX  0.13.20181108
Numerical library for small projects and teaching purposes
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
numcxx::TSolverUMFPACK< T > Class Template Reference

Description

template<typename T>
class numcxx::TSolverUMFPACK< T >

Bridge class for using umfpack as solver for vmatrix.

UMFPACK is a GPL licensed sparse matrix package by Tim Davis of Texas A&M university, see wikipedia and its homepage

Examples:
15-numcxx-umfpack.cxx, 40-stationary-heat-fe.cxx, 41-stationary-heat-fv.cxx, 42-convtest-fem-sin.cxx, 43-convtest-fvm-sin.cxx, 44-transient-heat-fe.cxx, 45-convdiff1d.cxx, and 46-nonlin-fvm.cxx.

Definition at line 20 of file tsolver-umfpack.hxx.

+ Inheritance diagram for numcxx::TSolverUMFPACK< T >:
+ Collaboration diagram for numcxx::TSolverUMFPACK< T >:

Public Member Functions

 TSolverUMFPACK ()
 
 TSolverUMFPACK (const std::shared_ptr< TSparseMatrix< T >> pA)
 Create LU factorization class. More...
 
 TSolverUMFPACK (const TSparseMatrix< T > &A)
 Create LU factorization class. More...
 
 TSolverUMFPACK (const TSolverUMFPACK< T > &A)=delete
 
 ~TSolverUMFPACK ()
 
void update ()
 Perform actual computation of LU factorization. More...
 
void update (const TSparseMatrix< T > &A)
 Perform actual computation of LU factorization. More...
 
void solve (TArray< T > &Sol, const TArray< T > &Rhs)
 Solve LU factorized system. More...
 
void solve (std::shared_ptr< TArray< T > > Sol, const std::shared_ptr< TArray< T > > Rhs)
 
virtual void solve (TArray< T > &sol, const TArray< T > &rhs) const
 

Static Public Member Functions

static std::shared_ptr< TSolverUMFPACK< T > > create (const std::shared_ptr< TSparseMatrix< T >> pA)
 Create LU factorization class. More...
 

Private Attributes

const std::shared_ptr< TSparseMatrix< T > > pMatrix
 The corresponding matrix. More...
 
void * Symbolic
 Pointer to symbolic factorization data. More...
 
void * Numeric
 Pointer to numeric factorization data. More...
 
std::shared_ptr< TArray1< int > > pIA
 Row pointer of matrix. More...
 
std::shared_ptr< TArray1< int > > pJA
 Column indices. More...
 
std::shared_ptr< TArray1< T > > pA
 Entries. More...
 

Constructor & Destructor Documentation

template<typename T>
numcxx::TSolverUMFPACK< T >::TSolverUMFPACK ( )
inline

Definition at line 41 of file tsolver-umfpack.hxx.

41 {};

+ Here is the call graph for this function:

template<typename T >
numcxx::TSolverUMFPACK< T >::TSolverUMFPACK ( const std::shared_ptr< TSparseMatrix< T >>  pA)
inline

Create LU factorization class.

Definition at line 14 of file tsolver-umfpack.ixx.

14  :
16  Symbolic(nullptr),
17  Numeric(nullptr)
18  {
19  update();
20  }
const std::shared_ptr< TSparseMatrix< T > > pMatrix
The corresponding matrix.
void * Numeric
Pointer to numeric factorization data.
void * Symbolic
Pointer to symbolic factorization data.
void update()
Perform actual computation of LU factorization.

+ Here is the call graph for this function:

template<typename T >
numcxx::TSolverUMFPACK< T >::TSolverUMFPACK ( const TSparseMatrix< T > &  A)
inline

Create LU factorization class.

Definition at line 23 of file tsolver-umfpack.ixx.

23  :
24  pMatrix(nullptr),
25  Symbolic(nullptr),
26  Numeric(nullptr)
27  {
28  update(Matrix);
29  }
const std::shared_ptr< TSparseMatrix< T > > pMatrix
The corresponding matrix.
void * Numeric
Pointer to numeric factorization data.
void * Symbolic
Pointer to symbolic factorization data.
void update()
Perform actual computation of LU factorization.

+ Here is the call graph for this function:

template<typename T>
numcxx::TSolverUMFPACK< T >::TSolverUMFPACK ( const TSolverUMFPACK< T > &  A)
delete
template<typename T >
numcxx::TSolverUMFPACK< T >::~TSolverUMFPACK ( )
inline

Definition at line 32 of file tsolver-umfpack.ixx.

33  {
34  if (Symbolic!=nullptr)
35  {
36  umfpack_di_free_symbolic(&Symbolic);
37  Symbolic=nullptr;
38  }
39  if (Numeric!=nullptr)
40  {
41  umfpack_di_free_numeric(&Numeric);
42  Numeric=nullptr;
43  }
44  }
void * Numeric
Pointer to numeric factorization data.
void * Symbolic
Pointer to symbolic factorization data.

Member Function Documentation

template<typename T >
std::shared_ptr< TSolverUMFPACK< T > > numcxx::TSolverUMFPACK< T >::create ( const std::shared_ptr< TSparseMatrix< T >>  pA)
inlinestatic

Create LU factorization class.

Examples:
16-numcxx-umfpack-sharedptr.cxx.

Definition at line 48 of file tsolver-umfpack.ixx.

49  {
50  return std::make_shared<TSolverUMFPACK<T>>(pA);
51  }
std::shared_ptr< TArray1< T > > pA
Entries.
template<typename T >
void numcxx::TSolverUMFPACK< T >::update ( void  )
inlinevirtual

Perform actual computation of LU factorization.

Reimplemented from numcxx::TLinSolver< T >.

Examples:
15-numcxx-umfpack.cxx, 40-stationary-heat-fe.cxx, 41-stationary-heat-fv.cxx, 42-convtest-fem-sin.cxx, 43-convtest-fvm-sin.cxx, 44-transient-heat-fe.cxx, 45-convdiff1d.cxx, and 46-nonlin-fvm.cxx.

Definition at line 55 of file tsolver-umfpack.ixx.

56  {
57  if (pMatrix==nullptr)
58  throw std::runtime_error("numcxx: TSolverUMFPACK created without smartpointer");
59  update(*pMatrix);
60  }
const std::shared_ptr< TSparseMatrix< T > > pMatrix
The corresponding matrix.
void update()
Perform actual computation of LU factorization.
template<typename T >
void numcxx::TSolverUMFPACK< T >::update ( const TSparseMatrix< T > &  A)
inline

Perform actual computation of LU factorization.

copy matrix data for use in solve

Definition at line 62 of file tsolver-umfpack.ixx.

63  {
64  if (Matrix.empty()) return;
65  if (Matrix.pattern_changed())
66  throw std::runtime_error("numcxx: forgot flush() after sparse pattern changed");
67 
68  int n=Matrix.shape(0);
69  int nia=Matrix.pIA->size();
70  int nja=Matrix.pJA->size();
71 
72 
73  // double Control[UMFPACK_CONTROL];
74  // for (int i=0;i<UMFPACK_CONTROL;i++) Control[i]=0.0;
75  // Control[UMFPACK_PIVOT_TOLERANCE]=pivot_tolerance;
76  // Control[UMFPACK_DROPTOL]=drop_tolerance;
77  // Control[UMFPACK_PRL]=0;
78  // double *control=Control;
79  // if (pivot_tolerance<0) control=0;
80  double *control=nullptr;
81 
82  int status;
83  if (Matrix.pattern_changed() || Symbolic==nullptr)
84  {
85  if (Symbolic) umfpack_di_free_symbolic(&Symbolic),Symbolic=nullptr;
86  if (Numeric) umfpack_di_free_numeric(&Numeric),Numeric=nullptr;
87  status=umfpack_di_symbolic (n, n, Matrix.pIA->data(), Matrix.pJA->data(), Matrix.pA->data(), &Symbolic, 0, 0);
88  if (status>1)
89  {
90  char errormsg[80];
91  snprintf(errormsg,80,"numcxx::TSolverUMFPACK::update: umfpack_di_symbolic error %d\n",status);
92  throw std::runtime_error(errormsg);
93  }
94 
95  }
96  if (Numeric!=nullptr)
97  {
98  umfpack_di_free_numeric(&Numeric);
99  Numeric=nullptr;
100  }
101  status =umfpack_di_numeric (Matrix.pIA->data(), Matrix.pJA->data(), Matrix.pA->data(), Symbolic, &Numeric, control, 0) ;
102  if (status>1)
103  {
104  char errormsg[80];
105  snprintf(errormsg,80,"numcxx::TSolverUMFPACK::update: umfpack_di_numeric error %d\n",status);
106  throw std::runtime_error(errormsg);
107  }
109  pIA=Matrix.pIA;
110  pJA=Matrix.pJA;
111  pA=Matrix.pA;
112  }
std::shared_ptr< TArray1< int > > pIA
Row pointer of matrix.
std::shared_ptr< TArray1< int > > pJA
Column indices.
std::shared_ptr< TArray1< T > > pA
Entries.
void * Numeric
Pointer to numeric factorization data.
void * Symbolic
Pointer to symbolic factorization data.

+ Here is the call graph for this function:

template<typename T >
void numcxx::TSolverUMFPACK< T >::solve ( TArray< T > &  Sol,
const TArray< T > &  Rhs 
)
inline

Solve LU factorized system.

Examples:
15-numcxx-umfpack.cxx, 40-stationary-heat-fe.cxx, 41-stationary-heat-fv.cxx, 42-convtest-fem-sin.cxx, 43-convtest-fvm-sin.cxx, 44-transient-heat-fe.cxx, 45-convdiff1d.cxx, and 46-nonlin-fvm.cxx.

Definition at line 116 of file tsolver-umfpack.ixx.

117  {
118  Sol.resize(Rhs.size());
119  double *control=nullptr;
120  int status;
121  status=umfpack_di_solve (UMFPACK_At,pIA->data(), pJA->data(),pA->data(), Sol.data(), Rhs.data(), Numeric, control, 0 ) ;
122  if (status>1)
123  {
124  char errormsg[80];
125  snprintf(errormsg,80,"numcxx::TSolverUMFPACK::update: umfpack_di_solve error %d\n",status);
126  throw std::runtime_error(errormsg);
127  }
128  }
std::shared_ptr< TArray1< int > > pIA
Row pointer of matrix.
std::shared_ptr< TArray1< int > > pJA
Column indices.
std::shared_ptr< TArray1< T > > pA
Entries.
void * Numeric
Pointer to numeric factorization data.

+ Here is the call graph for this function:

template<typename T>
void numcxx::TSolverUMFPACK< T >::solve ( std::shared_ptr< TArray< T > >  Sol,
const std::shared_ptr< TArray< T > >  Rhs 
)
inline

Definition at line 66 of file tsolver-umfpack.hxx.

66 {solve(*Sol,*Rhs);};
void solve(TArray< T > &Sol, const TArray< T > &Rhs)
Solve LU factorized system.

+ Here is the call graph for this function:

template<typename T >
virtual void numcxx::TLinSolver< T >::solve ( TArray< T > &  sol,
const TArray< T > &  rhs 
) const
inlinevirtualinherited

Reimplemented in numcxx::TSolverLapackLU< T >, numcxx::TPreconILU< T >, and numcxx::TPreconJacobi< T >.

Definition at line 279 of file tarray.hxx.

279 {};

Member Data Documentation

template<typename T>
const std::shared_ptr< TSparseMatrix<T> > numcxx::TSolverUMFPACK< T >::pMatrix
private

The corresponding matrix.

Definition at line 23 of file tsolver-umfpack.hxx.

template<typename T>
void* numcxx::TSolverUMFPACK< T >::Symbolic
private

Pointer to symbolic factorization data.

Definition at line 26 of file tsolver-umfpack.hxx.

template<typename T>
void* numcxx::TSolverUMFPACK< T >::Numeric
private

Pointer to numeric factorization data.

Definition at line 29 of file tsolver-umfpack.hxx.

template<typename T>
std::shared_ptr<TArray1<int> > numcxx::TSolverUMFPACK< T >::pIA
private

Row pointer of matrix.

Definition at line 32 of file tsolver-umfpack.hxx.

template<typename T>
std::shared_ptr<TArray1<int> > numcxx::TSolverUMFPACK< T >::pJA
private

Column indices.

Definition at line 35 of file tsolver-umfpack.hxx.

template<typename T>
std::shared_ptr<TArray1 <T> > numcxx::TSolverUMFPACK< T >::pA
private

Entries.

Definition at line 38 of file tsolver-umfpack.hxx.


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