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