https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FunctionIC.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 "FunctionIC.h"
11#include "Function.h"
12
14
17{
19 params.addRequiredParam<FunctionName>("function", "The initial condition function.");
20
21 params.addClassDescription("An initial condition that uses a normal function of x, y, z to "
22 "produce values (and optionally gradients) for a field variable.");
23 params.addParam<Real>("scaling_factor", 1, "Scaling factor to apply on the function");
24
25 return params;
26}
27
29 : InitialCondition(parameters),
30 _func(getFunction("function")),
31 _scaling(getParam<Real>("scaling_factor"))
32{
33}
34
35Real
36FunctionIC::value(const Point & p)
37{
38 return _scaling * _func.value(_t, p);
39}
40
41RealGradient
42FunctionIC::gradient(const Point & p)
43{
44 return _scaling * _func.gradient(_t, p);
45}
46
47const FunctionName
49{
50 return _func.name();
51}
registerMooseObject("MooseApp", FunctionIC)
Defines an initial condition that forces the value to be a user specified function.
Definition FunctionIC.h:18
const FunctionName functionName() const
Definition FunctionIC.C:48
const Function & _func
Function to evaluate to form the initial condition.
Definition FunctionIC.h:46
virtual RealGradient gradient(const Point &p) override
The value of the gradient at a point.
Definition FunctionIC.C:42
FunctionIC(const InputParameters &parameters)
Definition FunctionIC.C:28
static InputParameters validParams()
Definition FunctionIC.C:16
const Real _scaling
Scaling factor, to be able to use a function with multiple ICs.
Definition FunctionIC.h:49
virtual Real value(const Point &p) override
The value of the variable at a point.
Definition FunctionIC.C:36
virtual RealGradient gradient(Real t, const Point &p) const
Function objects can optionally provide a gradient at a point.
Definition Function.C:62
virtual Real value(Real t, const Point &p) const
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero,...
Definition Function.C:30
This is a template class that implements the workhorse compute and computeNodal methods.
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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.
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103