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)
72 , is_contiguous_(true)
75 Teuchos::RCP<Teuchos::ParameterList> default_params
81 template <
class Matrix,
class Vector>
90 template<
class Matrix,
class Vector>
98 template <
class Matrix,
class Vector>
106 template <
class Matrix,
class Vector>
114 solver_.setMatrix( Teuchos::rcpFromRef(lu_) );
117 #ifdef HAVE_AMESOS2_TIMERS
118 Teuchos::TimeMonitor numFactTimer( this->timers_.numFactTime_ );
120 factor_ierr = solver_.factor();
124 Teuchos::broadcast(*(this->getComm()), 0, &factor_ierr);
125 TEUCHOS_TEST_FOR_EXCEPTION( factor_ierr != 0,
127 "Lapack factor routine returned error code "
133 template <
class Matrix,
class Vector>
141 const global_size_type ld_rhs = this->root_ ? X->getGlobalLength() : 0;
142 const size_t nrhs = X->getGlobalNumVectors();
144 const size_t val_store_size = as<size_t>(ld_rhs * nrhs);
146 rhsvals_.resize(val_store_size);
150 #ifdef HAVE_AMESOS2_TIMERS
151 Teuchos::TimeMonitor mvConvTimer( this->timers_.vecConvTime_ );
152 Teuchos::TimeMonitor redistTimer( this->timers_.vecRedistTime_ );
155 scalar_type> copy_helper;
156 if ( is_contiguous_ ==
true ) {
157 copy_helper::do_get(B, rhsvals_(), as<size_t>(ld_rhs), ROOTED, 0);
160 copy_helper::do_get(B, rhsvals_(), as<size_t>(ld_rhs), CONTIGUOUS_AND_ROOTED, 0);
168 #ifdef HAVE_AMESOS2_TIMERS
169 Teuchos::TimeMonitor solveTimer( this->timers_.solveTime_ );
172 using Teuchos::rcpFromRef;
173 typedef Teuchos::SerialDenseMatrix<int,scalar_type> DenseMat;
175 DenseMat rhs_dense_mat(Teuchos::View, rhsvals_.getRawPtr(),
176 as<int>(ld_rhs), as<int>(ld_rhs), as<int>(nrhs));
178 solver_.setVectors( rcpFromRef(rhs_dense_mat),
179 rcpFromRef(rhs_dense_mat) );
181 solve_ierr = solver_.solve();
187 Teuchos::broadcast(*(this->getComm()), 0, &solve_ierr);
188 TEUCHOS_TEST_FOR_EXCEPTION( solve_ierr != 0,
190 "Lapack solver solve method returned with error code "
195 #ifdef HAVE_AMESOS2_TIMERS
196 Teuchos::TimeMonitor redistTimer( this->timers_.vecRedistTime_ );
199 if ( is_contiguous_ ==
true ) {
209 CONTIGUOUS_AND_ROOTED);
217 template <
class Matrix,
class Vector>
224 return( this->globalNumCols_ == this->globalNumRows_ );
228 template <
class Matrix,
class Vector>
232 solver_.solveWithTranspose( parameterList->get<
bool>(
"Transpose",
233 this->control_.useTranspose_) );
235 solver_.factorWithEquilibration( parameterList->get<
bool>(
"Equilibrate",
true) );
237 if( parameterList->isParameter(
"IsContiguous") ){
238 is_contiguous_ = parameterList->get<
bool>(
"IsContiguous");
244 template <
class Matrix,
class Vector>
245 Teuchos::RCP<const Teuchos::ParameterList>
248 using Teuchos::ParameterList;
250 static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
252 if( is_null(valid_params) ){
253 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
255 pl->set(
"Equilibrate",
true,
"Whether to equilibrate the input matrix");
257 pl->set(
"IsContiguous",
true,
"Whether GIDs contiguous");
268 template <
class Matrix,
class Vector>
272 #ifdef HAVE_AMESOS2_TIMERS
273 Teuchos::TimeMonitor convTimer(this->timers_.mtxConvTime_);
277 if( current_phase < NUMFACT )
return(
false );
280 nzvals_.resize(this->globalNumNonZeros_);
281 rowind_.resize(this->globalNumNonZeros_);
282 colptr_.resize(this->globalNumCols_ + 1);
288 #ifdef HAVE_AMESOS2_TIMERS
289 Teuchos::TimeMonitor mtxRedistTimer( this->timers_.mtxRedistTime_ );
295 scalar_type, int,
int> ccs_helper;
296 if ( is_contiguous_ ==
true ) {
297 ccs_helper::do_get(this->matrixA_.ptr(),
298 nzvals_(), rowind_(), colptr_(),
299 nnz_ret, ROOTED, SORTED_INDICES, 0);
302 ccs_helper::do_get(this->matrixA_.ptr(),
303 nzvals_(), rowind_(), colptr_(),
304 nnz_ret, CONTIGUOUS_AND_ROOTED, SORTED_INDICES, 0);
310 lu_.shape(this->globalNumRows_, this->globalNumCols_);
313 global_size_type end_col = this->globalNumCols_;
314 for( global_size_type col = 0; col < end_col; ++col ){
315 global_ordinal_type ptr = colptr_[col];
316 global_ordinal_type end_ptr = colptr_[col+1];
317 for( ; ptr < end_ptr; ++ptr ){
318 lu_(rowind_[ptr], col) = nzvals_[ptr];
329 template<
class Matrix,
class Vector>
335 #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
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:100
Helper class for getting 1-D copies of multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:266
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > ¶meterList)
Definition: Amesos2_Lapack_def.hpp:230
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:314
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Lapack_def.hpp:219
A generic helper class for getting a CCS representation of a Matrix.
Definition: Amesos2_Util.hpp:765
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:92
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Lapack_def.hpp:246
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
Lapack solve.
Definition: Amesos2_Lapack_def.hpp:135
super_type & setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶meterList)
Set/update internal variables and solver options.
Definition: Amesos2_SolverCore_def.hpp:282
Declarations for the Amesos2 interface to LAPACK.
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_Lapack_def.hpp:270
~Lapack()
Destructor.
Definition: Amesos2_Lapack_def.hpp:82
Helper class for putting 1-D data arrays into multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:344
A templated MultiVector class adapter for Amesos2.
Definition: Amesos2_MultiVecAdapter_decl.hpp:176
int numericFactorization_impl()
Perform numeric factorization using LAPACK.
Definition: Amesos2_Lapack_def.hpp:108