65 TransposeSolve_(false),
68 IsSolverSetup_ =
new bool[1];
69 IsPrecondSetup_ =
new bool[1];
70 IsSolverSetup_[0] =
false;
71 IsPrecondSetup_[0] =
false;
74 ierr += InitializeDefaults();
80 for (
int i = MyRowStart_; i <= MyRowEnd_; i++) {
81 GlobalRowIDs[i-MyRowStart_] = i;
85 int new_value = 0;
int entries = 0;
86 std::set<int> Columns;
90 for(
int i = 0; i < NumMyRows_; i++){
91 ierr += HYPRE_ParCSRMatrixGetRow(ParMatrix_, i+MyRowStart_, &num_entries, &indices, &values);
92 ierr += HYPRE_ParCSRMatrixRestoreRow(ParMatrix_, i+MyRowStart_,&num_entries,&indices,&values);
94 entries = num_entries;
95 for(
int j = 0; j < num_entries; j++){
97 new_value = indices[j];
98 Columns.insert(new_value);
101 int NumMyCols = Columns.size();
104 std::set<int>::iterator it;
106 for (it = Columns.begin(); it != Columns.end(); it++) {
108 GlobalColIDs[counter] = *it;
109 counter = counter + 1;
113 Epetra_Map RowMap(-1, NumMyRows_, &GlobalRowIDs[0], 0, Comm());
114 Epetra_Map ColMap(-1, NumMyCols, &GlobalColIDs[0], 0, Comm());
117 SetMaps(RowMap, ColMap);
122 ierr += HYPRE_ParCSRMatrixGetComm(ParMatrix_, &comm);
125 ierr += HYPRE_IJVectorCreate(comm, MyRowStart_, MyRowEnd_, &X_hypre);
126 ierr += HYPRE_IJVectorSetObjectType(X_hypre, HYPRE_PARCSR);
127 ierr += HYPRE_IJVectorInitialize(X_hypre);
128 ierr += HYPRE_IJVectorAssemble(X_hypre);
129 ierr += HYPRE_IJVectorGetObject(X_hypre, (
void**) &par_x);
132 ierr += HYPRE_IJVectorCreate(comm, MyRowStart_, MyRowEnd_, &Y_hypre);
133 ierr += HYPRE_IJVectorSetObjectType(Y_hypre, HYPRE_PARCSR);
134 ierr += HYPRE_IJVectorInitialize(Y_hypre);
135 ierr += HYPRE_IJVectorAssemble(Y_hypre);
136 ierr += HYPRE_IJVectorGetObject(Y_hypre, (
void**) &par_y);
139 x_vec = (hypre_ParVector *) hypre_IJVectorObject(((hypre_IJVector *) X_hypre));
140 x_local = hypre_ParVectorLocalVector(x_vec);
142 y_vec = (hypre_ParVector *) hypre_IJVectorObject(((hypre_IJVector *) Y_hypre));
143 y_local = hypre_ParVectorLocalVector(y_vec);
146 SolverDestroyPtr_ = &HYPRE_ParCSRPCGDestroy;
147 SolverSetupPtr_ = &HYPRE_ParCSRPCGSetup;
148 SolverSolvePtr_ = &HYPRE_ParCSRPCGSolve;
149 SolverPrecondPtr_ = &HYPRE_ParCSRPCGSetPrecond;
153 PrecondDestroyPtr_ = &HYPRE_EuclidDestroy;
154 PrecondSetupPtr_ = &HYPRE_EuclidSetup;
155 PrecondSolvePtr_ = &HYPRE_EuclidSolve;
157 ComputeNumericConstants();
158 ComputeStructureConstants();
164 ierr += HYPRE_IJVectorDestroy(
X_hypre);
166 ierr += HYPRE_IJVectorDestroy(
Y_hypre);
184 double * Values,
int * Indices)
const
193 NumEntries = num_entries;
195 if(Length < NumEntries){
196 printf(
"The arrays passed in are not large enough. Allocate more space.\n");
200 for(
int i = 0; i < NumEntries; i++){
201 Values[i] = values[i];
215 NumEntries = nentries[0];
285 bool SameVectors =
false;
286 int NumVectors = X.NumVectors();
287 if (NumVectors != Y.NumVectors())
return -1;
288 if(X.Pointers() == Y.Pointers()){
291 for(
int VecNum = 0; VecNum < NumVectors; VecNum++) {
296 double *x_temp =
x_local->data;
297 double *y_temp =
y_local->data;
301 y_values =
new double[X.MyLength()];
316 int NumEntries = Y.MyLength();
317 std::vector<double> new_values; new_values.resize(NumEntries);
318 std::vector<int> new_indices; new_indices.resize(NumEntries);
319 for(
int i = 0; i < NumEntries; i++){
320 new_values[i] = y_values[i];
323 EPETRA_CHK_ERR((*Y(VecNum)).ReplaceMyValues(NumEntries, &new_values[0], &new_indices[0]));
566 if(UsePreconditioner ==
false){
600 bool SameVectors =
false;
601 int NumVectors = X.NumVectors();
602 if (NumVectors != Y.NumVectors())
return -1;
603 if(X.Pointers() == Y.Pointers()){
615 for(
int VecNum = 0; VecNum < NumVectors; VecNum++) {
623 y_values =
new double[X.MyLength()];
626 double *x_temp =
x_local->data;
629 double *y_temp =
y_local->data;
645 int NumEntries = Y.MyLength();
646 std::vector<double> new_values; new_values.resize(NumEntries);
647 std::vector<int> new_indices; new_indices.resize(NumEntries);
648 for(
int i = 0; i < NumEntries; i++){
649 new_values[i] = y_values[i];
652 EPETRA_CHK_ERR((*Y(VecNum)).ReplaceMyValues(NumEntries, &new_values[0], &new_indices[0]));
674 for(
int j = 0; j < num_entries; j++){
676 new_values[j] = X[i]*values[j];
677 new_indices[j] = indices[j];
681 EPETRA_CHK_ERR(HYPRE_IJMatrixSetValues(
Matrix_, 1, &num_entries, rows, &new_indices[0], &new_values[0]));
706 for(
int j = 0; j < num_entries; j++){
710 new_values[j] = values[j] * Import_Vector[index];
711 new_indices[j] = indices[j];
716 EPETRA_CHK_ERR(HYPRE_IJMatrixSetValues(
Matrix_, 1, &num_entries, rows, &new_indices[0], &new_values[0]));
736 int numRows, numCols;
745 int ColStart, ColEnd;
int ExtractMyEntryView(int CurEntry, double *&Value, int &RowIndex, int &ColIndex)
Returns a reference to the ith entry in the matrix, along with its row and column index...
virtual const Epetra_Map & RowMatrixRowMap() const
int Hypre_ParCSRLGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver)
LGMRES Create passing function.
bool * IsSolverSetup_
Flag to know if solver needs to be destoyed.
bool HaveNumericConstants_
virtual ~EpetraExt_HypreIJMatrix()
EpetraExt_HypreIJMatrix Destructor.
int LeftScale(const Epetra_Vector &X)
Scales the EpetraExt_HypreIJMatrix on the left with a Epetra_Vector x.
int InitializeDefaults()
Set global variables to default values.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
int(* SolverSetupPtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector)
int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a EpetraExt_HypreIJMatrix solving a Epetra_MultiVector X in Y...
#define EPETRA_CHK_ERR(a)
int(* PrecondDestroyPtr_)(HYPRE_Solver)
virtual int NumGlobalNonzeros() const
HYPRE_Solver Preconditioner_
int(* PrecondSolvePtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector)
int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a EpetraExt_HypreIJMatrix multiplied by a Epetra_MultiVector X in Y...
int MyRowEnd_
Last row on local processor.
int Hypre_ParCSRPCGCreate(MPI_Comm comm, HYPRE_Solver *solver)
PCG Create passing function.
int(* SolverDestroyPtr_)(HYPRE_Solver)
int(* SolverSolvePtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector)
EpetraExt_HypreIJMatrix(HYPRE_IJMatrix matrix)
Epetra_HypreIJMatrix constructor.
int MyRowStart_
First row on local processor.
int NumMyRowEntries(int MyRow, int &NumEntries) const
Return the current number of values stored for the specified local row.
int NumGlobalCols_
Number of columns across all processors.
Hypre_Chooser
Enumerated type to choose to solve or precondition.
int(* PrecondSetupPtr_)(HYPRE_Solver, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector)
Hypre_Chooser SolveOrPrec_
Choose to solve or apply preconditioner.
int Hypre_ParCSRGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver)
GMRES Create passing function.
int(EpetraExt_HypreIJMatrix::* PrecondCreatePtr_)(MPI_Comm, HYPRE_Solver *)
virtual const Epetra_Map & RowMatrixColMap() const
HYPRE_ParCSRMatrix ParMatrix_
void resize(size_type new_size, const value_type &x=value_type())
int RightScale(const Epetra_Vector &X)
Scales the EpetraExt_HypreIJMatrix on the right with a Epetra_Vector x.
int(EpetraExt_HypreIJMatrix::* SolverCreatePtr_)(MPI_Comm, HYPRE_Solver *)
int Hypre_ParCSRFlexGMRESCreate(MPI_Comm comm, HYPRE_Solver *solver)
FlexGMRES Create passing function.
int MatType_
Hypre matrix type (parCSR).
int NumGlobalRows_
Number of rows across all processors.
int CreatePrecond()
Create the preconditioner with selected type.
int(* SolverPrecondPtr_)(HYPRE_Solver, HYPRE_PtrToParSolverFcn, HYPRE_PtrToParSolverFcn, HYPRE_Solver)
int Hypre_ParaSailsCreate(MPI_Comm comm, HYPRE_Solver *solver)
ParaSails Create passing function.
virtual const Epetra_Import * Importer() const
int Hypre_AMSCreate(MPI_Comm comm, HYPRE_Solver *solver)
AMS Create passing function.
int Hypre_BoomerAMGCreate(MPI_Comm comm, HYPRE_Solver *solver)
AMG Create passing function.
Hypre_Solver
Enumerated type for Hypre solvers.
int Hypre_EuclidCreate(MPI_Comm comm, HYPRE_Solver *solver)
Euclid Create passing function.
int Hypre_ParCSRHybridCreate(MPI_Comm comm, HYPRE_Solver *solver)
Hybrid Create passing function.
int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const
Returns a copy of the specified local row in user-provided arrays.
bool * IsPrecondSetup_
Flag to know if preconditioner needs to be destroyed.
bool TransposeSolve_
Do a transpose solve, only BoomerAMG.
int NumMyRows_
Number of rows on local processor.
int SetParameter(Hypre_Chooser chooser, int(*pt2Func)(HYPRE_Solver, int), int parameter)
Set a parameter that takes a single int.
int Hypre_ParCSRBiCGSTABCreate(MPI_Comm comm, HYPRE_Solver *solver)
BiCGSTAB Create passing function.
void UpdateFlops(int Flops_in) const
int CreateSolver()
Create the solver with selected type.