https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
14
17{
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
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}
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("MooseApp", FVBodyForce)
This kernel implements a generic functional body force term: $ - c \cdof f$.
Definition FVBodyForce.h:22
ADReal computeQpResidual() override
This is the primary function that must be implemented for flux kernel terms.
Definition FVBodyForce.C:40
FVBodyForce(const InputParameters &parameters)
Definition FVBodyForce.C:31
const Function & _function
Optional function value.
Definition FVBodyForce.h:35
const PostprocessorValue & _postprocessor
Optional Postprocessor value.
Definition FVBodyForce.h:38
const Real & _scale
Scale factor.
Definition FVBodyForce.h:32
static InputParameters validParams()
Definition FVBodyForce.C:16
FVElemental is used for calculating residual contributions from volume integral terms of a PDE where ...
static InputParameters validParams()
const Elem *const & _current_elem
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
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.
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.