https://mooseframework.inl.gov
ParsedScalarReporter.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 "ParsedScalarReporter.h"
11 
12 registerMooseObject("OptimizationApp", ParsedScalarReporter);
13 
16 {
18  params.addRequiredParam<std::vector<ReporterName>>("reporter_names", "The input reporter names");
19  params.addClassDescription("Applies parsed functions to scalar entries held in reporters.");
20  return params;
21 }
22 
24  : ParsedReporterBase(parameters),
25  _output_reporter(declareValueByName<Real>(getParam<std::string>("name"), REPORTER_MODE_ROOT))
26 {
27  // get reporters to operate on
28  const std::vector<ReporterName> reporter_names(
29  getParam<std::vector<ReporterName>>("reporter_names"));
30  if (reporter_names.size() != _reporter_symbols.size())
31  paramError(
32  "reporter_names",
33  "reporter_names and reporter_symbols must be the same size: Number of reporter_names=",
34  reporter_names.size(),
35  "; Number of reporter_symbols=",
36  _reporter_symbols.size());
37 
38  _reporter_data.resize(reporter_names.size());
39  for (const auto rep_index : index_range(_reporter_data))
40  _reporter_data[rep_index] =
41  &getReporterValueByName<Real>(reporter_names[rep_index], REPORTER_MODE_ROOT);
42 }
43 
44 void
46 {
47  for (const auto i : index_range(_reporter_data))
48  _func_params[i] = *(_reporter_data[i]);
49 
50  if (_use_t)
51  _func_params[_reporter_data.size()] = _t;
52 
54 }
GenericReal< is_ad > evaluate(SymFunctionPtr &, const std::string &object_name="")
const ReporterMode REPORTER_MODE_ROOT
Reporter containing operation between vectors from another Reporter.
SymFunctionPtr _func_F
function parser object
void addRequiredParam(const std::string &name, const std::string &doc_string)
std::vector< const Real * > _reporter_data
Input reporter values.
const T & getParam(const std::string &name) const
static InputParameters validParams()
const std::vector< std::string > _reporter_symbols
Get symbols to corresponding reporter names need symbols because reporter names have a "/" and that w...
void paramError(const std::string &param, Args... args) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< GenericReal< is_ad > > _func_params
const bool _use_t
whether time is part of the parsed expression
ParsedScalarReporter(const InputParameters &parameters)
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)
Reporter containing operation between vectors from another Reporter.
registerMooseObject("OptimizationApp", ParsedScalarReporter)
virtual void finalize() override
auto index_range(const T &sizable)
Real & _output_reporter
output scalar