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

Generated by: LCOV version 1.14