LCOV - code coverage report
Current view: top level - src/dampers - MaxIncrement.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 19 19 100.0 %
Date: 2025-07-17 01:28:37 Functions: 3 3 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 "MaxIncrement.h"
      11             : 
      12             : registerMooseObject("MooseApp", MaxIncrement);
      13             : 
      14             : InputParameters
      15       14311 : MaxIncrement::validParams()
      16             : {
      17       14311 :   InputParameters params = ElementDamper::validParams();
      18       14311 :   params.addRequiredRangeCheckedParam<Real>(
      19             :       "max_increment", "max_increment > 0", "The maximum newton increment for the variable.");
      20       14311 :   MooseEnum increment_type("absolute fractional", "absolute");
      21       14311 :   params.addParam<MooseEnum>(
      22             :       "increment_type",
      23             :       increment_type,
      24             :       "Type of increment to compare against max_increment. 'absolute': use variable increment. "
      25             :       "'fractional': use variable increment divided by the variable value.");
      26             : 
      27       14311 :   params.addClassDescription("Limits a variable's update by some max fraction");
      28             : 
      29       28622 :   return params;
      30       14311 : }
      31             : 
      32          22 : MaxIncrement::MaxIncrement(const InputParameters & parameters)
      33             :   : ElementDamper(parameters),
      34          22 :     _max_increment(parameters.get<Real>("max_increment")),
      35          44 :     _increment_type(getParam<MooseEnum>("increment_type").getEnum<IncrementTypeEnum>())
      36             : {
      37          22 : }
      38             : 
      39             : Real
      40        5544 : MaxIncrement::computeQpDamping()
      41             : {
      42        5544 :   Real inc = std::abs(_u_increment[_qp]);
      43        5544 :   if (_increment_type == IncrementTypeEnum::fractional)
      44        2772 :     inc /= std::abs(_u[_qp]);
      45             : 
      46        5544 :   if (inc > _max_increment)
      47        4191 :     return _max_increment / inc;
      48             : 
      49        1353 :   return 1.0;
      50             : }

Generated by: LCOV version 1.14