LCOV - code coverage report
Current view: top level - src/materials - GeneralizedMaxwellBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 53 64 82.8 %
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 "GeneralizedMaxwellBase.h"
      11             : 
      12             : InputParameters
      13          48 : GeneralizedMaxwellBase::validParams()
      14             : {
      15          48 :   InputParameters params = LinearViscoelasticityBase::validParams();
      16          48 :   return params;
      17             : }
      18             : 
      19          36 : GeneralizedMaxwellBase::GeneralizedMaxwellBase(const InputParameters & parameters)
      20          36 :   : LinearViscoelasticityBase(parameters)
      21             : {
      22          36 :   _need_viscoelastic_properties_inverse = false;
      23          36 : }
      24             : 
      25             : void
      26        1984 : GeneralizedMaxwellBase::updateQpViscousStrains()
      27             : {
      28        1984 :   if (_t_step <= 1)
      29          64 :     return;
      30             : 
      31        1920 :   RankTwoTensor effective_strain = _elastic_strain_old[_qp] + _creep_strain_old[_qp];
      32        1920 :   if (_has_driving_eigenstrain)
      33         960 :     effective_strain += (*_driving_eigenstrain_old)[_qp];
      34             : 
      35        4800 :   for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
      36             :   {
      37        2880 :     Real theta_i = computeTheta(_dt_old, (*_dashpot_viscosities_old[i])[_qp]);
      38        2880 :     Real gamma = (*_dashpot_viscosities_old[i])[_qp] / (_dt_old * theta_i);
      39        2880 :     (*_viscous_strains[i])[_qp] =
      40        2880 :         (*_viscous_strains_old[i])[_qp] *
      41        2880 :         (((*_dashpot_viscosities_old[i])[_qp] * gamma - _dt_old * (1. - theta_i) * gamma) /
      42        2880 :          ((*_dashpot_viscosities_old[i])[_qp] * (1. + gamma)));
      43             :     (*_viscous_strains[i])[_qp] +=
      44        5760 :         effective_strain *
      45        2880 :         (((*_dashpot_viscosities_old[i])[_qp] + _dt_old * (1. - theta_i) * gamma) /
      46        2880 :          ((*_dashpot_viscosities_old[i])[_qp] * (1. + gamma)));
      47             :   }
      48             : 
      49        1920 :   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        1984 : GeneralizedMaxwellBase::computeQpApparentElasticityTensors()
      60             : {
      61             : 
      62        1984 :   _elasticity_tensor[_qp] = _first_elasticity_tensor[_qp];
      63        1984 :   _apparent_elasticity_tensor[_qp] = _first_elasticity_tensor[_qp];
      64             : 
      65        4960 :   for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
      66             :   {
      67        2976 :     Real theta_i = computeTheta(_dt, (*_dashpot_viscosities[i])[_qp]);
      68        2976 :     Real gamma = (*_dashpot_viscosities[i])[_qp] / (_dt * theta_i);
      69        2976 :     _elasticity_tensor[_qp] += (*_springs_elasticity_tensors[i])[_qp];
      70        2976 :     _apparent_elasticity_tensor[_qp] +=
      71        5952 :         (*_springs_elasticity_tensors[i])[_qp] * (gamma / (1. + gamma));
      72             :   }
      73             : 
      74        1984 :   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        1984 :   _apparent_elasticity_tensor_inv[_qp] = _apparent_elasticity_tensor[_qp].invSymm();
      85        1984 :   _elasticity_tensor_inv[_qp] = _elasticity_tensor[_qp].invSymm();
      86        1984 : }
      87             : 
      88             : void
      89        1984 : GeneralizedMaxwellBase::computeQpApparentCreepStrain()
      90             : {
      91        1984 :   _apparent_creep_strain[_qp].zero();
      92             : 
      93        4960 :   for (unsigned int i = 0; i < _springs_elasticity_tensors.size(); ++i)
      94             :   {
      95        2976 :     Real theta_i = computeTheta(_dt, (*_dashpot_viscosities[i])[_qp]);
      96        2976 :     Real gamma = (*_dashpot_viscosities[i])[_qp] / (_dt * theta_i);
      97        2976 :     _apparent_creep_strain[_qp] +=
      98        2976 :         ((*_springs_elasticity_tensors[i])[_qp] * (*_viscous_strains[i])[_qp]) *
      99        2976 :         (gamma / (1. + gamma));
     100             :   }
     101             : 
     102        1984 :   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        1984 :   _apparent_creep_strain[_qp] = _apparent_elasticity_tensor_inv[_qp] * _apparent_creep_strain[_qp];
     111             : 
     112        1984 :   if (_has_driving_eigenstrain)
     113             :   {
     114         992 :     _apparent_creep_strain[_qp] +=
     115         992 :         (_elasticity_tensor[_qp] * _apparent_elasticity_tensor_inv[_qp]) *
     116        1984 :         (*_driving_eigenstrain)[_qp];
     117         992 :     _apparent_creep_strain[_qp] -= (*_driving_eigenstrain)[_qp];
     118             :   }
     119        1984 : }

Generated by: LCOV version 1.14