www.mooseframework.org
BodyForce.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "BodyForce.h"
16 
17 // MOOSE
18 #include "Function.h"
19 
20 template <>
23 {
25  params.addClassDescription("Demonstrates the multiple ways that scalar values can be introduced "
26  "into kernels, e.g. (controllable) constants, functions, and "
27  "postprocessors. Implements the weak form $(\\psi_i, -f)$.");
28  params.addParam<Real>("value", 1.0, "Coefficent to multiply by the body force term");
29  params.addParam<FunctionName>("function", "1", "A function that describes the body force");
30  params.addParam<PostprocessorName>(
31  "postprocessor", 1, "A postprocessor whose value is multiplied by the body force");
32  params.declareControllable("value");
33  return params;
34 }
35 
37  : Kernel(parameters),
38  _scale(getParam<Real>("value")),
39  _function(getFunction("function")),
40  _postprocessor(getPostprocessorValue("postprocessor"))
41 {
42 }
43 
44 Real
46 {
47  Real factor = _scale * _postprocessor * _function.value(_t, _q_point[_qp]);
48  return _test[_i][_qp] * -factor;
49 }
virtual Real value(Real t, const Point &p)
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
Definition: Function.C:43
const VariableTestValue & _test
the current test function
Definition: KernelBase.h:152
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const PostprocessorValue & _postprocessor
Optional Postprocessor value.
Definition: BodyForce.h:50
unsigned int _i
current index for the test function
Definition: KernelBase.h:146
void declareControllable(const std::string &name)
Declare the given parameters as controllable.
InputParameters validParams< Kernel >()
Definition: Kernel.C:30
virtual Real computeQpResidual() override
Compute this Kernel&#39;s contribution to the residual at the current quadrature point.
Definition: BodyForce.C:45
const Real & _scale
Scale factor.
Definition: BodyForce.h:44
Definition: Kernel.h:25
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...
BodyForce(const InputParameters &parameters)
Definition: BodyForce.C:36
const MooseArray< Point > & _q_point
The physical location of the element&#39;s quadrature Points, indexed by _qp.
Definition: KernelBase.h:134
Function & _function
Optional function value.
Definition: BodyForce.h:47
unsigned int _qp
The current quadrature point index.
Definition: KernelBase.h:131
InputParameters validParams< BodyForce >()
Definition: BodyForce.C:22