LCOV - code coverage report
Current view: top level - src/bcs - StickyBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 19 20 95.0 %
Date: 2025-07-25 05:00:39 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14