Class documentation of Concepts

Loading...
Searching...
No Matches
PETSc.hh
Go to the documentation of this file.
1
9#ifndef op_PETSC_hh
10#define op_PETSC_hh
11
12extern "C" {
13 // forwards for PETSc
14 typedef struct _p_SLES* SLES;
15 typedef struct _p_Mat* Mat;
16 typedef struct _p_Vec* Vec;
17}
18#include <string>
19
20#include "compositions.hh"
21#include "basics/typedefs.hh"
22#include "matrix.hh"
23
24namespace concepts {
25
26 // forward declarations
27 template<class F>
28 class Function;
29
30 template<class F>
31 class Vector;
32
33 template<class F>
34 class Space;
35
36 template<class F, class G>
37 class BilinearForm;
38
39 // **************************************************************** PETSc **
40
74 class PETSc : public Operator<Real> {
75 public:
82 PETSc(Operator<Real>& A, const Real maxeps, const std::string ksptype,
83 const std::string pctype = std::string("none"));
84 ~PETSc();
85 virtual void operator()(const Function<Real>& fncY, Function<Real>& fncX);
86
90 uint iterations() const { return iterations_; }
91 protected:
92 virtual std::ostream& info(std::ostream& os) const;
93 private:
94 typedef int (*multPointer)(Mat, Vec, Vec);
95 typedef void (*PETScmultPointer)();
96
99
101 int iterations_;
102
104 Mat PETScA_;
105 bool destroyPETScA_;
106
108 SLES solver_;
109
111 Vec x_, y_;
112 };
113
114 // ************************************************************* PETScMat **
115
148 class PETScMat : public Matrix<Real> {
149 public:
153
158
161
162 ~PETScMat();
163
164 virtual void operator()(const Function<double>& fncY,
166 virtual void operator()(const Function<std::complex<double> >& fncY,
167 Function<std::complex<double> >& fncX);
168 void operator()(const Vector<double>& fncY,
170 virtual void transpMult(const Vector<double>& fncY,
172 virtual void transpMult(const Vector<std::complex<double> >& fncY,
173 Vector<std::complex<double> >& fncX);
174
175 virtual Real operator()(const uint i, const uint j) const;
181 virtual Real& operator()(const uint i, const uint j);
182
183 virtual const Space<double>& spaceX() const { return spcX_; }
184 virtual const Space<double>& spaceY() const { return spcY_; }
185
187 operator Mat() { return A_; }
188
189 void storeMatlab(const char* name) const;
190 protected:
191 std::ostream& info(std::ostream& os) const;
192 private:
194 const Space<Real>& spcX_;
195
197 uint nX_;
198
200 const Space<Real>& spcY_;
201
203 uint nY_;
204
206 Vec x_, y_;
207
209 Mat A_;
210 };
211
212} // namespace concepts
213
214#endif // op_PETSC_hh
virtual Real operator()(const uint i, const uint j) const
Returns entry with indices i and j.
PETScMat(const Space< Real > &spcX, const Space< Real > &spcY)
PETScMat(const Space< Real > &spc, BilinearForm< Real, Real > &bf)
PETScMat(const SparseMatrix< Real > &matrix)
Constructor. Copies the matrix from matrix.
virtual Real & operator()(const uint i, const uint j)
std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
uint iterations() const
Definition PETSc.hh:90
PETSc(Operator< Real > &A, const Real maxeps, const std::string ksptype, const std::string pctype=std::string("none"))
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320