IFEM 90A354
ISTLMatrix.h
Go to the documentation of this file.
1// $Id$
2//==============================================================================
13//==============================================================================
14
15#ifndef _ISTL_MATRIX_H
16#define _ISTL_MATRIX_H
17
18#include "SparseMatrix.h"
19#include "ISTLSolParams.h"
20#include <memory>
21
22class LinSolParams;
23
24
29class ISTLVector : public StdVector
30{
31public:
33 explicit ISTLVector(const ProcessAdm& padm);
35 ISTLVector(const ProcessAdm& padm, size_t n);
37 ISTLVector(const ProcessAdm& padm, const Real* values, size_t n);
41 ~ISTLVector() override;
42
44 LinAlg::MatrixType getType() const override { return LinAlg::ISTL; }
45
47 void init(Real value = Real(0)) override;
48
50 size_t dim() const override { return x.size(); }
51
53 void redim(size_t n) override;
54
56 bool endAssembly() override;
57
59 Real L1norm() const override;
60
62 Real L2norm() const override;
63
65 Real Linfnorm() const override;
66
68 const ProcessAdm& getAdm() const { return adm; }
69
71 ISTL::Vec& getVector() { return x; }
73 const ISTL::Vec& getVector() const { return x; }
74
75protected:
76 ISTL::Vec x;
77 const ProcessAdm& adm;
78};
79
80
86{
87public:
89 ISTLMatrix(const ProcessAdm& padm, const LinSolParams& spar);
91 ISTLMatrix(const ISTLMatrix& A);
93 ~ISTLMatrix() override;
94
96 LinAlg::MatrixType getType() const override { return LinAlg::ISTL; }
97
99 size_t dim(int = 1) const override { return 0; }
100
102 SystemMatrix* copy() const override { return new ISTLMatrix(*this); }
103
107 void initAssembly(const SAM& sam, char) override;
108
110 void init() override;
111
113 bool endAssembly() override;
114
117 bool solve(SystemVector& B, Real*) override;
118
122 bool solve(const SystemVector& B, SystemVector& x) override;
123
125 Real Linfnorm() const override;
126
128 ISTL::Mat& getMatrix() { return iA; }
130 const ISTL::Mat& getMatrix() const { return iA; }
131
132protected:
134 void handleSolverReset();
135
136 std::unique_ptr<ISTL::Operator> op;
137 std::unique_ptr<ISTL::InverseOperator> solver;
138 std::unique_ptr<ISTL::Preconditioner> pre;
139
140 ISTL::Mat iA;
143 int nLinSolves = 0;
144};
145
146#endif
Linear solver parameters for ISTL matrices.
#define Real
The floating point type to use.
Definition ImmersedBoundaries.h:18
Representation of the system matrix on an unstructured sparse format.
Class for representing the system matrix in ISTL format.
Definition ISTLMatrix.h:86
const ProcessAdm & adm
Process administrator.
Definition ISTLMatrix.h:141
ISTL::Mat & getMatrix()
Returns the ISTL matrix (for assignment).
Definition ISTLMatrix.h:128
SystemMatrix * copy() const override
Creates a copy of the system matrix and returns a pointer to it.
Definition ISTLMatrix.h:102
int nLinSolves
Number of linear solves.
Definition ISTLMatrix.h:143
std::unique_ptr< ISTL::Preconditioner > pre
Preconditioner to use.
Definition ISTLMatrix.h:138
const ISTL::Mat & getMatrix() const
Returns the ISTL matrix (for read access).
Definition ISTLMatrix.h:130
bool endAssembly() override
Copies the assembled matrix into iA.
Definition ISTLMatrix.C:150
LinAlg::MatrixType getType() const override
Returns the matrix type.
Definition ISTLMatrix.h:96
bool solve(SystemVector &B, Real *) override
Solves the linear system of equations for a given right-hand-side.
Definition ISTLMatrix.C:169
size_t dim(int=1) const override
Returns the dimension of the system matrix.
Definition ISTLMatrix.h:99
std::unique_ptr< ISTL::InverseOperator > solver
Solver to use.
Definition ISTLMatrix.h:137
ISTLSolParams solParams
Linear solver parameters.
Definition ISTLMatrix.h:142
void init() override
Initializes the matrix to zero assuming it is properly dimensioned.
Definition ISTLMatrix.C:160
void initAssembly(const SAM &sam, char) override
Initializes the element assembly process. that are needed before the actual assembly can start are pe...
Definition ISTLMatrix.C:120
Real Linfnorm() const override
Returns the L-infinity norm of the matrix.
Definition ISTLMatrix.C:232
void handleSolverReset()
Handles solver resets.
Definition ISTLMatrix.C:238
std::unique_ptr< ISTL::Operator > op
The matrix adapter.
Definition ISTLMatrix.h:136
~ISTLMatrix() override
The destructor frees the dynamically allocated arrays.
Definition ISTLMatrix.C:114
ISTL::Mat iA
The actual ISTL matrix.
Definition ISTLMatrix.h:140
Class for ISTL solver parameters.
Definition ISTLSolParams.h:225
Class for representing the system vector in ISTL format.
Definition ISTLMatrix.h:30
Real Linfnorm() const override
Linfinity-norm of vector.
Definition ISTLMatrix.C:92
ISTL::Vec & getVector()
Returns the ISTL vector (for assignment).
Definition ISTLMatrix.h:71
void redim(size_t n) override
Sets the dimension of the system vector.
Definition ISTLMatrix.C:64
bool endAssembly() override
Copies the assembled vector into x.
Definition ISTLMatrix.C:71
const ISTL::Vec & getVector() const
Returns the ISTL vector (for read access).
Definition ISTLMatrix.h:73
size_t dim() const override
Returns the dimension of the system vector.
Definition ISTLMatrix.h:50
~ISTLVector() override
Destructor.
Definition ISTLMatrix.C:51
const ProcessAdm & getAdm() const
Return associated process administrator.
Definition ISTLMatrix.h:68
const ProcessAdm & adm
Process administrator.
Definition ISTLMatrix.h:77
ISTL::Vec x
The actual ISTL vector.
Definition ISTLMatrix.h:76
Real L1norm() const override
L1-norm of vector.
Definition ISTLMatrix.C:80
LinAlg::MatrixType getType() const override
Returns the vector type.
Definition ISTLMatrix.h:44
Real L2norm() const override
L2-norm of vector.
Definition ISTLMatrix.C:86
void init(Real value=Real(0)) override
Initializes the vector to a given scalar value.
Definition ISTLMatrix.C:57
Class for linear solver parameters.
Definition LinSolParams.h:67
Class for administration of MPI processes in IFEM library.
Definition ProcessAdm.h:33
This class contains data and functions for the assembly of FE matrices.
Definition SAM.h:39
Class for representing a system matrix on an unstructured sparse form.
Definition SparseMatrix.h:38
Vector A
Stores the nonzero matrix elements.
Definition SparseMatrix.h:298
Standard system vector stored as a single continuous array.
Definition SystemMatrix.h:124
virtual const Vector & vec() const
Reference to underlying utl::vector.
Definition SystemMatrix.h:171
Base class for representing a system matrix on different formats.
Definition SystemMatrix.h:220
Base class for representing a system vector on different formats.
Definition SystemMatrix.h:32
MatrixType
The available system matrix formats and associated solvers.
Definition LinAlgenums.h:22
@ ISTL
Sparse matrices / Dune solver.
Definition LinAlgenums.h:28