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 )
76 ::KLU2::klu_defaults<slu_type, local_ordinal_type> (&(data_.common_)) ;
77 data_.symbolic_ = NULL;
78 data_.numeric_ = NULL;
85 template <
class Matrix,
class Vector>
93 if (data_.symbolic_ != NULL)
94 ::KLU2::klu_free_symbolic<slu_type, local_ordinal_type>
95 (&(data_.symbolic_), &(data_.common_)) ;
96 if (data_.numeric_ != NULL)
97 ::KLU2::klu_free_numeric<slu_type, local_ordinal_type>
98 (&(data_.numeric_), &(data_.common_)) ;
111 template<
class Matrix,
class Vector>
117 #ifdef HAVE_AMESOS2_TIMERS 118 Teuchos::TimeMonitor preOrderTimer(this->
timers_.preOrderTime_);
125 template <
class Matrix,
class Vector>
129 if (data_.symbolic_ != NULL)
130 ::KLU2::klu_free_symbolic<slu_type, local_ordinal_type>
131 (&(data_.symbolic_), &(data_.common_)) ;
132 data_.symbolic_ = ::KLU2::klu_analyze<slu_type, local_ordinal_type>
134 rowind_.getRawPtr(), &(data_.common_)) ;
140 template <
class Matrix,
class Vector>
155 #ifdef HAVE_AMESOS2_TIMERS 156 Teuchos::TimeMonitor numFactTimer(this->
timers_.numFactTime_);
159 #ifdef HAVE_AMESOS2_VERBOSE_DEBUG 160 std::cout <<
"KLU2:: Before numeric factorization" << std::endl;
161 std::cout <<
"nzvals_ : " <<
nzvals_.toString() << std::endl;
162 std::cout <<
"rowind_ : " <<
rowind_.toString() << std::endl;
163 std::cout <<
"colptr_ : " <<
colptr_.toString() << std::endl;
166 if (data_.numeric_ != NULL)
167 ::KLU2::klu_free_numeric<slu_type, local_ordinal_type>
168 (&(data_.numeric_), &(data_.common_)) ;
169 data_.numeric_ = ::KLU2::klu_factor<slu_type, local_ordinal_type>
171 data_.symbolic_, &(data_.common_)) ;
178 Teuchos::broadcast(*(this->
matrixA_->getComm()), 0, &info);
196 template <
class Matrix,
class Vector>
204 const global_size_type ld_rhs = this->
root_ ? X->getGlobalLength() : 0;
205 const size_t nrhs = X->getGlobalNumVectors();
207 const size_t val_store_size = as<size_t>(ld_rhs * nrhs);
208 Teuchos::Array<slu_type> bValues(val_store_size);
211 #ifdef HAVE_AMESOS2_TIMERS 212 Teuchos::TimeMonitor mvConvTimer(this->
timers_.vecConvTime_);
213 Teuchos::TimeMonitor redistTimer( this->
timers_.vecRedistTime_ );
216 slu_type>::do_get(B, bValues(),
229 #ifdef HAVE_AMESOS2_TIMERS 230 Teuchos::TimeMonitor solveTimer(this->
timers_.solveTime_);
234 ::KLU2::klu_solve<slu_type, local_ordinal_type>
235 (data_.symbolic_, data_.numeric_,
237 (local_ordinal_type)nrhs,
238 bValues.getRawPtr(), &(data_.common_)) ;
242 ::KLU2::klu_tsolve<slu_type, local_ordinal_type>
243 (data_.symbolic_, data_.numeric_,
245 (local_ordinal_type)nrhs,
246 bValues.getRawPtr(), &(data_.common_)) ;
254 Teuchos::broadcast(*(this->
getComm()), 0, &ierr);
271 #ifdef HAVE_AMESOS2_TIMERS 272 Teuchos::TimeMonitor redistTimer(this->
timers_.vecRedistTime_);
286 template <
class Matrix,
class Vector>
293 return( this->
matrixA_->getGlobalNumRows() == this->
matrixA_->getGlobalNumCols() );
297 template <
class Matrix,
class Vector>
302 using Teuchos::getIntegralValue;
303 using Teuchos::ParameterEntryValidator;
309 if( parameterList->isParameter(
"Trans") ){
310 RCP<const ParameterEntryValidator> trans_validator = valid_params->getEntry(
"Trans").validator();
311 parameterList->getEntry(
"Trans").setValidator(trans_validator);
313 transFlag_ = getIntegralValue<int>(*parameterList,
"Trans");
318 template <
class Matrix,
class Vector>
319 Teuchos::RCP<const Teuchos::ParameterList>
323 using Teuchos::tuple;
324 using Teuchos::ParameterList;
325 using Teuchos::setStringToIntegralParameter;
327 static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
329 if( is_null(valid_params) )
331 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
333 pl->set(
"Equil",
true,
"Whether to equilibrate the system before solve, does nothing now");
335 setStringToIntegralParameter<int>(
"Trans",
"NOTRANS",
336 "Solve for the transpose system or not",
337 tuple<string>(
"NOTRANS",
"TRANS",
"CONJ"),
338 tuple<string>(
"Solve with transpose",
339 "Do not solve with transpose",
340 "Solve with the conjugate transpose"),
350 template <
class Matrix,
class Vector>
356 if(current_phase == SOLVE)
return(
false);
358 #ifdef HAVE_AMESOS2_TIMERS 359 Teuchos::TimeMonitor convTimer(this->
timers_.mtxConvTime_);
369 local_ordinal_type nnz_ret = 0;
371 #ifdef HAVE_AMESOS2_TIMERS 372 Teuchos::TimeMonitor mtxRedistTimer( this->
timers_.mtxRedistTime_ );
383 TEUCHOS_TEST_FOR_EXCEPTION( nnz_ret != as<local_ordinal_type>(this->
globalNumNonZeros_),
385 "Did not get the expected number of non-zero vals");
392 template<
class Matrix,
class Vector>
398 #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
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
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_KLU2_def.hpp:320
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_KLU2_def.hpp:352
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:86
Definition: Amesos2_TypeDecl.hpp:142
Control control_
Parameters for solving.
Definition: Amesos2_SolverCore_decl.hpp:495
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
Definition: Amesos2_AbstractConcreteMatrixAdapter.hpp:48
void setParameters_impl(const Teuchos::RCP< Teuchos::ParameterList > ¶meterList)
Definition: Amesos2_KLU2_def.hpp:299
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using KLU2.
Definition: Amesos2_KLU2_def.hpp:127
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:113
Teuchos::Array< local_ordinal_type > rowind_
Stores the location in Ai_ and Aval_ that starts row j.
Definition: Amesos2_KLU2_decl.hpp:232
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:198
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_KLU2_def.hpp:288
A Matrix adapter interface for Amesos2.
Definition: Amesos2_MatrixAdapter_decl.hpp:76
int numericFactorization_impl()
KLU2 specific numeric factorization.
Definition: Amesos2_KLU2_def.hpp:142
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
int transFlag_
Definition: Amesos2_KLU2_decl.hpp:243
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
global_size_type rowIndexBase_
Index base of rowmap of matrixA_.
Definition: Amesos2_SolverCore_decl.hpp:485