waves
Basic FE playground
BelosStatusTestWeightedGenResNorm_MP_Vector.hpp
Go to the documentation of this file.
1 //@HEADER
2 // ************************************************************************
3 //
4 // Belos: Block Linear Solvers Package
5 // Copyright 2004 Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ************************************************************************
40 //@HEADER
41 
42 #ifndef BELOS_STATUS_TEST_WEIGHTED_GEN_RESNORM_MP_VECTORH
43 #define BELOS_STATUS_TEST_WEIGHTED_GEN_RESNORM_MP_VECTORH
44 
50 #include "BelosStatusTestResNorm.hpp"
51 #include "BelosLinearProblem.hpp"
52 #include "BelosMultiVecTraits.hpp"
53 
54 #include "EnsembleTraits.h"
55 
80 namespace Belos
81 {
82 
83 template <class ScalarType, class MV, class OP>
84 class StatusTestWeightedGenResNorm : public StatusTestResNorm<ScalarType, MV, OP>
85 {
86 
87 public:
88  // Convenience typedefs
89  typedef Teuchos::ScalarTraits<ScalarType> SCT;
90  typedef typename SCT::magnitudeType MagnitudeType;
91  typedef MultiVecTraits<ScalarType, MV> MVT;
92 
94 
95 
99  enum ResType
100  {
104  };
105 
107 
109 
110 
124  StatusTestWeightedGenResNorm(MagnitudeType Tolerance, Teuchos::RCP<MV> weights, int quorum = -1, bool showMaxResNormOnly = false);
125 
129 
131 
132 
134 
141  int defineResForm(ResType TypeOfResidual, NormType TypeOfNorm);
142 
144 
164  int defineScaleForm(ScaleType TypeOfScaling, NormType TypeOfNorm, MagnitudeType ScaleValue = Teuchos::ScalarTraits<MagnitudeType>::one());
165 
166  NormType getResNormType() { return resnormtype_; }
167 
169 
173  {
174  tolerance_ = tolerance;
175  return (0);
176  }
177 
180  int setQuorum(int quorum)
181  {
182  quorum_ = quorum;
183  return (0);
184  }
185 
187  int setShowMaxResNormOnly(bool showMaxResNormOnly)
188  {
189  showMaxResNormOnly_ = showMaxResNormOnly;
190  return (0);
191  }
192 
194 
196 
197 
204  StatusType checkStatus(Iteration<ScalarType, MV, OP> *iSolver);
205 
207  StatusType getStatus() const { return (status_); };
209 
211 
212 
214  void reset();
215 
217 
219 
220 
222  void print(std::ostream &os, int indent = 0) const;
223 
225  void printStatus(std::ostream &os, StatusType type) const;
227 
229 
230 
234  Teuchos::RCP<MV> getSolution() { return curSoln_; }
235 
238  int getQuorum() const { return quorum_; }
239 
242 
244  std::vector<int> convIndices() { return ind_; }
245 
247  MagnitudeType getTolerance() const { return (tolerance_); };
248 
250  const std::vector<MagnitudeType> *getTestValue() const { return (&testvector_); };
251 
253  const std::vector<MagnitudeType> *getResNormValue() const { return (&resvector_); };
254 
256  const std::vector<MagnitudeType> *getScaledNormValue() const { return (&scalevector_); };
257 
260  bool getLOADetected() const { return false; }
261 
263  const std::vector<int> getEnsembleIterations() const { return ensemble_iterations; }
265 
268 
274  StatusType firstCallCheckStatusSetup(Iteration<ScalarType, MV, OP> *iSolver);
276 
279 
281  std::string description() const
282  {
283  std::ostringstream oss;
284  oss << "Belos::StatusTestWeightedGenResNorm<>: " << resFormStr();
285  oss << ", tol = " << tolerance_;
286  return oss.str();
287  }
289 
290 protected:
291 private:
293 
294 
295  std::string resFormStr() const
296  {
297  std::ostringstream oss;
298  oss << "(";
299  oss << ((resnormtype_ == OneNorm) ? "1-Norm" : (resnormtype_ == TwoNorm) ? "2-Norm" : "Inf-Norm");
300  oss << " Exp";
301  oss << " Res Vec) ";
302 
303  // If there is no residual scaling, return current string.
304  if (scaletype_ != None)
305  {
306  // Insert division sign.
307  oss << "/ ";
308 
309  // Determine output string for scaling, if there is any.
310  if (scaletype_ == UserProvided)
311  oss << " (User Scale)";
312  else
313  {
314  oss << "(";
315  oss << ((scalenormtype_ == OneNorm) ? "1-Norm" : (resnormtype_ == TwoNorm) ? "2-Norm" : "Inf-Norm");
316  if (scaletype_ == NormOfInitRes || scaletype_ == NormOfFullInitRes || scaletype_ == NormOfFullScaledInitRes)
317  oss << " Res0";
318  else if (scaletype_ == NormOfPrecInitRes || scaletype_ == NormOfFullPrecInitRes || scaletype_ == NormOfFullScaledPrecInitRes)
319  oss << " Prec Res0";
320  else
321  oss << " RHS ";
322  oss << ")";
323  }
324  }
325 
326  return oss.str();
327  }
328 
330 
332 
333 
334  // calculate weighted norm
335  void MvWNorm(const MV &mv, const MV &w, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &normVec, NormType type = TwoNorm)
336  {
337 
338  Teuchos::RCP<MV> wmv = MVT::CloneCopy(mv);
339 
340  Teuchos::ArrayRCP<typename MV::scalar_type> wmv_entries;
341  Teuchos::ArrayRCP<const typename MV::scalar_type> w_entries;
342 
343  for (size_t j = 0; j < MVT::GetNumberVecs(mv); ++j)
344  {
345  wmv_entries = wmv->getDataNonConst(j);
346  w_entries = w.getData(j);
347  for (size_t i = 0; i < wmv_entries.size(); ++i)
348  wmv_entries[i] *= w_entries[i];
349  }
350  MVT::MvNorm(*wmv, normVec, type);
351  }
353 
355 
356 
359 
361  int quorum_;
362 
365 
367  NormType resnormtype_;
368 
370  ScaleType scaletype_;
371 
373  NormType scalenormtype_;
374 
377 
379  std::vector<MagnitudeType> scalevector_;
380 
382  std::vector<MagnitudeType> resvector_;
383 
385  std::vector<MagnitudeType> testvector_;
386 
388  std::vector<int> ind_;
389 
391  Teuchos::RCP<MV> curSoln_;
392 
394  StatusType status_;
395 
398 
401 
403  std::vector<int> curLSIdx_;
404 
407 
409  int numrhs_;
410 
413 
416 
419 
421  Teuchos::RCP<MV> weights_;
422 
424  std::vector<int> ensemble_iterations;
425 
427 };
428 
429 template <class ScalarType, class MV, class OP>
431  StatusTestWeightedGenResNorm(MagnitudeType Tolerance, Teuchos::RCP<MV> weights, int quorum, bool showMaxResNormOnly)
432  : tolerance_(Tolerance),
433  quorum_(quorum),
434  showMaxResNormOnly_(showMaxResNormOnly),
435  resnormtype_(TwoNorm),
436  scaletype_(NormOfInitRes),
437  scalenormtype_(TwoNorm),
438  scalevalue_(Teuchos::ScalarTraits<MagnitudeType>::one()),
439  status_(Undefined),
440  curBlksz_(0),
441  curNumRHS_(0),
442  curLSNum_(0),
443  numrhs_(0),
444  firstcallCheckStatus_(true),
445  firstcallDefineResForm_(true),
446  firstcallDefineScaleForm_(true),
447  weights_(weights),
448  ensemble_iterations(EnsembleTraits<ScalarType>::size, 0)
449 {
450  // This constructor will compute the residual ||r_i||/||r0_i|| <= tolerance using the 2-norm of
451  // the explicit residual std::vector.
452 }
453 
454 template <class ScalarType, class MV, class OP>
456 {
457 }
458 
459 template <class ScalarType, class MV, class OP>
461 {
462  status_ = Undefined;
463  curBlksz_ = 0;
464  curLSNum_ = 0;
465  curLSIdx_.resize(0);
466  numrhs_ = 0;
467  ind_.resize(0);
468  firstcallCheckStatus_ = true;
469  curSoln_ = Teuchos::null;
470 }
471 
472 template <class ScalarType, class MV, class OP>
474 {
475  TEUCHOS_TEST_FOR_EXCEPTION(firstcallDefineResForm_ == false, StatusTestError,
476  "StatusTestWeightedGenResNorm::defineResForm(): The residual form has already been defined.");
477  firstcallDefineResForm_ = false;
478 
479  resnormtype_ = TypeOfNorm;
480 
481  return (0);
482 }
483 
484 template <class ScalarType, class MV, class OP>
485 int StatusTestWeightedGenResNorm<ScalarType, MV, OP>::defineScaleForm(ScaleType TypeOfScaling, NormType TypeOfNorm,
486  MagnitudeType ScaleValue)
487 {
488  TEUCHOS_TEST_FOR_EXCEPTION(firstcallDefineScaleForm_ == false, StatusTestError,
489  "StatusTestWeightedGenResNorm::defineScaleForm(): The scaling type has already been defined.");
490  firstcallDefineScaleForm_ = false;
491 
492  scaletype_ = TypeOfScaling;
493  scalenormtype_ = TypeOfNorm;
494  scalevalue_ = ScaleValue;
495 
496  return (0);
497 }
498 
499 template <class ScalarType, class MV, class OP>
500 StatusType StatusTestWeightedGenResNorm<ScalarType, MV, OP>::checkStatus(Iteration<ScalarType, MV, OP> *iSolver)
501 {
502  typedef EnsembleTraits<ScalarType> ET;
503  const int ensemble_size = ET::size;
504  MagnitudeType zero = Teuchos::ScalarTraits<MagnitudeType>::zero();
505  const LinearProblem<ScalarType, MV, OP> &lp = iSolver->getProblem();
506  // Compute scaling term (done once for each block that's being solved)
507  if (firstcallCheckStatus_)
508  {
509  StatusType status = firstCallCheckStatusSetup(iSolver);
510  if (status == Failed)
511  {
512  status_ = Failed;
513  return (status_);
514  }
515  }
516  //
517  // This section computes the norm of the residual std::vector
518  //
519  if (curLSNum_ != lp.getLSNumber())
520  {
521  //
522  // We have moved on to the next rhs block
523  //
524  curLSNum_ = lp.getLSNumber();
525  curLSIdx_ = lp.getLSIndex();
526  curBlksz_ = (int)curLSIdx_.size();
527  int validLS = 0;
528  for (int i = 0; i < curBlksz_; ++i)
529  {
530  if (curLSIdx_[i] > -1 && curLSIdx_[i] < numrhs_)
531  validLS++;
532  }
533  curNumRHS_ = validLS;
534  curSoln_ = Teuchos::null;
535  //
536  }
537  else
538  {
539  //
540  // We are in the same rhs block, return if we are converged
541  //
542  if (status_ == Passed)
543  {
544  return status_;
545  }
546  }
547  {
548  //
549  // Request the true residual for this block of right-hand sides.
550  //
551  Teuchos::RCP<MV> cur_update = iSolver->getCurrentUpdate();
552  curSoln_ = lp.updateSolution(cur_update);
553  Teuchos::RCP<MV> cur_res = MVT::Clone(*curSoln_, MVT::GetNumberVecs(*curSoln_));
554  lp.computeCurrResVec(&*cur_res, &*curSoln_);
555  std::vector<MagnitudeType> tmp_resvector(MVT::GetNumberVecs(*cur_res));
556  MvWNorm(*cur_res, *weights_, tmp_resvector, resnormtype_);
557  typename std::vector<int>::iterator p = curLSIdx_.begin();
558  for (int i = 0; p < curLSIdx_.end(); ++p, ++i)
559  {
560  // Check if this index is valid
561  if (*p != -1)
562  resvector_[*p] = tmp_resvector[i];
563  }
564  }
565  //
566  // Compute the new linear system residuals for testing.
567  // (if any of them don't meet the tolerance or are NaN, then we exit with that status)
568  //
569  if (scalevector_.size() > 0)
570  {
571  typename std::vector<int>::iterator p = curLSIdx_.begin();
572  for (; p < curLSIdx_.end(); ++p)
573  {
574  // Check if this index is valid
575  if (*p != -1)
576  {
577  // Scale the std::vector accordingly
578  if (scalevector_[*p] != zero)
579  {
580  // Don't intentionally divide by zero.
581  testvector_[*p] = resvector_[*p] / scalevector_[*p] / scalevalue_;
582  }
583  else
584  {
585  testvector_[*p] = resvector_[*p] / scalevalue_;
586  }
587  }
588  }
589  }
590  else
591  {
592  typename std::vector<int>::iterator p = curLSIdx_.begin();
593  for (; p < curLSIdx_.end(); ++p)
594  {
595  // Check if this index is valid
596  if (*p != -1)
597  testvector_[*p] = resvector_[*p] / scalevalue_;
598  }
599  }
600 
601  // Check status of new linear system residuals and see if we have the quorum.
602  int have = 0;
603  ind_.resize(curLSIdx_.size());
604  typename std::vector<int>::iterator p = curLSIdx_.begin();
605  for (; p < curLSIdx_.end(); ++p)
606  {
607  // Check if this index is valid
608  if (*p != -1)
609  {
610  // Check if any of the residuals are larger than the tolerance.
611  bool all_converged = true;
612  for (int ii = 0; ii < ensemble_size; ++ii)
613  {
614  if (ET::coeff(testvector_[*p], ii) > ET::coeff(tolerance_, ii))
615  {
616  ++ensemble_iterations[ii];
617  all_converged = false;
618  }
619  else if (!(ET::coeff(testvector_[*p], ii) <= ET::coeff(tolerance_, ii)))
620  {
621  // Throw an std::exception if a NaN is found.
622  status_ = Failed;
623  TEUCHOS_TEST_FOR_EXCEPTION(true, StatusTestError, "StatusTestWeightedGenResNorm::checkStatus(): NaN has been detected.");
624  }
625  }
626  if (all_converged)
627  {
628  ind_[have] = *p;
629  have++;
630  }
631  }
632  }
633  ind_.resize(have);
634  int need = (quorum_ == -1) ? curNumRHS_ : quorum_;
635  status_ = (have >= need) ? Passed : Failed;
636 
637  // Return the current status
638  return status_;
639 }
640 
641 template <class ScalarType, class MV, class OP>
642 void StatusTestWeightedGenResNorm<ScalarType, MV, OP>::print(std::ostream &os, int indent) const
643 {
644  for (int j = 0; j < indent; j++)
645  os << ' ';
646  printStatus(os, status_);
647  os << resFormStr();
648  if (status_ == Undefined)
649  os << ", tol = " << tolerance_ << std::endl;
650  else
651  {
652  os << std::endl;
653  if (showMaxResNormOnly_ && curBlksz_ > 1)
654  {
655  const MagnitudeType maxRelRes = *std::max_element(
656  testvector_.begin() + curLSIdx_[0], testvector_.begin() + curLSIdx_[curBlksz_ - 1]);
657  for (int j = 0; j < indent + 13; j++)
658  os << ' ';
659  os << "max{residual[" << curLSIdx_[0] << "..." << curLSIdx_[curBlksz_ - 1] << "]} = " << maxRelRes
660  << (maxRelRes <= tolerance_ ? " <= " : " > ") << tolerance_ << std::endl;
661  }
662  else
663  {
664  for (int i = 0; i < numrhs_; i++)
665  {
666  for (int j = 0; j < indent + 13; j++)
667  os << ' ';
668  os << "residual [ " << i << " ] = " << testvector_[i];
669  os << ((testvector_[i] < tolerance_) ? " < " : (testvector_[i] == tolerance_) ? " == " : (testvector_[i] > tolerance_) ? " > " : " ") << tolerance_ << std::endl;
670  }
671  }
672  }
673  os << std::endl;
674 }
675 
676 template <class ScalarType, class MV, class OP>
677 void StatusTestWeightedGenResNorm<ScalarType, MV, OP>::printStatus(std::ostream &os, StatusType type) const
678 {
679  os << std::left << std::setw(13) << std::setfill('.');
680  switch (type)
681  {
682  case Passed:
683  os << "Converged";
684  break;
685  case Failed:
686  os << "Unconverged";
687  break;
688  case Undefined:
689  default:
690  os << "**";
691  break;
692  }
693  os << std::left << std::setfill(' ');
694  return;
695 }
696 
697 template <class ScalarType, class MV, class OP>
698 StatusType StatusTestWeightedGenResNorm<ScalarType, MV, OP>::firstCallCheckStatusSetup(Iteration<ScalarType, MV, OP> *iSolver)
699 {
700  int i;
701  MagnitudeType zero = Teuchos::ScalarTraits<MagnitudeType>::zero();
702  MagnitudeType one = Teuchos::ScalarTraits<MagnitudeType>::one();
703  const LinearProblem<ScalarType, MV, OP> &lp = iSolver->getProblem();
704  // Compute scaling term (done once for each block that's being solved)
705  if (firstcallCheckStatus_)
706  {
707  //
708  // Get some current solver information.
709  //
710  firstcallCheckStatus_ = false;
711 
712  if (scaletype_ == NormOfRHS)
713  {
714  Teuchos::RCP<const MV> rhs = lp.getRHS();
715  numrhs_ = MVT::GetNumberVecs(*rhs);
716  scalevector_.resize(numrhs_);
717  MvWNorm(*rhs, *weights_, scalevector_, scalenormtype_);
718  }
719  else if (scaletype_ == NormOfInitRes || scaletype_ == NormOfFullInitRes || scaletype_ == NormOfFullScaledInitRes)
720  {
721  Teuchos::RCP<const MV> init_res = lp.getInitResVec();
722  numrhs_ = MVT::GetNumberVecs(*init_res);
723  scalevector_.resize(numrhs_);
724  MvWNorm(*init_res, *weights_, scalevector_, scalenormtype_);
725  }
726  else if (scaletype_ == NormOfPrecInitRes || scaletype_ == NormOfFullPrecInitRes || scaletype_ == NormOfFullScaledPrecInitRes)
727  {
728  Teuchos::RCP<const MV> init_res = lp.getInitPrecResVec();
729  numrhs_ = MVT::GetNumberVecs(*init_res);
730  scalevector_.resize(numrhs_);
731  MvWNorm(*init_res, *weights_, scalevector_, scalenormtype_);
732  }
733  else
734  {
735  numrhs_ = MVT::GetNumberVecs(*(lp.getRHS()));
736  }
737 
738  resvector_.resize(numrhs_);
739  testvector_.resize(numrhs_);
740 
741  curLSNum_ = lp.getLSNumber();
742  curLSIdx_ = lp.getLSIndex();
743  curBlksz_ = (int)curLSIdx_.size();
744  int validLS = 0;
745  for (i = 0; i < curBlksz_; ++i)
746  {
747  if (curLSIdx_[i] > -1 && curLSIdx_[i] < numrhs_)
748  validLS++;
749  }
750  curNumRHS_ = validLS;
751  //
752  // Initialize the testvector.
753  for (i = 0; i < numrhs_; i++)
754  {
755  testvector_[i] = one;
756  }
757 
758  // Return an error if the scaling is zero.
759  if (scalevalue_ == zero)
760  {
761  return Failed;
762  }
763  }
764  return Undefined;
765 }
766 
767 } // end namespace Belos
768 
769 #endif /* BELOS_STATUS_TEST_RESNORM_H */
Belos::StatusTestWeightedGenResNorm::Implicit
@ Implicit
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:101
Belos::StatusTestWeightedGenResNorm::status_
StatusType status_
Status.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:394
Belos::StatusTestWeightedGenResNorm::Explicit
@ Explicit
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:102
Belos::StatusTestWeightedGenResNorm::ind_
std::vector< int > ind_
Vector containing the indices for the vectors that passed the test.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:388
Belos::StatusTestWeightedGenResNorm::curLSNum_
int curLSNum_
The current number of linear systems that have been loaded into the linear problem.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:406
Belos::StatusTestWeightedGenResNorm::firstCallCheckStatusSetup
StatusType firstCallCheckStatusSetup(Iteration< ScalarType, MV, OP > *iSolver)
Call to setup initial scaling std::vector.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:698
Belos::StatusTestWeightedGenResNorm::quorum_
int quorum_
Number of residuals that must pass the convergence test before Passed is returned.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:361
Belos::StatusTestWeightedGenResNorm::setShowMaxResNormOnly
int setShowMaxResNormOnly(bool showMaxResNormOnly)
Set whether the only maximum residual norm is displayed when the print() method is called.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:187
Belos::StatusTestWeightedGenResNorm::getStatus
StatusType getStatus() const
Return the result of the most recent CheckStatus call.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:207
Belos::StatusTestWeightedGenResNorm::checkStatus
StatusType checkStatus(Iteration< ScalarType, MV, OP > *iSolver)
Check convergence status: Passed, Failed, or Undefined.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:500
Belos::StatusTestWeightedGenResNorm::MagnitudeType
SCT::magnitudeType MagnitudeType
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:90
Belos::StatusTestWeightedGenResNorm::scaletype_
ScaleType scaletype_
Type of scaling to use (Norm of RHS, Norm of Initial Residual, None or User provided)
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:370
Belos::StatusTestWeightedGenResNorm::scalevalue_
MagnitudeType scalevalue_
Scaling value.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:376
Belos::StatusTestWeightedGenResNorm::resFormStr
std::string resFormStr() const
Description of current residual form.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:295
Belos::StatusTestWeightedGenResNorm::getQuorum
int getQuorum() const
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:238
Belos::StatusTestWeightedGenResNorm::scalenormtype_
NormType scalenormtype_
Type of norm to use on the scaling (OneNorm, TwoNorm, or InfNorm)
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:373
Belos::StatusTestWeightedGenResNorm::ResType
ResType
Select how the residual std::vector is produced.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:99
Belos::StatusTestWeightedGenResNorm::MVT
MultiVecTraits< ScalarType, MV > MVT
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:91
Belos::StatusTestWeightedGenResNorm::description
std::string description() const
Method to return description of the maximum iteration status test
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:281
Belos::StatusTestWeightedGenResNorm::SCT
Teuchos::ScalarTraits< ScalarType > SCT
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:89
Belos::StatusTestWeightedGenResNorm::defineResForm
int defineResForm(ResType TypeOfResidual, NormType TypeOfNorm)
Define form of the residual, its norm and optional weighting std::vector.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:473
Belos::StatusTestWeightedGenResNorm::getEnsembleIterations
const std::vector< int > getEnsembleIterations() const
Returns number of ensemble iterations.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:263
Belos::StatusTestWeightedGenResNorm::getTolerance
MagnitudeType getTolerance() const
Returns the value of the tolerance, , set in the constructor.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:247
Belos::StatusTestWeightedGenResNorm::showMaxResNormOnly_
bool showMaxResNormOnly_
Determines if the entries for all of the residuals are shown or just the max.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:364
Belos::StatusTestWeightedGenResNorm::numrhs_
int numrhs_
The total number of right-hand sides being solved for.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:409
EnsembleTraits
Definition: EnsembleTraits.h:8
Belos::StatusTestWeightedGenResNorm::getSolution
Teuchos::RCP< MV > getSolution()
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:234
Belos::StatusTestWeightedGenResNorm::print
void print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:642
Belos::StatusTestWeightedGenResNorm::getShowMaxResNormOnly
bool getShowMaxResNormOnly()
Returns whether the only maximum residual norm is displayed when the print() method is called.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:241
Belos::StatusTestWeightedGenResNorm::setTolerance
int setTolerance(MagnitudeType tolerance)
Set the value of the tolerance.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:172
Belos::StatusTestWeightedGenResNorm::curNumRHS_
int curNumRHS_
The current number of right-hand sides being solved for.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:400
Belos::StatusTestWeightedGenResNorm::tolerance_
MagnitudeType tolerance_
Tolerance used to determine convergence.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:358
Belos::StatusTestWeightedGenResNorm::getTestValue
const std::vector< MagnitudeType > * getTestValue() const
Returns the test value, , computed in most recent call to CheckStatus.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:250
Belos::StatusTestWeightedGenResNorm::firstcallDefineScaleForm_
bool firstcallDefineScaleForm_
Is this the first time DefineScaleForm is called?
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:418
Belos::StatusTestWeightedGenResNorm::getScaledNormValue
const std::vector< MagnitudeType > * getScaledNormValue() const
Returns the scaled norm value, .
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:256
Belos::StatusTestWeightedGenResNorm::getResNormValue
const std::vector< MagnitudeType > * getResNormValue() const
Returns the residual norm value, , computed in most recent call to CheckStatus.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:253
Belos::StatusTestWeightedGenResNorm::curBlksz_
int curBlksz_
The current blocksize of the linear system being solved.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:397
EnsembleTraits.h
Belos::StatusTestWeightedGenResNorm
An implementation of StatusTestResNorm using a family of weighted residual norms.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:84
Belos::StatusTestWeightedGenResNorm::convIndices
std::vector< int > convIndices()
Returns the std::vector containing the indices of the residuals that passed the test.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:244
Belos::StatusTestWeightedGenResNorm::firstcallCheckStatus_
bool firstcallCheckStatus_
Is this the first time CheckStatus is called?
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:412
Belos
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:80
Belos::StatusTestWeightedGenResNorm::printStatus
void printStatus(std::ostream &os, StatusType type) const
Print message for each status specific to this stopping test.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:677
Belos::StatusTestWeightedGenResNorm::StatusTestWeightedGenResNorm
StatusTestWeightedGenResNorm(MagnitudeType Tolerance, Teuchos::RCP< MV > weights, int quorum=-1, bool showMaxResNormOnly=false)
Constructor.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:431
Belos::StatusTestWeightedGenResNorm::reset
void reset()
Resets the internal configuration to the initial state.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:460
Belos::StatusTestWeightedGenResNorm::MvWNorm
void MvWNorm(const MV &mv, const MV &w, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normVec, NormType type=TwoNorm)
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:335
Belos::StatusTestWeightedGenResNorm::firstcallDefineResForm_
bool firstcallDefineResForm_
Is this the first time DefineResForm is called?
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:415
Belos::StatusTestWeightedGenResNorm::defineScaleForm
int defineScaleForm(ScaleType TypeOfScaling, NormType TypeOfNorm, MagnitudeType ScaleValue=Teuchos::ScalarTraits< MagnitudeType >::one())
Define form of the scaling, its norm, its optional weighting std::vector, or, alternatively,...
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:485
Belos::StatusTestWeightedGenResNorm::setQuorum
int setQuorum(int quorum)
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:180
Belos::StatusTestWeightedGenResNorm::getResNormType
NormType getResNormType()
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:166
Belos::StatusTestWeightedGenResNorm::scalevector_
std::vector< MagnitudeType > scalevector_
Scaling std::vector.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:379
Belos::StatusTestWeightedGenResNorm::curLSIdx_
std::vector< int > curLSIdx_
The indices of the current number of right-hand sides being solved for.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:403
Belos::StatusTestWeightedGenResNorm::curSoln_
Teuchos::RCP< MV > curSoln_
Most recent solution vector used by this status test.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:391
Belos::StatusTestWeightedGenResNorm::ensemble_iterations
std::vector< int > ensemble_iterations
The number of iterations at which point each ensemble component converges.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:424
Belos::StatusTestWeightedGenResNorm::weights_
Teuchos::RCP< MV > weights_
Weights of the used norm:
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:421
Belos::StatusTestWeightedGenResNorm::testvector_
std::vector< MagnitudeType > testvector_
Test std::vector = resvector_ / scalevector_.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:385
Belos::StatusTestWeightedGenResNorm::getLOADetected
bool getLOADetected() const
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:260
Belos::StatusTestWeightedGenResNorm::~StatusTestWeightedGenResNorm
virtual ~StatusTestWeightedGenResNorm()
Destructor.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:455
Belos::StatusTestWeightedGenResNorm::resnormtype_
NormType resnormtype_
Type of norm to use on residual (OneNorm, TwoNorm, or InfNorm).
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:367
Belos::StatusTestWeightedGenResNorm::resvector_
std::vector< MagnitudeType > resvector_
Residual norm std::vector.
Definition: BelosStatusTestWeightedGenResNorm_MP_Vector.hpp:382