52 #ifndef AMESOS2_KLU2_DEF_HPP 53 #define AMESOS2_KLU2_DEF_HPP 55 #include <Teuchos_Tuple.hpp> 56 #include <Teuchos_ParameterList.hpp> 57 #include <Teuchos_StandardParameterEntryValidators.hpp> 65 template <
class Matrix,
class Vector>
67 Teuchos::RCP<const Matrix> A,
68 Teuchos::RCP<Vector> X,
69 Teuchos::RCP<const Vector> B )
75 ::KLU2::klu_defaults<slu_type, local_ordinal_type> (&(data_.common_)) ;
76 data_.symbolic_ = NULL;
77 data_.numeric_ = NULL;
84 template <
class Matrix,
class Vector>
92 if (data_.symbolic_ != NULL)
93 ::KLU2::klu_free_symbolic<slu_type, local_ordinal_type>
94 (&(data_.symbolic_), &(data_.common_)) ;
95 if (data_.numeric_ != NULL)
96 ::KLU2::klu_free_numeric<slu_type, local_ordinal_type>
97 (&(data_.numeric_), &(data_.common_)) ;
110 template<
class Matrix,
class Vector>
116 #ifdef HAVE_AMESOS2_TIMERS 117 Teuchos::TimeMonitor preOrderTimer(this->
timers_.preOrderTime_);
124 template <
class Matrix,
class Vector>
128 data_.symbolic_ = ::KLU2::klu_analyze<slu_type, local_ordinal_type>
130 rowind_.getRawPtr(), &(data_.common_)) ;
136 template <
class Matrix,
class Vector>
151 #ifdef HAVE_AMESOS2_TIMERS 152 Teuchos::TimeMonitor numFactTimer(this->
timers_.numFactTime_);
155 #ifdef HAVE_AMESOS2_VERBOSE_DEBUG 156 std::cout <<
"KLU2:: Before numeric factorization" << std::endl;
157 std::cout <<
"nzvals_ : " <<
nzvals_.toString() << std::endl;
158 std::cout <<
"rowind_ : " <<
rowind_.toString() << std::endl;
159 std::cout <<
"colptr_ : " <<
colptr_.toString() << std::endl;
162 data_.numeric_ = ::KLU2::klu_factor<slu_type, local_ordinal_type>
164 data_.symbolic_, &(data_.common_)) ;
171 Teuchos::broadcast(*(this->
matrixA_->getComm()), 0, &info);
189 template <
class Matrix,
class Vector>
197 const global_size_type ld_rhs = this->
root_ ? X->getGlobalLength() : 0;
198 const size_t nrhs = X->getGlobalNumVectors();
200 const size_t val_store_size = as<size_t>(ld_rhs * nrhs);
201 Teuchos::Array<slu_type> bValues(val_store_size);
204 #ifdef HAVE_AMESOS2_TIMERS 205 Teuchos::TimeMonitor mvConvTimer(this->
timers_.vecConvTime_);
206 Teuchos::TimeMonitor redistTimer( this->
timers_.vecRedistTime_ );
209 slu_type>::do_get(B, bValues(),
222 #ifdef HAVE_AMESOS2_TIMERS 223 Teuchos::TimeMonitor solveTimer(this->
timers_.solveTime_);
225 ::KLU2::klu_solve<slu_type, local_ordinal_type>
226 (data_.symbolic_, data_.numeric_,
228 (local_ordinal_type)nrhs,
229 bValues.getRawPtr(), &(data_.common_)) ;
236 Teuchos::broadcast(*(this->
getComm()), 0, &ierr);
253 #ifdef HAVE_AMESOS2_TIMERS 254 Teuchos::TimeMonitor redistTimer(this->
timers_.vecRedistTime_);
268 template <
class Matrix,
class Vector>
275 return( this->
matrixA_->getGlobalNumRows() == this->
matrixA_->getGlobalNumCols() );
279 template <
class Matrix,
class Vector>
284 using Teuchos::getIntegralValue;
285 using Teuchos::ParameterEntryValidator;
289 if(parameterList->isParameter(
"Trans"))
306 template <
class Matrix,
class Vector>
307 Teuchos::RCP<const Teuchos::ParameterList>
310 using Teuchos::ParameterList;
312 static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
314 if( is_null(valid_params) ){
315 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
317 pl->set(
"Equil",
true,
"Whether to equilibrate the system before solve, does nothing now");
326 template <
class Matrix,
class Vector>
332 if(current_phase == SOLVE)
return(
false);
334 #ifdef HAVE_AMESOS2_TIMERS 335 Teuchos::TimeMonitor convTimer(this->
timers_.mtxConvTime_);
345 local_ordinal_type nnz_ret = 0;
347 #ifdef HAVE_AMESOS2_TIMERS 348 Teuchos::TimeMonitor mtxRedistTimer( this->
timers_.mtxRedistTime_ );
359 TEUCHOS_TEST_FOR_EXCEPTION( nnz_ret != as<local_ordinal_type>(this->
globalNumNonZeros_),
361 "Did not get the expected number of non-zero vals");
368 template<
class Matrix,
class Vector>
374 #endif // AMESOS2_KLU2_DEF_HPP Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers...
Definition: Amesos2_SolverCore_decl.hpp:105
Teuchos::Array< slu_type > nzvals_
Stores the values of the nonzero entries for KLU2.
Definition: Amesos2_KLU2_decl.hpp:230
KLU2(Teuchos::RCP< const Matrix > A, Teuchos::RCP< Vector > X, Teuchos::RCP< const Vector > B)
Initialize from Teuchos::RCP.
Definition: Amesos2_KLU2_def.hpp:66
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
KLU2 specific solve.
Definition: Amesos2_KLU2_def.hpp:191
EPhase
Used to indicate a phase in the direct solution.
Definition: Amesos2_TypeDecl.hpp:65
Amesos2 KLU2 declarations.
global_size_type globalNumCols_
Number of global columns in matrixA_.
Definition: Amesos2_SolverCore_decl.hpp:479
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_KLU2_def.hpp:328
bool root_
If true, then this is the root processor.
Definition: Amesos2_SolverCore_decl.hpp:507
Helper class for getting 1-D copies of multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:243
~KLU2()
Destructor.
Definition: Amesos2_KLU2_def.hpp:85
Definition: Amesos2_TypeDecl.hpp:142
Definition: Amesos2_AbstractConcreteMatrixAdapter.hpp:48
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > ¶meterList)
Definition: Amesos2_KLU2_def.hpp:281
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using KLU2.
Definition: Amesos2_KLU2_def.hpp:126
A generic helper class for getting a CCS representation of a Matrix.
Definition: Amesos2_Util.hpp:580
Definition: Amesos2_KLU2_FunctionMap.hpp:67
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_KLU2_def.hpp:112
Teuchos::Array< local_ordinal_type > rowind_
Stores the location in Ai_ and Aval_ that starts row j.
Definition: Amesos2_KLU2_decl.hpp:232
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Returns a pointer to the Teuchos::Comm communicator with this operator.
Definition: Amesos2_SolverCore_decl.hpp:363
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_KLU2_def.hpp:270
A Matrix adapter interface for Amesos2.
Definition: Amesos2_MatrixAdapter_decl.hpp:76
int numericFactorization_impl()
KLU2 specific numeric factorization.
Definition: Amesos2_KLU2_def.hpp:138
Teuchos::Array< local_ordinal_type > colptr_
Stores the row indices of the nonzero entries.
Definition: Amesos2_KLU2_decl.hpp:234
Amesos2 interface to the KLU2 package.
Definition: Amesos2_KLU2_decl.hpp:72
global_size_type globalNumNonZeros_
Number of global non-zero values in matrixA_.
Definition: Amesos2_SolverCore_decl.hpp:482
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_KLU2_def.hpp:308
Definition: Amesos2_TypeDecl.hpp:127
Timers timers_
Various timing statistics.
Definition: Amesos2_SolverCore_decl.hpp:498
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
Teuchos::RCP< const MatrixAdapter< Matrix > > matrixA_
The LHS operator.
Definition: Amesos2_SolverCore_decl.hpp:455