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 "BoundingValueNodalDamper.h" 11 : 12 : registerMooseObject("MooseApp", BoundingValueNodalDamper); 13 : 14 : InputParameters 15 14364 : BoundingValueNodalDamper::validParams() 16 : { 17 14364 : InputParameters params = NodalDamper::validParams(); 18 14364 : params.addClassDescription("Limits the value of a variable to be within user-specified bounds."); 19 43092 : params.addParam<Real>("max_value", 20 28728 : std::numeric_limits<Real>::max(), 21 : "The maximum permissible iterative value for the variable."); 22 43092 : params.addParam<Real>("min_value", 23 28728 : std::numeric_limits<Real>::lowest(), 24 : "The minimum permissible iterative value for the variable."); 25 14364 : return params; 26 0 : } 27 : 28 59 : BoundingValueNodalDamper::BoundingValueNodalDamper(const InputParameters & parameters) 29 : : NodalDamper(parameters), 30 59 : _max_value(parameters.get<Real>("max_value")), 31 118 : _min_value(parameters.get<Real>("min_value")) 32 : { 33 59 : if (_min_value > _max_value) 34 0 : mooseError("max_value must be greater than min_value"); 35 59 : } 36 : 37 : Real 38 7440 : BoundingValueNodalDamper::computeQpDamping() 39 : { 40 : // Note that _u_increment contains the negative of the increment 41 7440 : if (_u[_qp] < _min_value) 42 100 : return 1.0 - (_u[_qp] - _min_value) / -_u_increment[_qp]; 43 7340 : else if (_u[_qp] > _max_value) 44 2162 : return 1.0 - (_u[_qp] - _max_value) / -_u_increment[_qp]; 45 : 46 5178 : return 1.0; 47 : }