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