LCOV - code coverage report
Current view: top level - src/reporters - SolutionInvalidityReporter.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 24 25 96.0 %
Date: 2025-07-17 01:28:37 Functions: 3 3 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             : #include "SolutionInvalidityReporter.h"
      11             : 
      12             : #include "SolutionInvalidity.h"
      13             : 
      14             : registerMooseObject("MooseApp", SolutionInvalidityReporter);
      15             : 
      16             : InputParameters
      17       14527 : SolutionInvalidityReporter::validParams()
      18             : {
      19       14527 :   InputParameters params = GeneralReporter::validParams();
      20       14527 :   params.addClassDescription("Reports the Summary Table of Solution Invalid Counts.");
      21       14527 :   return params;
      22           0 : }
      23             : 
      24         131 : SolutionInvalidityReporter::SolutionInvalidityReporter(const InputParameters & parameters)
      25         131 :   : GeneralReporter(parameters)
      26             : {
      27         131 :   declareValueByName<const SolutionInvalidity *>(
      28         131 :       "solution_invalidity", REPORTER_MODE_ROOT, &_app.solutionInvalidity());
      29         131 : }
      30             : 
      31             : void
      32          99 : to_json(nlohmann::json & json, const SolutionInvalidity * const & solution_invalidity)
      33             : {
      34             :   mooseAssert(solution_invalidity->processor_id() == 0, "should only be called on rank 0");
      35             : 
      36          99 :   const auto & solution_registry = moose::internal::getSolutionInvalidityRegistry();
      37          99 :   const auto & counts = solution_invalidity->counts();
      38          99 :   if (counts.size() == 0)
      39             :     // Create an empty array
      40          14 :     json = nlohmann::json::array();
      41             :   else
      42             :     // Output data to json
      43         234 :     for (const auto id : index_range(solution_invalidity->counts()))
      44             :     {
      45         149 :       nlohmann::json entry;
      46         149 :       entry["object_type"] = solution_registry.item(id).object_type;
      47         149 :       entry["message"] = solution_registry.item(id).message;
      48         149 :       entry["converged_counts"] = counts[id].current_counts;
      49         149 :       entry["timestep_counts"] = counts[id].current_timestep_counts;
      50         149 :       entry["total_counts"] = counts[id].total_counts;
      51         149 :       json.push_back(entry);
      52         149 :     }
      53          99 : }

Generated by: LCOV version 1.14