Amesos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Amesos_Mumps.h
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 #ifndef AMESOS_MUMPS_H
30 #define AMESOS_MUMPS_H
31 
32 class Epetra_Import;
33 class Epetra_RowMatrix;
34 class Epetra_MultiVector;
35 #include "Epetra_Import.h"
36 #include "Epetra_CrsMatrix.h"
37 #include "Epetra_Map.h"
41 class Amesos_EpetraInterface;
42 
43 #include "Amesos_ConfigDefs.h"
44 #include "Amesos_BaseSolver.h"
45 #include "Amesos_NoCopiable.h"
46 #include "Amesos_Utils.h"
47 #include "Amesos_Time.h"
48 #include "Amesos_Status.h"
49 #include "Amesos_Control.h"
50 #include "Epetra_LinearProblem.h"
51 #ifdef EPETRA_MPI
52 #include "Epetra_MpiComm.h"
53 #else
54 #include "Epetra_Comm.h"
55 #endif
56 #include "Teuchos_RCP.hpp"
57 #include <map>
58 using namespace Teuchos;
59 
61 
108 extern "C" {
109 #include "dmumps_c.h"
110 }
111 
113  private Amesos_Time,
114  private Amesos_NoCopiable,
115  private Amesos_Utils,
116  private Amesos_Control,
117  private Amesos_Status {
118 
119 public:
120 
122 
126  Amesos_Mumps(const Epetra_LinearProblem& LinearProblem);
127 
129 
131  ~Amesos_Mumps(void);
133 
135 
136  int SymbolicFactorization() ;
137 
138  int NumericFactorization() ;
139 
140  int Solve();
141 
143  void Destroy();
144 
145  int SetUseTranspose(bool UseTranspose_in)
146  {
147  UseTranspose_ = UseTranspose_in;
148  if (UseTranspose_in)
149  return (-1);
150  return (0);
151  };
152 
153  bool UseTranspose() const {return(UseTranspose_);};
154 
155  int SetParameters( Teuchos::ParameterList &ParameterList );
156 
158 
160 
163 
166 
168  int NumSolve() const { return( Amesos_Status::NumSolve_ ); }
169 
171 
173 
175 
179  void PrintTiming() const;
180 
182 
185  void PrintStatus() const;
186 
188  void GetTiming( Teuchos::ParameterList &TimingParameterList ) const { Amesos_Time::GetTiming(TimingParameterList); }
189 
191 
193 
194 
195 #if 0
196 
205  int ComputeSchurComplement(bool flag,
206  int NumSchurComplementRows, int * SchurComplementRows);
207 
209 
214  Epetra_CrsMatrix * GetCrsSchurComplement();
215 
217 
222  Epetra_SerialDenseMatrix * GetDenseSchurComplement();
223 #endif
224 
226 
233  int SetPrecscaling(double * ColSca, double * RowSca )
234  {
235  ColSca_ = ColSca;
236  RowSca_ = RowSca;
237  return 0;
238  }
239 
241 
246  int SetRowScaling(double * RowSca )
247  {
248  RowSca_ = RowSca;
249  return 0;
250  }
251 
253 
258  int SetColScaling(double * ColSca )
259  {
260  ColSca_ = ColSca;
261  return 0;
262  }
263 
265 
269  int SetOrdering(int * PermIn)
270  {
271  PermIn_ = PermIn;
272  return 0;
273  }
274 
276 
280  double * GetRINFO() ;
281 
283 
285  int * GetINFO() ;
286 
288 
292  double * GetRINFOG() ;
293 
295 
298  int * GetINFOG() ;
299 
301  void SetICNTL(int pos, int value);
302 
304  void SetCNTL(int pos, double value);
305 
307 
308  bool MatrixShapeOK() const
309  {
310  bool OK = true;
311 
312  if ( GetProblem()->GetOperator()->OperatorRangeMap().NumGlobalPoints() !=
313  GetProblem()->GetOperator()->OperatorDomainMap().NumGlobalPoints() ) OK = false;
314  return OK;
315 }
316 
317 
319  const Epetra_Comm & Comm() const {return(GetProblem()->GetOperator()->Comm());};
320 
322  const Epetra_LinearProblem * GetProblem() const { return(Problem_); };
323 
324 protected:
325 
327  Epetra_RowMatrix& Matrix();
328 
329  const Epetra_RowMatrix& Matrix() const;
330 
332  Epetra_Map& RedistrMap();
333 
335  Epetra_Import& RedistrImporter();
336 
338  Epetra_RowMatrix& RedistrMatrix(const bool ImportMatrix = false);
339 
341  Epetra_Map& SerialMap();
342 
344  Epetra_Import& SerialImporter();
345 
347  int ConvertToTriplet(const bool OnlyValues);
348 
350  int CheckError();
351 
353  void CheckParameters();
354 
355  void SetICNTLandCNTL();
356 
361 
362 
363  bool NoDestroy_ ; // Set true to prevent memory freeing
364 
366  std::vector <int> Row;
368  std::vector<int> Col;
370  std::vector<double> Val;
371 
374 
377 
379  int MtxConvTime_, MtxRedistTime_, VecRedistTime_;
380  int SymFactTime_, NumFactTime_, SolveTime_;
381 
383  double * RowSca_, * ColSca_;
384 
386  int * PermIn_;
387 
392 
397 
398 #ifdef HAVE_MPI
399  MPI_Comm MUMPSComm_;
401 #endif
402 
405 
416 
417  DMUMPS_STRUC_C MDS;
418 
419  std::map<int, int> ICNTL;
420  std::map<int, double> CNTL;
421 }; // class Amesos_Mumps
422 
423 #endif /* AMESOS_MUMPS_H */
RCP< Epetra_Import > SerialImporter_
Importer from Matrix.OperatorDomainMap() to SerialMap_.
Definition: Amesos_Mumps.h:415
int NumSymbolicFact_
Number of symbolic factorization phases.
Definition: Amesos_Status.h:67
Amesos_Control: Container for some control variables.
bool MatrixShapeOK() const
Returns true if the solver can handle this matrix shape.
Definition: Amesos_Mumps.h:308
bool UseTranspose() const
Returns the current UseTranspose setting.
Definition: Amesos_Mumps.h:153
std::map< int, int > ICNTL
Definition: Amesos_Mumps.h:419
RCP< Epetra_CrsMatrix > CrsSchurComplement_
Pointer to the Schur complement, as CrsMatrix.
Definition: Amesos_Mumps.h:394
RCP< Epetra_Map > SerialMap_
Map with all elements on process 0 (for solution and rhs).
Definition: Amesos_Mumps.h:413
int NumSchurComplementRows_
Number of rows in the Schur complement (if required)
Definition: Amesos_Mumps.h:389
Amesos_Mumps: An object-oriented wrapper for the double precision version of MUMPS.
Definition: Amesos_Mumps.h:112
std::map< int, double > CNTL
Definition: Amesos_Mumps.h:420
int * PermIn_
PermIn for MUMPS.
Definition: Amesos_Mumps.h:386
int * SchurComplementRows_
Rows for the Schur complement (if required)
Definition: Amesos_Mumps.h:391
int NumNumericFact() const
Returns the number of numeric factorizations performed by this object.
Definition: Amesos_Mumps.h:165
RCP< Epetra_Map > RedistrMap_
Redistributed matrix.
Definition: Amesos_Mumps.h:407
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this matrix.
Definition: Amesos_Mumps.h:319
const Epetra_LinearProblem * Problem_
Pointer to the linear problem to be solved.
Definition: Amesos_Mumps.h:404
std::vector< int > Col
column indices of nonzero elements
Definition: Amesos_Mumps.h:368
int NumNumericFact_
Number of numeric factorization phases.
Definition: Amesos_Status.h:69
void GetTiming(Teuchos::ParameterList &TimingParameterList) const
Extracts timing information from the current solver and places it in the parameter list...
Definition: Amesos_Mumps.h:188
bool IsConvertToTripletOK_
true if matrix has already been converted to COO format
Definition: Amesos_Mumps.h:358
int NumSymbolicFact() const
Returns the number of symbolic factorizations performed by this object.
Definition: Amesos_Mumps.h:162
int NumSolve_
Number of solves.
Definition: Amesos_Status.h:71
int NumSolve() const
Returns the number of solves performed by this object.
Definition: Amesos_Mumps.h:168
int SetPrecscaling(double *ColSca, double *RowSca)
Set prescaling.
Definition: Amesos_Mumps.h:233
int SetUseTranspose(bool UseTranspose_in)
If set true, X will be set to the solution of AT X = B (not A X = B)
Definition: Amesos_Mumps.h:145
int SetColScaling(double *ColSca)
Set column scaling.
Definition: Amesos_Mumps.h:258
void GetTiming(Teuchos::ParameterList &list) const
Load up the current timing information into the parameter list.
Definition: Amesos_Time.h:124
int MaxProcs_
Maximum number of processors in the MUMPS&#39; communicator.
Definition: Amesos_Mumps.h:373
Amesos_Status: Container for some status variables.
Definition: Amesos_Status.h:20
Amesos_Time: Container for timing information.
Definition: Amesos_Time.h:50
DMUMPS_STRUC_C MDS
Definition: Amesos_Mumps.h:417
RCP< Epetra_CrsMatrix > RedistrMatrix_
Redistributed matrix (only if MaxProcs_ &gt; 1).
Definition: Amesos_Mumps.h:411
int SetOrdering(int *PermIn)
Sets ordering.
Definition: Amesos_Mumps.h:269
std::vector< int > Row
row indices of nonzero elements
Definition: Amesos_Mumps.h:366
RCP< Epetra_SerialDenseMatrix > DenseSchurComplement_
Pointer to the Schur complement,as DenseMatrix.
Definition: Amesos_Mumps.h:396
std::vector< double > Val
values of nonzero elements
Definition: Amesos_Mumps.h:370
const Epetra_LinearProblem * GetProblem() const
Gets a pointer to the Epetra_LinearProblem.
Definition: Amesos_Mumps.h:322
bool IsComputeSchurComplementOK_
true if the Schur complement has been computed (need to free memory)
Definition: Amesos_Mumps.h:360
bool CheckError(const std::string SolverType, const std::string Descriptor, const Epetra_RowMatrix &A, const Epetra_MultiVector &x, const Epetra_MultiVector &b, const Epetra_MultiVector &x_exact)
int Solve(int, TYPE *, TYPE *, TYPE *)
int SetRowScaling(double *RowSca)
Set row scaling.
Definition: Amesos_Mumps.h:246
RCP< Epetra_Import > RedistrImporter_
Redistributed importer (from Matrix().RowMatrixRowMap() to RedistrMatrix().RowMatrixRowMap()).
Definition: Amesos_Mumps.h:409
Amesos_BaseSolver: A pure virtual class for direct solution of real-valued double-precision operators...
double * RowSca_
Row and column scaling.
Definition: Amesos_Mumps.h:383
Amesos_NoCopiable: Simple class to prevent the usage of copy constructor and operator =...
bool UseTranspose_
If true, solve the problem with AT.
Definition: Amesos_Mumps.h:376
Amesos_Utils: Collections of basic utilities.
Definition: Amesos_Utils.h:19