PlayaMLOperator.cpp
00001
00002
00003
00004
00005 #include "PlayaMLOperator.hpp"
00006 #include "Teuchos_Array.hpp"
00007 #include "PlayaMPIComm.hpp"
00008 #include "PlayaEpetraVector.hpp"
00009
00010
00011
00012 #ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION
00013 #include "PlayaVectorImpl.hpp"
00014 #include "PlayaLinearOperatorImpl.hpp"
00015 #endif
00016
00017 using namespace Playa;
00018 using namespace Teuchos;
00019
00020 MLOperator::MLOperator(
00021 const LinearOperator<double>& op,
00022 const ParameterList& mlParams)
00023 : LinearOpWithSpaces<double>(op.domain(), op.range()),
00024 mlPrec_()
00025 {
00026 Epetra_CrsMatrix& A = EpetraMatrix::getConcrete(op);
00027
00028
00029 mlPrec_ = rcp(new ML_Epetra::MultiLevelPreconditioner(A, mlParams));
00030 }
00031
00032
00033 void MLOperator::apply(
00034 Teuchos::ETransp applyType,
00035 const Vector<double>& in,
00036 Vector<double> out) const
00037 {
00038
00039 const Epetra_Vector& epIn = EpetraVector::getConcrete(in);
00040 Epetra_Vector& epOut = EpetraVector::getConcrete(out);
00041
00042
00043 int ierr;
00044
00045
00046 if (applyType==NO_TRANS)
00047 {
00048 ierr = mlPrec_->ApplyInverse(epIn, epOut);
00049 }
00050 else
00051 {
00052 TEUCHOS_TEST_FOR_EXCEPTION(applyType != NO_TRANS, std::runtime_error,
00053 "ML preconditioner does not support transposes");
00054 }
00055 }
00056