www.mooseframework.org
FunctionIC.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
13 registerMooseObject("MooseApp", FunctionIC);
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 
35 Real
36 FunctionIC::value(const Point & p)
37 {
38  return _scaling * _func.value(_t, p);
39 }
40 
42 FunctionIC::gradient(const Point & p)
43 {
44  return _scaling * _func.gradient(_t, p);
45 }
46 
47 const FunctionName
49 {
50  return _func.name();
51 }
Defines a boundary condition that forces the value to be a user specified function at the boundary...
Definition: FunctionIC.h:26
virtual RealGradient gradient(const Point &p) override
The value of the gradient at a point.
Definition: FunctionIC.C:42
registerMooseObject("MooseApp", FunctionIC)
This is a template class that implements the workhorse compute and computeNodal methods.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
const Function & _func
Function to evaluate to form the initial condition.
Definition: FunctionIC.h:55
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:56
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...
const Real _scaling
Scaling factor, to be able to use a function with multiple ICs.
Definition: FunctionIC.h:58
const FunctionName functionName() const
Definition: FunctionIC.C:48
virtual Real value(const Point &p) override
The value of the variable at a point.
Definition: FunctionIC.C:36
static InputParameters validParams()
Definition: FunctionIC.C:16
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FunctionIC(const InputParameters &parameters)
Definition: FunctionIC.C:28
virtual RealGradient gradient(Real t, const Point &p) const
Function objects can optionally provide a gradient at a point.
Definition: Function.C:73
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 option parameter and a documentation string to the InputParameters object...
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:41