LCOV - code coverage report
Current view: top level - src/materials - ADComputeSmallStrain.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 25 27 92.6 %
Date: 2025-07-25 05:00:39 Functions: 6 6 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 "ADComputeSmallStrain.h"
      11             : #include "RankTwoTensor.h"
      12             : #include "SymmetricRankTwoTensor.h"
      13             : #include "libmesh/quadrature.h"
      14             : 
      15             : registerMooseObject("SolidMechanicsApp", ADComputeSmallStrain);
      16             : registerMooseObject("SolidMechanicsApp", ADSymmetricSmallStrain);
      17             : 
      18             : template <typename R2>
      19             : InputParameters
      20        1512 : ADComputeSmallStrainTempl<R2>::validParams()
      21             : {
      22        1512 :   InputParameters params = ADComputeStrainBase::validParams();
      23        1512 :   params.addClassDescription("Compute a small strain.");
      24        1512 :   return params;
      25           0 : }
      26             : 
      27             : template <typename R2>
      28        1134 : ADComputeSmallStrainTempl<R2>::ADComputeSmallStrainTempl(const InputParameters & parameters)
      29        1134 :   : ADComputeStrainBaseTempl<R2>(parameters)
      30             : {
      31        1134 : }
      32             : 
      33             : template <typename R2>
      34             : void
      35     1376780 : ADComputeSmallStrainTempl<R2>::computeProperties()
      36             : {
      37     1376780 :   ADReal volumetric_strain = 0.0;
      38             : 
      39     9328204 :   for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
      40             :   {
      41             :     // strain = (grad_disp + grad_disp^R2)/2
      42     7951424 :     _total_strain[_qp] = Moose::ADType<R2>::type::initializeSymmetric(
      43     7951424 :         (*_grad_disp[0])[_qp], (*_grad_disp[1])[_qp], (*_grad_disp[2])[_qp]);
      44             : 
      45     7951424 :     if (_volumetric_locking_correction)
      46        4608 :       volumetric_strain += _total_strain[_qp].trace() * _JxW[_qp] * _coord[_qp];
      47             :   }
      48             : 
      49     1376780 :   if (_volumetric_locking_correction)
      50         288 :     volumetric_strain /= _current_elem_volume;
      51             : 
      52     9328204 :   for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
      53             :   {
      54     7951424 :     if (_volumetric_locking_correction)
      55             :     {
      56        2304 :       ADReal correction = (volumetric_strain - _total_strain[_qp].trace()) / 3.0;
      57        2304 :       _total_strain[_qp].addIa(correction);
      58             :     }
      59             : 
      60     7951424 :     if (_global_strain)
      61           0 :       _total_strain[_qp] += (*_global_strain)[_qp];
      62             : 
      63     7951424 :     _mechanical_strain[_qp] = _total_strain[_qp];
      64             : 
      65             :     // Remove the Eigen strain
      66    12141664 :     for (auto es : _eigenstrains)
      67     4190240 :       _mechanical_strain[_qp] -= (*es)[_qp];
      68             :   }
      69     1376780 : }
      70             : 
      71             : template class ADComputeSmallStrainTempl<RankTwoTensor>;
      72             : template class ADComputeSmallStrainTempl<SymmetricRankTwoTensor>;

Generated by: LCOV version 1.14