forked from idaholab/moose
/
OptionallyCoupledForce.C
59 lines (51 loc) · 1.94 KB
/
OptionallyCoupledForce.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/****************************************************************/
/* DO NOT MODIFY THIS HEADER */
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* (c) 2010 Battelle Energy Alliance, LLC */
/* ALL RIGHTS RESERVED */
/* */
/* Prepared by Battelle Energy Alliance, LLC */
/* Under Contract No. DE-AC07-05ID14517 */
/* With the U. S. Department of Energy */
/* */
/* See COPYRIGHT for full restrictions */
/****************************************************************/
#include "OptionallyCoupledForce.h"
template<>
InputParameters validParams<OptionallyCoupledForce>()
{
InputParameters params = validParams<Kernel>();
params.addCoupledVar("v", 1, "The coupled variable which provides the force");
return params;
}
OptionallyCoupledForce::OptionallyCoupledForce(const std::string & name, InputParameters parameters) :
Kernel(name, parameters),
_v_var(coupled("v")),
_v(coupledValue("v")),
_grad_v(coupledGradient("v")),
_second_v(coupledSecond("v")),
_v_dot(coupledDot("v")),
_v_dot_du(coupledDotDu("v")),
_v_coupled(isCoupled("v"))
{
if (!_v_coupled && _v_var < 64)
mooseError("Something is wrong with the coupling system. It should be producing really huge numbers for coupled('v') But instead it generated: " << _v_var);
}
Real
OptionallyCoupledForce::computeQpResidual()
{
return -_v[_qp]*_test[_i][_qp];
}
Real
OptionallyCoupledForce::computeQpJacobian()
{
return 0;
}
Real
OptionallyCoupledForce::computeQpOffDiagJacobian(unsigned int jvar)
{
if (jvar == _v_var)
return -_phi[_j][_qp]*_test[_i][_qp];
return 0.0;
}