https://mooseframework.inl.gov
Loading...
Searching...
No Matches
VectorBodyForce.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 "VectorBodyForce.h"
11#include "Function.h"
12
14
17{
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
57Real
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 *
65 RealVectorValue(_function_x.value(_t, _q_point[_qp]),
68}
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:30
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:82
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was set by the user.
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 addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
unsigned int _qp
The current quadrature point index.
Definition KernelBase.h:43
const MooseArray< Point > & _q_point
The physical location of the element's quadrature Points, indexed by _qp.
Definition KernelBase.h:46
unsigned int _i
current index for the test function
Definition KernelBase.h:58
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
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 ...
Definition MooseBase.h:457
This kernel implements a generic functional body force term: $ - c \cdof \vec{f} \cdot \vec{\phi_i} $...
VectorBodyForce(const InputParameters &parameters)
const Function & _function_y
static InputParameters validParams()
virtual Real computeQpResidual() override
Compute this Kernel's contribution to the residual at the current quadrature point.
const Function & _function_z
const Function *const _function
Optional vectorValue function.
const PostprocessorValue & _postprocessor
Optional Postprocessor value.
const Function & _function_x
Optional component function value.
const Real & _scale
Scale factor.
const VectorVariableTestValue & _test
the current test function
static InputParameters validParams()