1
// Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle
3
// See the LICENSE.txt file for license information. Please report all
4
// bugs and problems to <gmsh@geuz.org>.
6
#ifndef _LINEAR_SYSTEM_GMM_H_
7
#define _LINEAR_SYSTEM_GMM_H_
11
#include "GmshConfig.h"
12
#include "GmshMessage.h"
13
#include "linearSystem.h"
18
template <class scalar>
19
class linearSystemGmm : public linearSystem<scalar> {
21
gmm::row_matrix<gmm::wsvector<scalar> > *_a;
22
std::vector<scalar> *_b, *_x;
27
: _a(0), _b(0), _x(0), _prec(1.e-8), _noisy(0), _gmres(0) {}
28
virtual bool isAllocated() const { return _a != 0; }
29
virtual void allocate(int _nbRows)
32
_a = new gmm::row_matrix< gmm::wsvector<scalar> >(_nbRows, _nbRows);
33
_b = new std::vector<scalar>(_nbRows);
34
_x = new std::vector<scalar>(_nbRows);
36
virtual ~linearSystemGmm()
49
virtual void addToMatrix(int _row, int _col, scalar _val)
51
if(_val != 0.0) (*_a)(_row, _col) += _val;
53
virtual scalar getFromMatrix (int _row, int _col) const
55
return (*_a)(_row, _col);
57
virtual void addToRightHandSide(int _row, scalar _val)
59
if(_val != 0.0) (*_b)[_row] += _val;
61
virtual scalar getFromRightHandSide(int _row) const
65
virtual scalar getFromSolution(int _row) const
69
virtual void zeroMatrix()
73
virtual void zeroRightHandSide()
75
for(unsigned int i = 0; i < _b->size(); i++) (*_b)[i] = 0.;
77
void setPrec(double p){ _prec = p; }
78
void setNoisy(int n){ _noisy = n; }
79
void setGmres(int n){ _gmres = n; }
80
virtual int systemSolve()
82
//gmm::ilutp_precond<gmm::row_matrix<gmm::wsvector<scalar> > > P(*_a, 25, 0.);
83
gmm::ildltt_precond<gmm::row_matrix<gmm::wsvector<scalar> > > P(*_a, 30, 1.e-10);
84
gmm::iteration iter(_prec);
85
iter.set_noisy(_noisy);
86
if(_gmres) gmm::gmres(*_a, *_x, *_b, P, 100, iter);
87
else gmm::cg(*_a, *_x, *_b, P, iter);
94
template <class scalar>
95
class linearSystemGmm : public linearSystem<scalar> {
99
Msg::Error("Gmm++ is not available in this version of Gmsh");
101
virtual bool isAllocated() const { return false; }
102
virtual void allocate(int nbRows) {}
103
virtual void addToMatrix(int _row, int _col, scalar val) {}
104
virtual scalar getFromMatrix(int _row, int _col) const { return 0.; }
105
virtual void addToRightHandSide(int _row, scalar val) {}
106
virtual scalar getFromRightHandSide(int _row) const { return 0.; }
107
virtual scalar getFromSolution(int _row) const { return 0.; }
108
virtual void zeroMatrix() {}
109
virtual void zeroRightHandSide() {}
110
virtual int systemSolve() { return 0; }
111
void setPrec(double p){}
112
virtual void clear(){}
113
void setNoisy(int n){}
114
void setGmres(int n){}