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

Generated by: LCOV version 1.14