29 "use_legacy_reporter_output",
false,
"Use reporter output that does not group by object.");
30 params.
addParam<
bool>(
"one_file_per_timestep",
32 "Create a unique output file for each time step of the simulation.");
33 params.
addParam<std::vector<ReporterName>>(
34 "reporters",
"Specific reporter values to output; if not set, all will be output");
36 "distributed",
true,
"Whether or not to output distributed data (data not on rank 0)");
42 _reporter_data(_problem_ptr->getReporterData()),
43 _one_file_per_timestep(getParam<bool>(
"one_file_per_timestep")),
45 _json(declareRestartableData<
nlohmann::json>(
"json_out_str"))
55 paramError(
"reporters",
"Reporter value '",
name,
"' was not found");
61 std::ostringstream file_name;
65 file_name <<
'_' << std::setw(
_padding) << std::setprecision(0) << std::setfill(
'0')
72 <<
"." << std::setw(digits) << std::setfill(
'0') <<
processor_id();
77 return file_name.str();
100 std::set<ReporterName> skip_names;
102 if (common_actions.size())
104 mooseAssert(common_actions.size() == 1,
"Should not be more than one");
105 const auto & action = *common_actions[0];
107 skip_names.insert(common_names.begin(), common_names.end());
111 std::set<ReporterName> r_names;
123 else if (skip_names.count(r_name))
126 r_names.emplace(r_name);
131 std::any_of(r_names.begin(),
140 auto & current_node =
_json[
"time_steps"].emplace_back();
158 auto & r_node =
_json[
"reporters"];
159 for (
const auto & r_name : r_names)
167 auto obj_node_pair = r_node.emplace(r_name.getObjectName(), nlohmann::json());
168 auto & obj_node = *(obj_node_pair.first);
171 bool should_store =
true;
174 if (obj_node_pair.second)
181 std::vector<Reporter *> objs;
185 .condition<AttribName>(r_name.getObjectName())
194 auto & reporter = *objs.front();
198 reporter.store(obj_node);
202 should_store = reporter.shouldStore();
207 auto value_node_pair = obj_node[
"values"].emplace(r_name.getValueName(), nlohmann::json());
209 if (value_node_pair.second)
211 context.storeInfo(*value_node_pair.first);
214 auto & node = current_node[r_name.getObjectName()][r_name.getValueName()];
231 out << std::setw(4) <<
_json << std::endl;
237 dataStore(std::ostream & stream, nlohmann::json & json,
void * )
244 dataLoad(std::istream & stream, nlohmann::json & json,
void * )
virtual void outputSystemInformation() override
A MultiMooseEnum object to hold "execute_on" flags.
virtual Real & time() const
const ReporterMode REPORTER_MODE_ROOT
const bool _one_file_per_timestep
Flag to create a file for each time step.
const ReporterData & _reporter_data
std::string _file_base
The base filename from the input paramaters.
virtual void output()
A single call to this function should output all the necessary data for a single timestep.
bool _on_nonlinear_residual
True if current output call is on the non-linear residual (used by time())
registerMooseObjectAliased("MooseApp", JSONOutput, "JSON")
virtual const std::string & name() const
Get the name of the class.
void dataLoad(std::istream &stream, nlohmann::json &json, void *)
bool _has_distributed
True when distributed data exists for output.
unsigned int _padding
Number of digits to pad the extensions.
const std::set< std::string > & getReporterOutput()
The list of Reporter names that are set for output.
processor_id_type n_processors() const
virtual void timestepSetup() override
Gets called at the beginning of the timestep before this object is asked to do its job...
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
PetscInt _linear_iter
Current linear iteration returned from PETSc.
virtual void timestepSetup()
Gets called at the beginning of the timestep before this object is asked to do its job...
TheWarehouse & theWarehouse() const
std::size_t queryID(const std::vector< std::unique_ptr< Attribute >> &conds)
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
void dataStore(std::ostream &stream, nlohmann::json &json, void *)
static InputParameters validParams()
ActionWarehouse & actionWarehouse()
Return a writable reference to the ActionWarehouse associated with this app.
const std::vector< ReporterName > *const _reporters
The names of the specific reporters to output (if any)
MooseApp & _app
The MOOSE application this is associated with.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
bool isValueSet(const std::string &value) const
Methods for seeing if a value is set in the MultiMooseEnum.
const ReporterMode REPORTER_MODE_DISTRIBUTED
virtual void outputReporters() override
Output Reporter values.
static InputParameters enableOutputTypes(const std::string &names=std::string())
A method for enabling individual output type control.
const ExecFlagType EXEC_LINEAR
virtual void initialSetup() override
Call init() method on setup.
virtual int & timeStep() const
const ExecFlagEnum & _execute_enum
Execute settings for this object.
Based class for output objects.
const ExecFlagType EXEC_NONLINEAR
int numDigits(const T &num)
Return the number of digits for a number.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
void to_json(nlohmann::json &json, const Moose::LibtorchArtificialNeuralNet *const &network)
const std::vector< ReporterName > & getCommonReporterNames() const
Get the specific reporter names that we do not want to include in general JSON output.
nlohmann::json & _json
The root JSON node for output.
bool hasReporterValue(const ReporterName &reporter_name) const
Return True if a Reporter value with the given type and name have been created.
std::vector< T * > & queryInto(const std::vector< std::unique_ptr< Attribute >> &conds, std::vector< T *> &results)
queryInto takes the given conditions (i.e.
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
JSONOutput(const InputParameters ¶meters)
virtual std::string filename() override
The filename for the output file.
bool hasReporterWithMode(const std::string &obj_name, const ReporterMode &mode) const
Return true if the supplied mode exists in the produced Reporter values.
static InputParameters validParams()
virtual int timeStep()
Get the current time step.
std::vector< const T * > getActions()
Retrieve all actions in a specific type ordered by their names.
processor_id_type processor_id() const
virtual void output() override
A single call to this function should output all the necessary data for a single timestep.
The Reporter system is comprised of objects that can contain any number of data values.
Meta-action for creating common output object parameters This action serves two purpose, first it adds common output object parameters.
PetscInt _nonlinear_iter
Current non-linear iteration returned from PETSc.
const ReporterContextBase & getReporterContextBase(const ReporterName &reporter_name) const
const ExecFlagType EXEC_INITIAL