Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
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 
28 ReporterTimes::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 
36 void
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 }
ReporterTimes(const InputParameters &parameters)
Definition: ReporterTimes.C:28
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Times objects are under the hood Reporters, but limited to a vector of Real.
Definition: Times.h:18
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void clearTimes()
Clear the times vector.
Definition: Times.C:111
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...
static InputParameters validParams()
Definition: Times.C:14
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
const ReporterMode REPORTER_MODE_DISTRIBUTED
Times from a Reporter.
Definition: ReporterTimes.h:18
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Definition: UserObject.h:211
static InputParameters validParams()
Definition: ReporterTimes.C:15
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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...
virtual void finalize() override
In charge of reduction across all ranks.
Definition: Times.C:117
registerMooseObject("MooseApp", ReporterTimes)
auto index_range(const T &sizable)
std::vector< Real > & _times
The vector holding the times.
Definition: Times.h:72
virtual void initialize() override
In charge of computing / loading the times, unless all that could be done there is done in the constr...
Definition: ReporterTimes.C:37