www.mooseframework.org
BodyForce.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 "BodyForce.h"
11 
12 // MOOSE
13 #include "Function.h"
14 
15 registerMooseObject("MooseApp", BodyForce);
16 
17 template <>
20 {
22  params.addClassDescription("Demonstrates the multiple ways that scalar values can be introduced "
23  "into kernels, e.g. (controllable) constants, functions, and "
24  "postprocessors. Implements the weak form $(\\psi_i, -f)$.");
25  params.addParam<Real>("value", 1.0, "Coefficient to multiply by the body force term");
26  params.addParam<FunctionName>("function", "1", "A function that describes the body force");
27  params.addParam<PostprocessorName>(
28  "postprocessor", 1, "A postprocessor whose value is multiplied by the body force");
29  params.declareControllable("value");
30  return params;
31 }
32 
34  : Kernel(parameters),
35  _scale(getParam<Real>("value")),
36  _function(getFunction("function")),
37  _postprocessor(getPostprocessorValue("postprocessor"))
38 {
39 }
40 
41 Real
43 {
44  Real factor = _scale * _postprocessor * _function.value(_t, _q_point[_qp]);
45  return _test[_i][_qp] * -factor;
46 }
This kernel implements a generic functional body force term: $ - c f $.
Definition: BodyForce.h:29
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:38
registerMooseObject("MooseApp", BodyForce)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const PostprocessorValue & _postprocessor
Optional Postprocessor value.
Definition: BodyForce.h:44
const VariableTestValue & _test
the current test function
Definition: Kernel.h:57
unsigned int _i
current index for the test function
Definition: KernelBase.h:165
InputParameters validParams< Kernel >()
Definition: Kernel.C:24
virtual Real computeQpResidual() override
Compute this Kernel&#39;s contribution to the residual at the current quadrature point.
Definition: BodyForce.C:42
const Real & _scale
Scale factor.
Definition: BodyForce.h:38
Definition: Kernel.h:20
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:33
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
const MooseArray< Point > & _q_point
The physical location of the element&#39;s quadrature Points, indexed by _qp.
Definition: KernelBase.h:153
Function & _function
Optional function value.
Definition: BodyForce.h:41
unsigned int _qp
The current quadrature point index.
Definition: KernelBase.h:150
InputParameters validParams< BodyForce >()
Definition: BodyForce.C:19