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 "ADStressDivergenceRZTensors.h" 11 : #include "Assembly.h" 12 : #include "RankTwoTensor.h" 13 : #include "ElasticityTensorTools.h" 14 : #include "libmesh/quadrature.h" 15 : 16 : registerMooseObject("TensorMechanicsApp", ADStressDivergenceRZTensors); 17 : 18 : InputParameters 19 276 : ADStressDivergenceRZTensors::validParams() 20 : { 21 276 : InputParameters params = ADStressDivergenceTensors::validParams(); 22 276 : params.addClassDescription( 23 : "Calculate stress divergence for an axisymmetric problem in cylindrical coordinates."); 24 552 : 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 276 : params.set<bool>("use_displaced_mesh") = true; 30 276 : return params; 31 0 : } 32 : 33 138 : ADStressDivergenceRZTensors::ADStressDivergenceRZTensors(const InputParameters & parameters) 34 138 : : ADStressDivergenceTensors(parameters) 35 : { 36 138 : } 37 : 38 : void 39 138 : ADStressDivergenceRZTensors::initialSetup() 40 : { 41 138 : 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 138 : } 45 : 46 : ADReal 47 12598400 : ADStressDivergenceRZTensors::computeQpResidual() 48 : { 49 12598400 : ADReal div = 0.0; 50 12598400 : if (_component == 0) 51 : { 52 6299200 : div = _grad_test[_i][_qp](0) * _stress[_qp](0, 0) + 53 6299200 : (_test[_i][_qp] / _ad_q_point[_qp](0)) * _stress[_qp](2, 2) + 54 12598400 : _grad_test[_i][_qp](1) * _stress[_qp](0, 1); // stress_{rz} 55 : 56 : // volumetric locking correction 57 6299200 : if (_volumetric_locking_correction) 58 3910912 : div += (_avg_grad_test[_i] - _grad_test[_i][_qp](0) - _test[_i][_qp] / _ad_q_point[_qp](0)) * 59 3910912 : (_stress[_qp].trace()) / 3.0; 60 : } 61 6299200 : else if (_component == 1) 62 : { 63 6299200 : div = _grad_test[_i][_qp](1) * _stress[_qp](1, 1) + 64 12598400 : _grad_test[_i][_qp](0) * _stress[_qp](1, 0); // stress_{zr} 65 : 66 : // volumetric locking correction 67 6299200 : if (_volumetric_locking_correction) 68 3910912 : 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 12598400 : return div; 74 : } 75 : 76 : void 77 655296 : ADStressDivergenceRZTensors::precalculateResidual() 78 : { 79 655296 : if (!_volumetric_locking_correction) 80 410864 : return; 81 : 82 244432 : ADReal ad_current_elem_volume = 0.0; 83 1222160 : for (unsigned int qp = 0; qp < _qrule->n_points(); qp++) 84 1955456 : ad_current_elem_volume += _ad_JxW[qp] * _ad_coord[qp]; 85 : 86 : // calculate volume averaged value of shape function derivative 87 244432 : _avg_grad_test.resize(_test.size()); 88 1222160 : for (_i = 0; _i < _test.size(); ++_i) 89 : { 90 977728 : _avg_grad_test[_i] = 0.0; 91 4888640 : for (_qp = 0; _qp < _qrule->n_points(); ++_qp) 92 : { 93 3910912 : if (_component == 0) 94 1955456 : _avg_grad_test[_i] += 95 3910912 : (_grad_test[_i][_qp](_component) + _test[_i][_qp] / _ad_q_point[_qp](0)) * 96 3910912 : _ad_JxW[_qp] * _ad_coord[_qp]; 97 : else 98 3910912 : _avg_grad_test[_i] += _grad_test[_i][_qp](_component) * _ad_JxW[_qp] * _ad_coord[_qp]; 99 : } 100 977728 : _avg_grad_test[_i] /= ad_current_elem_volume; 101 : } 102 : }