PlayaIfpackICCOperator.cpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 //   
00003 /* @HEADER@ */
00004 
00005 #include "PlayaIfpackICCOperator.hpp"
00006 #include "Teuchos_Array.hpp"
00007 #include "PlayaMPIComm.hpp"
00008 #include "PlayaEpetraVector.hpp"
00009 
00010 
00011 #ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION
00012 #include "PlayaVectorImpl.hpp"
00013 #include "PlayaLinearOperatorImpl.hpp"
00014 #endif
00015 
00016 namespace Playa
00017 {
00018 
00019 using namespace Teuchos;
00020 
00021 IfpackICCOperator::IfpackICCOperator(const EpetraMatrix* A,
00022   int fillLevels,
00023   int overlapFill,
00024   double relaxationValue,
00025   double relativeThreshold,
00026   double absoluteThreshold)
00027   : LinearOpWithSpaces<double>(A->domain(), A->range()),
00028     precond_()
00029 {
00030   const Epetra_CrsMatrix* matrix = A->crsMatrix();
00031 
00032   Ifpack_ICT* precond = new Ifpack_ICT(matrix);
00033   precond_ = rcp(precond);
00034 
00035   Teuchos::ParameterList List;
00036   
00037   List.set("fact: ict level-of-fill", fillLevels);
00038   List.set("fact: absolute threshold", absoluteThreshold);
00039   List.set("fact: relative threshold", relativeThreshold);
00040   List.set("fact: relax value", relaxationValue);
00041   List.set("fact: drop tolerance", 1.0E-4);
00042 
00043   //ierr = precond->InitValues(*matrix);
00044 
00045 
00046   int ierr = precond->Compute();
00047 
00048   TEUCHOS_TEST_FOR_EXCEPTION(ierr < 0, std::runtime_error,
00049     "IfpackOperator ctor: "
00050     "precond->Factor() failed with ierr="
00051     << ierr);
00052 }
00053 
00054 void IfpackICCOperator::apply(Teuchos::ETransp transApplyType,
00055   const Vector<double>& in,
00056   Vector<double> out) const
00057 {
00058   /* grab the epetra vector objects underlying the input and output vectors */
00059   const Epetra_Vector& epIn = EpetraVector::getConcrete(in);
00060   Epetra_Vector& epOut = EpetraVector::getConcrete(out);
00061 
00062   /* ifpack's solve is logically const but declared non-const because
00063    *  internal data changes. So, do a const_cast. */
00064   Ifpack_ICT* p = const_cast<Ifpack_ICT*>(precond_.get());
00065 
00066   int ierr;
00067 
00068   /* do the solve (or transpose solve) */
00069   if (transApplyType==NO_TRANS)
00070   {
00071     ierr = p->H().Solve(false,false,false, epIn, epOut);
00072   }
00073   else
00074   {
00075     ierr = p->H().Solve(false,true,false, epIn, epOut);
00076   }
00077 }
00078   
00079   void IfpackICCOperator::print(std::ostream& os) const 
00080 {
00081   precond_->Print(os);
00082 }
00083 
00084 string IfpackICCOperator::description() const 
00085 {
00086   std::string rtn = "ICC Preconditioner";
00087   return rtn;
00088 }
00089 
00090 }

Site Contact