Amesos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Amesos_Superlu.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 //
30 // Coding tasks:
31 // 1) Create the dense matrices in Solve() DONE
32 // 2) Make the call to dgsvx() in Factor() dONE
33 // 3) Make the call to dgsvx() in Solve() DONE
34 //
35 // Later coding tasks:
36 // 0) Factor called twice
37 // 1) Refactor()
38 // 2) Parameter list
39 // 3) Transpose - DONE
40 // 4) Destructor - In particular, need to call the SuperLU_FREE routines.
41 // 5) Coments - especially in Amesos_Superlu.h
42 //
43 // SymbolicFactorization() performs no action other than making sure that Factorization
44 // s performed
45 // NumericFactorization() performs the factorization but no solve (right hand side is
46 // is set to 0 vectors) reuses factors only if ReuseFactorization_ is set.
47 // If FactorizationOK_() && ReuseSymbolic_
48 // ReFactor()
49 // else
50 // Factor()
51 //
52 // Solve()
53 //
54 // Factor() does everything from scratch:
55 // Redistributes the data if necessary
56 // Deletes any data structures left over from the previous call to Factor()
57 // Copies the data into the format that SuperLU wants it
58 // Calls dgssvx to factor the matrix with factor set to true
59 // ReFactor()
60 // Redistributes the data if necessary
61 // - Attempting to check to make sure that the non-zero structure is unchanged
62 // Copies the data into the format that SuperLU already has it
63 // FIRST PASS - assert( false )
64 //
65 
66 #ifndef AMESOS_SUPERLU_H
67 #define AMESOS_SUPERLU_H
68 
69 #if defined(Amesos_SHOW_DEPRECATED_WARNINGS)
70 #ifdef __GNUC__
71 #warning "The Amesos package is deprecated"
72 #endif
73 #endif
74 
75 #include "Amesos_ConfigDefs.h"
76 #include "Amesos_BaseSolver.h"
77 #include "Amesos_NoCopiable.h"
78 #include "Amesos_Utils.h"
79 #include "Amesos_Time.h"
80 #include "Amesos_Status.h"
81 #include "Amesos_Control.h"
82 #include "Teuchos_RCP.hpp"
83 
84 class SLUData;
85 class Epetra_Comm;
86 class Epetra_CrsMatrix;
88 
90 
99  private Amesos_Time,
100  private Amesos_NoCopiable,
101  private Amesos_Utils,
102  private Amesos_Control,
103  private Amesos_Status {
104 
105 public:
106 
108 
116  Amesos_Superlu(const Epetra_LinearProblem& LinearProblem );
117 
119  ~Amesos_Superlu();
120 
122 
123 
124  int SymbolicFactorization();
125 
126  int NumericFactorization();
127 
128  int Solve();
129 
131 
132 
133  const Epetra_LinearProblem *GetProblem() const { return(Problem_); };
134 
135  bool MatrixShapeOK() const ;
136 
137  int SetUseTranspose (bool useTheTranspose) {
138  UseTranspose_ = useTheTranspose; return(0);
139  }
140 
141  bool UseTranspose() const {return(UseTranspose_);};
142 
143  const Epetra_Comm& Comm() const {return(GetProblem()->GetOperator()->Comm());};
144 
146 
149 
152 
154  int NumSolve() const { return( Amesos_Status::NumSolve_ ); }
155 
157  void PrintTiming() const;
158 
160  void PrintStatus() const;
161 
163  void GetTiming( Teuchos::ParameterList &TimingParameterList ) const { Amesos_Time::GetTiming(TimingParameterList); }
164 
165 private:
166 
168 
169 
171  // Note: this method is delicate!
172  const Epetra_Map& SerialMap() const
173  {
174  return(*(SerialMap_.get()));
175  }
176 
178  // Note: this method is delicate!
180  {
181  return(*(ImportToSerial_.get()));
182  }
183 
185  int Factor();
187  int ReFactor();
188 
190  int ConvertToSerial();
191 
193  // Note: All action is performed on process 0
195 
197 
200  std::vector<double> berr_;
201  std::vector<double> ferr_;
202  std::vector<int> perm_r_;
203  std::vector<int> perm_c_;
204  std::vector<int> etree_;
205  std::vector<double> R_;
206  std::vector<double> C_;
207  char equed_;
208  // no idea of the following.
209  double* DummyArray;
210 
212  std::vector <int> Ap_;
214  std::vector <int> Ai_;
216  std::vector <double> Aval_;
218  long long NumGlobalRows_;
228  int iam_;
244 
245 }; // End of class Amesos_Superlu
246 #endif /* AMESOS_SUPERLU_H */
int NumSymbolicFact_
Number of symbolic factorization phases.
Definition: Amesos_Status.h:73
void PrintStatus() const
Prints status information.
Amesos_Control: Container for some control variables.
std::vector< int > etree_
Teuchos::RCP< Epetra_Map > SerialMap_
Contains a map with all elements assigned to processor 0.
std::vector< double > Aval_
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
Epetra_RowMatrix * SerialMatrix_
For parallel runs, stores the matrix defined on SerialMap_.
int Solve()
Solves A X = B (or AT x = B)
std::vector< int > perm_c_
std::vector< int > Ap_
stores the matrix in SuperLU format.
std::vector< double > C_
const Epetra_Map & SerialMap() const
Returns a reference to the serial map.
T * get() const
const Epetra_Import & ImportToSerial() const
Returns a reference to the importer.
int Factor()
Factors the matrix, no previous factorization available.
int PerformNumericFactorization()
PerformNumericFactorization - Call Superlu to perform numeric factorization.
int MtxConvTime_
Quick access pointer to internal timing data.
bool UseTranspose_
If true, solve the linear system with the transpose of the matrix.
Amesos_Superlu: Amesos interface to Xioye Li&#39;s SuperLU 3.0 serial code.
long long NumGlobalNonzeros_
Global number of nonzeros in the matrix.
int NumNumericFact_
Number of numeric factorization phases.
Definition: Amesos_Status.h:75
int ReFactor()
Re-factors the matrix.
bool UseTranspose() const
Returns the current UseTranspose setting.
int NumSolve_
Number of solves.
Definition: Amesos_Status.h:77
void GetTiming(Teuchos::ParameterList &TimingParameterList) const
Extracts timing information from the current solver and places it in the parameter list...
bool MatrixShapeOK() const
Returns true if the solver can handle this matrix shape.
Amesos_Superlu(const Epetra_LinearProblem &LinearProblem)
Amesos_Superlu Constructor.
const Epetra_LinearProblem * GetProblem() const
Returns the Epetra_LinearProblem.
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
void GetTiming(Teuchos::ParameterList &list) const
Load up the current timing information into the parameter list.
Definition: Amesos_Time.h:130
int NumSolve() const
Returns the number of solves performed by this object.
Amesos_Status: Container for some status variables.
Definition: Amesos_Status.h:26
std::vector< double > ferr_
Amesos_Time: Container for timing information.
Definition: Amesos_Time.h:56
int SetUseTranspose(bool useTheTranspose)
If set true, X will be set to the solution of AT X = B (not A X = B)
Epetra_RowMatrix * RowMatrixA_
Pointer to the linear system matrix.
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
double * DummyArray
stores the matrix in SuperLU format.
int ConvertToSerial()
Sets up the matrix on processor 0.
int NumNumericFact() const
Returns the number of numeric factorizations performed by this object.
std::vector< double > R_
Teuchos::RCP< Epetra_CrsMatrix > SerialCrsMatrixA_
Contains a matrix with all rows assigned to processor 0.
Teuchos::RCP< Epetra_Import > ImportToSerial_
Importer from distributed to SerialMap_.
SLUData * data_
Main structure for SuperLU.
~Amesos_Superlu()
Amesos_Superlu Destructor.
std::vector< double > berr_
std::vector< int > perm_r_
bool FactorizationOK_
If true, the factorization has been successfully computed.
int iam_
Process number (i.e. Comm().MyPID()
void PrintTiming() const
Prints timing information.
Amesos_BaseSolver: A pure virtual class for direct solution of real-valued double-precision operators...
long long NumGlobalRows_
Global size of the matrix.
Amesos_NoCopiable: Simple class to prevent the usage of copy constructor and operator =...
std::vector< int > Ai_
stores the matrix in SuperLU format.
const Epetra_LinearProblem * Problem_
Pointer to the user&#39;s defined linear problem.
Amesos_Utils: Collections of basic utilities.
Definition: Amesos_Utils.h:25
int NumericFactorization()
Performs NumericFactorization on the matrix A.
int NumSymbolicFact() const
Returns the number of symbolic factorizations performed by this object.