Line data Source code
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 "CoupledForceNodalKernel.h" 11 : 12 : registerMooseObject("MooseApp", CoupledForceNodalKernel); 13 : 14 : InputParameters 15 14467 : CoupledForceNodalKernel::validParams() 16 : { 17 14467 : InputParameters params = NodalKernel::validParams(); 18 14467 : params.addClassDescription("Adds a force proportional to the value of the coupled variable"); 19 14467 : params.addRequiredCoupledVar("v", "The coupled variable which provides the force"); 20 43401 : params.addParam<Real>( 21 28934 : "coef", 1.0, "Coefficent ($\\sigma$) multiplier for the coupled force term."); 22 : 23 14467 : return params; 24 0 : } 25 : 26 106 : CoupledForceNodalKernel::CoupledForceNodalKernel(const InputParameters & parameters) 27 : : NodalKernel(parameters), 28 106 : _v_var(coupled("v")), 29 106 : _v(coupledValue("v")), 30 212 : _coef(getParam<Real>("coef")) 31 : { 32 106 : if (_var.number() == _v_var) 33 0 : mooseError( 34 : "Coupled variable 'v' needs to be different from 'variable' with CoupledForceNodalKernel, " 35 : "consider using Reaction or somethig similar"); 36 106 : } 37 : 38 : Real 39 155754 : CoupledForceNodalKernel::computeQpResidual() 40 : { 41 155754 : return -_coef * _v[_qp]; 42 : } 43 : 44 : Real 45 121086 : CoupledForceNodalKernel::computeQpJacobian() 46 : { 47 121086 : return 0; 48 : } 49 : 50 : Real 51 121086 : CoupledForceNodalKernel::computeQpOffDiagJacobian(unsigned int jvar) 52 : { 53 121086 : if (jvar == _v_var) 54 121086 : return -_coef; 55 0 : return 0.0; 56 : }