https://mooseframework.inl.gov
Loading...
Searching...
No Matches
BodyForce.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 "BodyForce.h"
11
12// MOOSE
13#include "Function.h"
14#include "Assembly.h"
15
18
19template <bool is_ad>
22{
24 params.addClassDescription("Demonstrates the multiple ways that scalar values can be introduced "
25 "into kernels, e.g. (controllable) constants, functions, and "
26 "postprocessors. Implements the weak form $(\\psi_i, -f)$.");
27 params.addParam<Real>("value", 1.0, "Coefficient to multiply by the body force term");
28 params.addParam<FunctionName>("function", "1", "A function that describes the body force");
29 params.addParam<PostprocessorName>(
30 "postprocessor", 1, "A postprocessor whose value is multiplied by the body force");
31 params.declareControllable("value");
32 return params;
33}
34
35template <bool is_ad>
37 : GenericKernel<is_ad>(parameters),
38 _scale(this->template getParam<Real>("value")),
39 _function(getFunction("function")),
40 _postprocessor(getPostprocessorValue("postprocessor")),
41 _generic_q_point(this->_use_displaced_mesh ? &this->_assembly.template genericQPoints<is_ad>()
42 : nullptr)
43{
44}
45
46template <bool is_ad>
49{
50 if (_generic_q_point)
51 return -_test[_i][_qp] * _scale * _postprocessor *
52 _function.value(_t, (*_generic_q_point)[_qp]);
53 else
54 return -_test[_i][_qp] * _scale * _postprocessor * _function.value(_t, _q_point[_qp]);
55}
56
57template class BodyForceTempl<false>;
58template class BodyForceTempl<true>;
registerMooseObject("MooseApp", BodyForce)
Moose::GenericType< Real, is_ad > GenericReal
Definition MooseTypes.h:698
This kernel implements a generic functional body force term: $ - c \cdof f \cdot \phi_i $.
Definition BodyForce.h:26
virtual GenericReal< is_ad > computeQpResidual() override
Compute this Kernel's contribution to the residual at the current quadrature point.
Definition BodyForce.C:48
static InputParameters validParams()
Definition BodyForce.C:21
BodyForceTempl(const InputParameters &parameters)
Definition BodyForce.C:36
static InputParameters validParams()
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.
virtual const OutputTools< T >::VariableValue & value()
The value of the variable this object is operating on.