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 "AverageValueConstraint.h" 11 : 12 : // MOOSE includes 13 : #include "Assembly.h" 14 : #include "MooseVariableScalar.h" 15 : 16 : registerMooseObject("MooseApp", AverageValueConstraint); 17 : 18 : InputParameters 19 14595 : AverageValueConstraint::validParams() 20 : { 21 14595 : InputParameters params = ScalarKernel::validParams(); 22 14595 : params.addClassDescription("This class is used to enforce integral of phi with a " 23 : "Lagrange multiplier approach."); 24 14595 : params.addRequiredParam<PostprocessorName>( 25 : "pp_name", "Name of the Postprocessor value we are trying to equate with 'value'."); 26 14595 : params.addRequiredParam<Real>( 27 : "value", "Given (constant) which we want the integral of the solution variable to match."); 28 : 29 14595 : return params; 30 0 : } 31 : 32 165 : AverageValueConstraint::AverageValueConstraint(const InputParameters & parameters) 33 : : ScalarKernel(parameters), 34 165 : _value(getParam<Real>("value")), 35 330 : _pp_value(getPostprocessorValue("pp_name")) 36 : { 37 165 : } 38 : 39 : void 40 473 : AverageValueConstraint::reinit() 41 : { 42 473 : } 43 : 44 : Real 45 272 : AverageValueConstraint::computeQpResidual() 46 : { 47 272 : return _pp_value - _value; 48 : } 49 : 50 : Real 51 120 : AverageValueConstraint::computeQpJacobian() 52 : { 53 : // Note: Here, the true on-diagonal Jacobian contribution is 54 : // actually zero, i.e. we are not making any approximation 55 : // here. That is because the "lambda"-equation in this system of 56 : // equations does not depend on lambda. For more information, see 57 : // the detailed writeup [0]. 58 : // 59 : // [0]: https://github.com/idaholab/large_media/blob/master/scalar_constraint_kernel.pdf 60 120 : return 0.; 61 : } 62 : 63 : void 64 0 : AverageValueConstraint::computeOffDiagJacobianScalar(unsigned int /*jvar*/) 65 : { 66 0 : } 67 : 68 : Real 69 0 : AverageValueConstraint::computeQpOffDiagJacobianScalar(unsigned int /*jvar*/) 70 : { 71 : // The off-diagonal contribution for this ScalarKernel (derivative 72 : // wrt the "primal" field variable) is not _actually_ zero, but we 73 : // are computing it elsewhere (see ScalarLagrangeMultiplier.C) so 74 : // here we simply return zero. For more information on this, see the 75 : // detailed writeup [0]. 76 : // 77 : // [0]: https://github.com/idaholab/large_media/blob/master/scalar_constraint_kernel.pdf 78 0 : return 0.; 79 : }