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_PARAKLETE
60 #include "Amesos_Paraklete.h"
61 #endif
62 #ifdef HAVE_AMESOS_CSPARSE
63 #include "Amesos_CSparse.h"
64 #endif
65 #include "Epetra_Object.h"
66 
67 static bool verbose = false;
68 
69 Amesos_BaseSolver* Amesos::Create(const char* ClassType,
70  const Epetra_LinearProblem& LinearProblem )
71 {
72  std::string CT = ClassType;
73  return(Create(CT,LinearProblem));
74 }
75 
76 Amesos_BaseSolver* Amesos::Create(const std::string CT,
77  const Epetra_LinearProblem& LinearProblem )
78 {
79 
80  if ((CT == "Amesos_Lapack") || (CT == "Lapack")) {
81 #ifdef HAVE_AMESOS_LAPACK
82  return new Amesos_Lapack(LinearProblem);
83 #else
84  if (verbose) std::cerr << "Amesos_Lapack is not implemented" << std::endl ;
85  return(0);
86 #endif
87  }
88 
89  if ((CT == "Amesos_Klu") || (CT == "Klu")) {
90 #ifdef HAVE_AMESOS_KLU
91  return new Amesos_Klu(LinearProblem);
92 #else
93  if (verbose) std::cerr << "Amesos_Klu is not implemented" << std::endl ;
94  return(0);
95 #endif
96  }
97 
98  if ((CT == "Amesos_Umfpack") || (CT == "Umfpack")) {
99 #ifdef HAVE_AMESOS_UMFPACK
100  return new Amesos_Umfpack(LinearProblem);
101 #else
102  if (verbose) std::cerr << "Amesos_Umfpack is not implemented" << std::endl ;
103  return(0);
104 #endif
105  }
106 
107  if ((CT == "Amesos_Superlu") || (CT == "Superlu")) {
108 #ifdef HAVE_AMESOS_SUPERLU
109  return new Amesos_Superlu(LinearProblem);
110 #else
111  if (verbose) std::cerr << "Amesos_Superlu is not implemented" << std::endl ;
112  return(0);
113 #endif
114  }
115 
116  if ((CT == "Amesos_Superludist") || (CT == "Superludist")) {
117 #ifdef HAVE_AMESOS_SUPERLUDIST
118  return new Amesos_Superludist(LinearProblem);
119 #else
120  if (verbose) std::cerr << "Amesos_Superludist is not implemented" << std::endl ;
121  return(0);
122 #endif
123  }
124 
125  if ((CT == "Amesos_Mumps") || (CT == "Mumps")) {
126 #if defined(HAVE_AMESOS_MUMPS) && defined(HAVE_MPI)
127  return new Amesos_Mumps(LinearProblem);
128 #else
129  if (verbose) std::cerr << "Amesos_Mumps is not implemented" << std::endl ;
130  return(0);
131 #endif
132  }
133 
134  if ((CT == "Amesos_Scalapack") || (CT == "Scalapack")) {
135 #ifdef HAVE_AMESOS_SCALAPACK
136  return new Amesos_Scalapack(LinearProblem);
137 #else
138  if (verbose) std::cerr << "Amesos_Scalapack is not implemented" << std::endl ;
139  return(0);
140 #endif
141  }
142 
143  if ((CT == "Amesos_Dscpack") || (CT == "Dscpack")) {
144 #ifdef HAVE_AMESOS_DSCPACK
145  return new Amesos_Dscpack(LinearProblem);
146 #else
147  if (verbose) std::cerr << "Amesos_Dscpack is not implemented" << std::endl ;
148  return(0);
149 #endif
150  }
151 
152  if ((CT == "Amesos_Pardiso") || (CT == "Pardiso")) {
153 #if defined(HAVE_AMESOS_PARDISO) || defined(HAVE_AMESOS_PARDISO_MKL)
154  return new Amesos_Pardiso(LinearProblem);
155 #else
156  if (verbose) std::cerr << "Amesos_Pardiso is not implemented" << std::endl ;
157  return(0);
158 #endif
159  }
160 
161  if ((CT == "Amesos_Paraklete") || (CT == "Paraklete")) {
162 #ifdef HAVE_AMESOS_PARAKLETE
163  return new Amesos_Paraklete(LinearProblem);
164 #else
165  if (verbose) std::cerr << "Amesos_Paraklete is not implemented" << std::endl ;
166  return(0);
167 #endif
168  }
169 
170  if ((CT == "Amesos_Taucs") || (CT == "Taucs")) {
171 #ifdef HAVE_AMESOS_TAUCS
172  return new Amesos_Taucs(LinearProblem);
173 #else
174  if (verbose) std::cerr << "Amesos_Taucs is not implemented" << std::endl ;
175  return(0);
176 #endif
177  }
178 
179  if ((CT == "Amesos_CSparse") || (CT == "CSparse")) {
180 #ifdef HAVE_AMESOS_CSPARSE
181  return new Amesos_CSparse(LinearProblem);
182 #else
183  if (verbose) std::cerr << "Amesos_CSparse is not implemented" << std::endl ;
184  return(0);
185 #endif
186  }
187 
188  if (verbose) std::cerr << "Unknown class type:" << CT << std::endl ;
189  return(0);
190 }
191 
192 // ====================================================================
193 bool Amesos::Query(const char* ClassType)
194 {
195  std::string CT = ClassType;
196  return(Query(CT));
197 }
198 
199 // ====================================================================
200 bool Amesos::Query(const std::string CT)
201 {
202 
203  if ((CT == "Amesos_Lapack") || (CT == "Lapack")) {
204 #ifdef HAVE_AMESOS_LAPACK
205  return true;
206 #else
207  return false;
208 #endif
209  }
210 
211  if ((CT == "Amesos_Klu") || (CT == "Klu")) {
212 #ifdef HAVE_AMESOS_KLU
213  return true;
214 #else
215  return false;
216 #endif
217  }
218 
219  if ((CT == "Amesos_Umfpack") || (CT == "Umfpack")) {
220 #ifdef HAVE_AMESOS_UMFPACK
221  return true;
222 #else
223  return false;
224 #endif
225  }
226 
227  if ((CT == "Amesos_Superlu") || ( CT == "Superlu")) {
228 #ifdef HAVE_AMESOS_SUPERLU
229  return true;
230 #else
231  return false;
232 #endif
233  }
234 
235  if ((CT == "Amesos_Superludist") || (CT == "Superludist")) {
236 #ifdef HAVE_AMESOS_SUPERLUDIST
237  return true;
238 #else
239  return false;
240 #endif
241  }
242 
243  if ((CT == "Amesos_Mumps") || (CT == "Mumps")) {
244 #ifdef HAVE_AMESOS_MUMPS
245  return true;
246 #else
247  return false;
248 #endif
249  }
250 
251  if ((CT == "Amesos_Scalapack") || (CT == "Scalapack")) {
252 #ifdef HAVE_AMESOS_SCALAPACK
253  return true;
254 #else
255  return false;
256 #endif
257  }
258 
259  if ((CT == "Amesos_Dscpack") || (CT == "Dscpack")) {
260 #ifdef HAVE_AMESOS_DSCPACK
261  return true;
262 #else
263  return false;
264 #endif
265  }
266 
267  if ((CT == "Amesos_Pardiso") || (CT == "Pardiso")) {
268 #if defined(HAVE_AMESOS_PARDISO) || defined(HAVE_AMESOS_PARDISO_MKL)
269  return true;
270 #else
271  return false;
272 #endif
273  }
274 
275  if ((CT == "Amesos_Taucs") || (CT == "Taucs")) {
276 #ifdef HAVE_AMESOS_TAUCS
277  return true;
278 #else
279  return false;
280 #endif
281  }
282 
283  if ((CT == "Amesos_Paraklete") || (CT == "Paraklete")) {
284 #ifdef HAVE_AMESOS_PARAKLETE
285  return true;
286 #else
287  return false;
288 #endif
289  }
290 
291  if ((CT == "Amesos_CSparse") || (CT == "CSparse")) {
292 #ifdef HAVE_AMESOS_CSPARSE
293  return true;
294 #else
295  return false;
296 #endif
297  }
298 
299  return(false);
300 
301 }
302 
304  Teuchos::ParameterList ParamList ;
305 
306  // Status Parameters - see Amesos_Status.cpp
307 
308  ParamList.set("OutputLevel",1 ) ;
309  ParamList.set("DebugLevel", 0 ) ;
310  ParamList.set("PrintTiming", false ) ;
311  ParamList.set("ComputeVectorNorms", false ) ;
312  ParamList.set("ComputeTrueResidual", false ) ;
313 
314 
315  // Control Parameters - see Amesos_Control.cpp
316  ParamList.set("AddZeroToDiag", false ) ;
317  ParamList.set("AddToDiag", 0.0 ) ;
318  ParamList.set("Refactorize", false ) ;
319  ParamList.set("RcondThreshold", 1e-12 ) ;
320  ParamList.set("MaxProcs", -1 ) ;
321  ParamList.set("MatrixProperty","general" ) ;
322  ParamList.set("ScaleMethod", 0 ) ;
323  ParamList.set("Reindex", false ) ;
324 
325 
326  // Klu Parameters
327  ParamList.set("TrustMe", false ) ; // If set, Amesos_Klu trusts that the data can be used in place - see Amesos_Klu.cpp
328 
329  // Superlu Parameters - none
330 
331  // Dscpack Parameters - none
332 
333  // Superludist Parameters
334  ParamList.set("Redistribute", false ) ;
335  Teuchos::ParameterList SuperludistParams;
336  {
337  SuperludistParams.set("ReuseSymbolic",false);
338  SuperludistParams.set("Fact","SamePattern");
339  SuperludistParams.set("Equil",false);
340  SuperludistParams.set("ColPerm","NOT SET");
341  SuperludistParams.set("RowPerm","NOT SET");
342  SuperludistParams.set("perm_c",(int*) 0);
343  SuperludistParams.set("perm_r",(int*) 0);
344  SuperludistParams.set("IterRefine","NOT SET");
345  SuperludistParams.set("ReplaceTinyPivot",true);
346  SuperludistParams.set("PrintNonzeros",false);
347  }
348  ParamList.set("Superludist", SuperludistParams ) ;
349  // MC64 Parameters - none
350 
351  // Lapack Parameters
352  Teuchos::ParameterList LapackParams;
353  {
354  LapackParams.set("Equilibrate",true);
355  }
356  ParamList.set("Lapack", LapackParams ) ;
357  // Mumps Parameters
358  ParamList.set("NoDestroy",false);
359  Teuchos::ParameterList MumpsParams;
360  {
361  MumpsParams.set("Equilibrate",true);
362  // ICNTL0, ICNT1, ..., ICNTL40
363  for (int i = 1 ; i <= 40 ; ++i)
364  {
365  char what[80];
366  sprintf(what, "ICNTL(%d)", i);
367  if (MumpsParams.isParameter(what))
368  MumpsParams.set(what,0);
369  }
370 
371  // CNTL0, CNTL1, ..., CNTL5
372  for (int i = 1 ; i <= 5 ; ++i)
373  {
374  char what[80];
375  sprintf(what, "CNTL(%d)", i);
376  if (MumpsParams.isParameter(what))
377  MumpsParams.set(what,0.0);
378  }
379  MumpsParams.set("RowScaling",(double *) 0);
380  MumpsParams.set("ColScaling",(double *) 0);
381 
382  }
383  ParamList.set("Mumps", MumpsParams ) ;
384 
385  // Paraklete Parameters - same as Klu
386 
387  // Pardiso Parameters
388  Teuchos::ParameterList PardisoParams;
389  {
390  PardisoParams.set("MSGLVL",0);
391  PardisoParams.set("IPARM(1)",0);
392  PardisoParams.set("IPARM(2)",0);
393  PardisoParams.set("IPARM(3)",0);
394  PardisoParams.set("IPARM(4)",0);
395  PardisoParams.set("IPARM(8)",0);
396  PardisoParams.set("IPARM(10)",0);
397  PardisoParams.set("IPARM(11)",0);
398  PardisoParams.set("IPARM(18)",0);
399  PardisoParams.set("IPARM(19)",0);
400  PardisoParams.set("IPARM(21)",0);
401 
402  }
403  ParamList.set("Pardiso", PardisoParams ) ;
404 
405  // Scalapack Parameters
406  Teuchos::ParameterList ScalapackParams;
407  {
408  ScalapackParams.set("2D distribution",true);
409  ScalapackParams.set("grid_nb",32);
410  }
411  ParamList.set("Scalapack", ScalapackParams ) ;
412  // Taucs Parameters - none
413 
414  // Umfpack Parameters - none
415 
416  return ParamList ;
417 }
Amesos_Klu: A serial, unblocked code ideal for getting started and for very sparse matrices...
Definition: Amesos_Klu.h:111
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:112
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Amesos_Dscpack: An object-oriented wrapper for Dscpack.
static bool verbose
Definition: Amesos.cpp:67
static Teuchos::ParameterList GetValidParameters()
Get the list of valid parameters.
Definition: Amesos.cpp:303
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:65
Amesos_BaseSolver * Create(const char *ClassType, const Epetra_LinearProblem &LinearProblem)
Amesos Create method.
Definition: Amesos.cpp:69
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:73
bool Query(const char *ClassType)
Queries whether a given interface is available or not.
Definition: Amesos.cpp:193