Belos Version of the Day
Loading...
Searching...
No Matches
BelosPCPGIter.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Belos: Block Linear Solvers Package
4//
5// Copyright 2004-2016 NTESS and the Belos contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef BELOS_PCPG_ITER_HPP
11#define BELOS_PCPG_ITER_HPP
12
17#include "BelosConfigDefs.hpp"
18#include "BelosTypes.hpp"
19
22#include "BelosStatusTest.hpp"
26#include "BelosCGIteration.hpp"
27
28#include "Teuchos_ScalarTraits.hpp"
29#include "Teuchos_ParameterList.hpp"
30#include "Teuchos_TimeMonitor.hpp"
31
32#include <vector>
33
45namespace Belos {
46
48
49
54 template <class ScalarType, class MV, class DM>
61 int curDim;
64
66 Teuchos::RCP<MV> R;
67
69 Teuchos::RCP<MV> Z;
70
72 Teuchos::RCP<MV> P;
73
75 Teuchos::RCP<MV> AP;
76
78 Teuchos::RCP<MV> U;
79
81 Teuchos::RCP<MV> C;
82
87 std::vector<ScalarType> D;
88
90 prevUdim(0),
91 R(Teuchos::null), Z(Teuchos::null),
92 P(Teuchos::null), AP(Teuchos::null),
93 U(Teuchos::null), C(Teuchos::null),
94 D(Teuchos::null)
95 {}
96 };
97
99
100 template<class ScalarType, class MV, class OP, class DM>
101 class PCPGIter : virtual public Iteration<ScalarType,MV,OP,DM> {
102
103 public:
104
105 //
106 // Convenience typedefs
107 //
111 typedef Teuchos::ScalarTraits<ScalarType> SCT;
112 typedef typename SCT::magnitudeType MagnitudeType;
113
115
116
125 const Teuchos::RCP<OutputManager<ScalarType> > &printer,
126 const Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > &tester,
127 Teuchos::ParameterList &params );
128
130 virtual ~PCPGIter() {};
132
133
135
136
155 void iterate();
156
176
185
195 state.Z = Z_; // CG state
196 state.P = P_;
197 state.AP = AP_;
198 state.R = R_;
199 state.U = U_; // seed state
200 state.C = C_;
201 state.D = D_;
202 state.curDim = curDim_;
203 state.prevUdim = prevUdim_;
204 return state;
205 }
206
208
209
211
212
214 int getNumIters() const { return iter_; }
215
217 void resetNumIters( int iter = 0 ) { iter_ = iter; }
218
221 Teuchos::RCP<const MV> getNativeResiduals( std::vector<MagnitudeType> * /* norms */ ) const { return R_; }
222
224
227 Teuchos::RCP<MV> getCurrentUpdate() const { return Teuchos::null; }
228
230 int getCurSubspaceDim() const {
231 if (!initialized_) return 0;
232 return curDim_;
233 };
234
236 int getPrevSubspaceDim() const {
237 if (!initialized_) return 0;
238 return prevUdim_;
239 };
240
242
243
245
246
248 const LinearProblem<ScalarType,MV,OP,DM>& getProblem() const { return *lp_; }
249
251 int getBlockSize() const { return 1; }
252
254 int getNumRecycledBlocks() const { return savedBlocks_; }
255
257
260 TEUCHOS_TEST_FOR_EXCEPTION(blockSize!=1,std::invalid_argument,
261 "Belos::PCPGIter::setBlockSize(): Cannot use a block size that is not one.");
262 }
263
265 void setSize( int savedBlocks );
266
268 bool isInitialized() { return initialized_; }
269
271 void resetState();
272
274
275 private:
276
277 //
278 // Internal methods
279 //
281 void setStateSize();
282
283 //
284 // Classes inputed through constructor that define the linear problem to be solved.
285 //
286 const Teuchos::RCP<LinearProblem<ScalarType,MV,OP,DM> > lp_;
287 const Teuchos::RCP<OutputManager<ScalarType> > om_;
288 const Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > stest_;
289
290 //
291 // Algorithmic parameters
292 // savedBlocks_ is the number of blocks allocated for the reused subspace
293 int savedBlocks_;
294 //
295 //
296 // Current solver state
297 //
298 // initialized_ specifies that the basis vectors have been initialized and the iterate() routine
299 // is capable of running; _initialize is controlled by the initialize() member method
300 // For the implications of the state of initialized_, please see documentation for initialize()
301 bool initialized_;
302
303 // stateStorageInitialized_ indicates that the state storage has be initialized to the current
304 // savedBlocks_. State storage initialization may be postponed if the linear problem was
305 // generated without either the right-hand side or solution vectors.
306 bool stateStorageInitialized_;
307
308 // keepDiagonal_ specifies that the iteration must keep the diagonal matrix of pivots
309 bool keepDiagonal_;
310
311 // initDiagonal_ specifies that the iteration will reinitialize the diagonal matrix by zeroing
312 // out all entries before an iteration is started.
313 bool initDiagonal_;
314
315 // Current subspace dimension
316 int curDim_;
317
318 // Dimension of seed space used to solve current linear system
319 int prevUdim_;
320
321 // Number of iterations performed
322 int iter_;
323 //
324 // State Storage ... of course this part is different for CG
325 //
326 // Residual
327 Teuchos::RCP<MV> R_;
328 //
329 // Preconditioned residual
330 Teuchos::RCP<MV> Z_;
331 //
332 // Direction std::vector
333 Teuchos::RCP<MV> P_;
334 //
335 // Operator applied to direction std::vector
336 Teuchos::RCP<MV> AP_;
337 //
338 // Recycled subspace vectors.
339 Teuchos::RCP<MV> U_;
340 //
341 // C = A * U, linear system is Ax=b
342 Teuchos::RCP<MV> C_;
343 //
344 // Projected matrices
345 // D_ : Diagonal matrix of pivots D = P'AP
346 std::vector<ScalarType> D_;
347 };
348
350 // Constructor.
351 template<class ScalarType, class MV, class OP, class DM>
353 const Teuchos::RCP<OutputManager<ScalarType> > &printer,
354 const Teuchos::RCP<StatusTest<ScalarType,MV,OP,DM> > &tester,
355 Teuchos::ParameterList &params ):
356 lp_(problem),
357 om_(printer),
358 stest_(tester),
359 savedBlocks_(0),
360 initialized_(false),
361 stateStorageInitialized_(false),
362 keepDiagonal_(false),
363 initDiagonal_(false),
364 curDim_(0),
365 prevUdim_(0),
366 iter_(0)
367 {
368 // Get the maximum number of blocks allowed for this Krylov subspace
369
370 TEUCHOS_TEST_FOR_EXCEPTION(!params.isParameter("Saved Blocks"), std::invalid_argument,
371 "Belos::PCPGIter::constructor: mandatory parameter \"Saved Blocks\" is not specified.");
372 int rb = Teuchos::getParameter<int>(params, "Saved Blocks");
373
374 // Find out whether we are saving the Diagonal matrix.
375 keepDiagonal_ = params.get("Keep Diagonal", false);
376
377 // Find out whether we are initializing the Diagonal matrix.
378 initDiagonal_ = params.get("Initialize Diagonal", false);
379
380 // Set the number of blocks and allocate data
381 setSize( rb );
382 }
383
385 // Set the block size and adjust as necessary
386 template<class ScalarType, class MV, class OP, class DM>
388 {
389 // allocate space only; perform no computation
390 // Any change in size invalidates the state of the solver as implemented here.
391
392 TEUCHOS_TEST_FOR_EXCEPTION(savedBlocks <= 0, std::invalid_argument, "Belos::PCPGIter::setSize() was passed a non-positive argument for \"Num Saved Blocks\".");
393
394 if ( savedBlocks_ != savedBlocks) {
395 stateStorageInitialized_ = false;
396 savedBlocks_ = savedBlocks;
397 initialized_ = false;
398 curDim_ = 0;
399 prevUdim_ = 0;
400 setStateSize(); // Use the current savedBlocks_ to initialize the state storage.
401 }
402 }
403
405 // Enable the reuse of a single solver object for completely different linear systems
406 template<class ScalarType, class MV, class OP, class DM>
408 {
409 stateStorageInitialized_ = false;
410 initialized_ = false;
411 curDim_ = 0;
412 prevUdim_ = 0;
413 setStateSize();
414 }
415
417 // Setup the state storage. Called by either initialize or, if savedBlocks_ changes, setSize.
418 template<class ScalarType, class MV, class OP, class DM>
420 {
421 if (!stateStorageInitialized_) {
422
423 // Check if there is any multivector to clone from.
424 Teuchos::RCP<const MV> lhsMV = lp_->getLHS();
425 Teuchos::RCP<const MV> rhsMV = lp_->getRHS();
426 if (lhsMV == Teuchos::null && rhsMV == Teuchos::null) {
427 return; // postpone exception
428 }
429 else {
430
432 // blockSize*recycledBlocks dependent
433 int newsd = savedBlocks_ ; //int newsd = blockSize_* savedBlocks_ ;
434 //
435 // Initialize the CG state storage
436 // If the subspace is not initialized, generate it using the LHS or RHS from lp_.
437 // Generate CG state only if it does not exist, otherwise resize it.
438 if (Z_ == Teuchos::null) {
439 Teuchos::RCP<const MV> tmp = ( (rhsMV!=Teuchos::null)? rhsMV: lhsMV );
440 Z_ = MVT::Clone( *tmp, 1 );
441 }
442 if (P_ == Teuchos::null) {
443 Teuchos::RCP<const MV> tmp = ( (rhsMV!=Teuchos::null)? rhsMV: lhsMV );
444 P_ = MVT::Clone( *tmp, 1 );
445 }
446 if (AP_ == Teuchos::null) {
447 Teuchos::RCP<const MV> tmp = ( (rhsMV!=Teuchos::null)? rhsMV: lhsMV );
448 AP_ = MVT::Clone( *tmp, 1 );
449 }
450
451 if (C_ == Teuchos::null) {
452
453 // Get the multivector that is not null.
454 Teuchos::RCP<const MV> tmp = ( (rhsMV!=Teuchos::null)? rhsMV: lhsMV );
455 TEUCHOS_TEST_FOR_EXCEPTION(tmp == Teuchos::null,std::invalid_argument,
456 "Belos::PCPGIter::setStateSize(): linear problem does not specify multivectors to clone from.");
457 TEUCHOS_TEST_FOR_EXCEPTION( 0 != prevUdim_,std::invalid_argument,
458 "Belos::PCPGIter::setStateSize(): prevUdim not zero and C is null.");
459 C_ = MVT::Clone( *tmp, savedBlocks_ );
460 }
461 else {
462 // Generate C_ by cloning itself ONLY if more space is needed.
463 if (MVT::GetNumberVecs(*C_) < savedBlocks_ ) {
464 Teuchos::RCP<const MV> tmp = C_;
465 C_ = MVT::Clone( *tmp, savedBlocks_ );
466 }
467 }
468 if (U_ == Teuchos::null) {
469 Teuchos::RCP<const MV> tmp = ( (rhsMV!=Teuchos::null)? rhsMV: lhsMV );
470 TEUCHOS_TEST_FOR_EXCEPTION( 0 != prevUdim_,std::invalid_argument,
471 "Belos::PCPGIter::setStateSize(): prevUdim not zero and U is null.");
472 U_ = MVT::Clone( *tmp, savedBlocks_ );
473 }
474 else {
475 // Generate U_ by cloning itself ONLY if more space is needed.
476 if (MVT::GetNumberVecs(*U_) < savedBlocks_ ) {
477 Teuchos::RCP<const MV> tmp = U_;
478 U_ = MVT::Clone( *tmp, savedBlocks_ );
479 }
480 }
481 if (keepDiagonal_) {
482 if (initDiagonal_ || ((int)(D_.size()) < newsd)) {
483 D_.resize( newsd );
484 }
485 }
486 // State storage has now been initialized.
487 stateStorageInitialized_ = true;
488 } // if there is a vector to clone from
489 } // if !stateStorageInitialized_
490 } // end of setStateSize
491
493 // Initialize the iteration object
494 template<class ScalarType, class MV, class OP, class DM>
496 {
497
498 TEUCHOS_TEST_FOR_EXCEPTION(!stateStorageInitialized_,std::invalid_argument,
499 "Belos::PCPGIter::initialize(): Cannot initialize state storage!");
500
501 // Requirements: R_ and consistent multivectors widths and lengths
502 //
503 std::string errstr("Belos::PCPGIter::initialize(): Specified multivectors must have a consistent length and width.");
504
505 if (newstate.R != Teuchos::null){
506
507 R_ = newstate.R; // SolverManager::R_ == newstate.R == Iterator::R_
508 if (newstate.U == Teuchos::null){
509 prevUdim_ = 0;
510 newstate.U = U_;
511 newstate.C = C_;
512 }
513 else {
514 prevUdim_ = newstate.curDim;
515 if (newstate.C == Teuchos::null){ // Stub for new feature
516 std::vector<int> index(prevUdim_);
517 for (int i=0; i< prevUdim_; ++i)
518 index[i] = i;
519 Teuchos::RCP<const MV> Ukeff = MVT::CloneView( *newstate.U, index );
520 newstate.C = MVT::Clone( *newstate.U, prevUdim_ );
521 Teuchos::RCP<MV> Ckeff = MVT::CloneViewNonConst( *newstate.C, index );
522 lp_->apply( *Ukeff, *Ckeff );
523 }
524 curDim_ = prevUdim_ ;
525 }
526
527 // Initialize the state storage if not already allocated in the constructor
528 if (!stateStorageInitialized_)
529 setStateSize();
530
531 //TEUCHOS_TEST_FOR_EXCEPTION( MVT::GetGlobalLength(*newstate.V) != MVT::GetGlobalLength(*V_), std::invalid_argument, errstr );
532 //TEUCHOS_TEST_FOR_EXCEPTION( MVT::GetNumberVecs(*newstate.V) < 1, std::invalid_argument, errstr );
533
534 newstate.prevUdim = prevUdim_; // big change in functionality from GCRODR
535 newstate.curDim = curDim_;
536
537 //TEUCHOS_TEST_FOR_EXCEPTION(newstate.z->numRows() < curDim_ || newstate.z->numCols() < 1, std::invalid_argument, errstr);
538
539 std::vector<int> zero_index(1);
540 zero_index[0] = 0;
541 if ( lp_->getLeftPrec() != Teuchos::null ) { // Compute the initial search direction
542 lp_->applyLeftPrec( *R_, *Z_ );
543 MVT::SetBlock( *Z_, zero_index , *P_ ); // P(:,zero_index) := Z
544 } else {
545 Z_ = R_;
546 MVT::SetBlock( *R_, zero_index, *P_ );
547 }
548
549 std::vector<int> nextind(1);
550 nextind[0] = curDim_;
551
552 MVT::SetBlock( *P_, nextind, *newstate.U ); // U(:,curDim_ ) := P_
553
554 ++curDim_;
555 newstate.curDim = curDim_;
556
557 TEUCHOS_TEST_FOR_EXCEPTION( MVT::GetNumberVecs(*newstate.U) != savedBlocks_ ,
558 std::invalid_argument, errstr );
559 if (newstate.U != U_) { // Why this is needed?
560 U_ = newstate.U;
561 }
562
563 TEUCHOS_TEST_FOR_EXCEPTION( MVT::GetNumberVecs(*newstate.C) != savedBlocks_ ,
564 std::invalid_argument, errstr );
565 if (newstate.C != C_) {
566 C_ = newstate.C;
567 }
568 }
569 else {
570
571 TEUCHOS_TEST_FOR_EXCEPTION(newstate.R == Teuchos::null,std::invalid_argument,
572 "Belos::PCPGIter::initialize(): PCPGStateIterState does not have initial kernel R_0.");
573 }
574
575 // the solver is initialized
576 initialized_ = true;
577 }
578
579
581 // Iterate until the status test informs us we should stop.
582 template<class ScalarType, class MV, class OP, class DM>
584 {
585 //
586 // Allocate/initialize data structures
587 //
588 if (initialized_ == false) {
589 initialize();
590 }
591 const bool debug = false;
592
593 // Allocate memory for scalars.
594 ScalarType alpha, beta, rHz_old;
595 Teuchos::RCP<DM> pAp = DMT::Create(1,1);
596 Teuchos::RCP<DM> rHz = DMT::Create(1,1);
597
598 if( iter_ != 0 )
599 std::cout << " Iterate Warning: begin from nonzero iter_ ?" << std::endl; //DMD
600
601 // GenOrtho Project Stubs
602 std::vector<int> prevInd;
603 Teuchos::RCP<const MV> Uprev;
604 Teuchos::RCP<const MV> Cprev;
605 Teuchos::RCP<DM> CZ;
606
607 if( prevUdim_ ){
608 prevInd.resize( prevUdim_ );
609 for( int i=0; i<prevUdim_ ; i++) prevInd[i] = i;
610 CZ = DMT::Create( prevUdim_ , 1 );
611 Uprev = MVT::CloneView(*U_, prevInd);
612 Cprev = MVT::CloneView(*C_, prevInd);
613 }
614
615 // Get the current solution std::vector.
616 Teuchos::RCP<MV> cur_soln_vec = lp_->getCurrLHSVec();
617
618 // Check that the current solution std::vector only has one column.
620 "Belos::PCPGIter::iterate(): current linear system has more than one std::vector!" );
621
622 //Check that the input is correctly set up
623 TEUCHOS_TEST_FOR_EXCEPTION( curDim_ != prevUdim_ + 1, CGIterationInitFailure,
624 "Belos::PCPGIter::iterate(): mistake in initialization !" );
625
626
627 const ScalarType zero = Teuchos::ScalarTraits<ScalarType>::zero();
628 const ScalarType one = Teuchos::ScalarTraits<ScalarType>::one();
629
630
631 std::vector<int> curind(1);
632 std::vector<ScalarType> rnorm(MVT::GetNumberVecs(*cur_soln_vec));
633 if (prevUdim_ > 0){ // A-orthonalize P=Z to Uprev
634 Teuchos::RCP<MV> P;
635 curind[0] = curDim_ - 1; // column = dimension - 1
636 P = MVT::CloneViewNonConst(*U_,curind);
637 MVT::MvTransMv( one, *Cprev, *P, *CZ );
638 MVT::MvTimesMatAddMv( -one, *Uprev, *CZ, one, *P ); // P -= U*(C'Z)
639
640 if( curDim_ == savedBlocks_ ){
641 std::vector<int> zero_index(1);
642 zero_index[0] = 0;
643 MVT::SetBlock( *P, zero_index, *P_ );
644 }
645 P = Teuchos::null;
646 }
647
648 // Compute first <r,z> a.k.a. rHz
649 MVT::MvTransMv( one, *R_, *Z_, *rHz );
650 DMT::SyncDeviceToHost( *rHz );
651
653 // iterate until the status test is satisfied
654 //
655 while (stest_->checkStatus(this) != Passed ) {
656 Teuchos::RCP<const MV> P;
657 Teuchos::RCP<MV> AP;
658 iter_++; // The next iteration begins.
659 //std::vector<int> curind(1);
660 curind[0] = curDim_ - 1; // column = dimension - 1
661 if( debug ){
662 MVT::MvNorm(*R_, rnorm);
663 std::cout << iter_ << " " << curDim_ << " " << rnorm[0] << std::endl;
664 }
665 if( prevUdim_ + iter_ < savedBlocks_ ){
666 P = MVT::CloneView(*U_,curind);
667 AP = MVT::CloneViewNonConst(*C_,curind);
668 lp_->applyOp( *P, *AP );
669 MVT::MvTransMv( one, *P, *AP, *pAp );
670 }else{
671 if( prevUdim_ + iter_ == savedBlocks_ ){
672 AP = MVT::CloneViewNonConst(*C_,curind);
673 lp_->applyOp( *P_, *AP );
674 MVT::MvTransMv( one, *P_, *AP, *pAp );
675 }else{
676 lp_->applyOp( *P_, *AP_ );
677 MVT::MvTransMv( one, *P_, *AP_, *pAp );
678 }
679 }
680 DMT::SyncDeviceToHost( *pAp );
681
682 if( keepDiagonal_ && prevUdim_ + iter_ <= savedBlocks_ )
683 D_[iter_-1] = DMT::ValueConst(*pAp,0,0);
684
685 // positive pAp required
687 "Belos::PCPGIter::iterate(): non-positive value for p^H*A*p encountered!" );
688
689 // alpha := <R_,Z_> / <P,AP>
690 alpha = DMT::ValueConst(*rHz,0,0) / DMT::ValueConst(*pAp,0,0);
691
692 // positive alpha required
694 "Belos::PCPGIter::iterate(): non-positive value for alpha encountered!" );
695
696 // solution update x += alpha * P
697 if( curDim_ < savedBlocks_ ){
698 MVT::MvAddMv( one, *cur_soln_vec, alpha, *P, *cur_soln_vec );
699 }else{
700 MVT::MvAddMv( one, *cur_soln_vec, alpha, *P_, *cur_soln_vec );
701 }
702 //
703 // The denominator of beta is saved before residual is updated [ old <R_, Z_> ].
704 //
705 rHz_old = DMT::ValueConst(*rHz,0,0);
706 //
707 // residual update R_ := R_ - alpha * AP
708 //
709 if( prevUdim_ + iter_ <= savedBlocks_ ){
710 MVT::MvAddMv( one, *R_, -alpha, *AP, *R_ );
711 AP = Teuchos::null;
712 }else{
713 MVT::MvAddMv( one, *R_, -alpha, *AP_, *R_ );
714 }
715 //
716 // update beta := [ new <R_, Z_> ] / [ old <R_, Z_> ] and the search direction p.
717 //
718 if ( lp_->getLeftPrec() != Teuchos::null ) {
719 lp_->applyLeftPrec( *R_, *Z_ );
720 } else {
721 Z_ = R_;
722 }
723 //
724 MVT::MvTransMv( one, *R_, *Z_, *rHz );
725 DMT::SyncDeviceToHost( *rHz );
726 //
727 beta = DMT::ValueConst(*rHz,0,0) / rHz_old;
728 //
729 if( curDim_ < savedBlocks_ ){
730 curDim_++; // update basis dim
731 curind[0] = curDim_ - 1;
732 Teuchos::RCP<MV> Pnext = MVT::CloneViewNonConst(*U_,curind);
733 MVT::MvAddMv( one, *Z_, beta, *P, *Pnext );
734 if( prevUdim_ ){ // Deflate seed space
735 MVT::MvTransMv( one, *Cprev, *Z_, *CZ );
736 MVT::MvTimesMatAddMv( -one, *Uprev, *CZ, one, *Pnext ); // Pnext -= U*(C'Z)
737 }
738 P = Teuchos::null;
739 if( curDim_ == savedBlocks_ ){
740 std::vector<int> zero_index(1);
741 zero_index[0] = 0;
742 MVT::SetBlock( *Pnext, zero_index, *P_ );
743 }
744 Pnext = Teuchos::null;
745 }else{
746 MVT::MvAddMv( one, *Z_, beta, *P_, *P_ );
747 if( prevUdim_ ){ // Deflate seed space
748 MVT::MvTransMv( one, *Cprev, *Z_, *CZ );
749 MVT::MvTimesMatAddMv( -one, *Uprev, *CZ, one, *P_ ); // P_ -= U*(C'Z)
750 }
751 }
752 // CGB: 5/26/2010
753 // this RCP<const MV> P was previously a variable outside the loop. however, it didn't appear to be see any use between
754 // loop iterations. therefore, I moved it inside to avoid scoping errors with previously used variables named P.
755 // to ensure that this wasn't a bug, I verify below that we have set P == null, i.e., that we are not going to use it again
756 // same for AP
757 TEUCHOS_TEST_FOR_EXCEPTION( AP != Teuchos::null || P != Teuchos::null, std::logic_error, "Loop recurrence violated. Please contact Belos team.");
758 } // end coupled two-term recursion
759 if( prevUdim_ + iter_ < savedBlocks_ ) --curDim_; // discard negligible search direction
760 }
761
762} // end Belos namespace
763
764#endif /* BELOS_PCPG_ITER_HPP */
Pure virtual base class which augments the basic interface for a conjugate gradient linear solver ite...
Belos header file which uses auto-configuration information to include necessary C++ headers.
Class which describes the linear problem to be solved by the iterative solver.
Declaration of basic traits for the multivector type.
Class which defines basic traits for the operator type.
Class which manages the output and verbosity of the Belos solvers.
Pure virtual base class for defining the status testing capabilities of Belos.
Collection of types and exceptions used within the Belos solvers.
CGIterationInitFailure is thrown when the CGIteration object is unable to generate an initial iterate...
CGPositiveDefiniteFailure is thrown when the the CG 'alpha = p^H*A*P' value is less than zero,...
Alternative run-time polymorphic interface for operators.
Operator()
Default constructor (does nothing).
This class implements the PCPG iteration, where a single-vector Krylov subspace is constructed....
int getBlockSize() const
Get the maximum number of blocks used by the iterative solver in solving this linear problem.
int getPrevSubspaceDim() const
Get the dimension of the search subspace used to solve the current solution to the linear problem.
void initialize()
Initialize the solver with the initial vectors from the linear problem. An exception is thrown if ini...
void resetState()
tell the Iterator to "reset" itself; delete and rebuild the seed space.
void iterate()
PCPGIter iterates CG until the status test either requests a stop or detects an error....
void setBlockSize(int blockSize)
Get the blocksize to be used by the iterative solver in solving this linear problem.
Teuchos::RCP< MV > getCurrentUpdate() const
Get the current update to the linear system solution?.
DenseMatTraits< ScalarType, DM > DMT
int getNumIters() const
Get the current iteration count.
int getNumRecycledBlocks() const
Get the maximum number of recycled blocks used by the iterative solver in solving this linear problem...
PCPGIterState< ScalarType, MV, DM > getState() const
Get the current state of the linear solver.
int getCurSubspaceDim() const
Get the current dimension of the whole seed subspace.
MultiVecTraits< ScalarType, MV, DM > MVT
OperatorTraits< ScalarType, MV, OP > OPT
PCPGIter(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP, DM > > &problem, const Teuchos::RCP< OutputManager< ScalarType > > &printer, const Teuchos::RCP< StatusTest< ScalarType, MV, OP, DM > > &tester, Teuchos::ParameterList &params)
PCPGIter constructor with linear problem, solver utilities, and parameter list of solver options.
bool isInitialized()
States whether the solver has been initialized or not.
void setSize(int savedBlocks)
Set the maximum number of saved or recycled blocks used by the iterative solver.
SCT::magnitudeType MagnitudeType
void resetNumIters(int iter=0)
Reset the iteration count.
Teuchos::ScalarTraits< ScalarType > SCT
Teuchos::RCP< const MV > getNativeResiduals(std::vector< MagnitudeType > *) const
Get the norms of the residuals native to the solver.
virtual ~PCPGIter()
Destructor.
const LinearProblem< ScalarType, MV, OP, DM > & getProblem() const
Get a constant reference to the linear problem.
Structure to contain pointers to PCPGIter state variables.
Teuchos::RCP< MV > AP
The matrix A applied to current decent direction std::vector.
int curDim
The current dimension of the reduction.
int prevUdim
Number of block columns in matrices C and U before current iteration.
Teuchos::RCP< MV > C
C = AU, U spans recycled subspace.
Teuchos::RCP< MV > P
The current decent direction std::vector.
std::vector< ScalarType > D
The current diagonal matrix.
Teuchos::RCP< MV > R
The current residual.
Teuchos::RCP< MV > Z
The current preconditioned residual.
Teuchos::RCP< MV > U
The recycled subspace.

Generated for Belos by doxygen 1.9.8