idaholab/moose: framework coverage diff

Base bb0a08 Head #31706 f8ed4a
Total Total +/- New
Rate 86.02% 86.02% +0.00% 100.00%
Hits 124559 124594 +35 45
Misses 20244 20244 - 0
Filename Stmts Miss Cover
framework/include/loops/ThreadedNodeLoop.h 0 +1 -2.70%
framework/src/base/MooseError.C 0 +1 -1.82%
framework/src/convergence/IterationCountConvergence.C 0 -2 +4.35%
framework/src/convergence/PostprocessorConvergence.C +35 0 +3.18%
TOTAL +35 0 +0.00%
code
coverage unchanged
code
coverage increased
code
coverage decreased
+
line added or modified

framework/include/loops/ThreadedNodeLoop.h

104  
105  
106  
107  
108  
109  
110  
    for (IteratorType nd = range.begin(); nd != range.end(); ++nd)
    {
      if (!keepGoing())
        break;

      onNode(nd);

framework/src/base/MooseError.C

113  
114  
115  
116  
117  
118  
119  
    // In parallel with libMesh configured with --enable-tracefiles, this will
    // dump a trace for each rank to file
    if (libMesh::global_n_processors() > 1)
      libMesh::write_traceout();

    MOOSE_ABORT;
  }

framework/src/convergence/IterationCountConvergence.C

50  
51  
52  
53 +
54 +
55  
56  
57  
58  
59  
60 +
61 +
62  
63  
64  
      {
        if (_converge_at_max_iterations)
        {
          oss << COLOR_GREEN << "Converged due to iterations (" << iter << ") >= max iterations ("
              << _max_iterations << ") and 'converge_at_max_iterations' = 'true'." << COLOR_DEFAULT;
          verboseOutput(oss);
          return MooseConvergenceStatus::CONVERGED;
        }
        else
        {
          oss << COLOR_RED << "Diverged due to iterations (" << iter << ") >= max iterations ("
              << _max_iterations << ")." << COLOR_DEFAULT;
          verboseOutput(oss);
          return MooseConvergenceStatus::DIVERGED;
        }
79  
80  
81  
82  
83  
84  
85  
86  
        return MooseConvergenceStatus::CONVERGED;
      break;

    case MooseConvergenceStatus::DIVERGED:
      return MooseConvergenceStatus::DIVERGED;
      break;

    default:

framework/src/convergence/PostprocessorConvergence.C

20  
21  
22  
23 +
24 +
25  
26 +
27  
28  
29 +
30  
31 +
32  
33  
34  

  params.addRequiredParam<PostprocessorName>("postprocessor",
                                             "Post-processor to use for convergence criteria");
  params.addRequiredParam<Real>("tolerance", "Absolute tolerance to use for convergence criteria");
  params.addParam<unsigned int>(
      "max_diverging_iterations",
      std::numeric_limits<unsigned int>::max(),
      "Number of consecutive iterations of the post-processor value either increasing or not "
      "reducing fast enough, at which to consider the solve diverged");
  params.addParam<Real>(
      "diverging_iteration_rel_reduction",
      0.0,
      "The relative reduction with respect to the previous iteration, for which the iteration "
      "counts as a diverging iteration with respect to 'max_diverging_iterations': an iteration is "
      "diverging if (|pp_old| - |pp_new|)/|pp_old| < rel_reduction. The default value of 0 "
41  
42  
43  
44 +
45 +
46 +
47 +
48 +
49  
50  
51  
52  
53 +
54  
55 +
56  
57  
58 +
59  
60 +
61 +
62  
63  
64  
65 +
66 +
67  
68 +
69  
70 +
71 +
72 +
73 +
74 +
75 +
76  
77 +
78 +
79  
80 +
81  
82  
83 +
84 +
85  
86  
87  
88 +
89  
90 +
91 +
92 +
93 +
94 +
95 +
96  
97  
98 +
99 +
100 +
101 +
102  
103 +
104  
105  
PostprocessorConvergence::PostprocessorConvergence(const InputParameters & parameters)
  : IterationCountConvergence(parameters),
    _postprocessor(getPostprocessorValue("postprocessor")),
    _tol(getParam<Real>("tolerance")),
    _max_diverging_iterations(getParam<unsigned int>("max_diverging_iterations")),
    _div_rel_reduction(getParam<Real>("diverging_iteration_rel_reduction")),
    _diverging_iterations(0),
    _pp_value_old(std::numeric_limits<Real>::max())
{
}

Convergence::MooseConvergenceStatus
PostprocessorConvergence::checkConvergenceInner(unsigned int iter)
{
  const auto pp_value = std::abs(_postprocessor);

  // Initialize diverging iteration data
  if (iter == 0)
  {
    _diverging_iterations = 0;
    _pp_value_old = std::numeric_limits<Real>::max();
  }

  // Check for diverging iteration
  const Real rel_reduction = (_pp_value_old - pp_value) / _pp_value_old;
  if (rel_reduction < _div_rel_reduction)
  {
    _diverging_iterations++;

    std::ostringstream oss;
    oss << COLOR_YELLOW << "Diverging iteration: (" << _pp_value_old << "-" << pp_value << ")/"
        << _pp_value_old << " = " << rel_reduction << " < " << _div_rel_reduction << "."
        << COLOR_DEFAULT;
    verboseOutput(oss);
  }
  else
    _diverging_iterations = 0;
  _pp_value_old = pp_value;

  if (pp_value <= _tol)
  {
    std::ostringstream oss;
    oss << COLOR_GREEN << "Converged due to |post-processor| (" << pp_value << ") <= tolerance ("
        << _tol << ")." << COLOR_DEFAULT;
    verboseOutput(oss);
    return MooseConvergenceStatus::CONVERGED;
  }
  else if (_diverging_iterations > _max_diverging_iterations)
  {
    std::ostringstream oss;
    oss << COLOR_RED << "Diverged due to exceeding maximum number of diverging iterations ("
        << _max_diverging_iterations << ")." << COLOR_DEFAULT;
    verboseOutput(oss);
    return MooseConvergenceStatus::DIVERGED;
  }
  else
  {
    std::ostringstream oss;
    oss << "Still iterating due to |post-processor| (" << pp_value << ") > tolerance (" << _tol
        << ").";
    verboseOutput(oss);
    return MooseConvergenceStatus::ITERATING;
  }
}