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 "ADStressDivergenceRZTensors.h" 11 : #include "Assembly.h" 12 : #include "RankTwoTensor.h" 13 : #include "ElasticityTensorTools.h" 14 : #include "libmesh/quadrature.h" 15 : 16 : registerMooseObject("SolidMechanicsApp", ADStressDivergenceRZTensors); 17 : 18 : InputParameters 19 552 : ADStressDivergenceRZTensors::validParams() 20 : { 21 552 : InputParameters params = ADStressDivergenceTensors::validParams(); 22 552 : params.addClassDescription( 23 : "Calculate stress divergence for an axisymmetric problem in cylindrical coordinates."); 24 1104 : params.addRequiredRangeCheckedParam<unsigned int>( 25 : "component", 26 : "component < 2", 27 : "An integer corresponding to the direction the variable this kernel acts in. (0 " 28 : "refers to the radial and 1 to the axial displacement.)"); 29 552 : params.set<bool>("use_displaced_mesh") = true; 30 552 : return params; 31 0 : } 32 : 33 276 : ADStressDivergenceRZTensors::ADStressDivergenceRZTensors(const InputParameters & parameters) 34 276 : : ADStressDivergenceTensors(parameters) 35 : { 36 276 : } 37 : 38 : void 39 276 : ADStressDivergenceRZTensors::initialSetup() 40 : { 41 276 : if (getBlockCoordSystem() != Moose::COORD_RZ) 42 0 : mooseError("The coordinate system in the Problem block must be set to RZ for axisymmetric " 43 : "geometries."); 44 276 : } 45 : 46 : ADReal 47 24609408 : ADStressDivergenceRZTensors::computeQpResidual() 48 : { 49 24609408 : ADReal div = 0.0; 50 24609408 : if (_component == 0) 51 : { 52 12304704 : div = _grad_test[_i][_qp](0) * _stress[_qp](0, 0) + 53 12304704 : (_test[_i][_qp] / _ad_q_point[_qp](0)) * _stress[_qp](2, 2) + 54 24609408 : _grad_test[_i][_qp](1) * _stress[_qp](0, 1); // stress_{rz} 55 : 56 : // volumetric locking correction 57 12304704 : if (_volumetric_locking_correction) 58 7757056 : div += (_avg_grad_test[_i] - _grad_test[_i][_qp](0) - _test[_i][_qp] / _ad_q_point[_qp](0)) * 59 7757056 : (_stress[_qp].trace()) / 3.0; 60 : } 61 12304704 : else if (_component == 1) 62 : { 63 12304704 : div = _grad_test[_i][_qp](1) * _stress[_qp](1, 1) + 64 24609408 : _grad_test[_i][_qp](0) * _stress[_qp](1, 0); // stress_{zr} 65 : 66 : // volumetric locking correction 67 12304704 : if (_volumetric_locking_correction) 68 7757056 : div += (_avg_grad_test[_i] - _grad_test[_i][_qp](1)) * (_stress[_qp].trace()) / 3.0; 69 : } 70 : else 71 0 : mooseError("Invalid component for this AxisymmetricRZ problem."); 72 : 73 24609408 : return div; 74 : } 75 : 76 : void 77 1287376 : ADStressDivergenceRZTensors::precalculateResidual() 78 : { 79 1287376 : if (!_volumetric_locking_correction) 80 802560 : return; 81 : 82 484816 : ADReal ad_current_elem_volume = 0.0; 83 2424080 : for (unsigned int qp = 0; qp < _qrule->n_points(); qp++) 84 3878528 : ad_current_elem_volume += _ad_JxW[qp] * _ad_coord[qp]; 85 : 86 : // calculate volume averaged value of shape function derivative 87 484816 : _avg_grad_test.resize(_test.size()); 88 2424080 : for (_i = 0; _i < _test.size(); ++_i) 89 : { 90 1939264 : _avg_grad_test[_i] = 0.0; 91 9696320 : for (_qp = 0; _qp < _qrule->n_points(); ++_qp) 92 : { 93 7757056 : if (_component == 0) 94 3878528 : _avg_grad_test[_i] += 95 7757056 : (_grad_test[_i][_qp](_component) + _test[_i][_qp] / _ad_q_point[_qp](0)) * 96 7757056 : _ad_JxW[_qp] * _ad_coord[_qp]; 97 : else 98 7757056 : _avg_grad_test[_i] += _grad_test[_i][_qp](_component) * _ad_JxW[_qp] * _ad_coord[_qp]; 99 : } 100 1939264 : _avg_grad_test[_i] /= ad_current_elem_volume; 101 : } 102 : }