www.mooseframework.org
EqualGradientLagrangeInterface.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 
9 // MOOSE includes
10 #include "MooseVariable.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<InterfaceKernel>();
17  params.addClassDescription("Enforce componentwise gradient continuity between two different "
18  "variables across a subdomain boundary using a Lagrange multiplier");
19  params.addRequiredParam<unsigned int>("component", "Gradient component to constrain");
20  params.addCoupledVar("lambda",
21  "The gradient constrained variable on this side of the interface.");
22  return params;
23 }
24 
26  : InterfaceKernel(parameters),
27  _component(getParam<unsigned int>("component")),
28  _lambda(getVar("lambda", 0)->sln()),
29  _lambda_jvar(getVar("lambda", 0)->number())
30 {
31 }
32 
33 Real
35 {
36  switch (type)
37  {
38  case Moose::Element:
39  return _lambda[_qp] * _grad_test[_i][_qp](_component);
40 
41  case Moose::Neighbor:
42  return -_lambda[_qp] * _grad_test_neighbor[_i][_qp](_component);
43  }
44 
45  mooseError("Internal error.");
46 }
47 
48 Real EqualGradientLagrangeInterface::computeQpJacobian(Moose::DGJacobianType /*type*/)
49 {
50  return 0.0;
51 }
52 
53 Real
55  unsigned int jvar)
56 {
57  if (jvar != _lambda_jvar)
58  return 0.0;
59 
60  // lambda is only solved on the element side
61  switch (type)
62  {
63  case Moose::ElementElement:
64  return _phi[_j][_qp] * _grad_test[_i][_qp](_component);
65 
66  case Moose::NeighborElement:
67  return -_phi[_j][_qp] * _grad_test_neighbor[_i][_qp](_component);
68 
69  default:
70  return 0.0;
71  }
72 }
virtual Real computeQpJacobian(Moose::DGJacobianType type) override
virtual Real computeQpOffDiagJacobian(Moose::DGJacobianType type, unsigned int jvar) override
virtual Real computeQpResidual(Moose::DGResidualType type) override
InputParameters validParams< EqualGradientLagrangeInterface >()
const VariableValue & _lambda
Lagrange multiplier.
EqualGradientLagrangeInterface(const InputParameters &parameters)