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 "EqualGradientLagrangeInterface.h" 11 : 12 : // MOOSE includes 13 : #include "MooseVariable.h" 14 : 15 : registerMooseObject("PhaseFieldApp", EqualGradientLagrangeInterface); 16 : 17 : InputParameters 18 23 : EqualGradientLagrangeInterface::validParams() 19 : { 20 23 : InputParameters params = InterfaceKernel::validParams(); 21 23 : params.addClassDescription("Enforce componentwise gradient continuity between two different " 22 : "variables across a subdomain boundary using a Lagrange multiplier"); 23 46 : params.addRequiredParam<unsigned int>("component", "Gradient component to constrain"); 24 46 : params.addCoupledVar("lambda", 25 : "The gradient constrained variable on this side of the interface."); 26 23 : return params; 27 0 : } 28 : 29 12 : EqualGradientLagrangeInterface::EqualGradientLagrangeInterface(const InputParameters & parameters) 30 : : InterfaceKernel(parameters), 31 12 : _component(getParam<unsigned int>("component")), 32 12 : _lambda(getVar("lambda", 0)->sln()), 33 24 : _lambda_jvar(getVar("lambda", 0)->number()) 34 : { 35 12 : } 36 : 37 : Real 38 214400 : EqualGradientLagrangeInterface::computeQpResidual(Moose::DGResidualType type) 39 : { 40 214400 : switch (type) 41 : { 42 107200 : case Moose::Element: 43 107200 : return _lambda[_qp] * _grad_test[_i][_qp](_component); 44 : 45 107200 : case Moose::Neighbor: 46 107200 : return -_lambda[_qp] * _grad_test_neighbor[_i][_qp](_component); 47 : } 48 : 49 0 : mooseError("Internal error."); 50 : } 51 : 52 156160 : Real EqualGradientLagrangeInterface::computeQpJacobian(Moose::DGJacobianType /*type*/) 53 : { 54 156160 : return 0.0; 55 : } 56 : 57 : Real 58 156160 : EqualGradientLagrangeInterface::computeQpOffDiagJacobian(Moose::DGJacobianType type, 59 : unsigned int jvar) 60 : { 61 156160 : if (jvar != _lambda_jvar) 62 : return 0.0; 63 : 64 : // lambda is only solved on the element side 65 156160 : switch (type) 66 : { 67 39040 : case Moose::ElementElement: 68 39040 : return _phi[_j][_qp] * _grad_test[_i][_qp](_component); 69 : 70 39040 : case Moose::NeighborElement: 71 39040 : return -_phi[_j][_qp] * _grad_test_neighbor[_i][_qp](_component); 72 : 73 : default: 74 : return 0.0; 75 : } 76 : }