// @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_DENSESOLVER_DEF_HPP #define IFPACK2_DETAILS_DENSESOLVER_DEF_HPP #include "Ifpack2_LocalFilter.hpp" #include "Teuchos_LAPACK.hpp" #include "Ifpack2_Details_DenseSolver.hpp" #include "Tpetra_Map.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 DenseSolver:: DenseSolver (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> DenseSolver::getDomainMap () const { TEUCHOS_TEST_FOR_EXCEPTION( A_.is_null (), std::runtime_error, "Ifpack2::Details::DenseSolver::" "getDomainMap: The input matrix A is null. Please call setMatrix() with a " "nonnull input matrix before calling this method."); // For an input matrix A, DenseSolver solves Ax=b for x. // Thus, its Maps are reversed from those of the input matrix. return A_->getRangeMap (); } template Teuchos::RCP::map_type> DenseSolver::getRangeMap () const { TEUCHOS_TEST_FOR_EXCEPTION( A_.is_null (), std::runtime_error, "Ifpack2::Details::DenseSolver::" "getRangeMap: The input matrix A is null. Please call setMatrix() with a " "nonnull input matrix before calling this method."); // For an input matrix A, DenseSolver solves Ax=b for x. // Thus, its Maps are reversed from those of the input matrix. return A_->getDomainMap (); } template void DenseSolver:: setParameters (const Teuchos::ParameterList& params) { (void) params; // this preconditioner doesn't currently take any parameters } template bool DenseSolver::isInitialized () const { return isInitialized_; } template bool DenseSolver::isComputed () const { return isComputed_; } template int DenseSolver::getNumInitialize () const { return numInitialize_; } template int DenseSolver::getNumCompute () const { return numCompute_; } template int DenseSolver::getNumApply () const { return numApply_; } template double DenseSolver::getInitializeTime () const { return initializeTime_; } template double DenseSolver::getComputeTime () const { return computeTime_; } template double DenseSolver::getApplyTime () const { return applyTime_; } template Teuchos::RCP::row_matrix_type> DenseSolver::getMatrix () const { return A_; } template void DenseSolver:: reset () { isInitialized_ = false; isComputed_ = false; A_local_ = Teuchos::null; A_local_dense_.reshape (0, 0); ipiv_.resize (0); } template void DenseSolver:: 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::DenseSolver::" "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 DenseSolver::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::DenseSolver::initialize"); RCP