https://mooseframework.inl.gov
CoupledForceNodalKernel.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 
11 
13 
16 {
18  params.addClassDescription("Adds a force proportional to the value of the coupled variable");
19  params.addRequiredCoupledVar("v", "The coupled variable which provides the force");
20  params.addParam<Real>(
21  "coef", 1.0, "Coefficent ($\\sigma$) multiplier for the coupled force term.");
22 
23  return params;
24 }
25 
27  : NodalKernel(parameters),
28  _v_var(coupled("v")),
29  _v(coupledValue("v")),
30  _coef(getParam<Real>("coef"))
31 {
32  if (_var.number() == _v_var)
33  mooseError(
34  "Coupled variable 'v' needs to be different from 'variable' with CoupledForceNodalKernel, "
35  "consider using Reaction or somethig similar");
36 }
37 
38 Real
40 {
41  return -_coef * _v[_qp];
42 }
43 
44 Real
46 {
47  return 0;
48 }
49 
50 Real
52 {
53  if (jvar == _v_var)
54  return -_coef;
55  return 0.0;
56 }
const unsigned int _v_var
The number of the coupled variable.
unsigned int number() const
Get variable number coming from libMesh.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
MooseVariable & _var
variable this works on
Adds a force proportional to the value of the coupled variable.
virtual Real computeQpJacobian() override
The user can override this function to compute the "on-diagonal" Jacobian contribution.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real computeQpResidual() override
The user can override this function to compute the residual at a node.
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
This is the virtual that derived classes should override for computing an off-diagonal jacobian compo...
const VariableValue & _v
The value of the coupled variable.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
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...
CoupledForceNodalKernel(const InputParameters &parameters)
static InputParameters validParams()
Class constructor.
Definition: NodalKernel.C:18
static InputParameters validParams()
Base class for creating nodal kernels with hand-coded Jacobians.
Definition: NodalKernel.h:17
registerMooseObject("MooseApp", CoupledForceNodalKernel)
unsigned int _qp
Quadrature point index.
const Real _coef
A multiplicative factor for computing the coupled force.