https://mooseframework.inl.gov
FVBodyForce.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 "FVBodyForce.h"
11 #include "Function.h"
12 
13 registerMooseObject("MooseApp", FVBodyForce);
14 
17 {
19  params.addClassDescription(
20  "Demonstrates the multiple ways that scalar values can be introduced "
21  "into finite volume kernels, e.g. (controllable) constants, functions, and "
22  "postprocessors.");
23  params.addParam<Real>("value", 1.0, "Coefficient to multiply by the body force term");
24  params.addParam<FunctionName>("function", "1", "A function that describes the body force");
25  params.addParam<PostprocessorName>(
26  "postprocessor", 1, "A postprocessor whose value is multiplied by the body force");
27  params.declareControllable("value");
28  return params;
29 }
30 
32  : FVElementalKernel(parameters),
33  _scale(getParam<Real>("value")),
34  _function(getFunction("function")),
35  _postprocessor(getPostprocessorValue("postprocessor"))
36 {
37 }
38 
39 ADReal
41 {
42  // FVKernels are not evaluated at quadrature points like our finite element kernels.
43  // computeQpResidual is currrently only called once per element. With that in mind we'll just read
44  // our function at the element centroid
45  Real factor = _scale * _postprocessor * _function.value(_t, _current_elem->vertex_average());
46  return -factor;
47 }
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
ADReal computeQpResidual() override
This is the primary function that must be implemented for flux kernel terms.
Definition: FVBodyForce.C:40
registerMooseObject("MooseApp", FVBodyForce)
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:47
FVBodyForce(const InputParameters &parameters)
Definition: FVBodyForce.C:31
const PostprocessorValue & _postprocessor
Optional Postprocessor value.
Definition: FVBodyForce.h:38
FVElemental is used for calculating residual contributions from volume integral terms of a PDE where ...
const Elem *const & _current_elem
This kernel implements a generic functional body force term: $ - c f$.
Definition: FVBodyForce.h:21
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
Definition: FVBodyForce.C:16
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 optional 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:44
const Real & _scale
Scale factor.
Definition: FVBodyForce.h:32
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
const Function & _function
Optional function value.
Definition: FVBodyForce.h:35