https://mooseframework.inl.gov
SolutionInvalidityReporter.C
Go to the documentation of this file.
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 
11 
12 #include "SolutionInvalidity.h"
13 
15 
18 {
20  params.addClassDescription("Reports the Summary Table of Solution Invalid Counts.");
21  return params;
22 }
23 
25  : GeneralReporter(parameters)
26 {
27  declareValueByName<const SolutionInvalidity *>(
28  "solution_invalidity", REPORTER_MODE_ROOT, &_app.solutionInvalidity());
29 }
30 
31 void
32 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  const auto & solution_registry = moose::internal::getSolutionInvalidityRegistry();
37  const auto & counts = solution_invalidity->counts();
38  if (counts.size() == 0)
39  // Create an empty array
40  json = nlohmann::json::array();
41  else
42  // Output data to json
43  for (const auto id : index_range(solution_invalidity->counts()))
44  {
45  nlohmann::json entry;
46  entry["object_type"] = solution_registry.item(id).object_type;
47  entry["message"] = solution_registry.item(id).message;
48  entry["converged_counts"] = counts[id].current_counts;
49  entry["timestep_counts"] = counts[id].current_timestep_counts;
50  entry["total_counts"] = counts[id].total_counts;
51  json.push_back(entry);
52  }
53 }
const std::vector< InvalidCounts > & counts() const
Access the private solution invalidity counts.
Reporter object that has a single execution of the "execute" method for for each execute flag...
const ReporterMode REPORTER_MODE_ROOT
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:167
registerMooseObject("MooseApp", SolutionInvalidityReporter)
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:84
The SolutionInvalidity will contain all the information about the occurrence(s) of solution invalidit...
SolutionInvalidityRegistry & getSolutionInvalidityRegistry()
Get the global SolutionInvalidityRegistry singleton.
Reports the summary table of solution invalid warnings.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void to_json(nlohmann::json &json, const SolutionInvalidity *const &solution_invalidity)
SolutionInvalidityReporter(const InputParameters &parameters)
processor_id_type processor_id() const
auto index_range(const T &sizable)
static InputParameters validParams()