Amesos Package Browser (Single Doxygen Collection) Development
Loading...
Searching...
No Matches
Amesos_Klu.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_KLU_H
40#define AMESOS_KLU_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
60// class EpetraExt::MultiVector_Reindex ;
61// class EpetraExt::CrsMatrix_Reindex ;
63
101// Amesos_Klu_Pimpl contains a pointer to two structures defined in
102// klu.h: trilinos_klu_symbolic and trilinos_klu_numeric. This prevents Amesos_Klu.h
103// from having to include klu.h.
104//
105// Doxygen does not handle forward class references well.
106#ifndef DOXYGEN_SHOULD_SKIP_THIS
107class Amesos_Klu_Pimpl ;
109#endif
110
112 private Amesos_Time,
113 private Amesos_NoCopiable,
114 private Amesos_Utils,
115 private Amesos_Control,
116 private Amesos_Status {
117
118public:
119
121
129 Amesos_Klu(const Epetra_LinearProblem& LinearProblem );
130
132 ~Amesos_Klu(void);
133
135
136
138
140
141 int Solve();
142
144
145
147 const Epetra_LinearProblem *GetProblem() const { return(Problem_); };
148
150
153 bool MatrixShapeOK() const ;
154
156
160 int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
161
162 bool UseTranspose() const {return(UseTranspose_);};
163
164 const Epetra_Comm & Comm() const {return(GetProblem()->GetOperator()->Comm());};
165
166 int SetParameters( Teuchos::ParameterList &ParameterList );
167
170
173
175 int NumSolve() const { return( Amesos_Status::NumSolve_ ); }
176
178 void PrintTiming() const;
179
181 void PrintStatus() const;
182
184 void GetTiming( Teuchos::ParameterList &TimingParameterList ) const { Amesos_Time::GetTiming( TimingParameterList ); }
185
186private:
187
189
190
191 /*
192 CreateLocalMatrixAndExporters - Prepare to convert matrix and vectors to serial
193 Preconditions:
194 Problem_ must be set
195
196 Postconditions:
197 UseDataInPlace_ is set to 1 if the input matrix can be used in place, i.e.
198 1) is entirely stored on process 0
199 2) range map and domain map are same as the row map
200 The following are only set if (! UseDataInPlace_ )"
201 SerialMap_
202 ImportToSerial_
203 SerialCrsMatrixA_
204
205 SerialMatrix_
206 */
208 /*
209 ExportToSerial
210 Preconditions:
211 UseDataInPlace_ must be set
212 ImportToSerial and SerialCrsMatrixA_ must be set if UseDataInPlace_ != 1
213 Postconditions
214 SerialMatrix_ points to a serial version of the matrix
215 */
216 int ExportToSerial() ;
217 /*
218 ConvertToKluCRS - Convert matrix to form expected by Klu: Ai, Ap, Aval
219 Preconditions:
220 numentries_, RowMatrixA_, ImportToSerial_, StdIndexMatrix_, Reindex_
221 Postconditions:
222 SerialCrsMatrixA_
223 */
224 int ConvertToKluCRS(bool firsttime);
225
226 /*
227 PerformSymbolicFactorization - Call Klu to perform symbolic factorization
228 Preconditions:
229 UseDataInPlace_ must be set to 1 if the input matrix is entirely stored on process 0
230 Ap, Ai and Aval point to a compressed row storage version of the input matrix A.
231 Postconditions:
232 Symbolic points to an KLU internal opaque object containing the
233 symbolic factorization and accompanying information.
234 SymbolicFactorizationOK_ = true;
235 Note: All action is performed on process 0
236
237 Returns non-zero if the symbolic factorization failed
238 */
239
241
242 /*
243 PerformNumericFactorization - Call Klu to perform numeric factorization
244 Preconditions:
245 UseDataInPlace_ must be set
246 Ap, Ai and Aval point to a compressed row storage version of the input matrix A.
247 Symbolic must be set
248 Postconditions:
249 Numeric points to an KLU internal opaque object containing the
250 numeric factorization and accompanying information.
251 NumericFactorizationOK_ = true;
252 Note: All action is performed on process 0
253 */
255
256 // @}
257
259
260#ifdef Bug_8212
261 int *lose_this_;
262#endif
263 //
264 // PrivateKluData_ contains pointers to data needed by klu whose
265 // data structures are defined by klu.h
266 //
267 Teuchos::RCP<Amesos_Klu_Pimpl> PrivateKluData_;
268 Teuchos::RCP<Amesos_StandardIndex> StdIndex_;
269 Teuchos::RCP<Amesos_StandardIndex> StdIndexRange_;
270 Teuchos::RCP<Amesos_StandardIndex> StdIndexDomain_;
271
276 std::vector <int> Ap;
277 std::vector <int> VecAi;
278 std::vector <double> VecAval;
279 double* Aval;
280 int *Ai;
281
285 long long numentries_;
288
290 Epetra_RowMatrix* RowMatrixA_;
292 Epetra_CrsMatrix* CrsMatrixA_;
293#if 0
295 Teuchos::RCP<EpetraExt::MultiVector_Reindex> VecTrans_;
297 Teuchos::RCP<EpetraExt::CrsMatrix_Reindex> MatTrans_;
299 Teuchos::RCP<Epetra_Map> ContiguousMap_;
300#endif
302 Teuchos::RCP<Epetra_Map> SerialMap_;
304 Teuchos::RCP<Epetra_CrsMatrix> SerialCrsMatrixA_;
306 Epetra_RowMatrix* StdIndexMatrix_ ;
308 Epetra_RowMatrix* SerialMatrix_ ;
309
311 // serially, StorageOptimized, the LHS and RHS are assumed to be available
312 // when SymbolicFactorization is called and not to change (address or number
313 // of vectors) thereafter.
321 Teuchos::RCP<Epetra_MultiVector> SerialB_ ;
322 Teuchos::RCP<Epetra_MultiVector> SerialX_ ;
324 Teuchos::RCP<Epetra_MultiVector> SerialXextract_;
325 Teuchos::RCP<Epetra_MultiVector> SerialBextract_;
326
330 const Epetra_LinearProblem * Problem_;
331
333 std::vector<int> ColIndicesV_;
335 std::vector<double> RowValuesV_;
337 Teuchos::RCP<Epetra_Import> ImportToSerial_;
338 Teuchos::RCP<Epetra_Import> ImportRangeToSerial_;
339 Teuchos::RCP<Epetra_Import> ImportDomainToSerial_;
343
344}; // class Amesos_Klu
345
346#endif /* AMESOS_KLU_H */
Amesos_BaseSolver: A pure virtual class for direct solution of real-valued double-precision operators...
Amesos_Control: Container for some control variables.
Amesos_Klu: A serial, unblocked code ideal for getting started and for very sparse matrices,...
Definition Amesos_Klu.h:116
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
void PrintTiming() const
Prints timing information.
const Epetra_LinearProblem * GetProblem() const
Get a pointer to the Problem.
Definition Amesos_Klu.h:147
Teuchos::RCP< Epetra_MultiVector > SerialXextract_
Serial versions of the LHS and RHS (if necessary)
Definition Amesos_Klu.h:324
int NumSymbolicFact() const
Returns the number of symbolic factorizations performed by this object.
Definition Amesos_Klu.h:169
double * Aval
Definition Amesos_Klu.h:279
Teuchos::RCP< Epetra_MultiVector > SerialB_
Serial versions of the LHS and RHS (may point to the original vector if serial)
Definition Amesos_Klu.h:321
int MtxConvTime_
Definition Amesos_Klu.h:341
int PerformNumericFactorization()
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
int SerialXlda_
Definition Amesos_Klu.h:258
std::vector< double > VecAval
Definition Amesos_Klu.h:278
int CreateLocalMatrixAndExporters()
bool TrustMe_
If true, no checks are made and the matrix is assume to be distributed.
Definition Amesos_Klu.h:314
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
Definition Amesos_Klu.h:164
bool UseTranspose() const
Returns the current UseTranspose setting.
Definition Amesos_Klu.h:162
int SetUseTranspose(bool UseTranspose_in)
SetUseTranpose(true) is more efficient in Amesos_Klu.
Definition Amesos_Klu.h:160
bool UseTranspose_
If true, the transpose of A is used.
Definition Amesos_Klu.h:328
Epetra_CrsMatrix * CrsMatrixA_
Operator converted to a CrsMatrix.
Definition Amesos_Klu.h:292
~Amesos_Klu(void)
Amesos_Klu Destructor.
Teuchos::RCP< Epetra_Import > ImportDomainToSerial_
Definition Amesos_Klu.h:339
Teuchos::RCP< Epetra_Import > ImportToSerial_
Importer to process 0.
Definition Amesos_Klu.h:337
Teuchos::RCP< Epetra_Map > SerialMap_
Points to a Serial Map (unused if UseDataInPlace_ == 1 )
Definition Amesos_Klu.h:302
std::vector< int > ColIndicesV_
Only used for RowMatrices to extract copies.
Definition Amesos_Klu.h:333
Teuchos::RCP< Amesos_Klu_Pimpl > PrivateKluData_
Definition Amesos_Klu.h:267
int MtxRedistTime_
Quick access ids for the individual timings.
Definition Amesos_Klu.h:341
int ExportToSerial()
Teuchos::RCP< Amesos_StandardIndex > StdIndexDomain_
Definition Amesos_Klu.h:270
Teuchos::RCP< Epetra_MultiVector > SerialX_
Definition Amesos_Klu.h:322
double * SerialBvalues_
Definition Amesos_Klu.h:319
int SymFactTime_
Definition Amesos_Klu.h:342
int UseDataInPlace_
1 if Problem_->GetOperator() is stored entirely on process 0
Definition Amesos_Klu.h:283
void PrintStatus() const
Prints information about the factorization and solution phases.
std::vector< double > RowValuesV_
Only used for RowMatrices to extract copies.
Definition Amesos_Klu.h:335
Epetra_RowMatrix * RowMatrixA_
Operator converted to a RowMatrix.
Definition Amesos_Klu.h:290
Amesos_Klu(const Epetra_LinearProblem &LinearProblem)
Amesos_Klu Constructor.
Teuchos::RCP< Epetra_Import > ImportRangeToSerial_
Definition Amesos_Klu.h:338
Teuchos::RCP< Epetra_CrsMatrix > SerialCrsMatrixA_
Points to a Serial Copy of A (unused if UseDataInPlace_==1)
Definition Amesos_Klu.h:304
Teuchos::RCP< Amesos_StandardIndex > StdIndex_
Definition Amesos_Klu.h:268
const Epetra_LinearProblem * Problem_
Pointer to the linear system problem.
Definition Amesos_Klu.h:330
Teuchos::RCP< Epetra_MultiVector > SerialBextract_
Definition Amesos_Klu.h:325
int NumFactTime_
Definition Amesos_Klu.h:342
std::vector< int > VecAi
Definition Amesos_Klu.h:277
int NumericFactorization()
Performs NumericFactorization on the matrix A.
int VecRedistTime_
Definition Amesos_Klu.h:341
int NumSolve() const
Returns the number of solves performed by this object.
Definition Amesos_Klu.h:175
Teuchos::RCP< Amesos_StandardIndex > StdIndexRange_
Definition Amesos_Klu.h:269
int Solve()
Solves A X = B (or AT x = B)
int ConvertToKluCRS(bool firsttime)
int PerformSymbolicFactorization()
long long numentries_
Number of non-zero entries in Problem_->GetOperator()
Definition Amesos_Klu.h:285
std::vector< int > Ap
Ap, Ai, Aval form the compressed row storage used by Klu Ai and Aval can point directly into a matrix...
Definition Amesos_Klu.h:276
Epetra_RowMatrix * StdIndexMatrix_
Points to a Contiguous Copy of A.
Definition Amesos_Klu.h:306
bool MatrixShapeOK() const
Returns true if KLU can handle this matrix shape.
int NumVectors_
Number of vectors in RHS and LHS.
Definition Amesos_Klu.h:316
void GetTiming(Teuchos::ParameterList &TimingParameterList) const
Extracts timing information and places in parameter list.
Definition Amesos_Klu.h:184
int OverheadTime_
Definition Amesos_Klu.h:342
Epetra_RowMatrix * SerialMatrix_
Points to a Serial Copy of A.
Definition Amesos_Klu.h:308
double * SerialXBvalues_
Pointer to the actual values in the serial version of X and B.
Definition Amesos_Klu.h:318
long long NumGlobalElements_
Number of rows and columns in the Problem_->GetOperator()
Definition Amesos_Klu.h:287
int NumNumericFact() const
Returns the number of numeric factorizations performed by this object.
Definition Amesos_Klu.h:172
Amesos_NoCopiable: Simple class to prevent the usage of copy constructor and operator =.
Amesos_Status: Container for some status variables.
int NumSymbolicFact_
Number of symbolic factorization phases.
int NumSolve_
Number of solves.
int NumNumericFact_
Number of numeric factorization phases.
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.
Amesos_Utils: Collections of basic utilities.