LCOV - code coverage report
Current view: top level - src/reporters - SolutionInvalidityReporter.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 24 25 96.0 %
Date: 2026-05-29 20:35:17 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        3301 : SolutionInvalidityReporter::validParams()
      18             : {
      19        3301 :   InputParameters params = GeneralReporter::validParams();
      20        6602 :   params.addClassDescription("Reports the Summary Table of Solution Invalid Counts.");
      21             :   // This reporter is simply executed on JSON output
      22        3301 :   params.suppressParameter<ExecFlagEnum>("execute_on");
      23        3301 :   return params;
      24           0 : }
      25             : 
      26         120 : SolutionInvalidityReporter::SolutionInvalidityReporter(const InputParameters & parameters)
      27         120 :   : GeneralReporter(parameters)
      28             : {
      29         120 :   declareValueByName<const SolutionInvalidity *>(
      30         120 :       "solution_invalidity", REPORTER_MODE_ROOT, &_app.solutionInvalidity());
      31         120 : }
      32             : 
      33             : void
      34          89 : to_json(nlohmann::json & json, const SolutionInvalidity * const & solution_invalidity)
      35             : {
      36             :   mooseAssert(solution_invalidity->processor_id() == 0, "should only be called on rank 0");
      37             : 
      38          89 :   const auto & solution_registry = moose::internal::getSolutionInvalidityRegistry();
      39          89 :   const auto & counts = solution_invalidity->counts();
      40          89 :   if (counts.size() == 0)
      41             :     // Create an empty array
      42          12 :     json = nlohmann::json::array();
      43             :   else
      44             :     // Output data to json
      45         225 :     for (const auto id : index_range(solution_invalidity->counts()))
      46             :     {
      47         148 :       nlohmann::json entry;
      48         148 :       entry["object_type"] = solution_registry.item(id).object_type;
      49         148 :       entry["message"] = solution_registry.item(id).message;
      50         148 :       entry["timestep_counts"] = counts[id].current_timestep_counts;
      51         148 :       entry["total_counts"] = counts[id].total_counts;
      52         148 :       json.push_back(entry);
      53         148 :     }
      54          89 : }

Generated by: LCOV version 1.14