https://mooseframework.inl.gov
MatBodyForce.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 "MatBodyForce.h"
11 
14 
15 template <bool is_ad, class Parent>
18 {
20  params.addClassDescription("Kernel that defines a body force modified by a material property");
21  params.addRequiredParam<MaterialPropertyName>("material_property",
22  "Material property defining the body force");
23  return params;
24 }
25 
26 template <bool is_ad, class Parent>
28  : Parent(parameters),
29  _property(this->template getGenericMaterialProperty<Real, is_ad>("material_property"))
30 {
31 }
32 
33 template <bool is_ad, class Parent>
36 {
37  return Parent::computeQpResidual() * _property[_qp];
38 }
39 
41  : MatBodyForceParent(parameters),
42  _dpropertydv(getMaterialPropertyDerivative<Real>("material_property", _var.name())),
43  _dpropertydarg(_n_args)
44 {
45  // Get derivatives of property wrt coupled variables
46  for (unsigned int i = 0; i < _n_args; ++i)
47  _dpropertydarg[i] = &getMaterialPropertyDerivative<Real>("material_property", i);
48 }
49 
50 void
52 {
53  validateNonlinearCoupling<Real>("material_property");
54 }
55 
56 Real
58 {
59  return _dpropertydv[_qp] * BodyForce::computeQpResidual() * _phi[_j][_qp];
60 }
61 
62 Real
64 {
65  const unsigned int cvar = mapJvarToCvar(jvar);
66  return (*_dpropertydarg[cvar])[_qp] * BodyForce::computeQpResidual() * _phi[_j][_qp];
67 }
68 
69 template class MatBodyForceTempl<false,
std::string name(const ElemQuality q)
Moose::GenericType< Real, is_ad > GenericReal
Definition: MooseTypes.h:648
virtual GenericReal< is_ad > computeQpResidual() override
Definition: MatBodyForce.C:35
virtual GenericReal< is_ad > computeQpResidual() override
Compute this Kernel&#39;s contribution to the residual at the current quadrature point.
Definition: BodyForce.C:48
MatBodyForceTempl(const InputParameters &parameters)
Definition: MatBodyForce.C:27
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
Definition: MatBodyForce.C:63
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const MaterialProperty< Real > & _dpropertydv
derivative of the property wrt the kernel&#39;s nonlinear variable
Definition: MatBodyForce.h:51
InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
virtual void initialSetup() override
Definition: MatBodyForce.C:51
registerMooseObject("MooseApp", MatBodyForce)
This kernel creates a body force that is modified by a mask defined as a material.
Definition: MatBodyForce.h:22
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Interface class ("Veneer") to provide generator methods for derivative material property names...
static InputParameters validParams()
Definition: MatBodyForce.C:17
MatBodyForce(const InputParameters &parameters)
Definition: MatBodyForce.C:40
std::vector< const MaterialProperty< Real > * > _dpropertydarg
Reaction rate derivatives w.r.t. other coupled variables.
Definition: MatBodyForce.h:54
virtual Real computeQpJacobian() override
Definition: MatBodyForce.C:57
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...