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 "BoundingValueElementDamper.h" 11 : 12 : registerMooseObject("MooseApp", BoundingValueElementDamper); 13 : 14 : InputParameters 15 14385 : BoundingValueElementDamper::validParams() 16 : { 17 14385 : InputParameters params = ElementDamper::validParams(); 18 14385 : params.addClassDescription("This class implements a damper that limits the value of a variable " 19 : "to be within user-specified bounds."); 20 43155 : params.addParam<Real>("max_value", 21 28770 : std::numeric_limits<Real>::max(), 22 : "The maximum permissible iterative value for the variable."); 23 43155 : params.addParam<Real>("min_value", 24 28770 : std::numeric_limits<Real>::lowest(), 25 : "The minimum permissible iterative value for the variable."); 26 14385 : return params; 27 0 : } 28 : 29 70 : BoundingValueElementDamper::BoundingValueElementDamper(const InputParameters & parameters) 30 : : ElementDamper(parameters), 31 70 : _max_value(parameters.get<Real>("max_value")), 32 140 : _min_value(parameters.get<Real>("min_value")) 33 : { 34 70 : if (_min_value > _max_value) 35 0 : mooseError("max_value must be greater than min_value"); 36 70 : } 37 : 38 : Real 39 7630 : BoundingValueElementDamper::computeQpDamping() 40 : { 41 : // Note that _u_increment contains the negative of the increment 42 7630 : if (_u[_qp] < _min_value) 43 39 : return 1.0 - (_u[_qp] - _min_value) / -_u_increment[_qp]; 44 7591 : else if (_u[_qp] > _max_value) 45 758 : return 1.0 - (_u[_qp] - _max_value) / -_u_increment[_qp]; 46 : 47 6833 : return 1.0; 48 : }