LCOV - code coverage report
Current view: top level - src/outputs - SolutionInvalidityOutput.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 27 27 100.0 %
Date: 2026-05-29 20:35:17 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : // Moose includes
      11             : #include "SolutionInvalidityOutput.h"
      12             : #include "MooseApp.h"
      13             : #include "MooseObjectParameterName.h"
      14             : #include "InputParameterWarehouse.h"
      15             : #include "ConsoleUtils.h"
      16             : #include "FEProblemBase.h"
      17             : 
      18             : registerMooseObject("MooseApp", SolutionInvalidityOutput);
      19             : 
      20             : InputParameters
      21      129353 : SolutionInvalidityOutput::validParams()
      22             : {
      23      129353 :   InputParameters params = Output::validParams();
      24             : 
      25      388059 :   params.set<ExecFlagEnum>("execute_on") = {EXEC_FINAL};
      26             : 
      27      388059 :   params.addParam<unsigned int>("solution_invalidity_timestep_interval",
      28      258706 :                                 1,
      29             :                                 "The number of time steps to group together in the table reporting "
      30             :                                 "the warnings and solution invalidity occurrences.");
      31             : 
      32      129353 :   params.addClassDescription("Controls output of the time history of regular warnings and solution "
      33             :                              "invalidity errors and warnings");
      34             : 
      35      129353 :   return params;
      36      129353 : }
      37             : 
      38       60370 : SolutionInvalidityOutput::SolutionInvalidityOutput(const InputParameters & parameters)
      39             :   : Output(parameters),
      40       60370 :     _timestep_interval(getParam<unsigned int>("solution_invalidity_timestep_interval")),
      41      120740 :     _solution_invalidity(_app.solutionInvalidity())
      42             : {
      43       60370 : }
      44             : 
      45             : bool
      46     1200519 : SolutionInvalidityOutput::shouldOutput()
      47             : {
      48             :   // Note: if this happens in other cases, we should just sync if solutionInvalidity is not synced
      49             :   // FAILED: solver could have failed before any iteration completed, thus before a sync
      50             :   // FINAL: we could have hit a solution invalidity on EXEC_FINAL and there are no solver steps
      51             :   // or multiapp fixed point iterations after to cause a sync.
      52     2399189 :   if (_problem_ptr->getCurrentExecuteOnFlag() == EXEC_FAILED ||
      53     1198670 :       _problem_ptr->getCurrentExecuteOnFlag() == EXEC_FINAL)
      54       56719 :     _solution_invalidity.syncIteration();
      55             :   // At the known end of a simulation, always output the total summary if anything happened
      56     2399189 :   if (_problem_ptr->getCurrentExecuteOnFlag() == EXEC_FAILED ||
      57     1198670 :       _problem_ptr->getCurrentExecuteOnFlag() == EXEC_FINAL)
      58       56719 :     return Output::shouldOutput() && _solution_invalidity.hasEverHadSolutionIssue();
      59             :   // At other points, we check the current state of the simulation
      60     1143800 :   return Output::shouldOutput() && _solution_invalidity.hasInvalidSolution();
      61             : }
      62             : 
      63             : void
      64        1435 : SolutionInvalidityOutput::output()
      65             : {
      66        4305 :   if (isParamSetByUser("solution_invalidity_timestep_interval"))
      67           9 :     mooseInfo("Set Outputs/solution_invalidity_history=false to silence the default Solution "
      68             :               "Invalid Warnings History table above.");
      69        1435 :   _console << '\n';
      70        1435 :   _solution_invalidity.printHistory(_console, _timestep_interval);
      71        1435 :   _console << std::flush;
      72        1435 : }

Generated by: LCOV version 1.14