LCOV - code coverage report
Current view: top level - src/materials - ADCompute2DIncrementalStrain.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #31405 (292dce) with base fef103 Lines: 35 37 94.6 %
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 "ADCompute2DIncrementalStrain.h"
      11             : 
      12             : #include "libmesh/quadrature.h"
      13             : 
      14             : InputParameters
      15         108 : ADCompute2DIncrementalStrain::validParams()
      16             : {
      17         108 :   InputParameters params = ADComputeIncrementalStrain::validParams();
      18         108 :   params.addClassDescription("Compute strain increment for incremental strains in 2D geometries.");
      19             : 
      20         216 :   MooseEnum outOfPlaneDirection("x y z", "z");
      21         216 :   params.addParam<MooseEnum>(
      22             :       "out_of_plane_direction", outOfPlaneDirection, "The direction of the out-of-plane strain.");
      23         108 :   return params;
      24         108 : }
      25             : 
      26          81 : ADCompute2DIncrementalStrain::ADCompute2DIncrementalStrain(const InputParameters & parameters)
      27             :   : ADComputeIncrementalStrain(parameters),
      28         162 :     _out_of_plane_direction(getParam<MooseEnum>("out_of_plane_direction"))
      29             : {
      30          81 : }
      31             : 
      32             : void
      33          21 : ADCompute2DIncrementalStrain::initialSetup()
      34             : {
      35          84 :   for (unsigned int i = 0; i < 3; ++i)
      36             :   {
      37          63 :     if (_out_of_plane_direction == i)
      38             :     {
      39          21 :       _disp[i] = &_ad_zero;
      40          21 :       _grad_disp[i] = &_ad_grad_zero;
      41             :     }
      42             :     else
      43             :     {
      44          42 :       _disp[i] = &adCoupledValue("displacements", i);
      45          42 :       _grad_disp[i] = &adCoupledGradient("displacements", i);
      46             :     }
      47             : 
      48          63 :     if (_fe_problem.isTransient() && i != _out_of_plane_direction)
      49          42 :       _grad_disp_old[i] = &coupledGradientOld("displacements", i);
      50             :     else
      51          21 :       _grad_disp_old[i] = &_grad_zero;
      52             :   }
      53          21 : }
      54             : 
      55             : void
      56      156992 : ADCompute2DIncrementalStrain::computeTotalStrainIncrement(ADRankTwoTensor & total_strain_increment)
      57             : {
      58             :   // Deformation gradient calculation for 2D problems
      59             :   auto A = ADRankTwoTensor::initializeFromRows(
      60      156992 :       (*_grad_disp[0])[_qp], (*_grad_disp[1])[_qp], (*_grad_disp[2])[_qp]); // Deformation gradient
      61             :   auto Fbar =
      62      156992 :       RankTwoTensor::initializeFromRows((*_grad_disp_old[0])[_qp],
      63      156992 :                                         (*_grad_disp_old[1])[_qp],
      64      156992 :                                         (*_grad_disp_old[2])[_qp]); // Old Deformation gradient
      65             : 
      66             :   // Compute the displacement gradient of the out of plane direction for plane strain,
      67             :   // generalized plane strain, or axisymmetric problems
      68      156992 :   A(_out_of_plane_direction, _out_of_plane_direction) = computeOutOfPlaneGradDisp();
      69      156992 :   Fbar(_out_of_plane_direction, _out_of_plane_direction) = computeOutOfPlaneGradDispOld();
      70             : 
      71      156992 :   A -= Fbar; // very nearly A = gradU - gradUold
      72             : 
      73      156992 :   total_strain_increment = 0.5 * (A + A.transpose());
      74      156992 : }
      75             : 
      76             : void
      77          60 : ADCompute2DIncrementalStrain::displacementIntegrityCheck()
      78             : {
      79          60 :   if (_out_of_plane_direction != 2 && _ndisp != 3)
      80           0 :     mooseError("For 2D simulations where the out-of-plane direction is x or y the number of "
      81             :                "supplied displacements must be three.");
      82          60 :   else if (_out_of_plane_direction == 2 && _ndisp != 2)
      83           0 :     mooseError("For 2D simulations where the out-of-plane direction is z the number of supplied "
      84             :                "displacements must be two.");
      85          60 : }

Generated by: LCOV version 1.14