Amesos Package Browser (Single Doxygen Collection)  Development
Amesos_Paraklete.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 
39 #ifndef AMESOS_PARAKLETE_H
40 #define AMESOS_PARAKLETE_H
41 
42 #include "Amesos_ConfigDefs.h"
43 #include "Amesos_BaseSolver.h"
44 #include "Amesos_NoCopiable.h"
45 #include "Amesos_Utils.h"
46 #include "Amesos_Time.h"
47 #include "Amesos_Status.h"
48 #include "Amesos_Control.h"
49 #include "Epetra_LinearProblem.h"
50 #include "Epetra_Time.h"
51 #include "Epetra_Import.h"
52 #ifdef EPETRA_MPI
53 #include "Epetra_MpiComm.h"
54 #else
55 #include "Epetra_Comm.h"
56 #endif
57 #include "Epetra_CrsGraph.h"
58 #include "Epetra_CrsMatrix.h"
59 #ifdef HAVE_AMESOS_EPETRAEXT
60 #include "EpetraExt_Transpose_RowMatrix.h"
61 #endif
62 
63 
65 
84 // Amesos_Paraklete_Pimpl contains a pointer to structures defined in
85 // paraklete.h. This prevents Amesos_Paraklete.h
86 // from having to include paraklete.h.
87 //
88 // Doxygen does not handle forward class references well.
89 #ifndef DOXYGEN_SHOULD_SKIP_THIS
91 class Amesos_StandardIndex ;
92 #endif
93 
95  private Amesos_Time,
96  private Amesos_NoCopiable,
97  private Amesos_Utils,
98  private Amesos_Control,
99  private Amesos_Status {
100 
101 public:
102 
104 
112  Amesos_Paraklete(const Epetra_LinearProblem& LinearProblem );
113 
115  ~Amesos_Paraklete(void);
116 
118 
119 
120  int SymbolicFactorization() ;
121 
122  int NumericFactorization() ;
123 
124  int Solve();
125 
127 
128 
130  const Epetra_LinearProblem *GetProblem() const { return(Problem_); };
131 
133 
136  bool MatrixShapeOK() const ;
137 
139 
143  int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
144 
145  bool UseTranspose() const {return(UseTranspose_);};
146 
147  const Epetra_Comm & Comm() const {return(GetProblem()->GetOperator()->Comm());};
148 
149  int SetParameters( Teuchos::ParameterList &ParameterList );
150 
153 
156 
158  int NumSolve() const { return( Amesos_Status::NumSolve_ ); }
159 
161  void PrintTiming() const;
162 
164  void PrintStatus() const;
165 
167  void GetTiming( Teuchos::ParameterList &TimingParameterList ) const { Amesos_Time::GetTiming(TimingParameterList); }
168 
169 private:
170 
172 
173 
174  /*
175  CreateLocalMatrixAndExporters - Prepare to convert matrix and vectors to serial
176  Preconditions:
177  Problem_ must be set
178 
179  Postconditions:
180  UseDataInPlace_ is set to 1 if the input matrix can be used in place, i.e.
181  1) is entirely stored on process 0
182  2) range map and domain map are same as the row map
183  The following are only set if (! UseDataInPlace_ )"
184  SerialMap_
185  ImportToSerial_
186  SerialCrsMatrixA_
187 
188  SerialMatrix_
189  */
191  /*
192  ExportToSerial
193  Preconditions:
194  UseDataInPlace_ must be set
195  ImportToSerial and SerialCrsMatrixA_ must be set if UseDataInPlace_ != 1
196  Postconditions
197  SerialMatrix_ points to a serial version of the matrix
198  */
199  int ExportToSerial() ;
200  /*
201  ConvertToParakleteCRS - Convert matrix to form expected by Paraklete: Ai, Ap, Aval
202  Preconditions:
203  numentries_, RowMatrixA_, ImportToSerial_, StdIndexMatrix_, Reindex_
204  Postconditions:
205  SerialCrsMatrixA_
206  */
207  int ConvertToParakleteCRS(bool firsttime);
208 
209  /*
210  PerformSymbolicFactorization - Call Paraklete to perform symbolic factorization
211  Preconditions:
212  UseDataInPlace_ must be set to 1 if the input matrix is entirely stored on process 0
213  Ap, Ai and Aval point to a compressed row storage version of the input matrix A.
214  Postconditions:
215  Symbolic points to an PARAKLETE internal opaque object containing the
216  symbolic factorization and accompanying information.
217  SymbolicFactorizationOK_ = true;
218  Note: All action is performed on process 0
219  */
220 
222 
223  /*
224  PerformNumericFactorization - Call Paraklete to perform numeric factorization
225  Preconditions:
226  UseDataInPlace_ must be set
227  Ap, Ai and Aval point to a compressed row storage version of the input matrix A.
228  Symbolic must be set
229  Postconditions:
230  Numeric points to an PARAKLETE internal opaque object containing the
231  numeric factorization and accompanying information.
232  NumericFactorizationOK_ = true;
233  Note: All action is performed on process 0
234  */
236 
237  // @}
238 
239  bool IamInGroup_; // True if this process is involved in the computation. Set by SymbolicFactorization
240 
242  //
243  // PrivateParakleteData_ contains pointers to data needed by paraklete whose
244  // data structures are defined by paraklete.h
245  //
246  Teuchos::RCP<Amesos_Paraklete_Pimpl> PrivateParakleteData_;
247  Teuchos::RCP<Amesos_StandardIndex> StdIndex_;
248  Teuchos::RCP<Amesos_StandardIndex> StdIndexRange_;
249  Teuchos::RCP<Amesos_StandardIndex> StdIndexDomain_;
250  MPI_Comm ParakleteComm_;
251 
256  std::vector <long> Ap;
257  std::vector <long> Ai;
258  std::vector <double> VecAval;
259  double* Aval;
260 
267 
269  Epetra_RowMatrix* RowMatrixA_;
271  Epetra_CrsMatrix* CrsMatrixA_;
272  //
273  // transposer_ transposes a CrsMatrix
274  // Created in CreateLocalMatrixAndExporters
275  // Used in ExportToSerial()
276  //
277 #ifdef HAVE_AMESOS_EPETRAEXT
278  Teuchos::RCP<EpetraExt::RowMatrix_Transpose> transposer_;
279 #endif
281  Teuchos::RCP<Epetra_Map> SerialMap_;
283  Teuchos::RCP<Epetra_CrsMatrix> SerialCrsMatrixA_;
285  Epetra_RowMatrix* StdIndexMatrix_ ;
286  Epetra_MultiVector* StdIndexDomainVector_ ;
287  Epetra_MultiVector* StdIndexRangeVector_ ;
289  Epetra_RowMatrix* SerialMatrix_ ;
290 
292  // serially, StorageOptimized, the LHS and RHS are assumed to be available
293  // when SymbolicFactorization is called and not to change (address or number
294  // of vectors) thereafter.
295  bool TrustMe_;
299  double *SerialXBvalues_ ;
300  double *SerialBvalues_ ;
302  Epetra_MultiVector* SerialB_ ;
303  Epetra_MultiVector* SerialX_ ;
305  Teuchos::RCP<Epetra_MultiVector> SerialXextract_;
306  Teuchos::RCP<Epetra_MultiVector> SerialBextract_;
307 
311  const Epetra_LinearProblem * Problem_;
312 
314  std::vector<int> ColIndicesV_;
316  std::vector<double> RowValuesV_;
318  Teuchos::RCP<Epetra_Import> ImportToSerial_;
319  Teuchos::RCP<Epetra_Import> ImportRangeToSerial_;
320  Teuchos::RCP<Epetra_Import> ImportDomainToSerial_;
321 
325 
326 }; // class Amesos_Paraklete
327 
328 #endif /* AMESOS_PARAKLETE_H */
Amesos_BaseSolver: A pure virtual class for direct solution of real-valued double-precision operators...
Amesos_Control: Container for some control variables.
Amesos_NoCopiable: Simple class to prevent the usage of copy constructor and operator =.
Amesos_Paraklete: A serial, unblocked code ideal for getting started and for very sparse matrices,...
int NumNumericFact() const
Returns the number of numeric factorizations performed by this object.
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
bool UseTranspose() const
Returns the current UseTranspose setting.
bool MatrixShapeOK() const
Returns true if PARAKLETE can handle this matrix shape.
bool TrustMe_
If true, no checks are made and the matrix is assume to be distributed.
int NumSolve() const
Returns the number of solves performed by this object.
Epetra_MultiVector * SerialX_
std::vector< int > ColIndicesV_
Only used for RowMatrices to extract copies.
std::vector< long > Ai
int MtxConvTime_
Quick access pointers to internal timing information.
Epetra_MultiVector * StdIndexDomainVector_
int UseDataInPlace_
1 if Problem_->GetOperator() is stored entirely on process 0
Teuchos::RCP< Epetra_MultiVector > SerialXextract_
Serial versions of the LHS and RHS (if necessary)
int numentries_
Number of non-zero entries in Problem_->GetOperator()
std::vector< long > Ap
Ap, Ai, Aval form the compressed row storage used by Paraklete Ai and Aval can point directly into a ...
Epetra_MultiVector * SerialB_
Serial versions of the LHS and RHS (may point to the original vector if serial)
Teuchos::RCP< Epetra_CrsMatrix > SerialCrsMatrixA_
Points to a Serial Copy of A (unused if UseDataInPlace_==1)
Epetra_RowMatrix * SerialMatrix_
Points to a Serial Copy of A.
void PrintStatus() const
Prints information about the factorization and solution phases.
int NumSymbolicFact() const
Returns the number of symbolic factorizations performed by this object.
int NumericFactorization()
Performs NumericFactorization on the matrix A.
std::vector< double > RowValuesV_
Only used for RowMatrices to extract copies.
Teuchos::RCP< Amesos_StandardIndex > StdIndexDomain_
int NumVectors_
Number of vectors in RHS and LHS.
double * SerialXBvalues_
Pointer to the actual values in the serial version of X and B.
Teuchos::RCP< Amesos_StandardIndex > StdIndex_
void PrintTiming() const
Prints timing information.
Epetra_CrsMatrix * CrsMatrixA_
Operator converted to a CrsMatrix.
Teuchos::RCP< Amesos_Paraklete_Pimpl > PrivateParakleteData_
Teuchos::RCP< Amesos_StandardIndex > StdIndexRange_
int ConvertToParakleteCRS(bool firsttime)
Teuchos::RCP< Epetra_MultiVector > SerialBextract_
int SetUseTranspose(bool UseTranspose_in)
SetUseTranpose()
int Solve()
Solves A X = B (or AT x = B)
const Epetra_LinearProblem * Problem_
Pointer to the linear system problem.
bool UseTranspose_
If true, the transpose of A is used.
Epetra_RowMatrix * StdIndexMatrix_
Points to a Contiguous Copy of A.
~Amesos_Paraklete(void)
Amesos_Paraklete Destructor.
Teuchos::RCP< Epetra_Map > SerialMap_
Points to a Serial Map (unused if UseDataInPlace_ == 1 )
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
void GetTiming(Teuchos::ParameterList &TimingParameterList) const
Extracts timing information from the current solver and places it in the parameter list.
Amesos_Paraklete(const Epetra_LinearProblem &LinearProblem)
Amesos_Paraklete Constructor.
std::vector< double > VecAval
Epetra_MultiVector * StdIndexRangeVector_
Teuchos::RCP< Epetra_Import > ImportDomainToSerial_
int NumGlobalElements_
Number of rows and columns in the Problem_->GetOperator()
const Epetra_LinearProblem * GetProblem() const
Get a pointer to the Problem.
Teuchos::RCP< Epetra_Import > ImportRangeToSerial_
Epetra_RowMatrix * RowMatrixA_
Operator converted to a RowMatrix.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
Teuchos::RCP< Epetra_Import > ImportToSerial_
Importer to process 0.
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