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)
69 , is_contiguous_(true)
72 Teuchos::RCP<Teuchos::ParameterList> default_params
78 template <
class Matrix,
class Vector>
87 template<
class Matrix,
class Vector>
95 template <
class Matrix,
class Vector>
103 template <
class Matrix,
class Vector>
111 solver_.setMatrix( Teuchos::rcpFromRef(lu_) );
114 #ifdef HAVE_AMESOS2_TIMERS
115 Teuchos::TimeMonitor numFactTimer( this->timers_.numFactTime_ );
117 factor_ierr = solver_.factor();
121 Teuchos::broadcast(*(this->getComm()), 0, &factor_ierr);
122 TEUCHOS_TEST_FOR_EXCEPTION( factor_ierr != 0,
124 "Lapack factor routine returned error code "
130 template <
class Matrix,
class Vector>
138 const global_size_type ld_rhs = this->root_ ? X->getGlobalLength() : 0;
139 const size_t nrhs = X->getGlobalNumVectors();
141 const size_t val_store_size = as<size_t>(ld_rhs * nrhs);
143 rhsvals_.resize(val_store_size);
147 #ifdef HAVE_AMESOS2_TIMERS
148 Teuchos::TimeMonitor mvConvTimer( this->timers_.vecConvTime_ );
149 Teuchos::TimeMonitor redistTimer( this->timers_.vecRedistTime_ );
152 scalar_type> copy_helper;
153 copy_helper::do_get(B, rhsvals_(),
155 (is_contiguous_ ==
true) ? ROOTED : CONTIGUOUS_AND_ROOTED,
163 #ifdef HAVE_AMESOS2_TIMERS
164 Teuchos::TimeMonitor solveTimer( this->timers_.solveTime_ );
167 using Teuchos::rcpFromRef;
168 typedef Teuchos::SerialDenseMatrix<int,scalar_type> DenseMat;
170 DenseMat rhs_dense_mat(Teuchos::View, rhsvals_.getRawPtr(),
171 as<int>(ld_rhs), as<int>(ld_rhs), as<int>(nrhs));
173 solver_.setVectors( rcpFromRef(rhs_dense_mat),
174 rcpFromRef(rhs_dense_mat) );
176 solve_ierr = solver_.solve();
182 Teuchos::broadcast(*(this->getComm()), 0, &solve_ierr);
183 TEUCHOS_TEST_FOR_EXCEPTION( solve_ierr != 0,
185 "Lapack solver solve method returned with error code "
190 #ifdef HAVE_AMESOS2_TIMERS
191 Teuchos::TimeMonitor redistTimer( this->timers_.vecRedistTime_ );
197 (is_contiguous_ ==
true) ? ROOTED : CONTIGUOUS_AND_ROOTED);
204 template <
class Matrix,
class Vector>
211 return( this->globalNumCols_ == this->globalNumRows_ );
215 template <
class Matrix,
class Vector>
219 solver_.solveWithTranspose( parameterList->get<
bool>(
"Transpose",
220 this->control_.useTranspose_) );
222 solver_.factorWithEquilibration( parameterList->get<
bool>(
"Equilibrate",
true) );
224 if( parameterList->isParameter(
"IsContiguous") ){
225 is_contiguous_ = parameterList->get<
bool>(
"IsContiguous");
231 template <
class Matrix,
class Vector>
232 Teuchos::RCP<const Teuchos::ParameterList>
235 using Teuchos::ParameterList;
237 static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
239 if( is_null(valid_params) ){
240 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
242 pl->set(
"Equilibrate",
true,
"Whether to equilibrate the input matrix");
244 pl->set(
"IsContiguous",
true,
"Whether GIDs contiguous");
255 template <
class Matrix,
class Vector>
259 #ifdef HAVE_AMESOS2_TIMERS
260 Teuchos::TimeMonitor convTimer(this->timers_.mtxConvTime_);
264 if( current_phase < NUMFACT )
return(
false );
267 Kokkos::resize(nzvals_view_,this->globalNumNonZeros_);
268 Kokkos::resize(rowind_view_,this->globalNumNonZeros_);
269 Kokkos::resize(colptr_view_,this->globalNumCols_ + 1);
275 #ifdef HAVE_AMESOS2_TIMERS
276 Teuchos::TimeMonitor mtxRedistTimer( this->timers_.mtxRedistTime_ );
282 host_value_type_array, host_ordinal_type_array, host_ordinal_type_array> ccs_helper;
284 ccs_helper::do_get(this->matrixA_.ptr(),
285 nzvals_view_, rowind_view_, colptr_view_, nnz_ret,
286 (is_contiguous_ ==
true) ? ROOTED : CONTIGUOUS_AND_ROOTED,
288 this->rowIndexBase_);
293 lu_.shape(this->globalNumRows_, this->globalNumCols_);
296 global_size_type end_col = this->globalNumCols_;
297 for( global_size_type col = 0; col < end_col; ++col ){
298 global_ordinal_type ptr = colptr_view_[col];
299 global_ordinal_type end_ptr = colptr_view_[col+1];
300 for( ; ptr < end_ptr; ++ptr ){
301 lu_(rowind_view_[ptr], col) = nzvals_view_[ptr];
312 template<
class Matrix,
class Vector>
318 #endif // AMESOS2_LAPACK_DEF_HPP
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const override
Return a const parameter list of all of the valid parameters that this->setParameterList(...) will accept.
Definition: Amesos2_SolverCore_def.hpp:558
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
A generic helper class for getting a CCS representation of a Matrix.
Definition: Amesos2_Util.hpp:648
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:97
super_type & setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶meterList) override
Set/update internal variables and solver options.
Definition: Amesos2_SolverCore_def.hpp:526
Helper class for getting 1-D copies of multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:267
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > ¶meterList)
Definition: Amesos2_Lapack_def.hpp:217
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Lapack_def.hpp:206
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:89
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Lapack_def.hpp:233
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
Lapack solve.
Definition: Amesos2_Lapack_def.hpp:132
Declarations for the Amesos2 interface to LAPACK.
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_Lapack_def.hpp:257
~Lapack()
Destructor.
Definition: Amesos2_Lapack_def.hpp:79
Helper class for putting 1-D data arrays into multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:373
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:105