MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
linsol.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/libraries/libmbwrap/linsol.h,v 1.50 2017/01/12 14:44:25 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 /* linear solver generico */
33 
34 #ifndef LINEARSOLVER_H
35 #define LINEARSOLVER_H
36 
37 /* Integrator - begin */
38 
39 class LinSol {
40 public:
41  enum SolverType {
52 
54  };
55 
56  enum SolverFlags {
64  //permutations
72 
81  };
82 
83  /* solver data */
84  struct solver_t {
85  const char *const s_name;
86  const char *const s_alias;
88  unsigned s_flags;
89  unsigned s_default_flags;
92  };
93 
94 protected:
96  unsigned solverFlags;
97 
98  /*
99  * number of threads
100  * currently used by:
101  * SparseLU
102  */
103  unsigned nThreads;
104 
105  /*
106  * max workspace size
107  * currently used by:
108  * Y12
109  */
111 
112  /*
113  * block size
114  * currently used by:
115  * Umfpack
116  */
117  unsigned blockSize;
118 
119  /*
120  * pivot factor
121  * currently used by:
122  * SparseLU 0.0 -> 1.0
123  * Y12 0.0=no, 1.0=full
124  * Umfpack 0.0 -> 1.0
125  * Naive 1.0 -> 0.0
126  */
128 
129  /*
130  * drop tolerance
131  * currently used by:
132  * Umfpack >= 0.0 (0.0: use all)
133  */
135 
136  /*
137  * matrix scaling
138  * currently used by:
139  * Naive, KLU, Umfpack
140  */
142 
143  /*
144  * maximum number of iterations for iterative refinement
145  * used only by:
146  * Umfpack
147  */
149 
150 public:
152 
153  LinSol(void);
154  virtual ~LinSol(void);
155 
156  SolverType GetSolver(void) const;
157  const char *const GetSolverName(void) const;
158  unsigned GetSolverFlags(void) const;
159  unsigned GetNumThreads(void) const;
160  integer iGetWorkSpaceSize(void) const;
161  const doublereal& dGetPivotFactor(void) const;
162  const doublereal& dGetDropTolerance(void) const;
163  unsigned GetBlockSize(void) const;
164  const SolutionManager::ScaleOpt& GetScale(void) const{ return scale; }
165  integer GetMaxIterations(void) const;
166 
167  const char *const GetSolverName(SolverType t) const;
168  unsigned GetSolverFlags(SolverType t) const;
169 
170  bool SetSolver(SolverType t, unsigned f = SOLVER_FLAGS_NONE);
171  bool SetSolverFlags(unsigned f);
172  bool AddSolverFlags(unsigned f);
173  bool MaskSolverFlags(unsigned f);
174  bool SetNumThreads(unsigned nt);
176  bool SetPivotFactor(const doublereal &d);
177  bool SetDropTolerance(const doublereal &d);
178  bool SetBlockSize(unsigned bs);
181  SolutionManager *const
182  GetSolutionManager(integer iNLD, integer iLWS = 0) const;
183 };
184 
185 extern const LinSol::solver_t solver[];
186 
187 /* LinSol - end */
188 
189 #endif // LINEARSOLVER_H
190 
bool SetScale(const SolutionManager::ScaleOpt &scale)
Definition: linsol.cc:417
static SolverType defaultSolver
Definition: linsol.h:151
bool SetPivotFactor(const doublereal &d)
Definition: linsol.cc:372
unsigned GetSolverFlags(void) const
Definition: linsol.cc:257
bool MaskSolverFlags(unsigned f)
Definition: linsol.cc:303
doublereal dPivotFactor
Definition: linsol.h:127
const SolutionManager::ScaleOpt & GetScale(void) const
Definition: linsol.h:164
unsigned GetNumThreads(void) const
Definition: linsol.cc:333
SolutionManager *const GetSolutionManager(integer iNLD, integer iLWS=0) const
Definition: linsol.cc:455
bool SetNumThreads(unsigned nt)
Definition: linsol.cc:314
unsigned blockSize
Definition: linsol.h:117
LinSol(void)
Definition: linsol.cc:156
Definition: linsol.h:39
const doublereal & dGetDropTolerance(void) const
Definition: linsol.cc:351
unsigned nThreads
Definition: linsol.h:103
const char *const s_name
Definition: linsol.h:85
bool SetSolver(SolverType t, unsigned f=SOLVER_FLAGS_NONE)
Definition: linsol.cc:181
integer GetMaxIterations(void) const
Definition: linsol.cc:434
unsigned s_default_flags
Definition: linsol.h:89
integer iMaxIter
Definition: linsol.h:148
bool SetSolverFlags(unsigned f)
Definition: linsol.cc:281
bool SetMaxIterations(integer iMaxIter)
Definition: linsol.cc:440
bool SetWorkSpaceSize(integer)
Definition: linsol.cc:357
bool AddSolverFlags(unsigned f)
Definition: linsol.cc:292
virtual ~LinSol(void)
Definition: linsol.cc:169
const doublereal & dGetPivotFactor(void) const
Definition: linsol.cc:345
doublereal s_drop_tolerance
Definition: linsol.h:91
SolutionManager::ScaleOpt scale
Definition: linsol.h:141
integer iWorkSpaceSize
Definition: linsol.h:110
doublereal s_pivot_factor
Definition: linsol.h:90
unsigned solverFlags
Definition: linsol.h:96
SolverFlags
Definition: linsol.h:56
const char *const s_alias
Definition: linsol.h:86
SolverType currSolver
Definition: linsol.h:95
bool SetBlockSize(unsigned bs)
Definition: linsol.cc:402
SolverType GetSolver(void) const
Definition: linsol.cc:175
enum SolverType s_type
Definition: linsol.h:87
doublereal dDropTolerance
Definition: linsol.h:134
integer iGetWorkSpaceSize(void) const
Definition: linsol.cc:339
SolverType
Definition: linsol.h:41
bool SetDropTolerance(const doublereal &d)
Definition: linsol.cc:384
unsigned GetBlockSize(void) const
Definition: linsol.cc:396
const char *const GetSolverName(void) const
Definition: linsol.cc:269
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
unsigned s_flags
Definition: linsol.h:88
const LinSol::solver_t solver[]
Definition: linsol.cc:58