LCOV - code coverage report
Current view: top level - src/materials - GeneralizedKelvinVoigtBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 63 67 94.0 %
Date: 2025-07-25 05:00:39 Functions: 5 5 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         144 : GeneralizedKelvinVoigtBase::validParams()
      14             : {
      15         144 :   InputParameters params = LinearViscoelasticityBase::validParams();
      16         144 :   params.set<bool>("need_viscoelastic_properties_inverse") = true;
      17         144 :   params.suppressParameter<bool>("need_viscoelastic_properties_inverse");
      18         144 :   return params;
      19           0 : }
      20             : 
      21         108 : GeneralizedKelvinVoigtBase::GeneralizedKelvinVoigtBase(const InputParameters & parameters)
      22             :   : LinearViscoelasticityBase(parameters),
      23         108 :     _first_elasticity_tensor_old(
      24         216 :         getMaterialPropertyOld<RankFourTensor>(_base_name + "spring_elasticity_tensor_0")),
      25         108 :     _first_elasticity_tensor_inv_old(
      26         216 :         getMaterialPropertyOld<RankFourTensor>(_base_name + "spring_elasticity_tensor_0_inv"))
      27             : {
      28         108 : }
      29             : 
      30             : void
      31        5312 : GeneralizedKelvinVoigtBase::updateQpViscousStrains()
      32             : {
      33        5312 :   if (_t_step <= 1)
      34         192 :     return;
      35             : 
      36        5120 :   RankTwoTensor effective_stress = _first_elasticity_tensor_old[_qp] * _elastic_strain_old[_qp];
      37             : 
      38        5120 :   if (_has_driving_eigenstrain)
      39         960 :     effective_stress += _first_elasticity_tensor_old[_qp] * (*_driving_eigenstrain_old)[_qp];
      40             : 
      41       12480 :   for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
      42             :   {
      43        7360 :     Real theta_i = computeTheta(_dt_old, (*_dashpot_viscosities_old[i])[_qp]);
      44        7360 :     Real gamma = (*_dashpot_viscosities_old[i])[_qp] / (_dt_old * theta_i);
      45        7360 :     (*_viscous_strains[i])[_qp] =
      46        7360 :         ((*_springs_elasticity_tensors_inv_old[i])[_qp] * effective_stress) /
      47        7360 :         (theta_i * (1. + gamma));
      48       14720 :     (*_viscous_strains[i])[_qp] += (*_viscous_strains_old[i])[_qp] *
      49        7360 :                                    (gamma / (theta_i * (1. + gamma)) - (1. - theta_i) / theta_i);
      50             :   }
      51             : 
      52        5120 :   if (_has_longterm_dashpot)
      53             :   {
      54        1920 :     (*_viscous_strains.back())[_qp] = (_first_elasticity_tensor_inv_old[_qp] * effective_stress) *
      55        1920 :                                       (_dt_old / (*_dashpot_viscosities_old.back())[_qp]);
      56        1920 :     (*_viscous_strains.back())[_qp] += (*_viscous_strains_old.back())[_qp];
      57             :   }
      58             : }
      59             : 
      60             : void
      61        5312 : GeneralizedKelvinVoigtBase::computeQpApparentElasticityTensors()
      62             : {
      63        5312 :   _elasticity_tensor[_qp] = _first_elasticity_tensor[_qp];
      64        5312 :   _elasticity_tensor_inv[_qp] = (*_first_elasticity_tensor_inv)[_qp];
      65        5312 :   _apparent_elasticity_tensor_inv[_qp] = (*_first_elasticity_tensor_inv)[_qp];
      66             : 
      67       12960 :   for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
      68             :   {
      69        7648 :     Real theta_i = computeTheta(_dt, (*_dashpot_viscosities[i])[_qp]);
      70        7648 :     Real gamma = (*_dashpot_viscosities[i])[_qp] / (_dt * theta_i);
      71        7648 :     _apparent_elasticity_tensor_inv[_qp] +=
      72       15296 :         (*_springs_elasticity_tensors_inv[i])[_qp] / (1. + gamma);
      73             :   }
      74             : 
      75        5312 :   if (_has_longterm_dashpot)
      76             :   {
      77        1984 :     Real theta_i = computeTheta(_dt, (*_dashpot_viscosities.back())[_qp]);
      78        1984 :     Real gamma = (*_dashpot_viscosities.back())[_qp] / (_dt * theta_i);
      79        3968 :     _apparent_elasticity_tensor_inv[_qp] += (*_first_elasticity_tensor_inv)[_qp] / gamma;
      80             :   }
      81             : 
      82        5312 :   _apparent_elasticity_tensor[_qp] = _apparent_elasticity_tensor_inv[_qp].invSymm();
      83        5312 : }
      84             : 
      85             : void
      86        5312 : GeneralizedKelvinVoigtBase::computeQpApparentCreepStrain()
      87             : {
      88        5312 :   _apparent_creep_strain[_qp].zero();
      89             : 
      90       12960 :   for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
      91             :   {
      92        7648 :     Real theta_i = computeTheta(_dt, (*_dashpot_viscosities[i])[_qp]);
      93        7648 :     Real gamma = (*_dashpot_viscosities[i])[_qp] / (_dt * theta_i);
      94        7648 :     _apparent_creep_strain[_qp] += (*_viscous_strains[i])[_qp] * (gamma / (1. + gamma));
      95             :   }
      96             : 
      97        5312 :   if (_has_longterm_dashpot)
      98        1984 :     _apparent_creep_strain[_qp] += (*_viscous_strains.back())[_qp];
      99             : 
     100        5312 :   if (_has_driving_eigenstrain)
     101             :   {
     102         992 :     RankFourTensor cumulated_driving_tensor;
     103         992 :     cumulated_driving_tensor.zero();
     104         992 :     for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
     105             :     {
     106           0 :       double theta_i = computeTheta(_dt, (*_dashpot_viscosities[i])[_qp]);
     107           0 :       double gamma = (*_dashpot_viscosities[i])[_qp] / (_dt * theta_i);
     108           0 :       cumulated_driving_tensor += (*_springs_elasticity_tensors_inv[i])[_qp] / (1. + gamma);
     109             :     }
     110             : 
     111         992 :     _apparent_creep_strain[_qp] +=
     112         992 :         (_elasticity_tensor[_qp] * cumulated_driving_tensor) * (*_driving_eigenstrain)[_qp];
     113             : 
     114         992 :     if (_has_longterm_dashpot)
     115             :     {
     116         992 :       double theta_i = computeTheta(_dt, (*_dashpot_viscosities.back())[_qp]);
     117         992 :       double gamma = (*_dashpot_viscosities.back())[_qp] / (_dt * theta_i);
     118         992 :       _apparent_creep_strain[_qp] += (*_driving_eigenstrain)[_qp] / gamma;
     119             :     }
     120             :   }
     121        5312 : }

Generated by: LCOV version 1.14