https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SmootherControl.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 "SmootherControl.h"
11
12registerMooseObject("ThermalHydraulicsApp", SmootherControl);
13
16{
18 params.addRequiredParam<std::string>("input", "Control data value to smooth.");
19 params.addRequiredParam<unsigned int>("n_points",
20 "The number of points to use in the moving average.");
21 params.addClassDescription("Computes a moving average value of the input control "
22 "with a user-specified number of points to average. "
23 "The output control value is named 'name:value', "
24 "where 'name' is the name of the control object.");
25 return params;
26}
27
29 : THMControl(parameters),
30 _input(getControlData<Real>("input")),
31 _n_points(getParam<unsigned int>("n_points")),
32 _output(declareComponentControlData<Real>("value")),
33 _values(declareRestartableData<std::vector<Real>>("values"))
34{
35}
36
37void
39{
41 {
42 if (_values.size() == _n_points)
43 _values.erase(_values.begin());
44
45 _values.push_back(_input);
46
47 _output = std::accumulate(_values.begin(), _values.end(), 0.0) / _values.size();
48 }
49}
const ExecFlagType EXEC_TIMESTEP_BEGIN
registerMooseObject("ThermalHydraulicsApp", SmootherControl)
void ErrorVector unsigned int
FEProblemBase & _fe_problem
const ExecFlagType & getCurrentExecuteOnFlag() const
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
Computes a moving average value of the input control with a user-specified number of points to averag...
const unsigned int _n_points
The number of points to use in the moving average.
Real & _output
Output control value.
std::vector< Real > & _values
Vector to store values.
static InputParameters validParams()
SmootherControl(const InputParameters &parameters)
virtual void execute()
const Real & _input
Input data.
static InputParameters validParams()
Definition THMControl.C:13