Amesos Package Browser (Single Doxygen Collection) Development
Loading...
Searching...
No Matches
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
32class Epetra_Import;
33class Epetra_RowMatrix;
34class Epetra_MultiVector;
35#include "Epetra_Import.h"
36#include "Epetra_CrsMatrix.h"
37#include "Epetra_Map.h"
38#include "Epetra_SerialDenseVector.h"
39class Epetra_IntSerialDenseVector;
40class Epetra_SerialDenseMatrix;
41class 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>
58using namespace Teuchos;
59
61
108extern "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
119public:
120
122
126 Amesos_Mumps(const Epetra_LinearProblem& LinearProblem);
127
129
131 ~Amesos_Mumps(void);
133
135
137
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
197
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
324protected:
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
381
383 double * RowSca_, * ColSca_;
384
386 int * PermIn_;
387
392
394 RCP<Epetra_CrsMatrix> CrsSchurComplement_;
396 RCP<Epetra_SerialDenseMatrix> DenseSchurComplement_;
397
398#ifdef HAVE_MPI
400 MPI_Comm MUMPSComm_;
401#endif
402
404 const Epetra_LinearProblem* Problem_;
405
407 RCP<Epetra_Map> RedistrMap_;
409 RCP<Epetra_Import> RedistrImporter_;
411 RCP<Epetra_CrsMatrix> RedistrMatrix_;
413 RCP<Epetra_Map> SerialMap_;
415 RCP<Epetra_Import> SerialImporter_;
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 */
Amesos_BaseSolver: A pure virtual class for direct solution of real-valued double-precision operators...
Amesos_Control: Container for some control variables.
Amesos_Mumps: An object-oriented wrapper for the double precision version of MUMPS.
Definition: Amesos_Mumps.h:117
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
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 Solve()
Solves A X = B (or AT x = B)
RCP< Epetra_Map > SerialMap_
Map with all elements on process 0 (for solution and rhs).
Definition: Amesos_Mumps.h:413
int NumSolve() const
Returns the number of solves performed by this object.
Definition: Amesos_Mumps.h:168
double * GetRINFO()
Gets the pointer to the RINFO array (defined on all processes).
bool UseTranspose_
If true, solve the problem with AT.
Definition: Amesos_Mumps.h:376
Epetra_RowMatrix & Matrix()
Returns a reference to the linear system matrix.
const Epetra_LinearProblem * GetProblem() const
Gets a pointer to the Epetra_LinearProblem.
Definition: Amesos_Mumps.h:322
void SetCNTL(int pos, double value)
Set CNTL[pos] to value. pos is expressed in FORTRAN style (starting from 1).
DMUMPS_STRUC_C MDS
Definition: Amesos_Mumps.h:417
void SetICNTL(int pos, int value)
Set ICNTL[pos] to value. pos is expressed in FORTRAN style (starting from 1).
Epetra_Map & RedistrMap()
Returns a reference to the map for redistributed matrix.
int NumSymbolicFact() const
Returns the number of symbolic factorizations performed by this object.
Definition: Amesos_Mumps.h:162
double * RowSca_
Row and column scaling.
Definition: Amesos_Mumps.h:383
int MtxConvTime_
Quick access pointers to the internal timers.
Definition: Amesos_Mumps.h:379
void PrintStatus() const
Prints information about the factorization and solution phases.
std::map< int, double > CNTL
Definition: Amesos_Mumps.h:420
Epetra_Import & RedistrImporter()
Returns a reference for the redistributed importer.
void SetICNTLandCNTL()
std::map< int, int > ICNTL
Definition: Amesos_Mumps.h:419
int NumericFactorization()
Performs NumericFactorization on the matrix A.
Epetra_RowMatrix & RedistrMatrix(const bool ImportMatrix=false)
Returns a reference to the redistributed matrix, imports it is ImportMatrix is true.
int * GetINFO()
Gets the pointer to the INFO array (defined on all processes).
bool IsConvertToTripletOK_
true if matrix has already been converted to COO format
Definition: Amesos_Mumps.h:358
int * SchurComplementRows_
Rows for the Schur complement (if required)
Definition: Amesos_Mumps.h:391
bool IsComputeSchurComplementOK_
true if the Schur complement has been computed (need to free memory)
Definition: Amesos_Mumps.h:360
RCP< Epetra_CrsMatrix > CrsSchurComplement_
Pointer to the Schur complement, as CrsMatrix.
Definition: Amesos_Mumps.h:394
int SetColScaling(double *ColSca)
Set column scaling.
Definition: Amesos_Mumps.h:258
int NumSchurComplementRows_
Number of rows in the Schur complement (if required)
Definition: Amesos_Mumps.h:389
std::vector< double > Val
values of nonzero elements
Definition: Amesos_Mumps.h:370
int SetOrdering(int *PermIn)
Sets ordering.
Definition: Amesos_Mumps.h:269
int MaxProcs_
Maximum number of processors in the MUMPS' communicator.
Definition: Amesos_Mumps.h:373
double * GetRINFOG()
Gets the pointer to the RINFOG array (defined on host only).
RCP< Epetra_Map > RedistrMap_
Redistributed matrix.
Definition: Amesos_Mumps.h:407
RCP< Epetra_CrsMatrix > RedistrMatrix_
Redistributed matrix (only if MaxProcs_ > 1).
Definition: Amesos_Mumps.h:411
double * ColSca_
Definition: Amesos_Mumps.h:383
RCP< Epetra_Import > RedistrImporter_
Redistributed importer (from Matrix().RowMatrixRowMap() to RedistrMatrix().RowMatrixRowMap()).
Definition: Amesos_Mumps.h:409
std::vector< int > Col
column indices of nonzero elements
Definition: Amesos_Mumps.h:368
int * GetINFOG()
Get the pointer to the INFOG array (defined on host only).
std::vector< int > Row
row indices of nonzero elements
Definition: Amesos_Mumps.h:366
int NumNumericFact() const
Returns the number of numeric factorizations performed by this object.
Definition: Amesos_Mumps.h:165
void PrintTiming() const
Prints timing information.
bool UseTranspose() const
Returns the current UseTranspose setting.
Definition: Amesos_Mumps.h:153
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this matrix.
Definition: Amesos_Mumps.h:319
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 MatrixShapeOK() const
Returns true if the solver can handle this matrix shape.
Definition: Amesos_Mumps.h:308
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
int SetPrecscaling(double *ColSca, double *RowSca)
Set prescaling.
Definition: Amesos_Mumps.h:233
int * PermIn_
PermIn for MUMPS.
Definition: Amesos_Mumps.h:386
Epetra_Import & SerialImporter()
Returns a reference to the importer for SerialMap().
int CheckError()
Checks for MUMPS error, prints them if any. See MUMPS' manual.
int ConvertToTriplet(const bool OnlyValues)
Converts to MUMPS format (COO format).
const Epetra_LinearProblem * Problem_
Pointer to the linear problem to be solved.
Definition: Amesos_Mumps.h:404
void CheckParameters()
Check input parameters.
RCP< Epetra_Import > SerialImporter_
Importer from Matrix.OperatorDomainMap() to SerialMap_.
Definition: Amesos_Mumps.h:415
RCP< Epetra_SerialDenseMatrix > DenseSchurComplement_
Pointer to the Schur complement,as DenseMatrix.
Definition: Amesos_Mumps.h:396
int SetRowScaling(double *RowSca)
Set row scaling.
Definition: Amesos_Mumps.h:246
Epetra_Map & SerialMap()
Returns a reference to the map with all elements on process 0.
~Amesos_Mumps(void)
Amesos_Mumps Destructor.
void Destroy()
Destroys all data associated with \sl this object.
Amesos_NoCopiable: Simple class to prevent the usage of copy constructor and operator =.
Amesos_Status: Container for some status variables.
Definition: Amesos_Status.h:21
int NumSymbolicFact_
Number of symbolic factorization phases.
Definition: Amesos_Status.h:67
int NumSolve_
Number of solves.
Definition: Amesos_Status.h:71
int NumNumericFact_
Number of numeric factorization phases.
Definition: Amesos_Status.h:69
Amesos_Time: Container for timing information.
Definition: Amesos_Time.h:51
void GetTiming(Teuchos::ParameterList &list) const
Load up the current timing information into the parameter list.
Definition: Amesos_Time.h:124
Amesos_Utils: Collections of basic utilities.
Definition: Amesos_Utils.h:20