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);
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 if ( is_contiguous_ ==
true ) {
154 copy_helper::do_get(B,
rhsvals_(), as<size_t>(ld_rhs),
ROOTED, 0);
165#ifdef HAVE_AMESOS2_TIMERS
166 Teuchos::TimeMonitor solveTimer( this->
timers_.solveTime_ );
169 using Teuchos::rcpFromRef;
170 typedef Teuchos::SerialDenseMatrix<int,scalar_type> DenseMat;
172 DenseMat rhs_dense_mat(Teuchos::View,
rhsvals_.getRawPtr(),
173 as<int>(ld_rhs), as<int>(ld_rhs), as<int>(nrhs));
175 solver_.setVectors( rcpFromRef(rhs_dense_mat),
176 rcpFromRef(rhs_dense_mat) );
184 Teuchos::broadcast(*(this->
getComm()), 0, &solve_ierr);
185 TEUCHOS_TEST_FOR_EXCEPTION( solve_ierr != 0,
187 "Lapack solver solve method returned with error code "
192#ifdef HAVE_AMESOS2_TIMERS
193 Teuchos::TimeMonitor redistTimer( this->
timers_.vecRedistTime_ );
196 if ( is_contiguous_ ==
true ) {
214 template <
class Matrix,
class Vector>
225 template <
class Matrix,
class Vector>
229 solver_.solveWithTranspose( parameterList->get<
bool>(
"Transpose",
230 this->control_.useTranspose_) );
232 solver_.factorWithEquilibration( parameterList->get<
bool>(
"Equilibrate",
true) );
234 if( parameterList->isParameter(
"IsContiguous") ){
235 is_contiguous_ = parameterList->get<
bool>(
"IsContiguous");
241 template <
class Matrix,
class Vector>
242 Teuchos::RCP<const Teuchos::ParameterList>
245 using Teuchos::ParameterList;
247 static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
249 if( is_null(valid_params) ){
250 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
252 pl->set(
"Equilibrate",
true,
"Whether to equilibrate the input matrix");
254 pl->set(
"IsContiguous",
true,
"Whether GIDs contiguous");
265 template <
class Matrix,
class Vector>
269#ifdef HAVE_AMESOS2_TIMERS
270 Teuchos::TimeMonitor convTimer(this->
timers_.mtxConvTime_);
274 if( current_phase < NUMFACT )
return(
false );
285#ifdef HAVE_AMESOS2_TIMERS
286 Teuchos::TimeMonitor mtxRedistTimer( this->
timers_.mtxRedistTime_ );
292 host_value_type_array, host_ordinal_type_array, host_ordinal_type_array> ccs_helper;
293 if ( is_contiguous_ ==
true ) {
294 ccs_helper::do_get(this->
matrixA_.ptr(),
299 ccs_helper::do_get(this->
matrixA_.ptr(),
311 for( global_size_type col = 0; col < end_col; ++col ){
314 for( ; ptr < end_ptr; ++ptr ){
326 template<
class Matrix,
class Vector>
Declarations for the Amesos2 interface to LAPACK.
@ ROOTED
Definition Amesos2_TypeDecl.hpp:127
@ CONTIGUOUS_AND_ROOTED
Definition Amesos2_TypeDecl.hpp:128
@ ARBITRARY
Definition Amesos2_TypeDecl.hpp:143
Teuchos::SerialDenseMatrix< int, scalar_type > lu_
L and U storage.
Definition Amesos2_Lapack_decl.hpp:225
~Lapack()
Destructor.
Definition Amesos2_Lapack_def.hpp:79
static const char * name
The name of this solver interface.
Definition Amesos2_Lapack_decl.hpp:88
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > ¶meterList)
Definition Amesos2_Lapack_def.hpp:227
host_size_type_array colptr_view_
Stores the row indices of the nonzero entries.
Definition Amesos2_Lapack_decl.hpp:221
Teuchos::SerialDenseSolver< int, scalar_type > solver_
The serial solver.
Definition Amesos2_Lapack_decl.hpp:229
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition Amesos2_Lapack_def.hpp:216
int numericFactorization_impl()
Perform numeric factorization using LAPACK.
Definition Amesos2_Lapack_def.hpp:105
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition Amesos2_Lapack_def.hpp:243
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition Amesos2_Lapack_def.hpp:267
host_value_type_array nzvals_view_
Stores the values of the nonzero entries for Umfpack.
Definition Amesos2_Lapack_decl.hpp:217
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
int preOrdering_impl()
No-op.
Definition Amesos2_Lapack_def.hpp:89
host_ordinal_type_array rowind_view_
Stores the location in Ai_ and Aval_ that starts row j.
Definition Amesos2_Lapack_decl.hpp:219
int symbolicFactorization_impl()
No-op.
Definition Amesos2_Lapack_def.hpp:97
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
Teuchos::Array< scalar_type > rhsvals_
Store for RHS and Solution values.
Definition Amesos2_Lapack_decl.hpp:213
Teuchos::RCP< const MatrixAdapter< Matrix > > matrixA_
Definition Amesos2_SolverCore_decl.hpp:455
bool root_
Definition Amesos2_SolverCore_decl.hpp:506
SolverCore(Teuchos::RCP< const Matrix > A, Teuchos::RCP< Vector > X, Teuchos::RCP< const Vector > B)
super_type & setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶meterList)
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
global_size_type globalNumCols_
Definition Amesos2_SolverCore_decl.hpp:479
Timers timers_
Definition Amesos2_SolverCore_decl.hpp:497
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Definition Amesos2_SolverCore_decl.hpp:363
global_size_type globalNumNonZeros_
Definition Amesos2_SolverCore_decl.hpp:482
global_size_type globalNumRows_
Definition Amesos2_SolverCore_decl.hpp:476
EPhase
Used to indicate a phase in the direct solution.
Definition Amesos2_TypeDecl.hpp:65
A templated MultiVector class adapter for Amesos2.
Definition Amesos2_MultiVecAdapter_decl.hpp:176
Helper class for getting 1-D copies of multivectors.
Definition Amesos2_MultiVecAdapter_decl.hpp:267
A generic helper class for getting a CCS representation of a Matrix.
Definition Amesos2_Util.hpp:652
Helper class for putting 1-D data arrays into multivectors.
Definition Amesos2_MultiVecAdapter_decl.hpp:373