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  // This reporter is simply executed on JSON output
22  params.suppressParameter<ExecFlagEnum>("execute_on");
23  return params;
24 }
25 
27  : GeneralReporter(parameters)
28 {
29  declareValueByName<const SolutionInvalidity *>(
30  "solution_invalidity", REPORTER_MODE_ROOT, &_app.solutionInvalidity());
31 }
32 
33 void
34 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  const auto & solution_registry = moose::internal::getSolutionInvalidityRegistry();
39  const auto & counts = solution_invalidity->counts();
40  if (counts.size() == 0)
41  // Create an empty array
42  json = nlohmann::json::array();
43  else
44  // Output data to json
45  for (const auto id : index_range(solution_invalidity->counts()))
46  {
47  nlohmann::json entry;
48  entry["object_type"] = solution_registry.item(id).object_type;
49  entry["message"] = solution_registry.item(id).message;
50  entry["timestep_counts"] = counts[id].current_timestep_counts;
51  entry["total_counts"] = counts[id].total_counts;
52  json.push_back(entry);
53  }
54 }
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
const std::vector< InvalidCounts > & counts() const
Access the private solution invalidity counts.
Reporter object that has a single execution of the "execute" method 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()
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn&#39;t required or valid in the derived class...
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:184
registerMooseObject("MooseApp", SolutionInvalidityReporter)
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:385
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()