46 #include "Epetra_MpiComm.h" 48 #include "Epetra_SerialComm.h" 49 #include "Epetra_CrsMatrix.h" 50 #include "Epetra_Vector.h" 51 #include "Epetra_LinearProblem.h" 52 #include "Galeri_Maps.h" 53 #include "Galeri_CrsMatrices.h" 54 #include "Galeri_Utils.h" 55 #include "Teuchos_ParameterList.hpp" 56 #include "Teuchos_RefCountPtr.hpp" 65 bool TestContainer(std::string Type,
const Teuchos::RefCountPtr<Epetra_RowMatrix>& A)
71 int NumMyRows = A->NumMyRows();
76 LHS_exact.Random(); LHS.PutScalar(0.0);
77 A->Multiply(
false, LHS_exact,
RHS);
82 cout <<
"Container type = " << Type << endl;
83 cout <<
"NumMyRows = " << NumMyRows <<
", NumVectors = " <<
NumVectors << endl;
87 Teuchos::RefCountPtr<Ifpack_Container> Container;
94 assert (Container != Teuchos::null);
98 for (
int i = 0 ; i < A->NumMyRows() ; ++i)
106 for (
int i = 0 ; i < A->NumMyRows() ; ++i)
108 Container->RHS(i,j) =
RHS[j][i];
109 Container->LHS(i,j) = LHS[j][i];
113 Teuchos::ParameterList List;
114 List.set(
"amesos: solver type", Type);
121 for (
int i = 0 ; i < A->NumMyRows() ; ++i)
123 LHS[j][i] = Container->LHS(i,j);
126 double residual = Galeri::ComputeNorm(&LHS, &LHS_exact);
128 if (A->Comm().MyPID() == 0 &&
verbose) {
129 cout <<
"||x_exact - x||_2 = " << residual << endl;
141 int main(
int argc,
char *argv[])
147 MPI_Init(&argc,&argv);
157 Teuchos::ParameterList GaleriList;
158 GaleriList.set(
"n", nx * nx);
159 GaleriList.set(
"nx", nx);
160 GaleriList.set(
"ny", nx);
162 Teuchos::RefCountPtr<Epetra_Map> Map = Teuchos::rcp( Galeri::CreateMap64(
"Linear", Comm, GaleriList) );
163 Teuchos::RefCountPtr<Epetra_RowMatrix> Matrix = Teuchos::rcp( Galeri::CreateCrsMatrix(
"Laplace2D", &*Map, GaleriList) );
165 Teuchos::RefCountPtr<Ifpack_LocalFilter> LocalMatrix = Teuchos::rcp(
new Ifpack_LocalFilter(Matrix) );
166 int TestPassed =
true;
169 if (!
TestContainer(
"sparse",LocalMatrix)) TestPassed =
false;
174 cout <<
"Test `TestContainer.exe' passed!" << endl;
177 cout <<
"Test `TestContainer.exe' FAILED!" << endl;
185 return(EXIT_SUCCESS);
int main(int argc, char *argv[])
Ifpack_SparseContainer: a class for storing and solving linear systems using sparse matrices...
Ifpack_LocalFilter a class for light-weight extraction of the submatrix corresponding to local rows a...
Ifpack_DenseContainer: a class to define containers for dense matrices.
#define IFPACK_CHK_ERR(ifpack_err)
bool TestContainer(std::string Type, const Teuchos::RefCountPtr< Epetra_RowMatrix > &A)