CppNoddy  0.92
Loading...
Searching...
No Matches
SparseLinearSystem.h
Go to the documentation of this file.
1/// \file SparseLinearSystem.h
2/// Specification of a sparse-storage linear system class.
3
4#ifndef SPARSELINEARSYSTEM_H
5#define SPARSELINEARSYSTEM_H
6
7#include <SparseMatrix.h>
8#include <DenseVector.h>
9#include <Exceptions.h>
10
11#if defined(PETSC_Z) || defined(PETSC_D)
12#include "petscksp.h"
13#endif
14
15namespace CppNoddy {
16 /// A linear system class for vector right-hand sides.
17 /// The class is constructed for SPARSE problems of the form
18 /// \f[ A_{NxN} \,{\underline x}_i = B_{1xN} \f].
19 template <typename _Type>
21
22 public:
23
24 /// Constructor for a sparse linear system object.
25 /// \param Aptr A pointer to the 'A matrix', an NxN double/complex sparse matrix
26 /// \param Bptr A pointer to the 'B vector' a size N double/complex dense vector
27 /// \param which A string that indicates which solver to use: native (default) pr petsc
28 SparseLinearSystem(SparseMatrix<_Type>* Aptr, DenseVector<_Type>* Bptr, std::string which = "native");
29
30 /// Destructor for a linear system object.
32
33 /// deallocates some objects
34 void cleanup();
35
36 /// Solve the sparse system
37 void solve();
38
39 /// Factorise the Ax=B system
40 void factorise();
41
42 /// Resolve the same system using the same factorisation
44
45 void temp_solve();
46
47 private:
48 // solve by linking to PETSc
49 void solve_petsc();
50
51 // factorise by linking to PETSc -- allow for re-solves
52 void factorise_petsc();
53
54 /// pointer to a sparse LHS matrix
56 /// pointer to the RHS vector
58
59 /// a string ID to pick out the appropriate solver
60 std::string m_version;
61
62 /// indicates that the matrix has been factorised
63 bool m_factorised;
64
65#if defined(PETSC_Z) || defined(PETSC_D)
66 Vec m_petsc_x,m_petsc_B; /* B = RHS and x = soln */
67 Mat m_petsc_F;
68 KSP m_petsc_ksp; /* linear solver context */
69 PC m_petsc_pc; /* preconditioner -- though hard wired for MUMPS direct method */
70 PetscMPIInt m_petsc_rank, m_petsc_size;
71#endif
72 };
73
74} //end namepsace
75#endif
Specification for a templated DenseVector class – a dense, dynamic, vector object.
The collection of CppNoddy exceptions.
A matrix class that constructs a SPARSE matrix as an STL Vector of SparseVectors, inheriting from Mat...
An DenseVector class – a dense vector object.
Definition: DenseVector.h:34
A linear system class for vector right-hand sides.
void factorise()
Factorise the Ax=B system.
void solve()
Solve the sparse system.
void solve_using_factorisation()
Resolve the same system using the same factorisation.
void cleanup()
deallocates some objects
~SparseLinearSystem()
Destructor for a linear system object.
A matrix class that constructs a SPARSE matrix as a row major std::vector of SparseVectors.
Definition: SparseMatrix.h:31
A collection of OO numerical routines aimed at simple (typical) applied problems in continuum mechani...

© 2012

R.E. Hewitt