52 #include "Teuchos_Time.hpp" 53 #include "Ifpack_config.h" 62 IsInitialized_(false),
64 Label_(
"Ifpack_ShyLU"),
71 void Ifpack_ShyLU::Destroy()
89 if (slu_config_.schurSolver ==
"Amesos")
91 delete slu_data_.dsolver;
93 else if (slu_config_.libName ==
"Belos")
94 delete slu_data_.innersolver;
96 delete[] slu_data_.DRowElems;
97 delete[] slu_data_.SRowElems;
98 delete[] slu_data_.DColElems;
99 delete[] slu_data_.gvals;
105 slu_data_.localSbargraph = Teuchos::null;
106 slu_data_.guided_prober = Teuchos::null;
112 if(
Comm().NumProc() != 1)
138 slu_config_.sym = Teuchos::getParameter<int>(List_,
140 slu_config_.libName = Teuchos::getParameter<string>(List_,
141 "Outer Solver Library");
142 string schurApproxMethod = Teuchos::getParameter<string>(List_,
143 "Schur Approximation Method");
144 slu_config_.schurSolver = Teuchos::getParameter<string>(List_,
145 "Schur Complement Solver");
146 slu_config_.schurAmesosSolver = List_.get<
string>(
"Schur Amesos Solver",
150 slu_config_.diagonalBlockSolver = List_.get<
string>(
"Diagonal Block Solver",
154 slu_config_.relative_threshold = 0.0;
155 slu_config_.Sdiagfactor = 0.05;
156 if (schurApproxMethod ==
"A22AndBlockDiagonals")
158 slu_config_.schurApproxMethod = 1;
159 slu_config_.Sdiagfactor = Teuchos::getParameter<double>(List_,
162 else if (schurApproxMethod ==
"Threshold")
164 slu_config_.schurApproxMethod = 2;
165 slu_config_.relative_threshold = Teuchos::getParameter<double>(List_,
166 "Relative Threshold");
168 else if (schurApproxMethod ==
"Guided Probing")
170 slu_config_.schurApproxMethod = 3;
171 slu_config_.reset_iter = List_.get<
int>(
"Schur Recompute Iteration", 10);
172 slu_config_.relative_threshold = Teuchos::getParameter<double>(List_,
173 "Relative Threshold");
175 if (schurApproxMethod ==
"IQR")
177 slu_config_.schurSolver =
"IQR";
178 slu_config_.schurApproxMethod = 4;
180 List_.set<
bool>(
"Use full IQR",
true,
"");
183 if (schurApproxMethod ==
"G")
185 slu_config_.schurSolver =
"G";
186 slu_config_.schurApproxMethod = 5;
188 List_.set<
bool>(
"Use full IQR",
false,
"");
192 slu_config_.schurPreconditioner = List_.get<
string>(
"Schur Preconditioner",
194 slu_config_.silent_subiter = List_.get<
bool>(
"Silent subiterations",
197 slu_config_.inner_tolerance = Teuchos::getParameter<double>(List_,
198 "Inner Solver Tolerance");
199 slu_config_.inner_maxiters = Teuchos::getParameter<int>(List_,
200 "Inner Solver MaxIters");
201 slu_config_.overlap = List_.get<
int>(
"Schur Preconditioner Overlap", 0);
202 string sep_type = Teuchos::getParameter<string>(List_,
209 (void) List_.get<
int>(
"Debug Level", 0);
212 if (sep_type ==
"Wide")
213 slu_config_.sep_type = 1;
215 slu_config_.sep_type = 2;
219 if (slu_config_.schurSolver ==
"Amesos")
221 slu_data_.LP2 = Teuchos::rcp(
new Epetra_LinearProblem());
225 if (slu_config_.libName ==
"Belos")
226 slu_data_.innersolver =
new AztecOO() ;
228 slu_data_.innersolver = NULL;
231 IsInitialized_ =
true;
237 #ifdef HAVE_IFPACK_DYNAMIC_FACTORY 238 List_ = parameterlist.sublist(
"ShyLU list",
true);
240 List_ = parameterlist;
247 Teuchos::Time ftime(
"setup time");
250 slu_data_.num_compute = NumCompute_;
266 solver = slu_data_.innersolver;
268 Epetra_Map BsMap(-1, slu_data_.Snr, slu_data_.SRowElems, 0, A_->Comm());
269 Epetra_MultiVector Xs(BsMap, 1);
270 Epetra_MultiVector Bs(BsMap, 1);
274 solver->Iterate(30, 1e-10);
279 Epetra_MultiVector& Y)
const 282 if (NumApplyInverse_ == 0)
284 EpetraExt::MultiVectorToMatlabFile(
"X.mat", X);
289 shylu_solve(&slu_sym_, &slu_data_, &slu_config_, X, Y);
291 if (NumApplyInverse_ == 0)
293 EpetraExt::MultiVectorToMatlabFile(
"Y.mat", Y);
303 const int MaxIters,
const double Tol, Epetra_RowMatrix* Matrix_in)
311 os <<
" !!!!!!!!! " << endl;
int shylu_solve(shylu_symbolic *ssym, shylu_data *data, shylu_config *config, const Epetra_MultiVector &X, Epetra_MultiVector &Y)
Call solve on multiple RHS.
int Compute()
Compute ILU factors L and U using the specified parameters.
virtual ostream & Print(ostream &os) const
Prints on stream basic information about this object.
Encapsulates the IQR inexact solver functionality.
Use ShyLU as a preconditioner within IFPACK.
double Condest(const Ifpack_CondestType CT=Ifpack_Cheap, const int MaxIters=1550, const double Tol=1e-9, Epetra_RowMatrix *Matrix_in=0)
Computes the estimated condition number and returns the value.
const Epetra_Comm & Comm() const
Returns the Epetra_BlockMap object associated with the range of this matrix operator.
int SetParameters(Teuchos::ParameterList ¶meterlist)
Set parameters using a Teuchos::ParameterList object.
int shylu_factor(Epetra_CrsMatrix *A, shylu_symbolic *ssym, shylu_data *data, shylu_config *config)
Main function call into ShylU.
int JustTryIt()
Returns the computed estimated condition number, or -1.0 if not computed.
int shylu_symbolic_factor(Epetra_CrsMatrix *A, shylu_symbolic *ssym, shylu_data *data, shylu_config *config)
Call symbolic factorization on matrix.
int Initialize()
Initialize the preconditioner, does not touch matrix values.
int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_Operator inverse applied to an Epetra_MultiVector X in Y...
Ifpack_ShyLU(Epetra_CrsMatrix *A)
Constructor.