LCOV - code coverage report
Current view: top level - src/userobjects - LinearViscoelasticityManager.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 32 34 94.1 %
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 "LinearViscoelasticityManager.h"
      11             : #include "libmesh/quadrature.h"
      12             : 
      13             : registerMooseObject("SolidMechanicsApp", LinearViscoelasticityManager);
      14             : 
      15             : InputParameters
      16          96 : LinearViscoelasticityManager::validParams()
      17             : {
      18          96 :   InputParameters params = ElementUserObject::validParams();
      19          96 :   params.addClassDescription("Manages the updating of the semi-implicit "
      20             :                              "single-step first-order finite difference "
      21             :                              "time-stepping scheme");
      22         192 :   params.addRequiredParam<std::string>("viscoelastic_model",
      23             :                                        "name of the LinearViscoelasticityBase object to manage");
      24         192 :   params.addParam<std::string>(
      25             :       "stress_name", "stress", "name of the stress tensor used for the viscoelastic update");
      26         192 :   params.addParam<std::string>("creep_strain_name",
      27             :                                "creep_strain",
      28             :                                "name of the creep strain tensor used for the viscoelastic update");
      29         192 :   params.addParam<std::string>(
      30             :       "elastic_strain_name",
      31             :       "elastic_strain",
      32             :       "name of the elastic strain tensor used for the viscoelastic update");
      33         384 :   params.set<ExecFlagEnum>("execute_on") = {EXEC_TIMESTEP_BEGIN, EXEC_TIMESTEP_END};
      34          96 :   params.suppressParameter<ExecFlagEnum>("execute_on");
      35          96 :   return params;
      36          96 : }
      37             : 
      38          48 : LinearViscoelasticityManager::LinearViscoelasticityManager(const InputParameters & parameters)
      39             :   : ElementUserObject(parameters),
      40          48 :     _stress_name(getParam<std::string>("stress_name")),
      41          96 :     _stress(getMaterialPropertyByName<RankTwoTensor>(_stress_name)),
      42         144 :     _creep_strain_name(getParam<std::string>("creep_strain_name")),
      43          48 :     _creep_strain(getMaterialPropertyByName<RankTwoTensor>(_creep_strain_name)),
      44         144 :     _elastic_strain_name(getParam<std::string>("elastic_strain_name")),
      45          48 :     _elastic_strain(getMaterialPropertyByName<RankTwoTensor>(_elastic_strain_name)),
      46          96 :     _viscoelastic_model_name(getParam<std::string>("viscoelastic_model")),
      47          48 :     _viscoelastic_model(nullptr)
      48             : {
      49          48 : }
      50             : 
      51             : void
      52          48 : LinearViscoelasticityManager::initialSetup()
      53             : {
      54          48 :   MaterialBase * test = &getMaterialByName(_viscoelastic_model_name, /*no_warn =*/true);
      55          48 :   if (!test)
      56           0 :     mooseError(_viscoelastic_model_name + " does not exist");
      57             : 
      58          48 :   _viscoelastic_model = dynamic_cast<LinearViscoelasticityBase *>(test);
      59          48 :   if (!_viscoelastic_model)
      60           0 :     mooseError(_viscoelastic_model_name + " is not a LinearViscoelasticityBase object");
      61          48 : }
      62             : 
      63             : void
      64        1824 : LinearViscoelasticityManager::execute()
      65             : {
      66        1824 :   if (_mi_feproblem.getCurrentExecuteOnFlag() == EXEC_TIMESTEP_BEGIN)
      67             :   {
      68        8208 :     for (unsigned int _qp = 0; _qp < _qrule->n_points(); ++_qp)
      69        7296 :       _viscoelastic_model->recomputeQpApparentProperties(_qp);
      70             :   }
      71        1824 : }

Generated by: LCOV version 1.14