https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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"
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
35void
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
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
53void
57
58void
62
63Real
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}
registerMooseObject("MooseApp", ChainControlDataPostprocessor)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
Gets a Real or bool chain control value.
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.
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.
ChainControlDataPostprocessor(const InputParameters &parameters)
virtual void execute() override
Execute method.
const ChainControlData< bool > * _bool_data
Chain control data if it has type 'bool'.
const ChainControlData< Real > * _real_data
Chain control data if it has type 'Real'.
const T & get() const
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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...
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:891
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
Definition MooseBase.h:87