Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://www.mooseframework.org 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 "StickyBC.h" 11 : #include "MooseVariable.h" 12 : 13 : registerMooseObject("TensorMechanicsApp", StickyBC); 14 : 15 : InputParameters 16 25 : StickyBC::validParams() 17 : { 18 25 : InputParameters params = NodalBC::validParams(); 19 50 : params.addParam<Real>( 20 : "min_value", 21 50 : std::numeric_limits<Real>::lowest(), 22 : "If the old variable value <= min_value, the variable is fixed at its old value"); 23 50 : params.addParam<Real>( 24 : "max_value", 25 50 : std::numeric_limits<Real>::max(), 26 : "If the old variable value >= max_value, the variable is fixed at its old value"); 27 25 : params.addClassDescription( 28 : "Imposes the boundary condition $u = u_{old}$ if $u_{old}$ exceeds the bounds provided"); 29 25 : return params; 30 0 : } 31 : 32 13 : StickyBC::StickyBC(const InputParameters & parameters) 33 : : NodalBC(parameters), 34 26 : _u_old(_var.dofValuesOld()), 35 26 : _min_value(getParam<Real>("min_value")), 36 39 : _max_value(getParam<Real>("max_value")) 37 : { 38 13 : if (_min_value > _max_value) 39 1 : mooseError("StickyBC: min_value must not be greater than max_value"); 40 12 : } 41 : 42 : bool 43 640 : StickyBC::shouldApply() 44 : { 45 : const unsigned qp = 0; // this is a NodalBC: all qp = 0 46 640 : return (_u_old[qp] <= _min_value || _u_old[qp] >= _max_value); 47 : } 48 : 49 : Real 50 80 : StickyBC::computeQpResidual() 51 : { 52 80 : return _u[_qp] - _u_old[_qp]; 53 : }