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 "LMDiffusion.h" 11 : 12 : registerMooseObject("ScalarTransportApp", LMDiffusion); 13 : 14 : InputParameters 15 79 : LMDiffusion::validParams() 16 : { 17 79 : InputParameters params = Kernel::validParams(); 18 158 : params.addRequiredCoupledVar("primal_variable", 19 : "The coupled primal variable from which to pull the Laplacian"); 20 158 : params.addParam<bool>( 21 : "lm_sign_positive", 22 158 : true, 23 : "Whether to use a positive sign when adding this object's residual to the Lagrange " 24 : "multiplier constraint equation. Positive or negative sign should be chosen such that the " 25 : "diagonals for the LM block of the matrix are positive"); 26 158 : params.addParam<Real>("diffusivity", 1, "The value of the diffusivity"); 27 79 : params.addClassDescription( 28 : "Adds a diffusion term to a Lagrange multiplier constrained primal equation"); 29 79 : return params; 30 0 : } 31 : 32 44 : LMDiffusion::LMDiffusion(const InputParameters & parameters) 33 : : Kernel(parameters), 34 44 : _primal_var(coupled("primal_variable")), 35 44 : _second_primal(coupledSecond("primal_variable")), 36 44 : _second_primal_phi(getVar("primal_variable", 0)->secondPhi()), 37 132 : _lm_sign(getParam<bool>("lm_sign_positive") ? 1. : -1), 38 132 : _diffusivity(getParam<Real>("diffusivity")) 39 : { 40 44 : if (_var.number() == _primal_var) 41 0 : paramError( 42 : "primal_variable", 43 : "Coupled variable 'primal_variable' needs to be different from 'variable' with " 44 : "LMDiffusion. It is expected in general that 'variable' should be a Lagrange multiplier " 45 : "variable, and that 'primal_variable' be the primal variable on which the Lagrange " 46 : "multiplier is acting"); 47 44 : } 48 : 49 : Real 50 504150 : LMDiffusion::computeQpResidual() 51 : { 52 504150 : return _lm_sign * _test[_i][_qp] * -_diffusivity * _second_primal[_qp].tr(); 53 : } 54 : 55 : Real 56 612600 : LMDiffusion::computeQpJacobian() 57 : { 58 612600 : return 0; 59 : } 60 : 61 : Real 62 910800 : LMDiffusion::computeQpOffDiagJacobian(unsigned int jvar) 63 : { 64 910800 : if (jvar == _primal_var) 65 910800 : return _lm_sign * _test[_i][_qp] * -_diffusivity * _second_primal_phi[_j][_qp].tr(); 66 : 67 : return 0; 68 : }