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 "ADCompute2DSmallStrain.h" 11 : 12 : #include "libmesh/quadrature.h" 13 : 14 : InputParameters 15 108 : ADCompute2DSmallStrain::validParams() 16 : { 17 108 : InputParameters params = ADComputeSmallStrain::validParams(); 18 108 : params.addClassDescription("Compute a small strain in a plane strain configuration."); 19 216 : MooseEnum outOfPlaneDirection("x y z", "z"); 20 216 : params.addParam<MooseEnum>( 21 : "out_of_plane_direction", outOfPlaneDirection, "The direction of the out-of-plane strain."); 22 108 : return params; 23 108 : } 24 : 25 81 : ADCompute2DSmallStrain::ADCompute2DSmallStrain(const InputParameters & parameters) 26 : : ADComputeSmallStrain(parameters), 27 162 : _out_of_plane_direction(getParam<MooseEnum>("out_of_plane_direction")) 28 : { 29 81 : } 30 : 31 : void 32 81 : ADCompute2DSmallStrain::initialSetup() 33 : { 34 81 : displacementIntegrityCheck(); 35 324 : for (unsigned int i = 0; i < 3; ++i) 36 : { 37 243 : if (_out_of_plane_direction == i) 38 : { 39 81 : _disp[i] = &_ad_zero; 40 81 : _grad_disp[i] = &_ad_grad_zero; 41 : } 42 : else 43 : { 44 162 : _disp[i] = &adCoupledValue("displacements", i); 45 162 : _grad_disp[i] = &adCoupledGradient("displacements", i); 46 : } 47 : } 48 81 : } 49 : 50 : void 51 50280 : ADCompute2DSmallStrain::computeProperties() 52 : { 53 50280 : const auto o0 = _out_of_plane_direction; 54 50280 : const auto o1 = (_out_of_plane_direction + 1) % 3; 55 50280 : const auto o2 = (_out_of_plane_direction + 2) % 3; 56 : 57 50280 : ADReal volumetric_strain = 0.0; 58 275848 : for (_qp = 0; _qp < _qrule->n_points(); ++_qp) 59 : { 60 225568 : _total_strain[_qp](o0, o0) = computeOutOfPlaneStrain(); 61 225568 : _total_strain[_qp](o1, o1) = (*_grad_disp[o1])[_qp](o1); 62 225568 : _total_strain[_qp](o2, o2) = (*_grad_disp[o2])[_qp](o2); 63 451136 : _total_strain[_qp](o1, o2) = ((*_grad_disp[o1])[_qp](o2) + (*_grad_disp[o2])[_qp](o1)) / 2.0; 64 225568 : _total_strain[_qp](o2, o1) = _total_strain[_qp](o1, o2); // force the symmetrical strain tensor 65 : 66 225568 : if (_volumetric_locking_correction) 67 0 : volumetric_strain += _total_strain[_qp].trace() * _JxW[_qp] * _coord[_qp]; 68 : } 69 : 70 50280 : if (_volumetric_locking_correction) 71 0 : volumetric_strain /= _current_elem_volume; 72 : 73 275848 : for (_qp = 0; _qp < _qrule->n_points(); ++_qp) 74 : { 75 225568 : 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 225568 : _mechanical_strain[_qp] = _total_strain[_qp]; 84 : 85 : // Remove the eigenstrains 86 226528 : for (const auto es : _eigenstrains) 87 960 : _mechanical_strain[_qp] -= (*es)[_qp]; 88 : } 89 50280 : } 90 : 91 : void 92 81 : ADCompute2DSmallStrain::displacementIntegrityCheck() 93 : { 94 81 : 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 81 : 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 81 : }