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 "ADCompute2DSmallStrain.h" 11 : 12 : #include "libmesh/quadrature.h" 13 : 14 : InputParameters 15 216 : ADCompute2DSmallStrain::validParams() 16 : { 17 216 : InputParameters params = ADComputeSmallStrain::validParams(); 18 216 : params.addClassDescription("Compute a small strain in a plane strain configuration."); 19 432 : MooseEnum outOfPlaneDirection("x y z", "z"); 20 432 : params.addParam<MooseEnum>( 21 : "out_of_plane_direction", outOfPlaneDirection, "The direction of the out-of-plane strain."); 22 216 : return params; 23 216 : } 24 : 25 162 : ADCompute2DSmallStrain::ADCompute2DSmallStrain(const InputParameters & parameters) 26 : : ADComputeSmallStrain(parameters), 27 324 : _out_of_plane_direction(getParam<MooseEnum>("out_of_plane_direction")) 28 : { 29 162 : } 30 : 31 : void 32 162 : ADCompute2DSmallStrain::initialSetup() 33 : { 34 162 : displacementIntegrityCheck(); 35 648 : for (unsigned int i = 0; i < 3; ++i) 36 : { 37 486 : if (_out_of_plane_direction == i) 38 : { 39 162 : _disp[i] = &_ad_zero; 40 162 : _grad_disp[i] = &_ad_grad_zero; 41 : } 42 : else 43 : { 44 324 : _disp[i] = &adCoupledValue("displacements", i); 45 324 : _grad_disp[i] = &adCoupledGradient("displacements", i); 46 : } 47 : } 48 162 : } 49 : 50 : void 51 99320 : ADCompute2DSmallStrain::computeProperties() 52 : { 53 99320 : const auto o0 = _out_of_plane_direction; 54 99320 : const auto o1 = (_out_of_plane_direction + 1) % 3; 55 99320 : const auto o2 = (_out_of_plane_direction + 2) % 3; 56 : 57 99320 : ADReal volumetric_strain = 0.0; 58 543144 : for (_qp = 0; _qp < _qrule->n_points(); ++_qp) 59 : { 60 443824 : _total_strain[_qp](o0, o0) = computeOutOfPlaneStrain(); 61 443824 : _total_strain[_qp](o1, o1) = (*_grad_disp[o1])[_qp](o1); 62 443824 : _total_strain[_qp](o2, o2) = (*_grad_disp[o2])[_qp](o2); 63 887648 : _total_strain[_qp](o1, o2) = ((*_grad_disp[o1])[_qp](o2) + (*_grad_disp[o2])[_qp](o1)) / 2.0; 64 443824 : _total_strain[_qp](o2, o1) = _total_strain[_qp](o1, o2); // force the symmetrical strain tensor 65 : 66 443824 : if (_volumetric_locking_correction) 67 0 : volumetric_strain += _total_strain[_qp].trace() * _JxW[_qp] * _coord[_qp]; 68 : } 69 : 70 99320 : if (_volumetric_locking_correction) 71 0 : volumetric_strain /= _current_elem_volume; 72 : 73 543144 : for (_qp = 0; _qp < _qrule->n_points(); ++_qp) 74 : { 75 443824 : if (_volumetric_locking_correction) 76 : { 77 0 : const ADReal correction = (volumetric_strain - _total_strain[_qp].trace()) / 3.0; 78 0 : _total_strain[_qp](0, 0) += correction; 79 0 : _total_strain[_qp](1, 1) += correction; 80 0 : _total_strain[_qp](2, 2) += correction; 81 : } 82 : 83 443824 : _mechanical_strain[_qp] = _total_strain[_qp]; 84 : 85 : // Remove the eigenstrains 86 445488 : for (const auto es : _eigenstrains) 87 1664 : _mechanical_strain[_qp] -= (*es)[_qp]; 88 : } 89 99320 : } 90 : 91 : void 92 162 : ADCompute2DSmallStrain::displacementIntegrityCheck() 93 : { 94 162 : if (_out_of_plane_direction != 2 && _ndisp != 3) 95 0 : mooseError("For 2D simulations where the out-of-plane direction is x or y the number of " 96 : "supplied displacements must be three."); 97 162 : else if (_out_of_plane_direction == 2 && _ndisp != 2) 98 0 : mooseError("For 2D simulations where the out-of-plane direction is z the number of supplied " 99 : "displacements must be two."); 100 162 : }