LCOV - code coverage report
Current view: top level - src/materials - GeneralizedMaxwellBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #31405 (292dce) with base fef103 Lines: 53 64 82.8 %
Date: 2025-09-04 07:57:23 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 "GeneralizedMaxwellBase.h"
      11             : 
      12             : InputParameters
      13          56 : GeneralizedMaxwellBase::validParams()
      14             : {
      15          56 :   InputParameters params = LinearViscoelasticityBase::validParams();
      16          56 :   return params;
      17             : }
      18             : 
      19          42 : GeneralizedMaxwellBase::GeneralizedMaxwellBase(const InputParameters & parameters)
      20          42 :   : LinearViscoelasticityBase(parameters)
      21             : {
      22          42 :   _need_viscoelastic_properties_inverse = false;
      23          42 : }
      24             : 
      25             : void
      26        2496 : GeneralizedMaxwellBase::updateQpViscousStrains()
      27             : {
      28        2496 :   if (_t_step <= 1)
      29          80 :     return;
      30             : 
      31        2416 :   RankTwoTensor effective_strain = _elastic_strain_old[_qp] + _creep_strain_old[_qp];
      32        2416 :   if (_has_driving_eigenstrain)
      33        1208 :     effective_strain += (*_driving_eigenstrain_old)[_qp];
      34             : 
      35        6040 :   for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
      36             :   {
      37        3624 :     Real theta_i = computeTheta(_dt_old, (*_dashpot_viscosities_old[i])[_qp]);
      38        3624 :     Real gamma = (*_dashpot_viscosities_old[i])[_qp] / (_dt_old * theta_i);
      39        3624 :     (*_viscous_strains[i])[_qp] =
      40        3624 :         (*_viscous_strains_old[i])[_qp] *
      41        3624 :         (((*_dashpot_viscosities_old[i])[_qp] * gamma - _dt_old * (1. - theta_i) * gamma) /
      42        3624 :          ((*_dashpot_viscosities_old[i])[_qp] * (1. + gamma)));
      43             :     (*_viscous_strains[i])[_qp] +=
      44        7248 :         effective_strain *
      45        3624 :         (((*_dashpot_viscosities_old[i])[_qp] + _dt_old * (1. - theta_i) * gamma) /
      46        3624 :          ((*_dashpot_viscosities_old[i])[_qp] * (1. + gamma)));
      47             :   }
      48             : 
      49        2416 :   if (_has_longterm_dashpot)
      50             :   {
      51           0 :     Real theta_i = computeTheta(_dt_old, (*_dashpot_viscosities_old.back())[_qp]);
      52           0 :     (*_viscous_strains.back())[_qp] = effective_strain / theta_i;
      53             :     (*_viscous_strains.back())[_qp] -=
      54           0 :         (*_viscous_strains_old.back())[_qp] * ((1. - theta_i) / theta_i);
      55             :   }
      56             : }
      57             : 
      58             : void
      59        2496 : GeneralizedMaxwellBase::computeQpApparentElasticityTensors()
      60             : {
      61             : 
      62        2496 :   _elasticity_tensor[_qp] = _first_elasticity_tensor[_qp];
      63        2496 :   _apparent_elasticity_tensor[_qp] = _first_elasticity_tensor[_qp];
      64             : 
      65        6240 :   for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
      66             :   {
      67        3744 :     Real theta_i = computeTheta(_dt, (*_dashpot_viscosities[i])[_qp]);
      68        3744 :     Real gamma = (*_dashpot_viscosities[i])[_qp] / (_dt * theta_i);
      69        3744 :     _elasticity_tensor[_qp] += (*_springs_elasticity_tensors[i])[_qp];
      70        3744 :     _apparent_elasticity_tensor[_qp] +=
      71        7488 :         (*_springs_elasticity_tensors[i])[_qp] * (gamma / (1. + gamma));
      72             :   }
      73             : 
      74        2496 :   if (_has_longterm_dashpot)
      75             :   {
      76           0 :     Real theta_i = computeTheta(_dt, (*_dashpot_viscosities.back())[_qp]);
      77           0 :     Real gamma = (*_dashpot_viscosities.back())[_qp] / (_dt * theta_i);
      78           0 :     _apparent_elasticity_tensor[_qp] += _first_elasticity_tensor[_qp] * gamma;
      79             : 
      80           0 :     mooseDoOnce(mooseWarning("Generalized Maxwell model with longterm viscosity may not converge "
      81             :                              "under Dirichlet boundary conditions"));
      82             :   }
      83             : 
      84        2496 :   _apparent_elasticity_tensor_inv[_qp] = _apparent_elasticity_tensor[_qp].invSymm();
      85        2496 :   _elasticity_tensor_inv[_qp] = _elasticity_tensor[_qp].invSymm();
      86        2496 : }
      87             : 
      88             : void
      89        2496 : GeneralizedMaxwellBase::computeQpApparentCreepStrain()
      90             : {
      91        2496 :   _apparent_creep_strain[_qp].zero();
      92             : 
      93        6240 :   for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
      94             :   {
      95        3744 :     Real theta_i = computeTheta(_dt, (*_dashpot_viscosities[i])[_qp]);
      96        3744 :     Real gamma = (*_dashpot_viscosities[i])[_qp] / (_dt * theta_i);
      97        3744 :     _apparent_creep_strain[_qp] +=
      98        3744 :         ((*_springs_elasticity_tensors[i])[_qp] * (*_viscous_strains[i])[_qp]) *
      99        3744 :         (gamma / (1. + gamma));
     100             :   }
     101             : 
     102        2496 :   if (_has_longterm_dashpot)
     103             :   {
     104           0 :     Real theta_i = computeTheta(_dt, (*_dashpot_viscosities.back())[_qp]);
     105           0 :     Real gamma = (*_dashpot_viscosities.back())[_qp] / (_dt * theta_i);
     106           0 :     _apparent_creep_strain[_qp] +=
     107           0 :         (_first_elasticity_tensor[_qp] * (*_viscous_strains.back())[_qp]) * gamma;
     108             :   }
     109             : 
     110        2496 :   _apparent_creep_strain[_qp] = _apparent_elasticity_tensor_inv[_qp] * _apparent_creep_strain[_qp];
     111             : 
     112        2496 :   if (_has_driving_eigenstrain)
     113             :   {
     114        1248 :     _apparent_creep_strain[_qp] +=
     115        1248 :         (_elasticity_tensor[_qp] * _apparent_elasticity_tensor_inv[_qp]) *
     116        2496 :         (*_driving_eigenstrain)[_qp];
     117        1248 :     _apparent_creep_strain[_qp] -= (*_driving_eigenstrain)[_qp];
     118             :   }
     119        2496 : }

Generated by: LCOV version 1.14