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 
14 template <>
17 {
19  params.addParam<Real>("default", "The default value");
20  params.addParam<bool>(
21  "initialize_old", true, "Initialize the old postprocessor value with the default value");
22  return params;
23 }
24 
26  : GeneralPostprocessor(params),
27  _initialize_old(getParam<bool>("initialize_old")),
28  _my_value(_fe_problem.getPostprocessorValue(_pp_name))
29 {
30 }
31 
32 Real
34 {
35  // Return the stored value (references stored value in getPostprocessorData)
36  return _my_value;
37 }
38 
39 void
41 {
42  if (isParamValid("default"))
43  {
44  Real value = getParam<Real>("default");
46  if (_initialize_old)
47  {
50  }
51  }
52 }
virtual void initialSetup() override
Initial setup function for applying the default value.
Definition: Receiver.C:40
bool _initialize_old
Flag for initializing the old value.
Definition: Receiver.h:54
const PostprocessorValue & _my_value
Reference to the value being stored in the associated PostprocessorData class.
Definition: Receiver.h:57
PostprocessorValue & getPostprocessorValueOld(const std::string &name)
Get the reference to the old value of a post-processor.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< GeneralPostprocessor >()
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
PostprocessorValue & getPostprocessorValueOlder(const std::string &name)
Get the reference to the older value of a post-processor.
Receiver(const InputParameters &parameters)
Class constructor.
Definition: Receiver.C:25
registerMooseObject("MooseApp", Receiver)
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Definition: UserObject.h:141
std::string _pp_name
Definition: Postprocessor.h:45
InputParameters validParams< Receiver >()
Definition: Receiver.C:16
A class for storing data, it allows the user to change the value of the postprocessor by altering the...
Definition: Receiver.h:24
virtual Real getValue() override
Returns the value stored in _my_value.
Definition: Receiver.C:33
PostprocessorValue & getPostprocessorValue(const PostprocessorName &name)
Get a reference to the value associated with the postprocessor.
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...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseObject.h:89