44 #ifndef AMESOS2_UMFPACK_DEF_HPP 45 #define AMESOS2_UMFPACK_DEF_HPP 47 #include <Teuchos_Tuple.hpp> 48 #include <Teuchos_ParameterList.hpp> 49 #include <Teuchos_StandardParameterEntryValidators.hpp> 52 #include "Amesos2_Umfpack_decl.hpp" 57 template <
class Matrix,
class Vector>
59 Teuchos::RCP<const Matrix> A,
60 Teuchos::RCP<Vector> X,
61 Teuchos::RCP<const Vector> B )
72 template <
class Matrix,
class Vector>
75 if (data_.Symbolic) function_map::umfpack_free_symbolic (&data_.Symbolic);
76 if (data_.Numeric) function_map::umfpack_free_numeric (&data_.Numeric);
79 template <
class Matrix,
class Vector>
83 std::ostringstream oss;
84 oss <<
"Umfpack solver interface";
88 template<
class Matrix,
class Vector>
96 template <
class Matrix,
class Vector>
102 if (data_.Symbolic) {
103 function_map::umfpack_free_symbolic(&(data_.Symbolic));
106 function_map::umfpack_defaults(data_.Control);
108 status = function_map::umfpack_symbolic(
109 this->globalNumRows_,this->globalNumCols_,
110 &(this->colptr_[0]), &(this->rowind_[0]),
111 &(this->nzvals_[0]), &(data_.Symbolic), data_.Control, data_.Info);
118 template <
class Matrix,
class Vector>
124 if(!data_.Symbolic) {
125 symbolicFactorization_impl();
128 function_map::umfpack_defaults(data_.Control);
131 function_map::umfpack_free_numeric(&(data_.Numeric));
134 status = function_map::umfpack_numeric(
136 &(this->rowind_[0]), &(this->nzvals_[0]), data_.Symbolic,
137 &(data_.Numeric), data_.Control, data_.Info);
142 template <
class Matrix,
class Vector>
149 const global_size_type ld_rhs = this->root_ ? X->getGlobalLength() : 0;
150 const size_t nrhs = X->getGlobalNumVectors();
152 const size_t val_store_size = as<size_t>(ld_rhs * nrhs);
153 Teuchos::Array<umfpack_type> xValues(val_store_size);
154 Teuchos::Array<umfpack_type> bValues(val_store_size);
157 #ifdef HAVE_AMESOS2_TIMERS 158 Teuchos::TimeMonitor mvConvTimer(this->timers_.vecConvTime_);
159 Teuchos::TimeMonitor redistTimer( this->timers_.vecRedistTime_ );
162 umfpack_type>::do_get(B, bValues(),
164 ROOTED, this->rowIndexBase_);
167 int UmfpackRequest = this->control_.useTranspose_ ? UMFPACK_At : UMFPACK_A;
173 #ifdef HAVE_AMESOS2_TIMER 174 Teuchos::TimeMonitor solveTimer(this->timers_.solveTime_);
176 if (data_.Symbolic) {
177 function_map::umfpack_free_symbolic(&(data_.Symbolic));
181 int i_ld_rhs = as<int>(ld_rhs);
183 for(
size_t j = 0 ; j < nrhs; j++) {
184 int status = function_map::umfpack_solve(
186 &(this->colptr_[0]), &(this->rowind_[0]), &(this->nzvals_[0]),
187 &xValues.getRawPtr()[j*i_ld_rhs],
188 &bValues.getRawPtr()[j*i_ld_rhs],
189 data_.Numeric, data_.Control, data_.Info);
200 Teuchos::broadcast(*(this->getComm()), 0, &ierr);
202 TEUCHOS_TEST_FOR_EXCEPTION( ierr != 0, std::runtime_error,
203 "umfpack_solve has error code: " << ierr );
207 #ifdef HAVE_AMESOS2_TIMERS 208 Teuchos::TimeMonitor redistTimer(this->timers_.vecRedistTime_);
214 ROOTED, this->rowIndexBase_);
221 template <
class Matrix,
class Vector>
228 return( this->matrixA_->getGlobalNumRows() == this->matrixA_->getGlobalNumCols() );
232 template <
class Matrix,
class Vector>
237 using Teuchos::getIntegralValue;
238 using Teuchos::ParameterEntryValidator;
240 RCP<const Teuchos::ParameterList> valid_params = getValidParameters_impl();
244 template <
class Matrix,
class Vector>
245 Teuchos::RCP<const Teuchos::ParameterList>
248 static Teuchos::RCP<const Teuchos::ParameterList> valid_params;
250 if( is_null(valid_params) ){
251 Teuchos::RCP<Teuchos::ParameterList> pl = Teuchos::parameterList();
260 template <
class Matrix,
class Vector>
264 if(current_phase == SOLVE) {
268 #ifdef HAVE_AMESOS2_TIMERS 269 Teuchos::TimeMonitor convTimer(this->timers_.mtxConvTime_);
274 nzvals_.resize(this->globalNumNonZeros_);
275 rowind_.resize(this->globalNumNonZeros_);
276 colptr_.resize(this->globalNumCols_ + 1);
281 #ifdef HAVE_AMESOS2_TIMERS 282 Teuchos::TimeMonitor mtxRedistTimer( this->timers_.mtxRedistTime_ );
285 TEUCHOS_TEST_FOR_EXCEPTION( this->rowIndexBase_ != this->columnIndexBase_,
287 "Row and column maps have different indexbase ");
290 nzvals_(), rowind_(),
291 colptr_(), nnz_ret,
ROOTED,
293 this->rowIndexBase_);
300 template<
class Matrix,
class Vector>
306 #endif // AMESOS2_UMFPACK_DEF_HPP Amesos2::SolverCore: A templated interface for interaction with third-party direct sparse solvers...
Definition: Amesos2_SolverCore_decl.hpp:105
EPhase
Used to indicate a phase in the direct solution.
Definition: Amesos2_TypeDecl.hpp:65
int symbolicFactorization_impl()
Perform symbolic factorization of the matrix using Umfpack.
Definition: Amesos2_Umfpack_def.hpp:98
Umfpack(Teuchos::RCP< const Matrix > A, Teuchos::RCP< Vector > X, Teuchos::RCP< const Vector > B)
Initialize from Teuchos::RCP.
Definition: Amesos2_Umfpack_def.hpp:58
Helper class for getting 1-D copies of multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:266
Definition: Amesos2_TypeDecl.hpp:143
Utility functions for Amesos2.
bool loadA_impl(EPhase current_phase)
Reads matrix data into internal structures.
Definition: Amesos2_Umfpack_def.hpp:262
int numericFactorization_impl()
Umfpack specific numeric factorization.
Definition: Amesos2_Umfpack_def.hpp:120
Amesos2 interface to the Umfpack package.
Definition: Amesos2_Umfpack_decl.hpp:63
Definition: Amesos2_AbstractConcreteMatrixAdapter.hpp:48
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters_impl() const
Definition: Amesos2_Umfpack_def.hpp:246
A generic helper class for getting a CCS representation of a Matrix.
Definition: Amesos2_Util.hpp:657
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:144
~Umfpack()
Destructor.
Definition: Amesos2_Umfpack_def.hpp:73
bool matrixShapeOK_impl() const
Determines whether the shape of the matrix is OK for this solver.
Definition: Amesos2_Umfpack_def.hpp:223
int preOrdering_impl()
Performs pre-ordering on the matrix to increase efficiency.
Definition: Amesos2_Umfpack_def.hpp:90
A Matrix adapter interface for Amesos2.
Definition: Amesos2_MatrixAdapter_decl.hpp:76
std::string description() const
Returns a short description of this Solver.
Definition: Amesos2_Umfpack_def.hpp:81
Definition: Amesos2_TypeDecl.hpp:127
Helper class for putting 1-D data arrays into multivectors.
Definition: Amesos2_MultiVecAdapter_decl.hpp:322
A templated MultiVector class adapter for Amesos2.
Definition: Amesos2_MultiVecAdapter_decl.hpp:176