LCOV - code coverage report
Current view: top level - src/kernels - ADStressDivergenceRZTensors.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #32971 (54bef8) with base c6cf66 Lines: 43 46 93.5 %
Date: 2026-05-29 20:40:07 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          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         332 : ADStressDivergenceRZTensors::validParams()
      20             : {
      21         332 :   InputParameters params = ADStressDivergenceTensors::validParams();
      22         332 :   params.addClassDescription(
      23             :       "Calculate stress divergence for an axisymmetric problem in cylindrical coordinates.");
      24         664 :   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         332 :   params.set<bool>("use_displaced_mesh") = true;
      30         332 :   return params;
      31           0 : }
      32             : 
      33         166 : ADStressDivergenceRZTensors::ADStressDivergenceRZTensors(const InputParameters & parameters)
      34         166 :   : ADStressDivergenceTensors(parameters)
      35             : {
      36         166 : }
      37             : 
      38             : void
      39         166 : ADStressDivergenceRZTensors::initialSetup()
      40             : {
      41         166 :   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         166 : }
      45             : 
      46             : ADReal
      47    14882176 : ADStressDivergenceRZTensors::computeQpResidual()
      48             : {
      49    14882176 :   ADReal div = 0.0;
      50    14882176 :   if (_component == 0)
      51             :   {
      52     7441088 :     div = _grad_test[_i][_qp](0) * _stress[_qp](0, 0) +
      53     7441088 :           (_test[_i][_qp] / _ad_q_point[_qp](0)) * _stress[_qp](2, 2) +
      54    14882176 :           _grad_test[_i][_qp](1) * _stress[_qp](0, 1); // stress_{rz}
      55             : 
      56             :     // volumetric locking correction
      57     7441088 :     if (_volumetric_locking_correction)
      58     3967424 :       div += (_avg_grad_test[_i] - _grad_test[_i][_qp](0) - _test[_i][_qp] / _ad_q_point[_qp](0)) *
      59     3967424 :              (_stress[_qp].trace()) / 3.0;
      60             :   }
      61     7441088 :   else if (_component == 1)
      62             :   {
      63     7441088 :     div = _grad_test[_i][_qp](1) * _stress[_qp](1, 1) +
      64    14882176 :           _grad_test[_i][_qp](0) * _stress[_qp](1, 0); // stress_{zr}
      65             : 
      66             :     // volumetric locking correction
      67     7441088 :     if (_volumetric_locking_correction)
      68     3967424 :       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    14882176 :   return div;
      74             : }
      75             : 
      76             : void
      77      698800 : ADStressDivergenceRZTensors::precalculateResidual()
      78             : {
      79      698800 :   if (!_volumetric_locking_correction)
      80      450836 :     return;
      81             : 
      82      247964 :   ADReal ad_current_elem_volume = 0.0;
      83     1239820 :   for (unsigned int qp = 0; qp < _qrule->n_points(); qp++)
      84     1983712 :     ad_current_elem_volume += _ad_JxW[qp] * _ad_coord[qp];
      85             : 
      86             :   // calculate volume averaged value of shape function derivative
      87      247964 :   _avg_grad_test.resize(_test.size());
      88     1239820 :   for (_i = 0; _i < _test.size(); ++_i)
      89             :   {
      90      991856 :     _avg_grad_test[_i] = 0.0;
      91     4959280 :     for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
      92             :     {
      93     3967424 :       if (_component == 0)
      94     1983712 :         _avg_grad_test[_i] +=
      95     3967424 :             (_grad_test[_i][_qp](_component) + _test[_i][_qp] / _ad_q_point[_qp](0)) *
      96     3967424 :             _ad_JxW[_qp] * _ad_coord[_qp];
      97             :       else
      98     3967424 :         _avg_grad_test[_i] += _grad_test[_i][_qp](_component) * _ad_JxW[_qp] * _ad_coord[_qp];
      99             :     }
     100      991856 :     _avg_grad_test[_i] /= ad_current_elem_volume;
     101             :   }
     102             : }

Generated by: LCOV version 1.14