www.mooseframework.org
VectorBodyForce.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 "VectorBodyForce.h"
11 #include "Function.h"
12 
14 
17 {
19  params.addClassDescription(
20  "Demonstrates the multiple ways that scalar values can be introduced "
21  "into kernels, e.g. (controllable) constants, functions, and "
22  "postprocessors. Implements the weak form $(\\vec{\\psi_i}, -\\vec{f})$.");
23  params.addParam<Real>("value", 1.0, "Coefficient to multiply by the body force term");
24  params.addParam<FunctionName>("function",
25  "A function that defines a vectorValue method. This cannot be "
26  "supplied with the component parameters.");
27  params.addParam<FunctionName>(
28  "function_x", "1", "A function that describes the x-component of the body force");
29  params.addParam<FunctionName>(
30  "function_y", "0", "A function that describes the y-component of the body force");
31  params.addParam<FunctionName>(
32  "function_z", "0", "A function that describes the z-component of the body force");
33  params.addParam<PostprocessorName>(
34  "postprocessor", 1, "A postprocessor whose value is multiplied by the body force");
35  params.declareControllable("value");
36  return params;
37 }
38 
40  : VectorKernel(parameters),
41  _scale(getParam<Real>("value")),
42  _function(isParamValid("function") ? &getFunction("function") : nullptr),
43  _function_x(getFunction("function_x")),
44  _function_y(getFunction("function_y")),
45  _function_z(getFunction("function_z")),
46  _postprocessor(getPostprocessorValue("postprocessor"))
47 {
48 
49  if (_function && parameters.isParamSetByUser("function_x"))
50  paramError("function_x", "The 'function' and 'function_x' parameters cannot both be set.");
51  if (_function && parameters.isParamSetByUser("function_y"))
52  paramError("function_y", "The 'function' and 'function_y' parameters cannot both be set.");
53  if (_function && parameters.isParamSetByUser("function_z"))
54  paramError("function_z", "The 'function' and 'function_z' parameters cannot both be set.");
55 }
56 
57 Real
59 {
60  Real factor = _scale * _postprocessor;
61  if (_function)
62  return _test[_i][_qp] * -factor * _function->vectorValue(_t, _q_point[_qp]);
63  else
64  return _test[_i][_qp] * -factor *
68 }
const Function & _function_x
Optional component function value.
const VectorVariableTestValue & _test
the current test function
Definition: VectorKernel.h:65
const Function *const _function
Optional vectorValue function.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual Real computeQpResidual() override
Compute this Kernel&#39;s contribution to the residual at the current quadrature point.
const Function & _function_y
unsigned int _i
current index for the test function
Definition: KernelBase.h:57
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
VectorBodyForce(const InputParameters &parameters)
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was by the user.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
Definition: VectorKernel.C:21
virtual RealVectorValue vectorValue(Real t, const Point &p) const
Override this to evaluate the vector function at a point (t,x,y,z), by default this returns a zero ve...
Definition: Function.C:87
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 InputParameters & parameters() const
Get the parameters of the object.
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...
This kernel implements a generic functional body force term: $ - c {f} {} $.
registerMooseObject("MooseApp", VectorBodyForce)
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
const PostprocessorValue & _postprocessor
Optional Postprocessor value.
const Function & _function_z
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
const Real & _scale
Scale factor.
const MooseArray< Point > & _q_point
The physical location of the element&#39;s quadrature Points, indexed by _qp.
Definition: KernelBase.h:45
static InputParameters validParams()
unsigned int _qp
The current quadrature point index.
Definition: KernelBase.h:42