44#ifndef IFPACK_BLOCKPRECONDITIONER_H
45#define IFPACK_BLOCKPRECONDITIONER_H
59#include "Teuchos_ParameterList.hpp"
60#include "Teuchos_RefCountPtr.hpp"
199 virtual const char*
Label()
const;
268 std::ostream&
Print(std::ostream& os)
const;
309#ifdef IFPACK_FLOPCOUNTERS
317 for (
unsigned int i = 0 ; i <
Containers_.size() ; ++i)
327#ifdef IFPACK_FLOPCOUNTERS
332 for (
unsigned int i = 0 ; i <
Containers_.size() ; ++i)
342#ifdef IFPACK_FLOPCOUNTERS
347 for (
unsigned int i = 0 ; i <
Containers_.size() ; ++i) {
428 Teuchos::RefCountPtr< const Epetra_RowMatrix >
Matrix_;
440 Teuchos::RefCountPtr<Ifpack_Graph>
Graph_;
442 Teuchos::RefCountPtr<Epetra_Vector>
W_;
501 int ierr =
Matrix().Apply(X,Y);
558 for (
int j = 0 ; j < rows ; ++j) {
559 int LRID = (*Partitioner_)(i,j);
568#ifdef SINGLETON_DEBUG
573 printf(
" %d of %d containers are singleton \n",issing,
NumLocalBlocks());
587 Time_.ResetStartTime();
591 if (
Matrix().NumGlobalRows64() !=
Matrix().NumGlobalCols64())
599 Matrix().RowMatrixRowMap()) );
622 Time_.ResetStartTime();
626 Teuchos::RefCountPtr< const Epetra_MultiVector > Xcopy;
630 Xcopy = Teuchos::rcp( &X,
false );
704 for (
int j = 0 ; j <
Partitioner_->NumRowsInPart(i) ; ++j) {
718 for (
int j = 0 ; j <
Partitioner_->NumRowsInPart(i) ; ++j) {
727 int LRID = (*Partitioner_)(i,0);
728 double b = X[0][LRID];
734#ifdef IFPACK_FLOPCOUNTERS
753 for (
int j = 0 ; j <
Partitioner_->NumRowsInPart(i) ; ++j) {
765 for (
int j = 0 ; j <
Partitioner_->NumRowsInPart(i) ; ++j) {
773 int LRID = (*Partitioner_)(i,0);
774 double w = (*W_)[LRID];
775 double b = w * X[0][LRID];
784#ifdef IFPACK_FLOPCOUNTERS
821 int Length =
Matrix().MaxNumEntries();
822 std::vector<int> Indices(Length);
823 std::vector<double> Values(Length);
825 int NumMyRows =
Matrix().NumMyRows();
831 Teuchos::RefCountPtr< Epetra_MultiVector > Y2;
835 Y2 = Teuchos::rcp( &Y,
false );
840 Y2->ExtractView(&y2_ptr);
857 for (
int j = 0 ; j <
Partitioner_->NumRowsInPart(i) ; ++j) {
858 LID = (*Partitioner_)(i,j);
862 &Values[0], &Indices[0]));
864 for (
int k = 0 ; k < NumEntries ; ++k) {
865 int col = Indices[k];
868 X[kk][LID] -= Values[k] * y2_ptr[kk][col];
876 for (
int j = 0 ; j <
Partitioner_->NumRowsInPart(i) ; ++j) {
884#ifdef IFPACK_FLOPCOUNTERS
888 for (
int j = 0 ; j <
Partitioner_->NumRowsInPart(i) ; ++j) {
892 y2_ptr[k][LID] += temp;
897 int LRID = (*Partitioner_)(i,0);
898 double b = X[0][LRID];
906#ifdef IFPACK_FLOPCOUNTERS
915 for (
int i = 0 ; i < NumMyRows ; ++i)
916 y_ptr[m][i] = y2_ptr[m][i];
946 int NumMyRows =
Matrix().NumMyRows();
949 int Length =
Matrix().MaxNumEntries();
950 std::vector<int> Indices;
951 std::vector<double> Values;
952 Indices.resize(Length);
953 Values.resize(Length);
958 Teuchos::RefCountPtr< Epetra_MultiVector > Y2;
962 Y2 = Teuchos::rcp( &Y,
false );
967 Y2->ExtractView(&y2_ptr);
983 for (
int j = 0 ; j <
Partitioner_->NumRowsInPart(i) ; ++j) {
984 LID = (*Partitioner_)(i,j);
987 &Values[0], &Indices[0]));
989 for (
int k = 0 ; k < NumEntries ; ++k) {
990 int col = Indices[k];
993 Xcopy[kk][LID] -= Values[k] * y2_ptr[kk][col];
1001 for (
int j = 0 ; j <
Partitioner_->NumRowsInPart(i) ; ++j) {
1009#ifdef IFPACK_FLOPCOUNTERS
1013 for (
int j = 0 ; j <
Partitioner_->NumRowsInPart(i) ; ++j) {
1021 int LRID = (*Partitioner_)(i,0);
1022 double b = Xcopy[0][LRID];
1028#ifdef IFPACK_FLOPCOUNTERS
1045 for (
int j = 0 ; j <
Partitioner_->NumRowsInPart(i) ; ++j) {
1046 LID = (*Partitioner_)(i,j);
1050 &Values[0], &Indices[0]));
1052 for (
int k = 0 ; k < NumEntries ; ++k) {
1053 int col = Indices[k];
1056 Xcopy[kk][LID] -= Values[k] * y2_ptr[kk][col];
1063 for (
int j = 0 ; j <
Partitioner_->NumRowsInPart(i) ; ++j) {
1071#ifdef IFPACK_FLOPCOUNTERS
1075 for (
int j = 0 ; j <
Partitioner_->NumRowsInPart(i) ; ++j) {
1083 int LRID = (*Partitioner_)(i,0);
1084 double b = Xcopy[0][LRID];
1090#ifdef IFPACK_FLOPCOUNTERS
1100 for (
int i = 0 ; i < NumMyRows ; ++i)
1101 y_ptr[m][i] = y2_ptr[m][i];
1116 PT =
"Gauss-Seidel";
1118 PT =
"symmetric Gauss-Seidel";
1120 if (!
Comm().MyPID()) {
1122 os <<
"================================================================================" << endl;
1123 os <<
"Ifpack_BlockRelaxation, " << PT << endl;
1127 os <<
", using zero starting solution" << endl;
1129 os <<
", using input starting solution" << endl;
1130 os <<
"Number of local blocks = " <<
Partitioner_->NumLocalParts() << endl;
1132 os <<
"Global number of rows = " <<
Matrix_->NumGlobalRows64() << endl;
1134 os <<
"Phase # calls Total Time (s) Total MFlops MFlops/s" << endl;
1135 os <<
"----- ------- -------------- ------------ --------" << endl;
1142 os <<
" " << std::setw(15) << 0.0 << endl;
1143 os <<
"Compute() " << std::setw(5) <<
NumCompute()
1149 os <<
" " << std::setw(15) << 0.0 << endl;
1156 os <<
" " << std::setw(15) << 0.0 << endl;
1157 os <<
"================================================================================" << endl;
1175 PT =
"Gauss-Seidel";
1177 PT =
"symmetric Gauss-Seidel";
1179 PT = List.get(
"relaxation: type", PT);
1181 if (PT ==
"Jacobi") {
1184 else if (PT ==
"Gauss-Seidel") {
1187 else if (PT ==
"symmetric Gauss-Seidel") {
1190 cerr <<
"Option `relaxation: type' has an incorrect value ("
1191 << PT <<
")'" << endl;
1192 cerr <<
"(file " << __FILE__ <<
", line " << __LINE__ <<
")" << endl;
1228 Label_ =
"IFPACK (" + PT2 +
", sweeps="
1241 Time_.ResetStartTime();
1276 for (
int j = 0 ; j <
Partitioner_->NumRowsInPart(i) ; ++j) {
1277 int LID = (*Partitioner_)(i,j);
1281 W_->Reciprocal(*
W_);
1293 Label_ =
"IFPACK (" + PT2 +
", auto-line, sweeps="
static const int IFPACK_JACOBI
static const int IFPACK_GS
static const int IFPACK_SGS
Ifpack_CondestType
Ifpack_CondestType: enum to define the type of condition number estimate.
@ Ifpack_Cheap
cheap estimate
#define IFPACK_RETURN(ifpack_err)
#define IFPACK_CHK_ERR(ifpack_err)
std::string Ifpack_toString(const int &x)
Converts an integer to std::string.
virtual int NumProc() const=0
int ExtractView(double **A, int *MyLDA) const
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
double ** Pointers() const
int PutScalar(double ScalarConstant)
virtual const Epetra_Comm & Comm() const=0
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the matrix to an Epetra_MultiVector.
virtual bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
virtual int ApplyInverseGS(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual int DoSGS(const Epetra_MultiVector &X, Epetra_MultiVector &Xtmp, Epetra_MultiVector &Y) const
Ifpack_BlockRelaxation & operator=(const Ifpack_BlockRelaxation &rhs)
operator= (PRIVATE, should not be used).
double ApplyInverseTime_
Contains the time for all successful calls to ApplyInverse().
bool IsInitialized_
If true, the preconditioner has been successfully initialized.
double InitializeFlops_
Contains the number of flops for Initialize().
Ifpack_BlockRelaxation(const Epetra_RowMatrix *Matrix)
Ifpack_BlockRelaxation constructor with given Epetra_RowMatrix.
bool IsComputed_
If true, the preconditioner has been successfully computed.
virtual int NumCompute() const
Returns the number of calls to Compute().
int NumApplyInverse_
Contains the number of successful call to ApplyInverse().
virtual double InitializeFlops() const
Returns the number of flops in the initialization phase.
double ComputeTime_
Contains the time for all successful calls to Compute().
virtual const Epetra_RowMatrix & Matrix() const
Returns a pointer to the matrix to be preconditioned.
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all the parameters for the preconditioner.
Ifpack_BlockRelaxation(const Ifpack_BlockRelaxation &rhs)
Copy constructor (PRIVATE, should not be used).
virtual bool UseTranspose() const
Returns the current UseTranspose setting.
virtual const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
virtual int SetUseTranspose(bool UseTranspose_in)
double DampingFactor_
Damping parameter.
Teuchos::RefCountPtr< Epetra_Import > Importer_
Teuchos::RefCountPtr< Ifpack_Graph > Graph_
virtual double ComputeFlops() const
Returns the number of flops in the computation phase.
double ApplyInverseFlops_
Contain sthe number of flops for ApplyInverse().
virtual const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
double InitializeTime_
Contains the time for all successful calls to Initialize().
virtual double ComputeTime() const
Returns the time spent in Compute().
std::ostream & Print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator<<.
virtual int DoGaussSeidel(Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual double ApplyInverseFlops() const
Returns the number of flops in the application of the preconditioner.
virtual double NormInf() const
Returns the infinity norm of the global matrix (not implemented)
virtual int Initialize()
Initializes the preconditioner.
virtual double Condest() const
Returns the computed condition number estimate, or -1.0 if not computed.
virtual int NumInitialize() const
Returns the number of calls to Initialize().
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the block Jacobi preconditioner to X, returns the result in Y.
int NumCompute_
Contains the number of successful call to Compute().
int NumLocalBlocks_
Number of local blocks.
bool ZeroStartingSolution_
If true, starting solution is the zero vector.
std::vector< Teuchos::RefCountPtr< T > > Containers_
virtual double Condest(const Ifpack_CondestType=Ifpack_Cheap, const int=1550, const double=1e-9, Epetra_RowMatrix *=0)
Computes the condition number estimate, returns its value.
virtual ~Ifpack_BlockRelaxation()
int NumLocalBlocks() const
Returns the number local blocks.
std::string Label_
Label for this object.
virtual bool IsInitialized() const
Returns true if the preconditioner has been successfully computed.
virtual bool IsComputed() const
Returns true if the preconditioner has been successfully computed.
Teuchos::RefCountPtr< Ifpack_Partitioner > Partitioner_
Contains information about non-overlapping partitions.
virtual const char * Label() const
virtual int NumApplyInverse() const
Returns the number of calls to ApplyInverse().
double ComputeFlops_
Contains the number of flops for Compute().
int NumSweeps_
Number of preconditioning sweeps.
Teuchos::RefCountPtr< Epetra_Vector > W_
Weights for overlapping Jacobi only.
int NumInitialize_
Contains the number of successful calls to Initialize().
Teuchos::ParameterList List_
Parameters list to be used to solve on each subblock.
virtual double InitializeTime() const
Returns the time spent in Initialize().
virtual int ApplyInverseSGS(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual double ApplyInverseTime() const
Returns the time spent in ApplyInverse().
virtual const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Teuchos::RefCountPtr< const Epetra_RowMatrix > Matrix_
Containers_[i] contains all the necessary information to solve on each subblock.
virtual int ApplyInverseJacobi(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual int DoJacobi(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual int Compute()
Computes the preconditioner.
std::string PartitionerType_
Ifpack_EquationPartitioner: A class to decompose an Ifpack_Graph so that each block will contain all ...
Ifpack_Graph_Epetra_RowMatrix: a class to define Ifpack_Graph as a light-weight conversion of Epetra_...
Ifpack_GreedyPartitioner: A class to decompose Ifpack_Graph's using a simple greedy algorithm.
Ifpack_LinearPartitioner: A class to define linear partitions.
Ifpack_METISPartitioner: A class to decompose Ifpack_Graph's using METIS.
Ifpack_Preconditioner: basic class for preconditioning in Ifpack.
Ifpack_UserPartitioner: A class to define linear partitions.