Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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
10 #include "CoupledForce.h"
12 #include "MooseVariable.h"
16 template <>
19 {
22  params.addClassDescription("Implements a source term proportional to the value of a coupled "
23  "variable. Weak form: $(\\psi_i, -\\sigma v)$.");
24  params.addRequiredCoupledVar("v", "The coupled variable which provides the force");
25  params.addParam<Real>(
26  "coef", 1.0, "Coefficent ($\\sigma$) multiplier for the coupled force term.");
28  return params;
29 }
32  : Kernel(parameters), _v_var(coupled("v")), _v(coupledValue("v")), _coef(getParam<Real>("coef"))
33 {
34  if (_var.number() == _v_var)
35  mooseError("Coupled variable 'v' needs to be different from 'variable' with CoupledForce, "
36  "consider using Reaction or somethig similar");
37 }
39 Real
41 {
42  return -_coef * _v[_qp] * _test[_i][_qp];
43 }
45 Real
47 {
48  return 0;
49 }
51 Real
53 {
54  if (jvar == _v_var)
55  return -_coef * _phi[_j][_qp] * _test[_i][_qp];
56  return 0.0;
57 }
registerMooseObject("MooseApp", CoupledForce)
MooseVariable & _var
This is a regular kernel so we cast to a regular MooseVariable.
Definition: Kernel.h:54
unsigned int number() const
Get variable number coming from libMesh.
virtual Real computeQpResidual() override
Compute this Kernel&#39;s contribution to the residual at the current quadrature point.
Definition: CoupledForce.C:40
CoupledForce(const InputParameters &parameters)
Definition: CoupledForce.C:31
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
Simple class to demonstrate off diagonal Jacobian contributions.
Definition: CoupledForce.h:23
const VariableValue & _v
Definition: CoupledForce.h:37
const VariableTestValue & _test
the current test function
Definition: Kernel.h:57
virtual Real computeQpJacobian() override
Compute this Kernel&#39;s contribution to the Jacobian at the current quadrature point.
Definition: CoupledForce.C:46
unsigned int _i
current index for the test function
Definition: KernelBase.h:165
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
This is the virtual that derived classes should override for computing an off-diagonal Jacobian compo...
Definition: CoupledForce.C:52
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
unsigned int _v_var
Definition: CoupledForce.h:36
unsigned int _j
current index for the shape function
Definition: KernelBase.h:168
InputParameters validParams< Kernel >()
Definition: Kernel.C:24
Definition: Kernel.h:20
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...
InputParameters validParams< CoupledForce >()
Definition: CoupledForce.C:18
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
const VariablePhiValue & _phi
the current shape functions
Definition: Kernel.h:63
unsigned int _qp
The current quadrature point index.
Definition: KernelBase.h:150