Amesos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Amesos_CSparse.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_CSPARSE_H
30 #define AMESOS_CSPARSE_H
31 
32 #if defined(Amesos_SHOW_DEPRECATED_WARNINGS)
33 #ifdef __GNUC__
34 #warning "The Amesos package is deprecated"
35 #endif
36 #endif
37 #ifdef HAVE_AMESOS_CSPARSE
38 
39 #include "Amesos_ConfigDefs.h"
40 #include "Amesos_BaseSolver.h"
41 #include "Amesos_NoCopiable.h"
42 #include "Amesos_Utils.h"
43 #include "Amesos_Time.h"
44 #include "Amesos_Status.h"
45 #include "Amesos_Control.h"
46 #include "Amesos_Support.h"
47 #include "Epetra_LinearProblem.h"
48 #include "Epetra_Time.h"
49 #include "Epetra_Map.h"
50 #include "Epetra_Import.h"
51 #include "Epetra_Comm.h"
52 #include "Epetra_RowMatrix.h"
53 #include "Epetra_CrsMatrix.h"
55 #include "Teuchos_RCP.hpp"
56 
57 #include "cs.h"
58 
60 
67 class Amesos_CSparse: public Amesos_BaseSolver,
68  private Amesos_Time,
69  private Amesos_NoCopiable,
70  private Amesos_Utils,
71  private Amesos_Control,
72  private Amesos_Status {
73 
74 public:
75 
77  Amesos_CSparse(const Epetra_LinearProblem& LinearProblem );
79 
81  ~Amesos_CSparse();
83 
85 
87  int SymbolicFactorization() ;
88 
90  int NumericFactorization() ;
91 
93  int Solve();
95 
97 
99  const Epetra_LinearProblem* GetProblem() const { return(Problem_); }
100 
102 
105  bool MatrixShapeOK() const;
106 
108 
112  int SetUseTranspose(bool UseTranspose) { UseTranspose_ = UseTranspose; return(0); }
113 
115  bool UseTranspose() const { return(UseTranspose_); }
116 
118  const Epetra_Comm& Comm() const { return(GetProblem()->GetOperator()->Comm()); }
119 
121  int SetParameters( Teuchos::ParameterList &ParameterList );
122 
124  int NumSymbolicFact() const { return( Amesos_Status::NumSymbolicFact_ ); }
125 
127  int NumNumericFact() const { return( Amesos_Status::NumNumericFact_ ); }
128 
130  int NumSolve() const { return( Amesos_Status::NumSolve_ ); }
131 
133  void PrintTiming() const;
134 
136  void PrintStatus() const;
137 
139  void GetTiming( Teuchos::ParameterList &TimingParameterList ) const { Amesos_Time::GetTiming(TimingParameterList); }
140 
142 
143 private:
144 
145  int CheckError(const int error) const;
146 
147  inline const Epetra_Map& Map() const
148  {
149  return(Matrix_->RowMatrixRowMap());
150  }
151 
152  inline const Epetra_RowMatrix& Matrix() const
153  {
154  return(*Matrix_);
155  }
156 
157  inline Epetra_Map& SerialMap()
158  {
159  return(*(SerialMap_.get()));
160  }
161 
162  inline Epetra_RowMatrix& SerialMatrix()
163  {
164  return(*(SerialMatrix_.get()));
165  }
166 
167  inline Epetra_CrsMatrix& SerialCrsMatrix()
168  {
169  return(*(SerialCrsMatrix_.get()));
170  }
171 
172  inline Epetra_Import& Importer()
173  {
174  return(*(Importer_.get()));
175  }
176 
177  int ConvertToSerial();
178  int ConvertToCSparse();
179  int PerformSymbolicFactorization();
180  int PerformNumericFactorization();
181 
182  Teuchos::RCP<Epetra_Map> SerialMap_;
183  Teuchos::RCP<Epetra_CrsMatrix> SerialCrsMatrix_;
184  Teuchos::RCP<Epetra_RowMatrix> SerialMatrix_;
185  Teuchos::RCP<Epetra_Import> Importer_;
187  Teuchos::RCP<Amesos_StandardIndex> StdIndexRange_;
188  Teuchos::RCP<Amesos_StandardIndex> StdIndexDomain_;
189 
190  const Epetra_Map* Map_;
191  const Epetra_RowMatrix* Matrix_;
192 
194  bool UseTranspose_;
196  const Epetra_LinearProblem* Problem_;
197 
199  int MtxConvTime_, MtxRedistTime_, VecRedistTime_;
200  int SymFactTime_, NumFactTime_, SolveTime_;
201 
202 #ifdef HAVE_AMESOS_CSPARSE
203  // Data for CSparse
204  cs csMatrix;
205  cs *csTranMatrix;
206  css *csSymbolic;
207  csn *csNumeric;
208 #endif
209 
210  //int mtype_;
211  //void* pt_[64];
212 
213  //int iparm_[64];
214  //int maxfct_; // Maximal number of factors with idential nonzero pattern (always 1)
215  //int mnum_; //! Actual matrix for solution phase (always 1)
216  //int msglvl_; //! Output level
217  //int nrhs_; // Number of RHS
218 
219 }; // class Amesos_CSparse
220 
221 #endif
222 #endif // AMESOS_CSPARSE_H
int NumSymbolicFact_
Number of symbolic factorization phases.
Definition: Amesos_Status.h:73
virtual const Epetra_Comm & Comm() const =0
Returns a pointer to the Epetra_Comm communicator associated with this operator.
Amesos_Control: Container for some control variables.
virtual int Solve()=0
Solves A X = B (or AT x = B)
virtual int NumSolve() const =0
Returns the number of solves performed by this object.
virtual int NumNumericFact() const =0
Returns the number of numeric factorizations performed by this object.
virtual int NumSymbolicFact() const =0
Returns the number of symbolic factorizations performed by this object.
virtual int NumericFactorization()=0
Performs NumericFactorization on the matrix A.
virtual int SymbolicFactorization()=0
Performs SymbolicFactorization on the matrix A.
virtual int SetParameters(Teuchos::ParameterList &ParameterList)=0
Updates internal variables.
int NumNumericFact_
Number of numeric factorization phases.
Definition: Amesos_Status.h:75
int NumSolve_
Number of solves.
Definition: Amesos_Status.h:77
virtual bool UseTranspose() const =0
Returns the current UseTranspose setting.
virtual void PrintTiming() const =0
Prints timing information about the current solver.
void GetTiming(Teuchos::ParameterList &list) const
Load up the current timing information into the parameter list.
Definition: Amesos_Time.h:130
Amesos_Status: Container for some status variables.
Definition: Amesos_Status.h:26
virtual int SetUseTranspose(bool UseTranspose)=0
If set true, X will be set to the solution of AT X = B (not A X = B)
Amesos_Time: Container for timing information.
Definition: Amesos_Time.h:56
virtual void GetTiming(Teuchos::ParameterList &TimingParameterList) const
Extracts timing information from the current solver and places it in the parameter list...
virtual void PrintStatus() const =0
Prints status information about the current solver.
virtual const Epetra_LinearProblem * GetProblem() const =0
Returns the Epetra_LinearProblem.
bool CheckError(const std::string SolverType, const std::string Descriptor, const Epetra_RowMatrix &A, const Epetra_MultiVector &x, const Epetra_MultiVector &b, const Epetra_MultiVector &x_exact)
virtual bool MatrixShapeOK() const =0
Returns true if the solver can handle this matrix shape.
Amesos_BaseSolver: A pure virtual class for direct solution of real-valued double-precision operators...
Amesos_NoCopiable: Simple class to prevent the usage of copy constructor and operator =...
Amesos_Utils: Collections of basic utilities.
Definition: Amesos_Utils.h:25