LCOV - code coverage report
Current view: top level - src/materials - GeneralizedKelvinVoigtModel.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #32971 (54bef8) with base c6cf66 Lines: 61 67 91.0 %
Date: 2026-05-29 20:40:07 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         112 : GeneralizedKelvinVoigtModel::validParams()
      16             : {
      17         112 :   InputParameters params = GeneralizedKelvinVoigtBase::validParams();
      18         112 :   params.addClassDescription(
      19             :       "Generalized Kelvin-Voigt model composed of a serial assembly of unit Kelvin-Voigt modules");
      20         224 :   params.addRequiredParam<Real>("young_modulus", "initial elastic modulus of the material");
      21         224 :   params.addRequiredParam<Real>("poisson_ratio", "initial poisson ratio of the material");
      22         224 :   params.addRequiredParam<std::vector<Real>>(
      23             :       "creep_modulus", "list of the elastic moduli of the different springs in the material");
      24         224 :   params.addRequiredParam<std::vector<Real>>(
      25             :       "creep_viscosity",
      26             :       "list of the characteristic times of the different dashpots in the material");
      27         224 :   params.addParam<std::vector<Real>>(
      28             :       "creep_ratio", "list of the poisson ratios of the different springs in the material");
      29         224 :   params.addParam<Real>("longterm_youngs_modulus",
      30             :                         "Young's modulus used in elasticity tensor associated with the long-term "
      31             :                         "dashpot (defaults to young_modulus if not specified)");
      32         224 :   params.addParam<Real>("longterm_poissons_ratio",
      33             :                         "Poisson's ratio of the elasticity tensor associated with the long-term "
      34             :                         "dashpot (defaults to poisson_ratio if not specified)");
      35         112 :   params.set<bool>("force_recompute_properties") = false;
      36         112 :   params.suppressParameter<bool>("force_recompute_properties");
      37         112 :   return params;
      38           0 : }
      39             : 
      40          84 : GeneralizedKelvinVoigtModel::GeneralizedKelvinVoigtModel(const InputParameters & parameters)
      41             :   : GeneralizedKelvinVoigtBase(parameters),
      42         168 :     _Ci(getParam<std::vector<Real>>("creep_modulus").size()),
      43         168 :     _eta_i(getParam<std::vector<Real>>("creep_viscosity")),
      44         252 :     _Si(getParam<std::vector<Real>>("creep_modulus").size()),
      45             :     _C_longterm(std::nullopt),
      46         168 :     _S_longterm(std::nullopt)
      47             : {
      48         168 :   Real young_modulus = getParam<Real>("young_modulus");
      49         168 :   Real poisson_ratio = getParam<Real>("poisson_ratio");
      50             : 
      51          84 :   _C0.fillFromInputVector({young_modulus, poisson_ratio}, RankFourTensor::symmetric_isotropic_E_nu);
      52          84 :   _S0 = _C0.invSymm();
      53             : 
      54         252 :   std::vector<Real> creep_modulus = getParam<std::vector<Real>>("creep_modulus");
      55             :   std::vector<Real> creep_ratio;
      56         168 :   if (isParamValid("creep_ratio"))
      57           0 :     creep_ratio = getParam<std::vector<Real>>("creep_ratio");
      58             :   else
      59          84 :     creep_ratio.resize(_Ci.size(), poisson_ratio);
      60             : 
      61          84 :   if (creep_modulus.size() != _Ci.size())
      62           0 :     mooseError("incompatible number of creep moduli and viscosities");
      63          84 :   if (creep_ratio.size() != _Ci.size())
      64           0 :     mooseError("incompatible number of creep ratios and viscosities");
      65          84 :   if (!(_Ci.size() == _eta_i.size() || _Ci.size() + 1 == _eta_i.size()))
      66           0 :     mooseError("incompatible number of creep ratios and viscosities");
      67             : 
      68         192 :   for (unsigned int i = 0; i < _Ci.size(); ++i)
      69             :   {
      70         108 :     _Ci[i].fillFromInputVector({creep_modulus[i], creep_ratio[i]},
      71             :                                RankFourTensor::symmetric_isotropic_E_nu);
      72         108 :     _Si[i] = _Ci[i].invSymm();
      73             :   }
      74             : 
      75         228 :   for (unsigned int i = 0; i < _eta_i.size(); ++i)
      76             :   {
      77         144 :     if (_eta_i[i] < 0 || MooseUtils::absoluteFuzzyEqual(_eta_i[i], 0.0))
      78           0 :       mooseError("material viscosity must be strictly > 0");
      79             :   }
      80             : 
      81          84 :   _components = _eta_i.size();
      82          84 :   _has_longterm_dashpot = (_eta_i.size() == _Ci.size() + 1);
      83             : 
      84          84 :   if (_has_longterm_dashpot)
      85             :   {
      86             :     Real longterm_youngs_modulus =
      87         120 :         (isParamValid("longterm_youngs_modulus") ? getParam<Real>("longterm_youngs_modulus")
      88             :                                                  : young_modulus);
      89             :     Real longterm_poissons_ratio =
      90         120 :         (isParamValid("longterm_poissons_ratio") ? getParam<Real>("longterm_poissons_ratio")
      91             :                                                  : poisson_ratio);
      92          36 :     _C_longterm = std::make_optional<RankFourTensor>();
      93          36 :     _C_longterm->fillFromInputVector({longterm_youngs_modulus, longterm_poissons_ratio},
      94             :                                      RankFourTensor::symmetric_isotropic_E_nu);
      95          36 :     _S_longterm = std::make_optional<RankFourTensor>();
      96          36 :     *_S_longterm = _C_longterm->invSymm();
      97             :   }
      98             : 
      99          84 :   issueGuarantee(_elasticity_tensor_name, Guarantee::ISOTROPIC);
     100          84 :   declareViscoelasticProperties();
     101          84 : }
     102             : 
     103             : void
     104        4784 : GeneralizedKelvinVoigtModel::computeQpViscoelasticProperties()
     105             : {
     106        4784 :   _first_elasticity_tensor[_qp] = _C0;
     107             : 
     108       10592 :   for (unsigned int i = 0; i < _Ci.size(); ++i)
     109        5808 :     (*_springs_elasticity_tensors[i])[_qp] = _Ci[i];
     110             : 
     111       12848 :   for (unsigned int i = 0; i < _eta_i.size(); ++i)
     112        8064 :     (*_dashpot_viscosities[i])[_qp] = _eta_i[i];
     113             : 
     114        4784 :   if (_has_longterm_dashpot)
     115        2256 :     (*_longterm_elasticity_tensor)[_qp] = *_C_longterm;
     116        4784 : }
     117             : 
     118             : void
     119        4784 : GeneralizedKelvinVoigtModel::computeQpViscoelasticPropertiesInv()
     120             : {
     121        4784 :   (*_first_elasticity_tensor_inv)[_qp] = _S0;
     122             : 
     123       10592 :   for (unsigned int i = 0; i < _Si.size(); ++i)
     124        5808 :     (*_springs_elasticity_tensors_inv[i])[_qp] = _Si[i];
     125             : 
     126        4784 :   if (_has_longterm_dashpot)
     127        2256 :     (*_longterm_elasticity_tensor_inv)[_qp] = *_S_longterm;
     128        4784 : }

Generated by: LCOV version 1.14