43 #ifndef IFPACK_SPARSECONTAINER_H
44 #define IFPACK_SPARSECONTAINER_H
46 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
48 #warning "The Ifpack package is deprecated"
53 #include "Epetra_IntSerialDenseVector.h"
54 #include "Epetra_MultiVector.h"
55 #include "Epetra_Vector.h"
56 #include "Epetra_Map.h"
57 #include "Epetra_RowMatrix.h"
58 #include "Epetra_CrsMatrix.h"
59 #include "Epetra_LinearProblem.h"
60 #include "Epetra_IntSerialDenseVector.h"
61 #include "Teuchos_ParameterList.hpp"
62 #include "Teuchos_RefCountPtr.hpp"
64 #include "Epetra_MpiComm.h"
66 #include "Epetra_SerialComm.h"
143 virtual double&
LHS(
const int i,
const int Vector = 0);
146 virtual double&
RHS(
const int i,
const int Vector = 0);
158 virtual int&
ID(
const int i);
253 return(
Inverse_->InitializeFlops());
277 return(
Inverse_->ApplyInverseFlops());
281 virtual std::ostream&
Print(std::ostream& os)
const;
293 Teuchos::RefCountPtr<Epetra_Map>
Map_;
295 Teuchos::RefCountPtr<Epetra_CrsMatrix>
Matrix_;
297 Teuchos::RefCountPtr<Epetra_MultiVector>
LHS_;
299 Teuchos::RefCountPtr<Epetra_MultiVector>
RHS_;
321 NumRows_(NumRows_in),
322 NumVectors_(NumVectors_in),
323 IsInitialized_(
false),
340 NumRows_(rhs.NumRows()),
342 IsInitialized_(rhs.IsInitialized()),
343 IsComputed_(rhs.IsComputed())
355 if (!rhs.
Matrix().is_null())
358 if (!rhs.
LHS().is_null())
361 if (!rhs.
RHS().is_null())
376 if (IsInitialized() ==
false)
387 if (IsInitialized_ ==
true)
390 IsInitialized_ =
false;
392 #if !defined(EPETRA_NO_32BIT_GLOBAL_INDICES) || !defined(EPETRA_NO_64BIT_GLOBAL_INDICES)
398 GID_.Reshape(NumRows_,1);
400 #if defined(HAVE_TEUCHOSCORE_CXX11)
418 Label_ =
"Ifpack_SparseContainer";
420 IsInitialized_ =
true;
429 return(((*LHS_)(Vector))->Values()[i]);
436 return(((*RHS_)(Vector))->Values()[i]);
444 if (!IsInitialized())
447 if ((row < 0) || (row >= NumRows())) {
451 if ((col < 0) || (col >= NumRows())) {
455 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
456 if(Matrix_->RowMatrixRowMap().GlobalIndicesInt()) {
457 int ierr = Matrix_->InsertGlobalValues((
int)row,1,(
double*)&value,(
int*)&col);
459 ierr = Matrix_->SumIntoGlobalValues((
int)row,1,(
double*)&value,(
int*)&col);
466 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
467 if(Matrix_->RowMatrixRowMap().GlobalIndicesLongLong()) {
468 long long col_LL = col;
469 int ierr = Matrix_->InsertGlobalValues(row,1,(
double*)&value,&col_LL);
471 ierr = Matrix_->SumIntoGlobalValues(row,1,(
double*)&value,&col_LL);
478 throw "Ifpack_SparseContainer<T>::SetMatrixElement: GlobalIndices type unknown";
490 if (!IsInitialized()) {
503 Label_ =
"Ifpack_SparseContainer";
514 if (IsComputed() ==
false) {
520 ApplyFlops_ += 2 * Matrix_->NumGlobalNonzeros64();
541 IsInitialized_ =
false;
568 for (
int j = 0 ; j < NumRows_ ; ++j) {
578 std::vector<double> Values;
579 Values.resize(Length);
580 std::vector<int> Indices;
581 Indices.resize(Length);
583 for (
int j = 0 ; j < NumRows_ ; ++j) {
591 &Values[0], &Indices[0]);
594 for (
int k = 0 ; k < NumEntries ; ++k) {
596 int LCID = Indices[k];
606 for (
int kk = 0 ; kk < NumRows_ ; ++kk)
611 SetMatrixElement(j,jj,Values[k]);
627 os <<
"================================================================================" << endl;
628 os <<
"Ifpack_SparseContainer" << endl;
629 os <<
"Number of rows = " << NumRows() << endl;
630 os <<
"Number of vectors = " <<
NumVectors() << endl;
631 os <<
"IsInitialized() = " << IsInitialized() << endl;
632 os <<
"IsComputed() = " << IsComputed() << endl;
633 os <<
"Flops in Initialize() = " << InitializeFlops() << endl;
634 os <<
"Flops in Compute() = " << ComputeFlops() << endl;
635 os <<
"Flops in ApplyInverse() = " << ApplyInverseFlops() << endl;
636 os <<
"================================================================================" << endl;
641 #endif // IFPACK_SPARSECONTAINER_H
virtual double ComputeFlops() const
Returns the flops in Compute().
virtual double InitializeFlops() const
Returns the flops in Compute().
Teuchos::RCP< const Epetra_MultiVector > LHS() const
Returns a pointer to the internally stored solution multi-vector.
virtual int NumRows() const
Returns the number of rows of the matrix and LHS/RHS.
int NumRows_
Number of rows in the local matrix.
Ifpack_SparseContainer & operator=(const Ifpack_SparseContainer< T > &rhs)
Operator =.
Teuchos::RCP< const Epetra_MultiVector > RHS() const
Returns a pointer to the internally stored rhs multi-vector.
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all necessary parameters.
virtual bool IsInitialized() const
Returns true is the container has been successfully initialized.
Teuchos::RCP< const Epetra_CrsMatrix > Matrix() const
Returns a pointer to the internally stored matrix.
Epetra_IntSerialDenseVector GID_
Contains the subrows/subcols of A that will be inserted in Matrix_.
virtual double & LHS(const int i, const int Vector=0)
Returns the i-th component of the vector Vector of LHS.
virtual int Initialize()
Initializes the container, by completing all the operations based on matrix structure.
Teuchos::RefCountPtr< T > Inverse_
Pointer to an Ifpack_Preconditioner object whose ApplyInverse() defined the action of the inverse of ...
bool IsInitialized_
If true, the container has been successfully initialized.
virtual int SetMatrixElement(const int row, const int col, const double value)
Set the matrix element (row,col) to value.
virtual const char * Label() const
Returns the label of this container.
Teuchos::RefCountPtr< Epetra_Map > Map_
Linear map on which the local matrix is based.
Teuchos::RefCountPtr< Epetra_CrsMatrix > Matrix_
Pointer to the local matrix.
virtual double & RHS(const int i, const int Vector=0)
Returns the i-th component of the vector Vector of RHS.
Teuchos::RefCountPtr< Epetra_Comm > SerialComm_
Serial communicator (containing only MPI_COMM_SELF if MPI is used).
Teuchos::ParameterList List_
bool IsComputed_
If true, the container has been successfully computed.
Teuchos::RCP< const Epetra_Map > Map() const
Returns a pointer to the internally stored map.
virtual int MaxNumEntries() const =0
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
std::string Label_
Label for this object.
virtual int NumVectors() const
Returns the number of vectors in LHS/RHS.
bool is_null(const RCP< T > &p)
Ifpack_SparseContainer: a class for storing and solving linear systems using sparse matrices...
virtual int SetNumVectors(const int NumVectors_in)
Sets the number of vectors for LHS/RHS.
virtual int ApplyInverse()
Apply the inverse of the matrix to RHS, result is stored in LHS.
Ifpack_SparseContainer(const int NumRows, const int NumVectors=1)
Constructor.
virtual int NumMyRows() const =0
virtual double ApplyFlops() const
Returns the flops in Apply().
virtual std::ostream & Print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator<<.
virtual ~Ifpack_SparseContainer()
Destructor.
Teuchos::RCP< const T > Inverse() const
Returns a pointer to the internally stored inverse operator.
int NumVectors_
Number of vectors in the local linear system.
const Epetra_IntSerialDenseVector & ID() const
Returns a pointer to the internally stored ID's.
Teuchos::RefCountPtr< Epetra_MultiVector > RHS_
right-hand side for local problems.
virtual int Destroy()
Destroys all data.
Teuchos::RefCountPtr< Epetra_MultiVector > LHS_
Solution vector.
Ifpack_Container: a pure virtual class for creating and solving local linear problems.
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const =0
virtual bool IsComputed() const
Returns true is the container has been successfully computed.
#define IFPACK_CHK_ERR(ifpack_err)
virtual int Compute(const Epetra_RowMatrix &Matrix_in)
Finalizes the linear system matrix and prepares for the application of the inverse.
virtual double ApplyInverseFlops() const
Returns the flops in ApplyInverse().
virtual int Extract(const Epetra_RowMatrix &Matrix_in)
Extract the submatrices identified by the ID set int ID().
virtual int Apply()
Apply the matrix to RHS, result is stored in LHS.