www.mooseframework.org
Receiver.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "Receiver.h"
11 
12 registerMooseObject("MooseApp", Receiver);
13 
16 {
18  params.addParam<Real>("default", 0, "The default value");
19  params.addParam<bool>(
20  "initialize_old", true, "Initialize the old postprocessor value with the default value");
21 
22  params.addClassDescription("Reports the value stored in this processor, which is usually filled "
23  "in by another object. The Receiver does not compute its own value.");
24  return params;
25 }
26 
28  : GeneralPostprocessor(params),
29  _initialize_old(getParam<bool>("initialize_old")),
30  _my_value(getPostprocessorValueByName(name()))
31 {
32  const PostprocessorReporterName r_name(name());
33  auto & write_data = _fe_problem.getReporterData(ReporterData::WriteKey());
34 
35  // Request that we need the old and older time values for this Receiver
36  write_data.needReporterTimeIndex<PostprocessorValue>(r_name, 2);
37 
38  // Initialize values
39  const Real & value = getParam<Real>("default");
40  write_data.setReporterValue<PostprocessorValue>(r_name, value, 0);
41  if (_initialize_old)
42  {
43  write_data.setReporterValue<PostprocessorValue>(r_name, value, 1);
44  write_data.setReporterValue<PostprocessorValue>(r_name, value, 2);
45  }
46 }
47 
48 Real
50 {
51  // Return the stored value (references stored value in getPostprocessorData)
52  return _my_value;
53 }
std::string name(const ElemQuality q)
bool _initialize_old
Flag for initializing the old value.
Definition: Receiver.h:45
const PostprocessorValue & _my_value
Reference to the value being stored in the associated PostprocessorData class.
Definition: Receiver.h:48
void needReporterTimeIndex(const ReporterName &reporter_name, const std::size_t time_index)
Method for setting that a specific time index is requested for a Reporter value.
Definition: ReporterData.h:483
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:56
static InputParameters validParams()
const ReporterData & getReporterData() const
Provides const access the ReporterData object.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
static InputParameters validParams()
Definition: Receiver.C:15
Real PostprocessorValue
various MOOSE typedefs
Definition: MooseTypes.h:191
Receiver(const InputParameters &parameters)
Class constructor.
Definition: Receiver.C:27
A ReporterName that represents a Postprocessor.
Definition: ReporterName.h:134
registerMooseObject("MooseApp", Receiver)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Definition: UserObject.h:210
virtual Real getValue() const override
Returns the value stored in _my_value.
Definition: Receiver.C:49
A class for storing data, it allows the user to change the value of the postprocessor by altering the...
Definition: Receiver.h:18
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...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...