LCOV - code coverage report
Current view: top level - src/materials - Compute2DFiniteStrain.C (source / functions) Hit Total Coverage
Test: idaholab/moose tensor_mechanics: d6b47a Lines: 48 57 84.2 %
Date: 2024-02-27 11:53:14 Functions: 4 5 80.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 "Compute2DFiniteStrain.h"
      11             : 
      12             : #include "libmesh/quadrature.h"
      13             : 
      14             : InputParameters
      15         796 : Compute2DFiniteStrain::validParams()
      16             : {
      17         796 :   InputParameters params = ComputeFiniteStrain::validParams();
      18         796 :   params.addClassDescription(
      19             :       "Compute a strain increment and rotation increment for finite strains in 2D geometries.");
      20             : 
      21        1592 :   MooseEnum outOfPlaneDirection("x y z", "z");
      22        1592 :   params.addParam<MooseEnum>(
      23             :       "out_of_plane_direction", outOfPlaneDirection, "The direction of the out-of-plane strain.");
      24         796 :   return params;
      25         796 : }
      26             : 
      27         597 : Compute2DFiniteStrain::Compute2DFiniteStrain(const InputParameters & parameters)
      28             :   : ComputeFiniteStrain(parameters),
      29        1194 :     _out_of_plane_direction(getParam<MooseEnum>("out_of_plane_direction"))
      30             : {
      31         597 : }
      32             : 
      33             : void
      34         561 : Compute2DFiniteStrain::initialSetup()
      35             : {
      36        2244 :   for (unsigned int i = 0; i < 3; ++i)
      37             :   {
      38        1683 :     if (_out_of_plane_direction == i)
      39             :     {
      40         561 :       _disp[i] = &_zero;
      41         561 :       _grad_disp[i] = &_grad_zero;
      42             :     }
      43             :     else
      44             :     {
      45        1122 :       _disp[i] = &coupledValue("displacements", i);
      46        1122 :       _grad_disp[i] = &coupledGradient("displacements", i);
      47             :     }
      48             : 
      49        1683 :     if (_fe_problem.isTransient() && i != _out_of_plane_direction)
      50        1122 :       _grad_disp_old[i] = &coupledGradientOld("displacements", i);
      51             :     else
      52         561 :       _grad_disp_old[i] = &_grad_zero;
      53             :   }
      54         561 : }
      55             : 
      56             : void
      57     1079670 : Compute2DFiniteStrain::computeProperties()
      58             : {
      59     1079670 :   RankTwoTensor ave_Fhat;
      60             :   Real ave_dfgrd_det = 0.0;
      61             : 
      62     5394090 :   for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
      63             :   {
      64             :     // Deformation gradient calculation for 2D problems
      65             :     auto A = RankTwoTensor::initializeFromRows(
      66     4314420 :         (*_grad_disp[0])[_qp], (*_grad_disp[1])[_qp], (*_grad_disp[2])[_qp]);
      67             : 
      68             :     // Old Deformation gradient
      69             :     auto Fbar = RankTwoTensor::initializeFromRows(
      70     4314420 :         (*_grad_disp_old[0])[_qp], (*_grad_disp_old[1])[_qp], (*_grad_disp_old[2])[_qp]);
      71             : 
      72             :     // Compute the displacement gradient for the out of plane direction for plane strain,
      73             :     // generalized plane strain, or axisymmetric problems
      74             : 
      75     4314420 :     A(_out_of_plane_direction, _out_of_plane_direction) = computeOutOfPlaneGradDisp();
      76     4314420 :     Fbar(_out_of_plane_direction, _out_of_plane_direction) = computeOutOfPlaneGradDispOld();
      77             : 
      78             :     // Gauss point deformation gradient
      79     4314420 :     _deformation_gradient[_qp] = A;
      80     4314420 :     _deformation_gradient[_qp].addIa(1.0);
      81             : 
      82             :     // deformation gradient midpoint
      83     4314420 :     if (_use_hw)
      84             :     {
      85           0 :       (*_def_grad_mid)[_qp].setToIdentity();
      86           0 :       (*_def_grad_mid)[_qp] += 0.5 * (A + Fbar);
      87             :     }
      88             : 
      89     4314420 :     A -= Fbar; // very nearly A = gradU - gradUold
      90             : 
      91             :     // _f_bar = dDU/dX_o
      92     4314420 :     if (_use_hw)
      93           0 :       (*_f_bar)[_qp] = A;
      94             : 
      95     4314420 :     Fbar.addIa(1.0); // Fbar = ( I + gradUold)
      96             : 
      97             :     // Incremental deformation gradient _Fhat = I + A Fbar^-1
      98     4314420 :     _Fhat[_qp] = A * Fbar.inverse();
      99     4314420 :     _Fhat[_qp].addIa(1.0);
     100             : 
     101     4314420 :     if (_volumetric_locking_correction)
     102             :     {
     103             :       // Calculate average _Fhat for volumetric locking correction
     104     3506016 :       ave_Fhat += _Fhat[_qp] * _JxW[_qp] * _coord[_qp];
     105             : 
     106             :       // Average deformation gradient
     107     3506016 :       ave_dfgrd_det += _deformation_gradient[_qp].det() * _JxW[_qp] * _coord[_qp];
     108             :     }
     109             :   }
     110     1079670 :   if (_volumetric_locking_correction)
     111             :   {
     112             :     // needed for volumetric locking correction
     113      876504 :     ave_Fhat /= _current_elem_volume;
     114             :     // average deformation gradient
     115      876504 :     ave_dfgrd_det /= _current_elem_volume;
     116             :   }
     117     5394090 :   for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
     118             :   {
     119     4314420 :     if (_volumetric_locking_correction)
     120             :     {
     121             :       // Finalize volumetric locking correction
     122     3506016 :       _Fhat[_qp] *= std::cbrt(ave_Fhat.det() / _Fhat[_qp].det());
     123             :       // Volumetric locking correction
     124     3506016 :       _deformation_gradient[_qp] *= std::cbrt(ave_dfgrd_det / _deformation_gradient[_qp].det());
     125             :     }
     126             : 
     127     4314420 :     computeQpStrain();
     128             :   }
     129     1079670 : }
     130             : 
     131             : void
     132           0 : Compute2DFiniteStrain::displacementIntegrityCheck()
     133             : {
     134           0 :   if (_out_of_plane_direction != 2 && _ndisp != 3)
     135           0 :     mooseError("For 2D simulations where the out-of-plane direction is x or y the number of "
     136             :                "supplied displacements must be three.");
     137           0 :   else if (_out_of_plane_direction == 2 && _ndisp != 2)
     138           0 :     mooseError("For 2D simulations where the out-of-plane direction is z the number of supplied "
     139             :                "displacements must be two.");
     140           0 : }

Generated by: LCOV version 1.14