1 // Gmsh - Copyright (C) 1997-2021 C. Geuzaine, J.-F. Remacle 2 // 3 // See the LICENSE.txt file in the Gmsh root directory for license information. 4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues. 5 6 #ifndef LINEAR_SYSTEM_MUMPS_H 7 #define LINEAR_SYSTEM_MUMPS_H 8 9 // Interface to a linear system with MUMPS 10 11 #include "GmshConfig.h" 12 #include "GmshMessage.h" 13 #include "linearSystem.h" 14 15 #if defined(HAVE_MUMPS) 16 #include "dmumps_c.h" 17 #include "zmumps_c.h" 18 19 template <class scalar> class linearSystemMUMPS : public linearSystem<scalar> { 20 public: linearSystemMUMPS()21 linearSystemMUMPS() 22 { 23 Msg::Info("linearSystemMUMPS not implemented for this element type"); 24 } 25 isAllocated()26 virtual bool isAllocated() const { return false; } allocate(int nbRows)27 virtual void allocate(int nbRows) {} clear()28 virtual void clear() {} zeroMatrix()29 virtual void zeroMatrix() {} zeroRightHandSide()30 virtual void zeroRightHandSide() {} zeroSolution()31 virtual void zeroSolution() {} systemSolve()32 virtual int systemSolve() { return 1; } insertInSparsityPattern(int row,int col)33 virtual void insertInSparsityPattern(int row, int col) {} normInfRightHandSide()34 virtual double normInfRightHandSide() const { return 0.; } normInfSolution()35 virtual double normInfSolution() const { return 0.; } 36 addToMatrix(int row,int col,const double & val)37 virtual void addToMatrix(int row, int col, const double &val) {} getFromMatrix(int row,int col,double & val)38 virtual void getFromMatrix(int row, int col, double &val) const {} 39 virtual void addToRightHandSide(int row, const scalar &val, int ith = 0) {} getFromRightHandSide(int row,scalar & val)40 virtual void getFromRightHandSide(int row, scalar &val) const {} getFromSolution(int row,scalar & val)41 virtual void getFromSolution(int row, scalar &val) const {} addToSolution(int row,const scalar & val)42 virtual void addToSolution(int row, const scalar &val) {} 43 }; 44 45 template <> class linearSystemMUMPS<double> : public linearSystem<double> { 46 private: 47 int _n; 48 int _nz; 49 50 std::vector<int> _irn; 51 std::vector<int> _jcn; 52 53 std::vector<DMUMPS_REAL> _x; 54 std::vector<DMUMPS_REAL> _b; 55 std::vector<DMUMPS_REAL> _a; 56 57 // _ij[i][j] is the index of _a that is the (i, j) element of 58 // the system matrix 59 std::vector<std::map<int, int> > _ij; 60 61 public: 62 linearSystemMUMPS(); 63 64 virtual bool isAllocated() const; 65 virtual void allocate(int nbRows); 66 virtual void clear(); 67 virtual void zeroMatrix(); 68 69 virtual void zeroRightHandSide(); 70 virtual void zeroSolution(); 71 virtual int systemSolve(); 72 virtual void insertInSparsityPattern(int row, int col); 73 virtual double normInfRightHandSide() const; 74 virtual double normInfSolution() const; 75 76 virtual void addToMatrix(int row, int col, const double &val); 77 virtual void getFromMatrix(int row, int col, double &val) const; 78 virtual void addToRightHandSide(int row, const double &val, int ith = 0); 79 virtual void getFromRightHandSide(int row, double &val) const; 80 virtual void getFromSolution(int row, double &val) const; 81 virtual void addToSolution(int row, const double &val); 82 }; 83 84 #endif 85 86 #endif 87