https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
33void
34to_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}
const ReporterMode REPORTER_MODE_ROOT
void to_json(nlohmann::json &json, const SolutionInvalidity *const &solution_invalidity)
registerMooseObject("MooseApp", SolutionInvalidityReporter)
A MultiMooseEnum object to hold "execute_on" flags.
Reporter object that has a single execution of the "execute" method for each execute flag.
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn't required or valid in the derived class...
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.
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition MooseApp.h:185
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
Reports the summary table of solution invalid warnings.
static InputParameters validParams()
SolutionInvalidityReporter(const InputParameters &parameters)
The SolutionInvalidity will contain all the information about the occurrence(s) of solution invalidit...
const std::vector< InvalidCounts > & counts() const
Access the private solution invalidity counts.
processor_id_type processor_id() const
SolutionInvalidityRegistry & getSolutionInvalidityRegistry()
Get the global SolutionInvalidityRegistry singleton.