LCOV - code coverage report
Current view: top level - src/materials - GeneralizedKelvinVoigtModel.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 47 53 88.7 %
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 "GeneralizedKelvinVoigtModel.h"
      11             : 
      12             : registerMooseObject("SolidMechanicsApp", GeneralizedKelvinVoigtModel);
      13             : 
      14             : InputParameters
      15         144 : GeneralizedKelvinVoigtModel::validParams()
      16             : {
      17         144 :   InputParameters params = GeneralizedKelvinVoigtBase::validParams();
      18         144 :   params.addClassDescription(
      19             :       "Generalized Kelvin-Voigt model composed of a serial assembly of unit Kelvin-Voigt modules");
      20         288 :   params.addRequiredParam<Real>("young_modulus", "initial elastic modulus of the material");
      21         288 :   params.addRequiredParam<Real>("poisson_ratio", "initial poisson ratio of the material");
      22         288 :   params.addRequiredParam<std::vector<Real>>(
      23             :       "creep_modulus", "list of the elastic moduli of the different springs in the material");
      24         288 :   params.addRequiredParam<std::vector<Real>>(
      25             :       "creep_viscosity",
      26             :       "list of the characteristic times of the different dashpots in the material");
      27         288 :   params.addParam<std::vector<Real>>(
      28             :       "creep_ratio", "list of the poisson ratios of the different springs in the material");
      29         144 :   params.set<bool>("force_recompute_properties") = false;
      30         144 :   params.suppressParameter<bool>("force_recompute_properties");
      31         144 :   return params;
      32           0 : }
      33             : 
      34         108 : GeneralizedKelvinVoigtModel::GeneralizedKelvinVoigtModel(const InputParameters & parameters)
      35             :   : GeneralizedKelvinVoigtBase(parameters),
      36         216 :     _Ci(getParam<std::vector<Real>>("creep_modulus").size()),
      37         216 :     _eta_i(getParam<std::vector<Real>>("creep_viscosity")),
      38         324 :     _Si(getParam<std::vector<Real>>("creep_modulus").size())
      39             : {
      40         216 :   Real young_modulus = getParam<Real>("young_modulus");
      41         216 :   Real poisson_ratio = getParam<Real>("poisson_ratio");
      42             : 
      43         108 :   _C0.fillFromInputVector({young_modulus, poisson_ratio}, RankFourTensor::symmetric_isotropic_E_nu);
      44         108 :   _S0 = _C0.invSymm();
      45             : 
      46         324 :   std::vector<Real> creep_modulus = getParam<std::vector<Real>>("creep_modulus");
      47             :   std::vector<Real> creep_ratio;
      48         216 :   if (isParamValid("creep_ratio"))
      49           0 :     creep_ratio = getParam<std::vector<Real>>("creep_ratio");
      50             :   else
      51         108 :     creep_ratio.resize(_Ci.size(), poisson_ratio);
      52             : 
      53         108 :   if (creep_modulus.size() != _Ci.size())
      54           0 :     mooseError("incompatible number of creep moduli and viscosities");
      55         108 :   if (creep_ratio.size() != _Ci.size())
      56           0 :     mooseError("incompatible number of creep ratios and viscosities");
      57         108 :   if (!(_Ci.size() == _eta_i.size() || _Ci.size() + 1 == _eta_i.size()))
      58           0 :     mooseError("incompatible number of creep ratios and viscosities");
      59             : 
      60         270 :   for (unsigned int i = 0; i < _Ci.size(); ++i)
      61             :   {
      62         324 :     _Ci[i].fillFromInputVector({creep_modulus[i], creep_ratio[i]},
      63             :                                RankFourTensor::symmetric_isotropic_E_nu);
      64         162 :     _Si[i] = _Ci[i].invSymm();
      65             :   }
      66             : 
      67         306 :   for (unsigned int i = 0; i < _eta_i.size(); ++i)
      68             :   {
      69         198 :     if (_eta_i[i] < 0 || MooseUtils::absoluteFuzzyEqual(_eta_i[i], 0.0))
      70           0 :       mooseError("material viscosity must be strictly > 0");
      71             :   }
      72             : 
      73         108 :   _components = _eta_i.size();
      74         108 :   _has_longterm_dashpot = (_eta_i.size() == _Ci.size() + 1);
      75             : 
      76         108 :   issueGuarantee(_elasticity_tensor_name, Guarantee::ISOTROPIC);
      77         108 :   declareViscoelasticProperties();
      78         108 : }
      79             : 
      80             : void
      81        5312 : GeneralizedKelvinVoigtModel::computeQpViscoelasticProperties()
      82             : {
      83        5312 :   _first_elasticity_tensor[_qp] = _C0;
      84             : 
      85       12960 :   for (unsigned int i = 0; i < _Ci.size(); ++i)
      86        7648 :     (*_springs_elasticity_tensors[i])[_qp] = _Ci[i];
      87             : 
      88       14944 :   for (unsigned int i = 0; i < _eta_i.size(); ++i)
      89        9632 :     (*_dashpot_viscosities[i])[_qp] = _eta_i[i];
      90        5312 : }
      91             : 
      92             : void
      93        5312 : GeneralizedKelvinVoigtModel::computeQpViscoelasticPropertiesInv()
      94             : {
      95        5312 :   (*_first_elasticity_tensor_inv)[_qp] = _S0;
      96             : 
      97       12960 :   for (unsigned int i = 0; i < _Si.size(); ++i)
      98        7648 :     (*_springs_elasticity_tensors_inv[i])[_qp] = _Si[i];
      99        5312 : }

Generated by: LCOV version 1.14