https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ReporterTimes.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
10#include "ReporterTimes.h"
11
13
16{
18 params.addRequiredParam<std::vector<ReporterName>>("reporters",
19 "Reporter(s) containing the times.");
20
21 // User reporter broadcasting behavior
22 params.set<bool>("auto_broadcast") = false;
23
24 params.addClassDescription("Import times from one or more reporters, for example other Times");
25 return params;
26}
27
28ReporterTimes::ReporterTimes(const InputParameters & parameters) : Times(parameters)
29{
30 // Attempt to obtain the positions. Will only succeed for other Times at this point
31 initialize();
32 // Broadcast if needed
33 finalize();
34}
35
36void
38{
39 clearTimes();
40
41 const auto & positions_reporters = getParam<std::vector<ReporterName>>("reporters");
42
43 for (const auto r_it : index_range(positions_reporters))
44 {
45 const auto & reporter_name = positions_reporters[r_it];
46
47 const auto & reporter_data = _fe_problem.getReporterData();
48 if (reporter_data.getReporterContextBase(reporter_name).getProducerModeEnum() ==
50 mooseError("Distributed reporter not implemented yet");
51 const auto & data = reporter_data.getReporterValue<std::vector<Real>>(reporter_name);
52
53 for (const auto & d : data)
54 {
55 _times.push_back(d);
56 }
57 }
58}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const ReporterMode REPORTER_MODE_DISTRIBUTED
registerMooseObject("MooseApp", ReporterTimes)
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
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.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
const T & getReporterValue(const ReporterName &reporter_name, const MooseObject &consumer, const ReporterMode &mode, const std::size_t time_index=0) const
Method for returning read only references to Reporter values.
Times from a Reporter.
virtual void initialize() override
In charge of computing / loading the times, unless all that could be done there is done in the constr...
ReporterTimes(const InputParameters &parameters)
static InputParameters validParams()
Times objects are under the hood Reporters, but limited to a vector of Real.
Definition Times.h:19
void clearTimes()
Clear the times vector.
Definition Times.C:118
static InputParameters validParams()
Definition Times.C:14
virtual void finalize() override
In charge of reduction across all ranks.
Definition Times.C:124
std::vector< Real > & _times
The vector holding the times.
Definition Times.h:74
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.