10 #ifndef AMESOS2_UMFPACK_DEF_HPP
11 #define AMESOS2_UMFPACK_DEF_HPP
13 #include <Teuchos_Tuple.hpp>
14 #include <Teuchos_ParameterList.hpp>
15 #include <Teuchos_StandardParameterEntryValidators.hpp>
18 #include "Amesos2_Umfpack_decl.hpp"
23 template <
class Matrix,
class Vector>
25 Teuchos::RCP<const Matrix> A,
26 Teuchos::RCP<Vector> X,
27 Teuchos::RCP<const Vector> B )
29 , is_contiguous_(true)
31 data_.Symbolic = NULL;
36 template <
class Matrix,
class Vector>
39 if (data_.Symbolic) function_map::umfpack_free_symbolic (&data_.Symbolic);
40 if (data_.Numeric) function_map::umfpack_free_numeric (&data_.Numeric);
43 template <
class Matrix,
class Vector>
47 std::ostringstream oss;
48 oss <<
"Umfpack solver interface";
52 template<
class Matrix,
class Vector>
60 template <
class Matrix,
class Vector>
67 function_map::umfpack_free_symbolic(&(data_.Symbolic));
70 function_map::umfpack_defaults(data_.Control);
72 status = function_map::umfpack_symbolic(
73 this->globalNumRows_,this->globalNumCols_,
74 &(this->colptr_view_[0]), &(this->rowind_view_[0]),
75 &(this->nzvals_view_[0]), &(data_.Symbolic), data_.Control, data_.Info);
82 template <
class Matrix,
class Vector>
89 symbolicFactorization_impl();
92 function_map::umfpack_defaults(data_.Control);
95 function_map::umfpack_free_numeric(&(data_.Numeric));
98 status = function_map::umfpack_numeric(
99 &(this->colptr_view_[0]),
100 &(this->rowind_view_[0]), &(this->nzvals_view_[0]), data_.Symbolic,
101 &(data_.Numeric), data_.Control, data_.Info);
106 template <
class Matrix,
class Vector>
113 const global_size_type ld_rhs = this->root_ ? X->getGlobalLength() : 0;
114 const size_t nrhs = X->getGlobalNumVectors();
116 const size_t val_store_size = as<size_t>(ld_rhs * nrhs);
117 Teuchos::Array<umfpack_type> xValues(val_store_size);
118 Teuchos::Array<umfpack_type> bValues(val_store_size);
121 #ifdef HAVE_AMESOS2_TIMERS
122 Teuchos::TimeMonitor mvConvTimer(this->timers_.vecConvTime_);
123 Teuchos::TimeMonitor redistTimer( this->timers_.vecRedistTime_ );
127 (is_contiguous_ ==
true) ? ROOTED : CONTIGUOUS_AND_ROOTED,
128 this->rowIndexBase_);
131 int UmfpackRequest = this->control_.useTranspose_ ? UMFPACK_At : UMFPACK_A;
137 #ifdef HAVE_AMESOS2_TIMER
138 Teuchos::TimeMonitor solveTimer(this->timers_.solveTime_);
140 if (data_.Symbolic) {
141 function_map::umfpack_free_symbolic(&(data_.Symbolic));
145 int i_ld_rhs = as<int>(ld_rhs);
147 for(
size_t j = 0 ; j < nrhs; j++) {
148 int status = function_map::umfpack_solve(
150 &(this->colptr_view_[0]), &(this->rowind_view_[0]), &(this->nzvals_view_[0]),
151 &xValues.getRawPtr()[j*i_ld_rhs],
152 &bValues.getRawPtr()[j*i_ld_rhs],
153 data_.Numeric, data_.Control, data_.Info);
164 Teuchos::broadcast(*(this->getComm()), 0, &ierr);
166 TEUCHOS_TEST_FOR_EXCEPTION( ierr != 0, std::runtime_error,
167 "umfpack_solve has error code: " << ierr );
171 #ifdef HAVE_AMESOS2_TIMERS
172 Teuchos::TimeMonitor redistTimer(this->timers_.vecRedistTime_);
177 (is_contiguous_ ==
true) ? ROOTED : CONTIGUOUS_AND_ROOTED,
178 this->rowIndexBase_);
185 template <
class Matrix,
class Vector>
192 return( this->matrixA_->getGlobalNumRows() == this->matrixA_->getGlobalNumCols() );
196 template <
class Matrix,
class Vector>
201 using Teuchos::getIntegralValue;
202 using Teuchos::ParameterEntryValidator;
204 RCP<const Teuchos::ParameterList> valid_params = getValidParameters_impl();
206 if( parameterList->isParameter(
"IsContiguous") ){
207 is_contiguous_ = parameterList->get<
bool>(
"IsContiguous");
212 template <
class Matrix,
class Vector>
213 Teuchos::RCP<const Teuchos::ParameterList>
216 static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
218 if( is_null(valid_params) ){
219 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
221 pl->set(
"IsContiguous",
true,
"Whether GIDs contiguous");
230 template <
class Matrix,
class Vector>
234 if(current_phase == SOLVE) {
238 #ifdef HAVE_AMESOS2_TIMERS
239 Teuchos::TimeMonitor convTimer(this->timers_.mtxConvTime_);
244 Kokkos::resize(nzvals_view_,this->globalNumNonZeros_);
245 Kokkos::resize(rowind_view_,this->globalNumNonZeros_);
246 Kokkos::resize(colptr_view_,this->globalNumCols_ + 1);
251 #ifdef HAVE_AMESOS2_TIMERS
252 Teuchos::TimeMonitor mtxRedistTimer( this->timers_.mtxRedistTime_ );
255 TEUCHOS_TEST_FOR_EXCEPTION( this->rowIndexBase_ != this->columnIndexBase_,
257 "Row and column maps have different indexbase ");
259 host_size_type_array>::do_get(this->matrixA_.ptr(),
260 nzvals_view_, rowind_view_, colptr_view_, nnz_ret,
261 (is_contiguous_ ==
true) ? ROOTED : CONTIGUOUS_AND_ROOTED,
263 this->rowIndexBase_);
270 template<
class Matrix,
class Vector>
276 #endif // AMESOS2_UMFPACK_DEF_HPP
Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers...
Definition: Amesos2_SolverCore_decl.hpp:71
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Umfpack_def.hpp:187
A generic helper class for getting a CCS representation of a Matrix.
Definition: Amesos2_Util.hpp:614
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Umfpack_def.hpp:214
EPhase
Used to indicate a phase in the direct solution.
Definition: Amesos2_TypeDecl.hpp:31
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using Umfpack.
Definition: Amesos2_Umfpack_def.hpp:62
Umfpack(Teuchos::RCP< const Matrix > A, Teuchos::RCP< Vector > X, Teuchos::RCP< const Vector > B)
Initialize from Teuchos::RCP.
Definition: Amesos2_Umfpack_def.hpp:24
int solve_impl(const Teuchos::Ptr< MultiVecAdapter< Vector > > X, const Teuchos::Ptr< const MultiVecAdapter< Vector > > B) const
Umfpack specific solve.
Definition: Amesos2_Umfpack_def.hpp:108
Helper class for getting 1-D copies of multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:233
Utility functions for Amesos2.
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_Umfpack_def.hpp:232
int numericFactorization_impl()
Umfpack specific numeric factorization.
Definition: Amesos2_Umfpack_def.hpp:84
Amesos2 interface to the Umfpack package.
Definition: Amesos2_Umfpack_decl.hpp:29
~Umfpack()
Destructor.
Definition: Amesos2_Umfpack_def.hpp:37
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_Umfpack_def.hpp:54
std::string description() const
Returns a short description of this Solver.
Definition: Amesos2_Umfpack_def.hpp:45
Helper class for putting 1-D data arrays into multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:339
A templated MultiVector class adapter for Amesos2.
Definition: Amesos2_MultiVecAdapter_decl.hpp:142