Skip to content

Commit

Permalink
Belos BlockFGmresIter: Cache currentUpdate vector
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Bettencourt authored and cgcgcg committed Jan 16, 2025
1 parent bf0d8b0 commit 3da11cd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/belos/src/BelosBlockFGmresIter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ class BlockFGmresIter : virtual public GmresIteration<ScalarType,MV,OP> {
// z_: Q applied to right-hand side of the least squares system
Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > R_;
Teuchos::RCP<Teuchos::SerialDenseMatrix<int,ScalarType> > z_;
mutable Teuchos::RCP<MV> currentUpdate_;

};

//////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -457,18 +459,18 @@ class BlockFGmresIter : virtual public GmresIteration<ScalarType,MV,OP> {
{
typedef Teuchos::SerialDenseMatrix<int, ScalarType> SDM;

Teuchos::RCP<MV> currentUpdate = Teuchos::null;
if (curDim_ == 0) {
// If this is the first iteration of the Arnoldi factorization,
// then there is no update, so return Teuchos::null.
return currentUpdate;
return currentUpdate_;
}
else {
const ScalarType zero = Teuchos::ScalarTraits<ScalarType>::zero ();
const ScalarType one = Teuchos::ScalarTraits<ScalarType>::one ();
Teuchos::BLAS<int,ScalarType> blas;

currentUpdate = MVT::Clone (*Z_, blockSize_);
if (currentUpdate_.is_null())
currentUpdate_ = MVT::Clone (*Z_, blockSize_);

// Make a view and then copy the RHS of the least squares problem. DON'T OVERWRITE IT!
SDM y (Teuchos::Copy, *z_, curDim_, blockSize_);
Expand All @@ -484,9 +486,9 @@ class BlockFGmresIter : virtual public GmresIteration<ScalarType,MV,OP> {
index[i] = i;
}
Teuchos::RCP<const MV> Zjp1 = MVT::CloneView (*Z_, index);
MVT::MvTimesMatAddMv (one, *Zjp1, y, zero, *currentUpdate);
MVT::MvTimesMatAddMv (one, *Zjp1, y, zero, *currentUpdate_);
}
return currentUpdate;
return currentUpdate_;
}


Expand Down

0 comments on commit 3da11cd

Please sign in to comment.