LCOV - code coverage report
Current view: top level - src/userobjects - NEMLMaterialPropertyReset.C (source / functions) Hit Total Coverage
Test: idaholab/blackbear: b15b36 Lines: 31 33 93.9 %
Date: 2025-07-18 16:15:14 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          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             : #ifdef NEML_ENABLED
      11             : 
      12             : #include "NEMLMaterialPropertyReset.h"
      13             : 
      14             : registerMooseObject("BlackBearApp", NEMLMaterialPropertyReset);
      15             : 
      16             : InputParameters
      17          27 : NEMLMaterialPropertyReset::validParams()
      18             : {
      19          27 :   InputParameters params = ElementUserObject::validParams();
      20             : 
      21          54 :   params.addCoupledVar("variable", "Coupled variable to trigger the reset");
      22          54 :   params.addRequiredParam<Real>("critical_value", "Value to trigger the reset at");
      23             : 
      24          54 :   params.addRequiredParam<std::vector<std::string>>("properties", "Properties to reset");
      25          54 :   params.addRequiredParam<MaterialName>("material", "The NEML material object to reset");
      26             : 
      27          27 :   return params;
      28           0 : }
      29             : 
      30          14 : NEMLMaterialPropertyReset::NEMLMaterialPropertyReset(const InputParameters & parameters)
      31             :   : ElementUserObject(parameters),
      32          14 :     _variable(coupledValue("variable")),
      33          28 :     _critical_value(getParam<Real>("critical_value")),
      34          56 :     _props(getParam<std::vector<std::string>>("properties"))
      35             : {
      36          14 : }
      37             : 
      38             : void
      39          14 : NEMLMaterialPropertyReset::initialSetup()
      40             : {
      41          14 :   _neml_material = dynamic_cast<CauchyStressFromNEML *>(&getMaterial("material"));
      42          14 :   if (_neml_material == nullptr)
      43           0 :     mooseError("Unable to link NEMLMaterialPropertyReset object to the "
      44             :                "stress calculator");
      45             : 
      46          14 :   _indices = _neml_material->provide_indices(_props);
      47          14 : }
      48             : 
      49             : void
      50         330 : NEMLMaterialPropertyReset::initialize()
      51             : {
      52         330 : }
      53             : 
      54             : void
      55         210 : NEMLMaterialPropertyReset::execute()
      56             : {
      57        1890 :   for (_qp = 0; _qp < _qrule->n_points(); _qp++)
      58        1680 :     resetQp();
      59         210 : }
      60             : 
      61             : void
      62        1680 : NEMLMaterialPropertyReset::resetQp()
      63             : {
      64        1680 :   if (_variable[_qp] >= _critical_value)
      65         280 :     _neml_material->reset_state(_indices, _qp);
      66        1680 : }
      67             : 
      68             : void
      69         300 : NEMLMaterialPropertyReset::finalize()
      70             : {
      71         300 : }
      72             : 
      73             : void
      74          30 : NEMLMaterialPropertyReset::threadJoin(const UserObject & /*y*/)
      75             : {
      76          30 : }
      77             : 
      78             : #endif // NEML_ENABLED

Generated by: LCOV version 1.14