File: linearSystem.h

package info (click to toggle)
gmsh 4.7.1%2Bds1-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 95,484 kB
  • sloc: cpp: 566,747; ansic: 150,384; yacc: 7,198; python: 6,130; java: 3,486; lisp: 622; lex: 621; makefile: 613; perl: 571; sh: 439; xml: 415; javascript: 113; pascal: 35; modula3: 32
file content (50 lines) | stat: -rw-r--r-- 1,720 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Gmsh - Copyright (C) 1997-2020 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// issues on https://gitlab.onelab.info/gmsh/gmsh/issues.

#ifndef LINEAR_SYSTEM_H
#define LINEAR_SYSTEM_H

#include <map>
#include <string>

// A class that encapsulates a linear system solver interface :
// building a sparse matrix, solving a linear system
class linearSystemBase {
protected:
  std::map<std::string, std::string> _parameters;

public:
  virtual ~linearSystemBase() {}
  virtual bool isAllocated() const = 0;
  virtual void allocate(int nbRows) = 0;
  virtual void preAllocateEntries(){};
  virtual void clear() = 0;
  virtual void zeroMatrix() = 0;
  virtual void zeroRightHandSide() = 0;
  virtual void zeroSolution() = 0;
  virtual int systemSolve() = 0;
  // x = A*b
  virtual int matMult() { return 0; }

  void setParameter(const std::string &key, std::string value);
  std::string getParameter(const std::string &key) const;
  virtual void insertInSparsityPattern(int _row, int _col){};
  virtual double normInfRightHandSide() const = 0;
  virtual double normInfSolution() const { return 0; };
};

template <class scalar> class linearSystem : public linearSystemBase {
public:
  linearSystem() {}
  virtual ~linearSystem() {}
  virtual void addToMatrix(int _row, int _col, const scalar &val) = 0;
  virtual void getFromMatrix(int _row, int _col, scalar &val) const = 0;
  virtual void addToRightHandSide(int _row, const scalar &val, int ith = 0) = 0;
  virtual void getFromRightHandSide(int _row, scalar &val) const = 0;
  virtual void getFromSolution(int _row, scalar &val) const = 0;
  virtual void addToSolution(int _row, const scalar &val) = 0;
};

#endif