Amesos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Amesos.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Amesos: Direct Sparse Solver Package
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // This library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as
12 // published by the Free Software Foundation; either version 2.1 of the
13 // License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 // USA
24 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
25 //
26 // ***********************************************************************
27 // @HEADER
28 
29 #include "Amesos_config.h"
30 #include "Amesos.h"
31 #include "Amesos_Klu.h"
32 #ifdef HAVE_AMESOS_LAPACK
33 #include "Amesos_Lapack.h"
34 #endif
35 #if defined(HAVE_AMESOS_MUMPS) && defined(HAVE_MPI)
36 #include "Amesos_Mumps.h"
37 #endif
38 #ifdef HAVE_AMESOS_SCALAPACK
39 #include "Amesos_Scalapack.h"
40 #endif
41 #ifdef HAVE_AMESOS_UMFPACK
42 #include "Amesos_Umfpack.h"
43 #endif
44 #ifdef HAVE_AMESOS_SUPERLUDIST
45 #include "Amesos_Superludist.h"
46 #endif
47 #ifdef HAVE_AMESOS_SUPERLU
48 #include "Amesos_Superlu.h"
49 #endif
50 #ifdef HAVE_AMESOS_DSCPACK
51 #include "Amesos_Dscpack.h"
52 #endif
53 #if defined(HAVE_AMESOS_PARDISO) || defined(HAVE_AMESOS_PARDISO_MKL)
54 #include "Amesos_Pardiso.h"
55 #endif
56 #ifdef HAVE_AMESOS_TAUCS
57 #include "Amesos_Taucs.h"
58 #endif
59 #ifdef HAVE_AMESOS_CSS_MKL
60 #include "Amesos_CssMKL.h"
61 #endif
62 #ifdef HAVE_AMESOS_PARAKLETE
63 #include "Amesos_Paraklete.h"
64 #endif
65 #ifdef HAVE_AMESOS_CSPARSE
66 #include "Amesos_CSparse.h"
67 #endif
68 #include "Epetra_Object.h"
69 
70 static bool verbose = false;
71 
72 Amesos_BaseSolver* Amesos::Create(const char* ClassType,
73  const Epetra_LinearProblem& LinearProblem )
74 {
75  std::string CT = ClassType;
76  return(Create(CT,LinearProblem));
77 }
78 
79 Amesos_BaseSolver* Amesos::Create(const std::string CT,
80  const Epetra_LinearProblem& LinearProblem )
81 {
82 
83  if ((CT == "Amesos_Lapack") || (CT == "Lapack")) {
84 #ifdef HAVE_AMESOS_LAPACK
85  return new Amesos_Lapack(LinearProblem);
86 #else
87  if (verbose) std::cerr << "Amesos_Lapack is not implemented" << std::endl ;
88  return(0);
89 #endif
90  }
91 
92  if ((CT == "Amesos_Klu") || (CT == "Klu")) {
93 #ifdef HAVE_AMESOS_KLU
94  return new Amesos_Klu(LinearProblem);
95 #else
96  if (verbose) std::cerr << "Amesos_Klu is not implemented" << std::endl ;
97  return(0);
98 #endif
99  }
100 
101  if ((CT == "Amesos_Umfpack") || (CT == "Umfpack")) {
102 #ifdef HAVE_AMESOS_UMFPACK
103  return new Amesos_Umfpack(LinearProblem);
104 #else
105  if (verbose) std::cerr << "Amesos_Umfpack is not implemented" << std::endl ;
106  return(0);
107 #endif
108  }
109 
110  if ((CT == "Amesos_Superlu") || (CT == "Superlu")) {
111 #ifdef HAVE_AMESOS_SUPERLU
112  return new Amesos_Superlu(LinearProblem);
113 #else
114  if (verbose) std::cerr << "Amesos_Superlu is not implemented" << std::endl ;
115  return(0);
116 #endif
117  }
118 
119  if ((CT == "Amesos_Superludist") || (CT == "Superludist")) {
120 #ifdef HAVE_AMESOS_SUPERLUDIST
121  return new Amesos_Superludist(LinearProblem);
122 #else
123  if (verbose) std::cerr << "Amesos_Superludist is not implemented" << std::endl ;
124  return(0);
125 #endif
126  }
127 
128  if ((CT == "Amesos_Mumps") || (CT == "Mumps")) {
129 #if defined(HAVE_AMESOS_MUMPS) && defined(HAVE_MPI)
130  return new Amesos_Mumps(LinearProblem);
131 #else
132  if (verbose) std::cerr << "Amesos_Mumps is not implemented" << std::endl ;
133  return(0);
134 #endif
135  }
136 
137  if ((CT == "Amesos_Scalapack") || (CT == "Scalapack")) {
138 #ifdef HAVE_AMESOS_SCALAPACK
139  return new Amesos_Scalapack(LinearProblem);
140 #else
141  if (verbose) std::cerr << "Amesos_Scalapack is not implemented" << std::endl ;
142  return(0);
143 #endif
144  }
145 
146  if ((CT == "Amesos_Dscpack") || (CT == "Dscpack")) {
147 #ifdef HAVE_AMESOS_DSCPACK
148  return new Amesos_Dscpack(LinearProblem);
149 #else
150  if (verbose) std::cerr << "Amesos_Dscpack is not implemented" << std::endl ;
151  return(0);
152 #endif
153  }
154 
155  if ((CT == "Amesos_Pardiso") || (CT == "Pardiso")) {
156 #if defined(HAVE_AMESOS_PARDISO) || defined(HAVE_AMESOS_PARDISO_MKL)
157  return new Amesos_Pardiso(LinearProblem);
158 #else
159  if (verbose) std::cerr << "Amesos_Pardiso is not implemented" << std::endl ;
160  return(0);
161 #endif
162  }
163 
164  if ((CT == "Amesos_CssMKL") || (CT == "CssMKL")) {
165 #ifdef HAVE_AMESOS_CSS_MKL
166  return new Amesos_CssMKL(LinearProblem);
167 #else
168  if (verbose) std::cerr << "Amesos_CssMKL is not implemented" << std::endl ;
169  return(0);
170 #endif
171  }
172 
173  if ((CT == "Amesos_Paraklete") || (CT == "Paraklete")) {
174 #ifdef HAVE_AMESOS_PARAKLETE
175  return new Amesos_Paraklete(LinearProblem);
176 #else
177  if (verbose) std::cerr << "Amesos_Paraklete is not implemented" << std::endl ;
178  return(0);
179 #endif
180  }
181 
182  if ((CT == "Amesos_Taucs") || (CT == "Taucs")) {
183 #ifdef HAVE_AMESOS_TAUCS
184  return new Amesos_Taucs(LinearProblem);
185 #else
186  if (verbose) std::cerr << "Amesos_Taucs is not implemented" << std::endl ;
187  return(0);
188 #endif
189  }
190 
191  if ((CT == "Amesos_CSparse") || (CT == "CSparse")) {
192 #ifdef HAVE_AMESOS_CSPARSE
193  return new Amesos_CSparse(LinearProblem);
194 #else
195  if (verbose) std::cerr << "Amesos_CSparse is not implemented" << std::endl ;
196  return(0);
197 #endif
198  }
199 
200  if (verbose) std::cerr << "Unknown class type:" << CT << std::endl ;
201  return(0);
202 }
203 
204 // ====================================================================
205 bool Amesos::Query(const char* ClassType)
206 {
207  std::string CT = ClassType;
208  return(Query(CT));
209 }
210 
211 // ====================================================================
212 bool Amesos::Query(const std::string CT)
213 {
214 
215  if ((CT == "Amesos_Lapack") || (CT == "Lapack")) {
216 #ifdef HAVE_AMESOS_LAPACK
217  return true;
218 #else
219  return false;
220 #endif
221  }
222 
223  if ((CT == "Amesos_Klu") || (CT == "Klu")) {
224 #ifdef HAVE_AMESOS_KLU
225  return true;
226 #else
227  return false;
228 #endif
229  }
230 
231  if ((CT == "Amesos_Umfpack") || (CT == "Umfpack")) {
232 #ifdef HAVE_AMESOS_UMFPACK
233  return true;
234 #else
235  return false;
236 #endif
237  }
238 
239  if ((CT == "Amesos_Superlu") || ( CT == "Superlu")) {
240 #ifdef HAVE_AMESOS_SUPERLU
241  return true;
242 #else
243  return false;
244 #endif
245  }
246 
247  if ((CT == "Amesos_Superludist") || (CT == "Superludist")) {
248 #ifdef HAVE_AMESOS_SUPERLUDIST
249  return true;
250 #else
251  return false;
252 #endif
253  }
254 
255  if ((CT == "Amesos_Mumps") || (CT == "Mumps")) {
256 #ifdef HAVE_AMESOS_MUMPS
257  return true;
258 #else
259  return false;
260 #endif
261  }
262 
263  if ((CT == "Amesos_Scalapack") || (CT == "Scalapack")) {
264 #ifdef HAVE_AMESOS_SCALAPACK
265  return true;
266 #else
267  return false;
268 #endif
269  }
270 
271  if ((CT == "Amesos_Dscpack") || (CT == "Dscpack")) {
272 #ifdef HAVE_AMESOS_DSCPACK
273  return true;
274 #else
275  return false;
276 #endif
277  }
278 
279  if ((CT == "Amesos_Pardiso") || (CT == "Pardiso")) {
280 #if defined(HAVE_AMESOS_PARDISO) || defined(HAVE_AMESOS_PARDISO_MKL)
281  return true;
282 #else
283  return false;
284 #endif
285  }
286 
287  if ((CT == "Amesos_CssMKL") || (CT == "Css_MKL")) {
288 #ifdef HAVE_AMESOS_CSS_MKL
289  return true;
290 #else
291  return false;
292 #endif
293  }
294 
295  if ((CT == "Amesos_Taucs") || (CT == "Taucs")) {
296 #ifdef HAVE_AMESOS_TAUCS
297  return true;
298 #else
299  return false;
300 #endif
301  }
302 
303  if ((CT == "Amesos_Paraklete") || (CT == "Paraklete")) {
304 #ifdef HAVE_AMESOS_PARAKLETE
305  return true;
306 #else
307  return false;
308 #endif
309  }
310 
311  if ((CT == "Amesos_CSparse") || (CT == "CSparse")) {
312 #ifdef HAVE_AMESOS_CSPARSE
313  return true;
314 #else
315  return false;
316 #endif
317  }
318 
319  return(false);
320 
321 }
322 
324  Teuchos::ParameterList ParamList ;
325 
326  // Status Parameters - see Amesos_Status.cpp
327 
328  ParamList.set("OutputLevel",1 ) ;
329  ParamList.set("DebugLevel", 0 ) ;
330  ParamList.set("PrintTiming", false ) ;
331  ParamList.set("ComputeVectorNorms", false ) ;
332  ParamList.set("ComputeTrueResidual", false ) ;
333 
334 
335  // Control Parameters - see Amesos_Control.cpp
336  ParamList.set("AddZeroToDiag", false ) ;
337  ParamList.set("AddToDiag", 0.0 ) ;
338  ParamList.set("Refactorize", false ) ;
339  ParamList.set("RcondThreshold", 1e-12 ) ;
340  ParamList.set("MaxProcs", -1 ) ;
341  ParamList.set("MatrixProperty","general" ) ;
342  ParamList.set("ScaleMethod", 0 ) ;
343  ParamList.set("Reindex", false ) ;
344 
345 
346  // Klu Parameters
347  ParamList.set("TrustMe", false ) ; // If set, Amesos_Klu trusts that the data can be used in place - see Amesos_Klu.cpp
348 
349  // Superlu Parameters - none
350 
351  // Dscpack Parameters - none
352 
353  // Superludist Parameters
354  ParamList.set("Redistribute", false ) ;
355  Teuchos::ParameterList SuperludistParams;
356  {
357  SuperludistParams.set("ReuseSymbolic",false);
358  SuperludistParams.set("Fact","SamePattern");
359  SuperludistParams.set("Equil",false);
360  SuperludistParams.set("ColPerm","NOT SET");
361  SuperludistParams.set("RowPerm","NOT SET");
362  SuperludistParams.set("perm_c",(int*) 0);
363  SuperludistParams.set("perm_r",(int*) 0);
364  SuperludistParams.set("IterRefine","NOT SET");
365  SuperludistParams.set("ReplaceTinyPivot",true);
366  SuperludistParams.set("PrintNonzeros",false);
367  }
368  ParamList.set("Superludist", SuperludistParams ) ;
369  // MC64 Parameters - none
370 
371  // Lapack Parameters
372  Teuchos::ParameterList LapackParams;
373  {
374  LapackParams.set("Equilibrate",true);
375  }
376  ParamList.set("Lapack", LapackParams ) ;
377  // Mumps Parameters
378  ParamList.set("NoDestroy",false);
379  Teuchos::ParameterList MumpsParams;
380  {
381  MumpsParams.set("Equilibrate",true);
382  // ICNTL0, ICNT1, ..., ICNTL40
383  for (int i = 1 ; i <= 40 ; ++i)
384  {
385  char what[80];
386  sprintf(what, "ICNTL(%d)", i);
387  if (MumpsParams.isParameter(what))
388  MumpsParams.set(what,0);
389  }
390 
391  // CNTL0, CNTL1, ..., CNTL5
392  for (int i = 1 ; i <= 5 ; ++i)
393  {
394  char what[80];
395  sprintf(what, "CNTL(%d)", i);
396  if (MumpsParams.isParameter(what))
397  MumpsParams.set(what,0.0);
398  }
399  MumpsParams.set("RowScaling",(double *) 0);
400  MumpsParams.set("ColScaling",(double *) 0);
401 
402  }
403  ParamList.set("Mumps", MumpsParams ) ;
404 
405  // Paraklete Parameters - same as Klu
406 
407  // Pardiso Parameters
408  Teuchos::ParameterList PardisoParams;
409  {
410  PardisoParams.set("MSGLVL",0);
411  PardisoParams.set("IPARM(1)",0);
412  PardisoParams.set("IPARM(2)",0);
413  PardisoParams.set("IPARM(3)",0);
414  PardisoParams.set("IPARM(4)",0);
415  PardisoParams.set("IPARM(8)",0);
416  PardisoParams.set("IPARM(10)",0);
417  PardisoParams.set("IPARM(11)",0);
418  PardisoParams.set("IPARM(18)",0);
419  PardisoParams.set("IPARM(19)",0);
420  PardisoParams.set("IPARM(21)",0);
421 
422  }
423  ParamList.set("Pardiso", PardisoParams ) ;
424 
425  // Scalapack Parameters
426  Teuchos::ParameterList ScalapackParams;
427  {
428  ScalapackParams.set("2D distribution",true);
429  ScalapackParams.set("grid_nb",32);
430  }
431  ParamList.set("Scalapack", ScalapackParams ) ;
432  // Taucs Parameters - none
433 
434  // Umfpack Parameters - none
435 
436  return ParamList ;
437 }
Amesos_Klu: A serial, unblocked code ideal for getting started and for very sparse matrices...
Definition: Amesos_Klu.h:117
Amesos_Paraklete: A serial, unblocked code ideal for getting started and for very sparse matrices...
Amesos_Superludist: An object-oriented wrapper for Superludist.
Amesos_Mumps: An object-oriented wrapper for the double precision version of MUMPS.
Definition: Amesos_Mumps.h:118
Amesos_Dscpack: An object-oriented wrapper for Dscpack.
static bool verbose
Definition: Amesos.cpp:70
static Teuchos::ParameterList GetValidParameters()
Get the list of valid parameters.
Definition: Amesos.cpp:323
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Amesos_Pardiso: Interface to the PARDISO package.
Amesos_Superlu: Amesos interface to Xioye Li&#39;s SuperLU 3.0 serial code.
bool isParameter(const std::string &name) const
Amesos_Lapack: an interface to LAPACK.
Definition: Amesos_Lapack.h:71
Amesos_BaseSolver * Create(const char *ClassType, const Epetra_LinearProblem &LinearProblem)
Amesos Create method.
Definition: Amesos.cpp:72
Amesos_CssMKL: Interface to the CSSMKL package.
Definition: Amesos_CssMKL.h:64
Amesos_BaseSolver: A pure virtual class for direct solution of real-valued double-precision operators...
Class Amesos_Umfpack: An object-oriented wrapper for UMFPACK.
Amesos_Scalapack: A serial and parallel dense solver. For now, we implement only the unsymmetric ScaL...
Amesos_Taucs: An interface to the TAUCS package.
Definition: Amesos_Taucs.h:79
bool Query(const char *ClassType)
Queries whether a given interface is available or not.
Definition: Amesos.cpp:205