43 #ifndef IFPACK2_IDENTITY_SOLVER_DEF_HPP 
   44 #define IFPACK2_IDENTITY_SOLVER_DEF_HPP 
   46 #include "Ifpack2_IdentitySolver_decl.hpp" 
   47 #include "Tpetra_Map.hpp" 
   48 #include "Tpetra_MultiVector.hpp" 
   49 #include "Tpetra_Export.hpp" 
   53 template<
class MatrixType>
 
   57     isInitialized_ (false),
 
   68 template<
class MatrixType>
 
   73 template<
class MatrixType>
 
   78 template<
class MatrixType>
 
   82     matrix_.is_null (), std::runtime_error, 
"Ifpack2::IdentitySolver: " 
   83     "You must call setMatrix() with a nonnull input matrix " 
   84     "before you may call initialize() or compute().");
 
   87     ! matrix_->getDomainMap ()->isCompatible (* (matrix_->getRangeMap ())),
 
   88     std::invalid_argument,
 
   89     "Ifpack2::IdentitySolver: The domain and range Maps " 
   90     "of the input matrix must be compatible.");
 
   95   if (! matrix_->getDomainMap ()->isSameAs (* (matrix_->getRangeMap ()))) {
 
   96     export_ = 
Teuchos::rcp (
new export_type (matrix_->getDomainMap (),
 
   97                                              matrix_->getRangeMap ()));
 
  102     export_ = Teuchos::null;
 
  105   isInitialized_ = 
true;
 
  109 template<
class MatrixType>
 
  113     matrix_.is_null (), std::runtime_error, 
"Ifpack2::IdentitySolver: " 
  114     "You must call setMatrix() with a nonnull input matrix " 
  115     "before you may call initialize() or compute().");
 
  117   if (! isInitialized_) {
 
  125 template<
class MatrixType>
 
  127 apply (
const Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& X,
 
  128        Tpetra::MultiVector<scalar_type,local_ordinal_type,global_ordinal_type,node_type>& Y,
 
  139     ! isComputed (), std::runtime_error,
 
  140     "Ifpack2::IdentitySolver::apply: If compute() has not yet been called, " 
  141     "or if you have changed the matrix via setMatrix(), " 
  142     "you must call compute() before you may call this method.");
 
  147   if (export_.is_null ()) {
 
  148     Y.update (alpha, X, beta);
 
  151     if (alpha == STS::one () && beta == STS::zero ()) { 
 
  152       Y.doExport (X, *export_, Tpetra::REPLACE);
 
  158       MV X_tmp (Y.getMap (), Y.getNumVectors ());
 
  159       X_tmp.doExport (X, *export_, Tpetra::REPLACE);
 
  160       Y.update (alpha, X_tmp, beta);
 
  166 template <
class MatrixType>
 
  168   return(numInitialize_);
 
  171 template <
class MatrixType>
 
  176 template <
class MatrixType>
 
  181 template <
class MatrixType>
 
  183   return(initializeTime_);
 
  186 template<
class MatrixType>
 
  188   return(computeTime_);
 
  191 template<
class MatrixType>
 
  196 template <
class MatrixType>
 
  199   std::ostringstream os;
 
  204   os << 
"\"Ifpack2::IdentitySolver\": {";
 
  205   if (this->getObjectLabel () != 
"") {
 
  206     os << 
"Label: \"" << this->getObjectLabel () << 
"\", ";
 
  208   os << 
"Initialized: " << (isInitialized () ? 
"true" : 
"false") << 
", " 
  209      << 
"Computed: " << (isComputed () ? 
"true" : 
"false") << 
", ";
 
  211   if (matrix_.is_null ()) {
 
  212     os << 
"Matrix: null";
 
  215     os << 
"Matrix: not null" 
  216        << 
", Global matrix dimensions: [" 
  217        << matrix_->getGlobalNumRows () << 
", " 
  218        << matrix_->getGlobalNumCols () << 
"]";
 
  225 template <
class MatrixType>
 
  237     out << 
"\"Ifpack2::IdentitySolver\":" << endl;
 
  240     out << 
"numInitialize: " << numInitialize_ << endl;
 
  241     out << 
"numCompute: " << numCompute_ << endl;
 
  242     out << 
"numApply: " << numApply_ << endl;
 
  246 template <
class MatrixType>
 
  250     matrix_.is_null (), std::runtime_error, 
"Ifpack2::IdentitySolver::getDomainMap: " 
  251     "The matrix is null.  Please call setMatrix() with a nonnull input " 
  252     "before calling this method.");
 
  253   return matrix_->getDomainMap ();
 
  256 template <
class MatrixType>
 
  260     matrix_.is_null (), std::runtime_error, 
"Ifpack2::IdentitySolver::getRangeMap: " 
  261     "The matrix is null.  Please call setMatrix() with a nonnull input " 
  262     "before calling this method.");
 
  263   return matrix_->getRangeMap ();
 
  266 template<
class MatrixType>
 
  272     ! A.
is_null () && A->getComm ()->getSize () == 1 &&
 
  273     A->getNodeNumRows () != A->getNodeNumCols (),
 
  274     std::runtime_error, 
"Ifpack2::IdentitySolver::setMatrix: If A's communicator only " 
  275     "contains one process, then A must be square.  Instead, you provided a " 
  276     "matrix A with " << A->getNodeNumRows () << 
" rows and " 
  277     << A->getNodeNumCols () << 
" columns.");
 
  282   isInitialized_ = 
false;
 
  284   export_ = Teuchos::null;
 
  291 #define IFPACK2_IDENTITYSOLVER_INSTANT(S,LO,GO,N)                            \ 
  292   template class Ifpack2::IdentitySolver< Tpetra::RowMatrix<S, LO, GO, N> >; 
  294 #endif // IFPACK2_IDENTITY_SOLVER_DEF_HPP 
int getNumApply() const 
Return the number of calls to apply(). 
Definition: Ifpack2_IdentitySolver_def.hpp:177
 
MatrixType::node_type node_type
Node type of the input matrix. 
Definition: Ifpack2_IdentitySolver_decl.hpp:78
 
double getComputeTime() const 
Return the time spent in compute(). 
Definition: Ifpack2_IdentitySolver_def.hpp:187
 
int getNumCompute() const 
Return the number of calls to compute(). 
Definition: Ifpack2_IdentitySolver_def.hpp:172
 
virtual ~IdentitySolver()
Destructor. 
Definition: Ifpack2_IdentitySolver_def.hpp:69
 
void apply(const Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &X, Tpetra::MultiVector< scalar_type, local_ordinal_type, global_ordinal_type, node_type > &Y, Teuchos::ETransp mode=Teuchos::NO_TRANS, scalar_type alpha=Teuchos::ScalarTraits< scalar_type >::one(), scalar_type beta=Teuchos::ScalarTraits< scalar_type >::zero()) const 
Apply the preconditioner to X, and put the result in Y. 
Definition: Ifpack2_IdentitySolver_def.hpp:127
 
Teuchos::RCP< const map_type > getRangeMap() const 
Return the Tpetra::Map object associated with the range of this operator. 
Definition: Ifpack2_IdentitySolver_def.hpp:257
 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
 
void setParameters(const Teuchos::ParameterList ¶ms)
Set this object's parameters. 
Definition: Ifpack2_IdentitySolver_def.hpp:74
 
void initialize()
Initialize. 
Definition: Ifpack2_IdentitySolver_def.hpp:79
 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
 
Teuchos::RCP< const map_type > getDomainMap() const 
Return the Tpetra::Map object associated with the domain of this operator. 
Definition: Ifpack2_IdentitySolver_def.hpp:247
 
IdentitySolver(const Teuchos::RCP< const row_matrix_type > &A)
Constructor: Takes the matrix to precondition. 
Definition: Ifpack2_IdentitySolver_def.hpp:55
 
MatrixType::local_ordinal_type local_ordinal_type
Type of the local indices of the input matrix. 
Definition: Ifpack2_IdentitySolver_decl.hpp:74
 
virtual void setMatrix(const Teuchos::RCP< const row_matrix_type > &A)
Set this preconditioner's matrix. 
Definition: Ifpack2_IdentitySolver_def.hpp:268
 
std::string description() const 
Return a simple one-line description of this object. 
Definition: Ifpack2_IdentitySolver_def.hpp:197
 
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const 
Print the object with some verbosity level to an FancyOStream object. 
Definition: Ifpack2_IdentitySolver_def.hpp:227
 
void compute()
Compute the preconditioner. 
Definition: Ifpack2_IdentitySolver_def.hpp:110
 
int getNumInitialize() const 
Return the number of calls to initialize(). 
Definition: Ifpack2_IdentitySolver_def.hpp:167
 
MatrixType::global_ordinal_type global_ordinal_type
Type of the global indices of the input matrix. 
Definition: Ifpack2_IdentitySolver_decl.hpp:76
 
double getInitializeTime() const 
Return the time spent in initialize(). 
Definition: Ifpack2_IdentitySolver_def.hpp:182
 
MatrixType::scalar_type scalar_type
Type of the entries of the input matrix. 
Definition: Ifpack2_IdentitySolver_decl.hpp:72
 
double getApplyTime() const 
Return the time spent in apply(). 
Definition: Ifpack2_IdentitySolver_def.hpp:192
 
static std::string name()