LCOV - code coverage report
Current view: top level - src/kernels - ADDynamicStressDivergenceTensors.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 27 36 75.0 %
Date: 2025-07-25 05:00:39 Functions: 3 3 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 "ADDynamicStressDivergenceTensors.h"
      11             : #include "ElasticityTensorTools.h"
      12             : 
      13             : registerMooseObject("SolidMechanicsApp", ADDynamicStressDivergenceTensors);
      14             : 
      15             : InputParameters
      16         108 : ADDynamicStressDivergenceTensors::validParams()
      17             : {
      18         108 :   InputParameters params = ADStressDivergenceTensors::validParams();
      19         108 :   params.addClassDescription(
      20             :       "Residual due to stress related Rayleigh damping and HHT time integration terms");
      21         216 :   params.addParam<MaterialPropertyName>("zeta",
      22         216 :                                         0.0,
      23             :                                         "Name of material property or a constant real "
      24             :                                         "number defining the zeta parameter for the "
      25             :                                         "Rayleigh damping.");
      26         216 :   params.addParam<Real>("alpha", 0, "alpha parameter for HHT time integration");
      27         216 :   params.addParam<bool>("static_initialization",
      28         216 :                         false,
      29             :                         "Set to true to get the system to "
      30             :                         "equilibrium under gravity by running a "
      31             :                         "quasi-static analysis (by solving Ku = F) "
      32             :                         "in the first time step");
      33         108 :   return params;
      34           0 : }
      35             : 
      36          54 : ADDynamicStressDivergenceTensors::ADDynamicStressDivergenceTensors(
      37          54 :     const InputParameters & parameters)
      38             :   : ADStressDivergenceTensors(parameters),
      39          54 :     _stress_older(getMaterialPropertyOlder<RankTwoTensor>(_base_name + "stress")),
      40         108 :     _stress_old(getMaterialPropertyOld<RankTwoTensor>(_base_name + "stress")),
      41         108 :     _zeta(getMaterialProperty<Real>("zeta")),
      42         108 :     _alpha(getParam<Real>("alpha")),
      43         162 :     _static_initialization(getParam<bool>("static_initialization"))
      44             : {
      45          54 : }
      46             : 
      47             : ADReal
      48    12579840 : ADDynamicStressDivergenceTensors::computeQpResidual()
      49             : {
      50             :   /**
      51             :    *This kernel needs to be used only if either Rayleigh damping or numerical damping through HHT
      52             :    *time integration scheme needs to be added to the problem through the stiffness dependent damping
      53             :    * parameter _zeta or HHT parameter _alpha, respectively.
      54             :    *
      55             :    * The residual of _zeta*K*[(1+_alpha)vel-_alpha vel_old]+ alpha K [ u - uold] + K u is required
      56             :    * = _zeta*[(1+_alpha)d/dt (Div sigma)-alpha d/dt(Div sigma_old)] +alpha [Div sigma - Div
      57             :    *sigma_old]+ Div sigma
      58             :    * = _zeta*[(1+alpha)(Div sigma - Div sigma_old)/dt - alpha (Div sigma_old - Div sigma_older)/dt]
      59             :    *   + alpha [Div sigma - Div sigma_old] +Div sigma
      60             :    * = [(1+_alpha)*_zeta/dt +_alpha+1]* Div sigma - [(1+2_alpha)*_zeta/dt + _alpha] Div sigma_old +
      61             :    *_alpha*_zeta/dt Div sigma_older
      62             :    */
      63             : 
      64             :   ADReal residual;
      65    12579840 :   if (_static_initialization && _t == _dt)
      66             :   {
      67             :     // If static initialization is true, then in the first step residual is only Ku which is
      68             :     // stress.grad(test).
      69           0 :     residual = _stress[_qp].row(_component) * _grad_test[_i][_qp];
      70             : 
      71           0 :     if (_volumetric_locking_correction)
      72             :       residual +=
      73           0 :           _stress[_qp].trace() / 3.0 * (_avg_grad_test[_i] - _grad_test[_i][_qp](_component));
      74             :   }
      75    12579840 :   else if (_dt > 0)
      76             :   {
      77             :     residual =
      78    12579840 :         _stress[_qp].row(_component) * _grad_test[_i][_qp] *
      79    12579840 :             (1.0 + _alpha + (1.0 + _alpha) * _zeta[_qp] / _dt) -
      80    25159680 :         (_alpha + (1.0 + 2.0 * _alpha) * _zeta[_qp] / _dt) * _stress_old[_qp].row(_component) *
      81    12579840 :             _grad_test[_i][_qp] +
      82    37739520 :         (_alpha * _zeta[_qp] / _dt) * _stress_older[_qp].row(_component) * _grad_test[_i][_qp];
      83             : 
      84    12579840 :     if (_volumetric_locking_correction)
      85           0 :       residual += (_stress[_qp].trace() * (1.0 + _alpha + (1.0 + _alpha) * _zeta[_qp] / _dt) -
      86           0 :                    (_alpha + (1.0 + 2.0 * _alpha) * _zeta[_qp] / _dt) * _stress_old[_qp].trace() +
      87           0 :                    (_alpha * _zeta[_qp] / _dt) * _stress_older[_qp].trace()) /
      88           0 :                   3.0 * (_avg_grad_test[_i] - _grad_test[_i][_qp](_component));
      89             :   }
      90             :   else
      91           0 :     residual = 0.0;
      92             : 
      93    12579840 :   return residual;
      94             : }

Generated by: LCOV version 1.14