https://mooseframework.inl.gov
ChainControlDataPostprocessor.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 
11 #include "MooseApp.h"
12 #include "ChainControlDataSystem.h"
13 
15 
18 {
20 
21  params.addClassDescription("Gets a Real or bool chain control value.");
22 
23  params.addRequiredParam<std::string>("chain_control_data_name", "Chain control data name");
24  return params;
25 }
26 
28  : GeneralPostprocessor(parameters),
29  _data_name(getParam<std::string>("chain_control_data_name")),
30  _real_data(nullptr),
31  _bool_data(nullptr)
32 {
33 }
34 
35 void
37 {
38  auto & chain_control_system = getMooseApp().getChainControlDataSystem();
39  if (chain_control_system.hasChainControlData(_data_name))
40  {
41  if (chain_control_system.hasChainControlDataOfType<Real>(_data_name))
42  _real_data = &chain_control_system.getChainControlData<Real>(_data_name);
43  else if (chain_control_system.hasChainControlDataOfType<bool>(_data_name))
44  _bool_data = &chain_control_system.getChainControlData<bool>(_data_name);
45  else
46  mooseError(
47  "The chain control data '", _data_name, "' exists but is not of type 'Real' or 'bool'.");
48  }
49  else
50  mooseError("The chain control data '", _data_name, "' does not exist.");
51 }
52 
53 void
55 {
56 }
57 
58 void
60 {
61 }
62 
63 Real
65 {
66  if (_real_data)
67  return _real_data->get();
68  else
69  {
70  mooseAssert(_bool_data, "This point should not be reachable.");
71 
72  // for booleans, 'true' should convert to 1.0 and 'false' to 0.0.
73  return _bool_data->get();
74  }
75 }
const T & get() const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void execute() override
Execute method.
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
Definition: MooseBase.h:45
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...
ChainControlDataPostprocessor(const InputParameters &parameters)
static InputParameters validParams()
const ChainControlData< Real > * _real_data
Chain control data if it has type &#39;Real&#39;.
const std::string & _data_name
Chain control data name.
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
registerMooseObject("MooseApp", ChainControlDataPostprocessor)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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...
ChainControlDataSystem & getChainControlDataSystem()
Gets the system that manages the ChainControls.
Definition: MooseApp.h:868
Gets a Real or bool chain control value.
const ChainControlData< bool > * _bool_data
Chain control data if it has type &#39;bool&#39;.
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.