Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "PlayaIfpackILUOperator.hpp"
00043 #include "Teuchos_Array.hpp"
00044 #include "PlayaMPIComm.hpp"
00045 #include "PlayaEpetraVector.hpp"
00046
00047
00048 #ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION
00049 #include "PlayaVectorImpl.hpp"
00050 #include "PlayaLinearOperatorImpl.hpp"
00051 #endif
00052
00053 namespace Playa
00054 {
00055
00056 using namespace Teuchos;
00057
00058 IfpackILUOperator::IfpackILUOperator(const EpetraMatrix* A,
00059 int fillLevels,
00060 int overlapFill,
00061 double relaxationValue,
00062 double relativeThreshold,
00063 double absoluteThreshold)
00064 : LinearOpWithSpaces<double>(A->domain(), A->range()),
00065 precondGraph_(),
00066 precond_()
00067 {
00068 const Epetra_CrsMatrix* matrix = A->crsMatrix();
00069
00070 const Epetra_CrsGraph& matrixGraph = matrix->Graph();
00071
00072 Ifpack_IlukGraph* precondGraph
00073 = new Ifpack_IlukGraph(matrixGraph, fillLevels, overlapFill);
00074 precondGraph_ = rcp(precondGraph);
00075
00076 int ierr = precondGraph->ConstructFilledGraph();
00077
00078 TEUCHOS_TEST_FOR_EXCEPTION(ierr < 0, std::runtime_error,
00079 "IfpackOperator ctor: "
00080 "precondGraph->ConstructFilledGraph() failed with ierr="
00081 << ierr);
00082
00083 Ifpack_CrsRiluk* precond = new Ifpack_CrsRiluk(*precondGraph);
00084 precond_ = rcp(precond);
00085
00086 precond->SetRelaxValue(relaxationValue);
00087 precond->SetRelativeThreshold(relativeThreshold);
00088 precond->SetAbsoluteThreshold(absoluteThreshold);
00089
00090 ierr = precond->InitValues(*matrix);
00091
00092 TEUCHOS_TEST_FOR_EXCEPTION(ierr < 0, std::runtime_error,
00093 "IfpackOperator ctor: "
00094 "precond->InitValues() failed with ierr="
00095 << ierr);
00096
00097 ierr = precond->Factor();
00098
00099 TEUCHOS_TEST_FOR_EXCEPTION(ierr < 0, std::runtime_error,
00100 "IfpackOperator ctor: "
00101 "precond->Factor() failed with ierr="
00102 << ierr);
00103 }
00104
00105 void IfpackILUOperator::apply(Teuchos::ETransp transApplyType,
00106 const Vector<double>& in,
00107 Vector<double> out) const
00108 {
00109
00110 const Epetra_Vector& epIn = EpetraVector::getConcrete(in);
00111 Epetra_Vector& epOut = EpetraVector::getConcrete(out);
00112
00113
00114
00115 Ifpack_CrsRiluk* p = const_cast<Ifpack_CrsRiluk*>(precond_.get());
00116
00117 int ierr;
00118
00119
00120 if (transApplyType==NO_TRANS)
00121 {
00122 ierr = p->Solve(false, epIn, epOut);
00123 }
00124 else
00125 {
00126 ierr = p->Solve(true, epIn, epOut);
00127 }
00128 TEUCHOS_TEST_FOR_EXCEPTION(ierr < 0, std::runtime_error,
00129 "Playa::IfpackILUOperator apply: "
00130 "p->Solve() (transpose state="
00131 << transApplyType << ") failed with ierr="
00132 << ierr);
00133 }
00134
00135 }