MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
wsmpwrap.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/libraries/libmbwrap/wsmpwrap.h,v 1.16 2017/01/12 14:44:25 masarati Exp $ */
2 /*
3  * HmFe (C) is a FEM analysis code.
4  *
5  * Copyright (C) 1996-2017
6  *
7  * Marco Morandini <morandini@aero.polimi.it>
8  *
9  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
10  * via La Masa, 34 - 20156 Milano, Italy
11  * http://www.aero.polimi.it
12  *
13  * Changing this copyright notice is forbidden.
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17  *
18  */
19 /* December 2001
20  * Modified to add a Sparse matrix in row form and to implement methods
21  * to be used in the parallel MBDyn Solver.
22  *
23  * Copyright (C) 2001-2017
24  *
25  * Giuseppe Quaranta <quaranta@aero.polimi.it>
26  *
27  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
28  * via La Masa, 34 - 20156 Milano, Italy
29  * http://www.aero.polimi.it
30  *
31  */
32 /*
33  * MBDyn (C) is a multibody analysis code.
34  * http://www.mbdyn.org
35  *
36  * Copyright (C) 1996-2017
37  *
38  * Pierangelo Masarati <masarati@aero.polimi.it>
39  * Paolo Mantegazza <mantegazza@aero.polimi.it>
40  *
41  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
42  * via La Masa, 34 - 20156 Milano, Italy
43  * http://www.aero.polimi.it
44  *
45  * Changing this copyright notice is forbidden.
46  *
47  * This program is free software; you can redistribute it and/or modify
48  * it under the terms of the GNU General Public License as published by
49  * the Free Software Foundation (version 2 of the License).
50  *
51  *
52  * This program is distributed in the hope that it will be useful,
53  * but WITHOUT ANY WARRANTY; without even the implied warranty of
54  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55  * GNU General Public License for more details.
56  *
57  * You should have received a copy of the GNU General Public License
58  * along with this program; if not, write to the Free Software
59  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
60  */
61 
62 #ifndef WsmpSparseSolutionManager_hh
63 #define WsmpSparseSolutionManager_hh
64 
65 #ifdef USE_WSMP
66 
67 #include <iostream>
68 #include <vector>
69 
70 #include "myassert.h"
71 #include "mynewmem.h"
72 #include "ls.h"
73 #include "solman.h"
74 #include "spmapmh.h"
75 #include "ccmh.h"
76 
77 
78 /* WsmpSolver: - begin */
79 
80 class WsmpSolver: public LinearSolver {
81 private:
82  integer iSize;
83  mutable doublereal *Axp;
84  mutable integer *Aip;
85  mutable integer *App;
86 
87  mutable int ldb;
88  mutable int nrhs;
89  mutable double *rmisc;
90  mutable int iparm[64];
91  mutable double dparm[64];
92 
93  bool Symbolic;
94 
95  bool bPrepareSymbolic(void);
96 
97  void Factor(void);
98 
99 public:
100  WsmpSolver(const integer &size, const doublereal &dPivot,
101  const unsigned blockSize, const unsigned nt = 1);
102  ~WsmpSolver(void);
103 
104  void Reset(void);
105  void Solve(void) const;
106 
108  std::vector<doublereal>& Ax,
109  std::vector<integer>& Ar,
110  std::vector<integer>& Ac,
111  std::vector<integer>& Ap) const;
112 };
113 
114 /* WsmpSolver - end */
115 
116 /* WsmpSparseSolutionManager - begin */
117 
118 class WsmpSparseSolutionManager: public SolutionManager {
119 protected:
120  mutable SpMapMatrixHandler A;
121 
122  /* rhs / solution */
123  std::vector<doublereal> xb;
124 
125  mutable MyVectorHandler xbVH;
126 
127  std::vector<doublereal> Ax;
128  std::vector<integer> Ai;
129  std::vector<integer> Adummy;
130  std::vector<integer> Ap;
131 
132  /* Passa in forma di Compressed Column (callback per solve,
133  * richiesto da SpMap e CC Matrix Handler) */
134  virtual void MakeCompressedColumnForm(void);
135 
136  /* Backward Substitution */
137  void BackSub(doublereal t_iniz = 0.);
138 
139 public:
140  WsmpSparseSolutionManager(integer Dim, doublereal dPivot = -1.,
141  const unsigned blockSize = 0, const unsigned nt = 1);
142  virtual ~WsmpSparseSolutionManager(void);
143 #ifdef DEBUG
144  virtual void IsValid(void) const {
145  NO_OP;
146  };
147 #endif /* DEBUG */
148 
149  /* Inizializzatore generico */
150  virtual void MatrReset(void);
151 
152  /* Risolve il sistema Backward Substitution; fattorizza se necessario */
153  virtual void Solve(void);
154 
155  /* Rende disponibile l'handler per la matrice */
156  virtual MatrixHandler* pMatHdl(void) const;
157 
158  /* Rende disponibile l'handler per il termine noto */
159  virtual MyVectorHandler* pResHdl(void) const;
160 
161  /* Rende disponibile l'handler per la soluzione */
162  virtual MyVectorHandler* pSolHdl(void) const;
163 };
164 
165 /* WsmpSparseSolutionManager - end */
166 
167 /* WsmpSparseCCSolutionManager - begin */
168 
169 template <class CC>
170 class WsmpSparseCCSolutionManager: public WsmpSparseSolutionManager {
171 protected:
172  bool CCReady;
174 
175  virtual void MatrReset(void);
176  virtual void MakeCompressedColumnForm(void);
177 
178 public:
179  WsmpSparseCCSolutionManager(integer Dim, doublereal dPivot = -1.,
180  const unsigned& blockSize = 0 , const unsigned nt = 1);
181  virtual ~WsmpSparseCCSolutionManager(void);
182 
183  /* Inizializzatore "speciale" */
184  virtual void MatrInitialize(void);
185 
186  /* Rende disponibile l'handler per la matrice */
187  virtual MatrixHandler* pMatHdl(void) const;
188 };
189 
190 /* WsmpSparseCCSolutionManager - end */
191 
192 #endif /* USE_WSMP */
193 
194 #endif /* WsmpSparseSolutionManager_hh */
195 
virtual void Reset(void)
Definition: ls.cc:68
virtual VectorHandler * pResHdl(void) const =0
#define NO_OP
Definition: myassert.h:74
virtual MatrixHandler * pMatHdl(void) const =0
virtual void MatrReset(void)=0
virtual void Solve(void)=0
virtual void Solve(void) const =0
virtual VectorHandler * pSolHdl(void) const =0
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
virtual void MakeCompactForm(SparseMatrixHandler &mh, std::vector< doublereal > &Ax, std::vector< integer > &Ar, std::vector< integer > &Ac, std::vector< integer > &Ap) const
Definition: ls.cc:123