LCOV - code coverage report
Current view: top level - src/materials - GeneralizedKelvinVoigtBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #32971 (54bef8) with base c6cf66 Lines: 69 73 94.5 %
Date: 2026-05-29 20:40:07 Functions: 6 6 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 "GeneralizedKelvinVoigtBase.h"
      11             : 
      12             : InputParameters
      13         112 : GeneralizedKelvinVoigtBase::validParams()
      14             : {
      15         112 :   InputParameters params = LinearViscoelasticityBase::validParams();
      16         112 :   params.set<bool>("need_viscoelastic_properties_inverse") = true;
      17         112 :   params.suppressParameter<bool>("need_viscoelastic_properties_inverse");
      18         112 :   return params;
      19           0 : }
      20             : 
      21          84 : GeneralizedKelvinVoigtBase::GeneralizedKelvinVoigtBase(const InputParameters & parameters)
      22             :   : LinearViscoelasticityBase(parameters),
      23          84 :     _first_elasticity_tensor_old(
      24         168 :         getMaterialPropertyOld<RankFourTensor>(_base_name + "spring_elasticity_tensor_0")),
      25          84 :     _longterm_elasticity_tensor_inv_old(nullptr)
      26             : {
      27          84 : }
      28             : 
      29             : void
      30          84 : GeneralizedKelvinVoigtBase::declareViscoelasticProperties()
      31             : {
      32          84 :   if (_has_longterm_dashpot && _need_viscoelastic_properties_inverse)
      33             :   {
      34          36 :     _longterm_elasticity_tensor_inv_old =
      35          72 :         &getMaterialPropertyOld<RankFourTensor>(_base_name + "longterm_elasticity_tensor_inv");
      36             :   }
      37          84 :   LinearViscoelasticityBase::declareViscoelasticProperties();
      38          84 : }
      39             : 
      40             : void
      41        4784 : GeneralizedKelvinVoigtBase::updateQpViscousStrains()
      42             : {
      43        4784 :   if (_t_step <= 1)
      44         168 :     return;
      45             : 
      46        4616 :   RankTwoTensor effective_stress = _first_elasticity_tensor_old[_qp] * _elastic_strain_old[_qp];
      47             : 
      48        4616 :   if (_has_driving_eigenstrain)
      49         728 :     effective_stress += _first_elasticity_tensor_old[_qp] * (*_driving_eigenstrain_old)[_qp];
      50             : 
      51       10208 :   for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
      52             :   {
      53        5592 :     Real theta_i = computeTheta(_dt_old, (*_dashpot_viscosities_old[i])[_qp]);
      54        5592 :     Real gamma = (*_dashpot_viscosities_old[i])[_qp] / (_dt_old * theta_i);
      55        5592 :     (*_viscous_strains[i])[_qp] =
      56        5592 :         ((*_springs_elasticity_tensors_inv_old[i])[_qp] * effective_stress) /
      57        5592 :         (theta_i * (1. + gamma));
      58       11184 :     (*_viscous_strains[i])[_qp] += (*_viscous_strains_old[i])[_qp] *
      59        5592 :                                    (gamma / (theta_i * (1. + gamma)) - (1. - theta_i) / theta_i);
      60             :   }
      61             : 
      62        4616 :   if (_has_longterm_dashpot)
      63             :   {
      64        2184 :     (*_viscous_strains.back())[_qp] =
      65        2184 :         ((*_longterm_elasticity_tensor_inv_old)[_qp] * effective_stress) *
      66        2184 :         (_dt_old / (*_dashpot_viscosities_old.back())[_qp]);
      67        2184 :     (*_viscous_strains.back())[_qp] += (*_viscous_strains_old.back())[_qp];
      68             :   }
      69             : }
      70             : 
      71             : void
      72        4784 : GeneralizedKelvinVoigtBase::computeQpApparentElasticityTensors()
      73             : {
      74        4784 :   _elasticity_tensor[_qp] = _first_elasticity_tensor[_qp];
      75        4784 :   _elasticity_tensor_inv[_qp] = (*_first_elasticity_tensor_inv)[_qp];
      76        4784 :   _apparent_elasticity_tensor_inv[_qp] = (*_first_elasticity_tensor_inv)[_qp];
      77             : 
      78       10592 :   for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
      79             :   {
      80        5808 :     Real theta_i = computeTheta(_dt, (*_dashpot_viscosities[i])[_qp]);
      81        5808 :     Real gamma = (*_dashpot_viscosities[i])[_qp] / (_dt * theta_i);
      82        5808 :     _apparent_elasticity_tensor_inv[_qp] +=
      83       11616 :         (*_springs_elasticity_tensors_inv[i])[_qp] / (1. + gamma);
      84             :   }
      85             : 
      86        4784 :   if (_has_longterm_dashpot)
      87             :   {
      88        2256 :     Real theta_i = computeTheta(_dt, (*_dashpot_viscosities.back())[_qp]);
      89        2256 :     Real gamma = (*_dashpot_viscosities.back())[_qp] / (_dt * theta_i);
      90        4512 :     _apparent_elasticity_tensor_inv[_qp] += (*_longterm_elasticity_tensor_inv)[_qp] / gamma;
      91             :   }
      92             : 
      93        4784 :   _apparent_elasticity_tensor[_qp] = _apparent_elasticity_tensor_inv[_qp].invSymm();
      94        4784 : }
      95             : 
      96             : void
      97        4784 : GeneralizedKelvinVoigtBase::computeQpApparentCreepStrain()
      98             : {
      99        4784 :   _apparent_creep_strain[_qp].zero();
     100             : 
     101       10592 :   for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
     102             :   {
     103        5808 :     Real theta_i = computeTheta(_dt, (*_dashpot_viscosities[i])[_qp]);
     104        5808 :     Real gamma = (*_dashpot_viscosities[i])[_qp] / (_dt * theta_i);
     105        5808 :     _apparent_creep_strain[_qp] += (*_viscous_strains[i])[_qp] * (gamma / (1. + gamma));
     106             :   }
     107             : 
     108        4784 :   if (_has_longterm_dashpot)
     109        2256 :     _apparent_creep_strain[_qp] += (*_viscous_strains.back())[_qp];
     110             : 
     111        4784 :   if (_has_driving_eigenstrain)
     112             :   {
     113         752 :     RankFourTensor cumulated_driving_tensor;
     114         752 :     cumulated_driving_tensor.zero();
     115         752 :     for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
     116             :     {
     117           0 :       double theta_i = computeTheta(_dt, (*_dashpot_viscosities[i])[_qp]);
     118           0 :       double gamma = (*_dashpot_viscosities[i])[_qp] / (_dt * theta_i);
     119           0 :       cumulated_driving_tensor += (*_springs_elasticity_tensors_inv[i])[_qp] / (1. + gamma);
     120             :     }
     121             : 
     122         752 :     _apparent_creep_strain[_qp] +=
     123         752 :         (_elasticity_tensor[_qp] * cumulated_driving_tensor) * (*_driving_eigenstrain)[_qp];
     124             : 
     125         752 :     if (_has_longterm_dashpot)
     126             :     {
     127         752 :       double theta_i = computeTheta(_dt, (*_dashpot_viscosities.back())[_qp]);
     128         752 :       double gamma = (*_dashpot_viscosities.back())[_qp] / (_dt * theta_i);
     129         752 :       _apparent_creep_strain[_qp] += (*_driving_eigenstrain)[_qp] / gamma;
     130             :     }
     131             :   }
     132        4784 : }

Generated by: LCOV version 1.14