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 
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  //
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 
272  //
273  // transposer_ transposes a CrsMatrix
274  // Created in CreateLocalMatrixAndExporters
275  // Used in ExportToSerial()
276  //
277 #ifdef HAVE_AMESOS_EPETRAEXT
279 #endif
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_ ;
307 
312 
314  std::vector<int> ColIndicesV_;
316  std::vector<double> RowValuesV_;
321 
325 
326 }; // class Amesos_Paraklete
327 
328 #endif /* AMESOS_PARAKLETE_H */
Amesos_Paraklete::CreateLocalMatrixAndExporters
int CreateLocalMatrixAndExporters()
Definition: Amesos_Paraklete.cpp:205
Amesos_Paraklete::GetProblem
const Epetra_LinearProblem * GetProblem() const
Get a pointer to the Problem.
Definition: Amesos_Paraklete.h:130
Amesos_Paraklete::RowValuesV_
std::vector< double > RowValuesV_
Only used for RowMatrices to extract copies.
Definition: Amesos_Paraklete.h:316
Amesos_Paraklete::SerialBvalues_
double * SerialBvalues_
Definition: Amesos_Paraklete.h:300
Amesos_Paraklete::ExportToSerial
int ExportToSerial()
Definition: Amesos_Paraklete.cpp:139
Amesos_Status::NumSolve_
int NumSolve_
Number of solves.
Definition: Amesos_Status.h:71
Amesos_Paraklete::NumFactTime_
int NumFactTime_
Definition: Amesos_Paraklete.h:324
Amesos_Paraklete::StdIndexDomain_
Teuchos::RCP< Amesos_StandardIndex > StdIndexDomain_
Definition: Amesos_Paraklete.h:249
Amesos_NoCopiable.h
Amesos_Paraklete::numentries_
int numentries_
Number of non-zero entries in Problem_->GetOperator()
Definition: Amesos_Paraklete.h:264
Amesos_Paraklete::PrintTiming
void PrintTiming() const
Prints timing information.
Definition: Amesos_Paraklete.cpp:896
Amesos_NoCopiable
Amesos_NoCopiable: Simple class to prevent the usage of copy constructor and operator =.
Definition: Amesos_NoCopiable.h:44
Amesos_Paraklete::NumSolve
int NumSolve() const
Returns the number of solves performed by this object.
Definition: Amesos_Paraklete.h:158
Amesos_Paraklete::StdIndexMatrix_
Epetra_RowMatrix * StdIndexMatrix_
Points to a Contiguous Copy of A.
Definition: Amesos_Paraklete.h:285
Amesos_Paraklete::MatrixShapeOK
bool MatrixShapeOK() const
Returns true if PARAKLETE can handle this matrix shape.
Definition: Amesos_Paraklete.cpp:563
Amesos_BaseSolver
Amesos_BaseSolver: A pure virtual class for direct solution of real-valued double-precision operators...
Definition: Amesos_BaseSolver.h:223
Amesos_Paraklete::PerformNumericFactorization
int PerformNumericFactorization()
Definition: Amesos_Paraklete.cpp:537
Amesos_Paraklete::ConvertToParakleteCRS
int ConvertToParakleteCRS(bool firsttime)
Definition: Amesos_Paraklete.cpp:352
Amesos_Status::NumSymbolicFact_
int NumSymbolicFact_
Number of symbolic factorization phases.
Definition: Amesos_Status.h:67
Epetra_CrsMatrix.h
Amesos_Paraklete::ParakleteComm_
MPI_Comm ParakleteComm_
Definition: Amesos_Paraklete.h:250
Amesos_Paraklete::Amesos_Paraklete
Amesos_Paraklete(const Epetra_LinearProblem &LinearProblem)
Amesos_Paraklete Constructor.
Definition: Amesos_Paraklete.cpp:101
Amesos_Paraklete::Ai
std::vector< long > Ai
Definition: Amesos_Paraklete.h:257
Amesos_Paraklete::VecRedistTime_
int VecRedistTime_
Definition: Amesos_Paraklete.h:323
Amesos_Paraklete::PrivateParakleteData_
Teuchos::RCP< Amesos_Paraklete_Pimpl > PrivateParakleteData_
Definition: Amesos_Paraklete.h:246
Amesos_Paraklete::NumSymbolicFact
int NumSymbolicFact() const
Returns the number of symbolic factorizations performed by this object.
Definition: Amesos_Paraklete.h:152
Amesos_Paraklete::UseTranspose
bool UseTranspose() const
Returns the current UseTranspose setting.
Definition: Amesos_Paraklete.h:145
Amesos_Paraklete::PerformSymbolicFactorization
int PerformSymbolicFactorization()
Definition: Amesos_Paraklete.cpp:519
Amesos_Paraklete::PrintStatus
void PrintStatus() const
Prints information about the factorization and solution phases.
Definition: Amesos_Paraklete.cpp:873
Amesos_Time.h
Epetra_Comm
Amesos_Paraklete::SymFactTime_
int SymFactTime_
Definition: Amesos_Paraklete.h:324
Amesos_Paraklete::Solve
int Solve()
Solves A X = B (or AT x = B)
Definition: Amesos_Paraklete.cpp:745
Amesos_Paraklete::NumericFactorization
int NumericFactorization()
Performs NumericFactorization on the matrix A.
Definition: Amesos_Paraklete.cpp:706
Amesos_Paraklete::GetTiming
void GetTiming(Teuchos::ParameterList &TimingParameterList) const
Extracts timing information from the current solver and places it in the parameter list.
Definition: Amesos_Paraklete.h:167
Epetra_LinearProblem.h
Teuchos::RCP< Amesos_Paraklete_Pimpl >
Amesos_Paraklete::ColIndicesV_
std::vector< int > ColIndicesV_
Only used for RowMatrices to extract copies.
Definition: Amesos_Paraklete.h:314
Epetra_CrsMatrix
Amesos_Paraklete::Problem_
const Epetra_LinearProblem * Problem_
Pointer to the linear system problem.
Definition: Amesos_Paraklete.h:311
Epetra_MpiComm.h
Amesos_Paraklete::SerialB_
Epetra_MultiVector * SerialB_
Serial versions of the LHS and RHS (may point to the original vector if serial)
Definition: Amesos_Paraklete.h:302
Amesos_Paraklete::MtxRedistTime_
int MtxRedistTime_
Definition: Amesos_Paraklete.h:323
Amesos_Status::NumNumericFact_
int NumNumericFact_
Number of numeric factorization phases.
Definition: Amesos_Status.h:69
Amesos_Paraklete::VecAval
std::vector< double > VecAval
Definition: Amesos_Paraklete.h:258
Amesos_Paraklete::NumNumericFact
int NumNumericFact() const
Returns the number of numeric factorizations performed by this object.
Definition: Amesos_Paraklete.h:155
Amesos_Paraklete::SerialMatrix_
Epetra_RowMatrix * SerialMatrix_
Points to a Serial Copy of A.
Definition: Amesos_Paraklete.h:289
Amesos_Utils
Amesos_Utils: Collections of basic utilities.
Definition: Amesos_Utils.h:19
Epetra_RowMatrix
Amesos_Paraklete::UseTranspose_
bool UseTranspose_
If true, the transpose of A is used.
Definition: Amesos_Paraklete.h:309
Amesos_Paraklete::IamInGroup_
bool IamInGroup_
Definition: Amesos_Paraklete.h:239
Amesos_BaseSolver.h
Amesos_Paraklete::RowMatrixA_
Epetra_RowMatrix * RowMatrixA_
Operator converted to a RowMatrix.
Definition: Amesos_Paraklete.h:269
Amesos_Paraklete::SerialBextract_
Teuchos::RCP< Epetra_MultiVector > SerialBextract_
Definition: Amesos_Paraklete.h:306
Amesos_Paraklete::SymbolicFactorization
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
Definition: Amesos_Paraklete.cpp:594
Amesos_Paraklete::MtxConvTime_
int MtxConvTime_
Quick access pointers to internal timing information.
Definition: Amesos_Paraklete.h:323
Epetra_LinearProblem
Amesos_Paraklete::Ap
std::vector< long > Ap
Ap, Ai, Aval form the compressed row storage used by Paraklete Ai and Aval can point directly into a ...
Definition: Amesos_Paraklete.h:256
Amesos_Paraklete::StdIndexRangeVector_
Epetra_MultiVector * StdIndexRangeVector_
Definition: Amesos_Paraklete.h:287
Amesos_Paraklete::ImportDomainToSerial_
Teuchos::RCP< Epetra_Import > ImportDomainToSerial_
Definition: Amesos_Paraklete.h:320
Epetra_Import.h
Amesos_Paraklete::OverheadTime_
int OverheadTime_
Definition: Amesos_Paraklete.h:324
Amesos_Control
Amesos_Control: Container for some control variables.
Definition: Amesos_Control.h:16
Amesos_Paraklete::SerialXlda_
int SerialXlda_
Definition: Amesos_Paraklete.h:241
Amesos_Paraklete_Pimpl
Definition: Amesos_Paraklete.cpp:87
Epetra_Comm.h
Amesos_Paraklete::SolveTime_
int SolveTime_
Definition: Amesos_Paraklete.h:324
Amesos_Paraklete::SetParameters
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
Definition: Amesos_Paraklete.cpp:488
Amesos_ConfigDefs.h
Amesos_Paraklete::StdIndexRange_
Teuchos::RCP< Amesos_StandardIndex > StdIndexRange_
Definition: Amesos_Paraklete.h:248
Amesos_Paraklete::CrsMatrixA_
Epetra_CrsMatrix * CrsMatrixA_
Operator converted to a CrsMatrix.
Definition: Amesos_Paraklete.h:271
Amesos_Paraklete::SerialCrsMatrixA_
Teuchos::RCP< Epetra_CrsMatrix > SerialCrsMatrixA_
Points to a Serial Copy of A (unused if UseDataInPlace_==1)
Definition: Amesos_Paraklete.h:283
Amesos_Paraklete::Aval
double * Aval
Definition: Amesos_Paraklete.h:259
Amesos_Paraklete::NumVectors_
int NumVectors_
Number of vectors in RHS and LHS.
Definition: Amesos_Paraklete.h:297
Epetra_MultiVector
Amesos_Utils.h
Amesos_Control.h
Amesos_Paraklete::SerialXextract_
Teuchos::RCP< Epetra_MultiVector > SerialXextract_
Serial versions of the LHS and RHS (if necessary)
Definition: Amesos_Paraklete.h:305
Amesos_StandardIndex
Definition: Amesos_Support.h:40
Amesos_Time::GetTiming
void GetTiming(Teuchos::ParameterList &list) const
Load up the current timing information into the parameter list.
Definition: Amesos_Time.h:124
Amesos_Paraklete::StdIndex_
Teuchos::RCP< Amesos_StandardIndex > StdIndex_
Definition: Amesos_Paraklete.h:247
Amesos_Paraklete::ImportToSerial_
Teuchos::RCP< Epetra_Import > ImportToSerial_
Importer to process 0.
Definition: Amesos_Paraklete.h:318
Epetra_CrsGraph.h
Amesos_Paraklete::SerialX_
Epetra_MultiVector * SerialX_
Definition: Amesos_Paraklete.h:303
Amesos_Paraklete::SerialXBvalues_
double * SerialXBvalues_
Pointer to the actual values in the serial version of X and B.
Definition: Amesos_Paraklete.h:299
Amesos_Paraklete
Amesos_Paraklete: A serial, unblocked code ideal for getting started and for very sparse matrices,...
Definition: Amesos_Paraklete.h:94
Teuchos::ParameterList
Amesos_Paraklete::~Amesos_Paraklete
~Amesos_Paraklete(void)
Amesos_Paraklete Destructor.
Definition: Amesos_Paraklete.cpp:125
Amesos_Paraklete::SetUseTranspose
int SetUseTranspose(bool UseTranspose_in)
SetUseTranpose()
Definition: Amesos_Paraklete.h:143
Amesos_Time
Amesos_Time: Container for timing information.
Definition: Amesos_Time.h:50
Amesos_Paraklete::Comm
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
Definition: Amesos_Paraklete.h:147
Amesos_Paraklete::NumGlobalElements_
int NumGlobalElements_
Number of rows and columns in the Problem_->GetOperator()
Definition: Amesos_Paraklete.h:266
Amesos_Paraklete::UseDataInPlace_
int UseDataInPlace_
1 if Problem_->GetOperator() is stored entirely on process 0
Definition: Amesos_Paraklete.h:262
Amesos_Paraklete::TrustMe_
bool TrustMe_
If true, no checks are made and the matrix is assume to be distributed.
Definition: Amesos_Paraklete.h:295
Amesos_Paraklete::ImportRangeToSerial_
Teuchos::RCP< Epetra_Import > ImportRangeToSerial_
Definition: Amesos_Paraklete.h:319
Amesos_Paraklete::StdIndexDomainVector_
Epetra_MultiVector * StdIndexDomainVector_
Definition: Amesos_Paraklete.h:286
Amesos_Paraklete::SerialMap_
Teuchos::RCP< Epetra_Map > SerialMap_
Points to a Serial Map (unused if UseDataInPlace_ == 1 )
Definition: Amesos_Paraklete.h:281
Epetra_Time.h
Amesos_Status
Amesos_Status: Container for some status variables.
Definition: Amesos_Status.h:20
Amesos_Status.h