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

Generated by: LCOV version 1.14