// @HEADER // ***************************************************************************** // Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package // // Copyright 2009 NTESS and the Ifpack2 contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef IFPACK2_DETAILS_TRIDISOLVER_DEF_HPP #define IFPACK2_DETAILS_TRIDISOLVER_DEF_HPP #include "Ifpack2_LocalFilter.hpp" #include "Teuchos_LAPACK.hpp" #include "Tpetra_MultiVector.hpp" #include "Tpetra_Map.hpp" #include "Tpetra_Import.hpp" #include "Tpetra_Export.hpp" #ifdef HAVE_MPI # include # include "Teuchos_DefaultMpiComm.hpp" #else # include "Teuchos_DefaultSerialComm.hpp" #endif // HAVE_MPI namespace Ifpack2 { namespace Details { ////////////////////////////////////////////////////////////////////// // Non-stub (full) implementation ////////////////////////////////////////////////////////////////////// template TriDiSolver:: TriDiSolver (const Teuchos::RCP& A) : A_ (A), initializeTime_ (0.0), computeTime_ (0.0), applyTime_ (0.0), numInitialize_ (0), numCompute_ (0), numApply_ (0), isInitialized_ (false), isComputed_ (false) {} template Teuchos::RCP::map_type> TriDiSolver::getDomainMap () const { TEUCHOS_TEST_FOR_EXCEPTION( A_.is_null (), std::runtime_error, "Ifpack2::Details::TriDiSolver::" "getDomainMap: The input matrix A is null. Please call setMatrix() with a " "nonnull input matrix before calling this method."); // For an input matrix A, TriDiSolver solves Ax=b for x. // Thus, its Maps are reversed from those of the input matrix. return A_->getRangeMap (); } template Teuchos::RCP::map_type> TriDiSolver::getRangeMap () const { TEUCHOS_TEST_FOR_EXCEPTION( A_.is_null (), std::runtime_error, "Ifpack2::Details::TriDiSolver::" "getRangeMap: The input matrix A is null. Please call setMatrix() with a " "nonnull input matrix before calling this method."); // For an input matrix A, TriDiSolver solves Ax=b for x. // Thus, its Maps are reversed from those of the input matrix. return A_->getDomainMap (); } template void TriDiSolver:: setParameters (const Teuchos::ParameterList& params) { (void) params; // this preconditioner doesn't currently take any parameters } template bool TriDiSolver::isInitialized () const { return isInitialized_; } template bool TriDiSolver::isComputed () const { return isComputed_; } template int TriDiSolver::getNumInitialize () const { return numInitialize_; } template int TriDiSolver::getNumCompute () const { return numCompute_; } template int TriDiSolver::getNumApply () const { return numApply_; } template double TriDiSolver::getInitializeTime () const { return initializeTime_; } template double TriDiSolver::getComputeTime () const { return computeTime_; } template double TriDiSolver::getApplyTime () const { return applyTime_; } template Teuchos::RCP::row_matrix_type> TriDiSolver::getMatrix () const { return A_; } template void TriDiSolver:: reset () { isInitialized_ = false; isComputed_ = false; A_local_ = Teuchos::null; A_local_tridi_.reshape (0); ipiv_.resize (0); } template void TriDiSolver:: setMatrix (const Teuchos::RCP& A) { // It's legitimate to call setMatrix() with a null input. This has // the effect of resetting the preconditioner's internal state. if (! A_.is_null ()) { const global_size_t numRows = A->getRangeMap ()->getGlobalNumElements (); const global_size_t numCols = A->getDomainMap ()->getGlobalNumElements (); TEUCHOS_TEST_FOR_EXCEPTION( numRows != numCols, std::invalid_argument, "Ifpack2::Details::TriDiSolver::" "setMatrix: Input matrix must be (globally) square. " "The matrix you provided is " << numRows << " by " << numCols << "."); } // Clear any previously computed objects. reset (); // Now that we've cleared the state, we can keep the matrix. A_ = A; } template void TriDiSolver::initialize () { using Teuchos::Comm; using Teuchos::null; using Teuchos::RCP; using Teuchos::rcp; using Teuchos::Time; using Teuchos::TimeMonitor; const std::string timerName ("Ifpack2::Details::TriDiSolver::initialize"); RCP