LCOV - code coverage report
Current view: top level - src/materials - ADComputeAxisymmetric1DFiniteStrain.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #33416 (b10b36) with base 9fbd27 Lines: 43 49 87.8 %
Date: 2026-07-23 16:20:48 Functions: 8 8 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 "ADComputeAxisymmetric1DFiniteStrain.h"
      11             : #include "UserObject.h"
      12             : 
      13             : registerMooseObject("SolidMechanicsApp", ADComputeAxisymmetric1DFiniteStrain);
      14             : 
      15             : InputParameters
      16          28 : ADComputeAxisymmetric1DFiniteStrain::validParams()
      17             : {
      18          28 :   InputParameters params = ADCompute1DFiniteStrain::validParams();
      19          28 :   params.addClassDescription("Compute a strain increment and rotation increment for finite strains "
      20             :                              "in an axisymmetric 1D problem");
      21          56 :   params.addParam<UserObjectName>("subblock_index_provider",
      22             :                                   "SubblockIndexProvider user object name");
      23          56 :   params.addCoupledVar("scalar_out_of_plane_strain", "Scalar variable for axisymmetric 1D problem");
      24          56 :   params.addCoupledVar("out_of_plane_strain", "Nonlinear variable for axisymmetric 1D problem");
      25             : 
      26          28 :   return params;
      27           0 : }
      28             : 
      29          21 : ADComputeAxisymmetric1DFiniteStrain::ADComputeAxisymmetric1DFiniteStrain(
      30          21 :     const InputParameters & parameters)
      31             :   : ADCompute1DFiniteStrain(parameters),
      32          21 :     _disp_old_0(coupledValueOld("displacements", 0)),
      33          21 :     _subblock_id_provider(isParamValid("subblock_index_provider")
      34          21 :                               ? &getUserObject<SubblockIndexProvider>("subblock_index_provider")
      35             :                               : nullptr),
      36          21 :     _has_out_of_plane_strain(isCoupled("out_of_plane_strain")),
      37          21 :     _out_of_plane_strain(_has_out_of_plane_strain ? adCoupledValue("out_of_plane_strain")
      38             :                                                   : _ad_zero),
      39          21 :     _out_of_plane_strain_old(_has_out_of_plane_strain ? coupledValueOld("out_of_plane_strain")
      40             :                                                       : _zero),
      41          42 :     _has_scalar_out_of_plane_strain(isCoupledScalar("scalar_out_of_plane_strain"))
      42             : {
      43          21 :   if (_has_out_of_plane_strain && _has_scalar_out_of_plane_strain)
      44           0 :     mooseError("Must define only one of out_of_plane_strain or scalar_out_of_plane_strain");
      45             : 
      46          21 :   if (_has_scalar_out_of_plane_strain)
      47             :   {
      48          21 :     const auto nscalar_strains = coupledScalarComponents("scalar_out_of_plane_strain");
      49          21 :     _scalar_out_of_plane_strain.resize(nscalar_strains);
      50          21 :     _scalar_out_of_plane_strain_old.resize(nscalar_strains);
      51          42 :     for (unsigned int i = 0; i < nscalar_strains; ++i)
      52             :     {
      53          21 :       _scalar_out_of_plane_strain[i] = &adCoupledScalarValue("scalar_out_of_plane_strain", i);
      54          21 :       _scalar_out_of_plane_strain_old[i] = &coupledScalarValueOld("scalar_out_of_plane_strain", i);
      55             :     }
      56             :   }
      57          21 : }
      58             : 
      59             : void
      60          21 : ADComputeAxisymmetric1DFiniteStrain::initialSetup()
      61             : {
      62          21 :   ADComputeIncrementalStrainBase::initialSetup();
      63             : 
      64          21 :   if (getBlockCoordSystem() != Moose::COORD_RZ)
      65           0 :     mooseError("The coordinate system must be set to RZ for Axisymmetric geometries.");
      66          21 : }
      67             : 
      68             : unsigned int
      69       11712 : ADComputeAxisymmetric1DFiniteStrain::getCurrentSubblockIndex() const
      70             : {
      71       11712 :   return _subblock_id_provider ? _subblock_id_provider->getSubblockIndex(*_current_elem) : 0;
      72             : }
      73             : 
      74             : ADReal
      75        5856 : ADComputeAxisymmetric1DFiniteStrain::computeGradDispYY()
      76             : {
      77             :   using std::exp;
      78        5856 :   if (_has_scalar_out_of_plane_strain)
      79       11712 :     return exp((*_scalar_out_of_plane_strain[getCurrentSubblockIndex()])[0]) - 1.0;
      80             :   else
      81           0 :     return exp(_out_of_plane_strain[_qp]) - 1.0;
      82             : }
      83             : 
      84             : Real
      85        5856 : ADComputeAxisymmetric1DFiniteStrain::computeGradDispYYOld()
      86             : {
      87             :   using std::exp;
      88        5856 :   if (_has_scalar_out_of_plane_strain)
      89        5856 :     return exp((*_scalar_out_of_plane_strain_old[getCurrentSubblockIndex()])[0]) - 1.0;
      90             :   else
      91           0 :     return exp(_out_of_plane_strain_old[_qp]) - 1.0;
      92             : }
      93             : 
      94             : ADReal
      95        5856 : ADComputeAxisymmetric1DFiniteStrain::computeGradDispZZ()
      96             : {
      97        5856 :   if (!MooseUtils::absoluteFuzzyEqual(_q_point[_qp](0), 0.0))
      98        5856 :     return (*_disp[0])[_qp] / _q_point[_qp](0);
      99             :   else
     100           0 :     return 0.0;
     101             : }
     102             : 
     103             : Real
     104        5856 : ADComputeAxisymmetric1DFiniteStrain::computeGradDispZZOld()
     105             : {
     106        5856 :   if (!MooseUtils::absoluteFuzzyEqual(_q_point[_qp](0), 0.0))
     107        5856 :     return _disp_old_0[_qp] / _q_point[_qp](0);
     108             :   else
     109             :     return 0.0;
     110             : }

Generated by: LCOV version 1.14