53 #ifndef AMESOS2_LAPACK_DEF_HPP 54 #define AMESOS2_LAPACK_DEF_HPP 56 #include <Teuchos_RCP.hpp> 64 template <
class Matrix,
class Vector>
66 Teuchos::RCP<Vector> X,
67 Teuchos::RCP<const Vector> B)
74 Teuchos::RCP<Teuchos::ParameterList> default_params
80 template <
class Matrix,
class Vector>
89 template<
class Matrix,
class Vector>
97 template <
class Matrix,
class Vector>
105 template <
class Matrix,
class Vector>
113 solver_.setMatrix( Teuchos::rcpFromRef(lu_) );
116 #ifdef HAVE_AMESOS2_TIMERS 117 Teuchos::TimeMonitor numFactTimer( this->timers_.numFactTime_ );
119 factor_ierr = solver_.factor();
123 Teuchos::broadcast(*(this->getComm()), 0, &factor_ierr);
124 TEUCHOS_TEST_FOR_EXCEPTION( factor_ierr != 0,
126 "Lapack factor routine returned error code " 132 template <
class Matrix,
class Vector>
140 const global_size_type ld_rhs = this->root_ ? X->getGlobalLength() : 0;
141 const size_t nrhs = X->getGlobalNumVectors();
143 const size_t val_store_size = as<size_t>(ld_rhs * nrhs);
145 rhsvals_.resize(val_store_size);
149 #ifdef HAVE_AMESOS2_TIMERS 150 Teuchos::TimeMonitor mvConvTimer( this->timers_.vecConvTime_ );
151 Teuchos::TimeMonitor redistTimer( this->timers_.vecRedistTime_ );
154 scalar_type> copy_helper;
155 copy_helper::do_get(B, rhsvals_(), as<size_t>(ld_rhs),
ROOTED);
162 #ifdef HAVE_AMESOS2_TIMERS 163 Teuchos::TimeMonitor solveTimer( this->timers_.solveTime_ );
166 using Teuchos::rcpFromRef;
167 typedef Teuchos::SerialDenseMatrix<int,scalar_type> DenseMat;
169 DenseMat rhs_dense_mat(Teuchos::View, rhsvals_.getRawPtr(),
170 as<int>(ld_rhs), as<int>(ld_rhs), as<int>(nrhs));
172 solver_.setVectors( rcpFromRef(rhs_dense_mat),
173 rcpFromRef(rhs_dense_mat) );
175 solve_ierr = solver_.solve();
181 Teuchos::broadcast(*(this->getComm()), 0, &solve_ierr);
182 TEUCHOS_TEST_FOR_EXCEPTION( solve_ierr != 0,
184 "Lapack solver solve method returned with error code " 189 #ifdef HAVE_AMESOS2_TIMERS 190 Teuchos::TimeMonitor redistTimer( this->timers_.vecRedistTime_ );
203 template <
class Matrix,
class Vector>
210 return( this->globalNumCols_ == this->globalNumRows_ );
214 template <
class Matrix,
class Vector>
218 solver_.solveWithTranspose( parameterList->get<
bool>(
"Transpose",
219 this->control_.useTranspose_) );
221 solver_.factorWithEquilibration( parameterList->get<
bool>(
"Equilibrate",
true) );
226 template <
class Matrix,
class Vector>
227 Teuchos::RCP<const Teuchos::ParameterList>
230 using Teuchos::ParameterList;
232 static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
234 if( is_null(valid_params) ){
235 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
237 pl->set(
"Equilibrate",
true,
"Whether to equilibrate the input matrix");
248 template <
class Matrix,
class Vector>
252 #ifdef HAVE_AMESOS2_TIMERS 253 Teuchos::TimeMonitor convTimer(this->timers_.mtxConvTime_);
257 if( current_phase < NUMFACT )
return(
false );
260 nzvals_.resize(this->globalNumNonZeros_);
261 rowind_.resize(this->globalNumNonZeros_);
262 colptr_.resize(this->globalNumCols_ + 1);
268 #ifdef HAVE_AMESOS2_TIMERS 269 Teuchos::TimeMonitor mtxRedistTimer( this->timers_.mtxRedistTime_ );
275 scalar_type, int,
int> ccs_helper;
276 ccs_helper::do_get(this->matrixA_.ptr(),
277 nzvals_(), rowind_(), colptr_(),
283 lu_.shape(this->globalNumRows_, this->globalNumCols_);
286 global_size_type end_col = this->globalNumCols_;
287 for( global_size_type col = 0; col < end_col; ++col ){
288 global_ordinal_type ptr = colptr_[col];
289 global_ordinal_type end_ptr = colptr_[col+1];
290 for( ; ptr < end_ptr; ++ptr ){
291 lu_(rowind_[ptr], col) = nzvals_[ptr];
302 template<
class Matrix,
class Vector>
308 #endif // AMESOS2_LAPACK_DEF_HPP Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers...
Definition: Amesos2_SolverCore_decl.hpp:105
Amesos2 interface to the LAPACK.
Definition: Amesos2_Lapack_decl.hpp:80
Definition: Amesos2_TypeDecl.hpp:141
EPhase
Used to indicate a phase in the direct solution.
Definition: Amesos2_TypeDecl.hpp:65
int symbolicFactorization_impl()
No-op.
Definition: Amesos2_Lapack_def.hpp:99
Helper class for getting 1-D copies of multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:243
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Lapack_def.hpp:205
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > ¶meterList)
Definition: Amesos2_Lapack_def.hpp:216
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Return a const parameter list of all of the valid parameters that this->setParameterList(...) will accept.
Definition: Amesos2_SolverCore_def.hpp:310
Definition: Amesos2_AbstractConcreteMatrixAdapter.hpp:48
A generic helper class for getting a CCS representation of a Matrix.
Definition: Amesos2_Util.hpp:580
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
Lapack solve.
Definition: Amesos2_Lapack_def.hpp:134
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Lapack_def.hpp:228
Lapack(Teuchos::RCP< const Matrix > A, Teuchos::RCP< Vector > X, Teuchos::RCP< const Vector > B)
Initialize from Teuchos::RCP.
Definition: Amesos2_Lapack_def.hpp:65
int preOrdering_impl()
No-op.
Definition: Amesos2_Lapack_def.hpp:91
super_type & setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶meterList)
Set/update internal variables and solver options.
Definition: Amesos2_SolverCore_def.hpp:278
Declarations for the Amesos2 interface to LAPACK.
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_Lapack_def.hpp:250
Definition: Amesos2_TypeDecl.hpp:127
~Lapack()
Destructor.
Definition: Amesos2_Lapack_def.hpp:81
Helper class for putting 1-D data arrays into multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:296
A templated MultiVector class adapter for Amesos2.
Definition: Amesos2_MultiVecAdapter_decl.hpp:175
int numericFactorization_impl()
Perform numeric factorization using LAPACK.
Definition: Amesos2_Lapack_def.hpp:107