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