https://mooseframework.inl.gov
ConstantFunction.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 "ConstantFunction.h"
11 
13 
16 {
18  params.addClassDescription(
19  "A function that returns a constant value as defined by an input parameter.");
20  params.addParam<Real>("value", 0.0, "The constant value");
21  params.declareControllable("value");
22  return params;
23 }
24 
26  : Function(parameters), _value(getParam<Real>("value"))
27 {
28 }
29 
30 Real
31 ConstantFunction::value(Real, const Point &) const
32 {
33  return _value;
34 }
35 
36 ADReal
37 ConstantFunction::value(const ADReal &, const ADPoint &) const
38 {
39  return _value;
40 }
41 
42 Real
43 ConstantFunction::timeDerivative(Real /*t*/, const Point & /*p*/) const
44 {
45  return 0;
46 }
47 
49 ConstantFunction::gradient(Real /*t*/, const Point & /*p*/) const
50 {
51  return RealVectorValue(0);
52 }
53 
54 Real
55 ConstantFunction::timeIntegral(Real t1, Real t2, const Point & /*p*/) const
56 {
57  return _value * (t2 - t1);
58 }
const Real & _value
Class that represents constant function.
virtual Real timeIntegral(Real t1, Real t2, const Point &p) const override
Computes the time integral at a spatial point between two time values.
Base class for function objects.
Definition: Function.h:36
virtual Real value(Real t, const Point &p) const override
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
ConstantFunction(const InputParameters &parameters)
virtual Real timeDerivative(Real t, const Point &p) const override
Get the time derivative of the function.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:47
registerMooseObject("MooseApp", ConstantFunction)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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 optional parameter and a documentation string to the InputParameters object...
static InputParameters validParams()
static InputParameters validParams()
Class constructor.
Definition: Function.C:16
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
virtual RealVectorValue gradient(Real t, const Point &p) const override
Function objects can optionally provide a gradient at a point.