LCOV - code coverage report
Current view: top level - src/kernels - ADGeneralizedPlaneStrain.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #33416 (b10b36) with base 9fbd27 Lines: 44 49 89.8 %
Date: 2026-07-23 16:20:48 Functions: 4 5 80.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             : 
       9             : #include "ADGeneralizedPlaneStrain.h"
      10             : 
      11             : #include "Function.h"
      12             : #include "RankTwoTensor.h"
      13             : 
      14             : registerMooseObject("SolidMechanicsApp", ADGeneralizedPlaneStrain);
      15             : 
      16             : InputParameters
      17         240 : ADGeneralizedPlaneStrain::validParams()
      18             : {
      19         240 :   InputParameters params = ADKernelScalarBase::validParams();
      20         240 :   params.addClassDescription(
      21             :       "Assembles the generalized plane strain scalar equation using automatic differentiation.");
      22         480 :   params.renameCoupledVar("scalar_variable",
      23             :                           "scalar_out_of_plane_strain",
      24             :                           "Scalar variable for generalized plane strain");
      25         240 :   params.makeParamRequired<std::vector<VariableName>>("scalar_out_of_plane_strain");
      26         480 :   params.addParam<FunctionName>("out_of_plane_pressure_function",
      27             :                                 "Function used to prescribe pressure (applied toward the body) in "
      28             :                                 "the out-of-plane direction");
      29         480 :   params.addDeprecatedParam<FunctionName>(
      30             :       "out_of_plane_pressure",
      31             :       "Function used to prescribe pressure (applied toward the body) in the out-of-plane direction",
      32             :       "This has been replaced by 'out_of_plane_pressure_function'");
      33         480 :   params.addParam<MaterialPropertyName>("out_of_plane_pressure_material",
      34             :                                         "0",
      35             :                                         "Material used to prescribe pressure (applied toward the "
      36             :                                         "body) in the out-of-plane direction");
      37         480 :   MooseEnum out_of_plane_direction("x y z", "z");
      38         480 :   params.addParam<MooseEnum>(
      39             :       "out_of_plane_direction", out_of_plane_direction, "The direction of the out-of-plane strain");
      40         480 :   params.addDeprecatedParam<Real>(
      41             :       "factor",
      42             :       "Scale factor applied to prescribed out-of-plane pressure (both material and function)",
      43             :       "This has been replaced by 'pressure_factor'");
      44         480 :   params.addParam<Real>(
      45             :       "pressure_factor",
      46             :       "Scale factor applied to prescribed out-of-plane pressure (both material and function)");
      47         480 :   params.addParam<std::string>("base_name", "Material property base name");
      48         240 :   params.set<bool>("compute_field_residuals") = false;
      49         240 :   params.suppressParameter<bool>("compute_field_residuals");
      50             : 
      51         240 :   return params;
      52         240 : }
      53             : 
      54         120 : ADGeneralizedPlaneStrain::ADGeneralizedPlaneStrain(const InputParameters & parameters)
      55             :   : ADKernelScalarBase(parameters),
      56         120 :     _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
      57         240 :     _stress(getADMaterialProperty<RankTwoTensor>(_base_name + "stress")),
      58         120 :     _out_of_plane_pressure_function(parameters.isParamSetByUser("out_of_plane_pressure_function")
      59         240 :                                         ? &getFunction("out_of_plane_pressure_function")
      60         225 :                                     : parameters.isParamSetByUser("out_of_plane_pressure")
      61         120 :                                         ? &getFunction("out_of_plane_pressure")
      62             :                                         : nullptr),
      63         240 :     _out_of_plane_pressure_material(getMaterialProperty<Real>("out_of_plane_pressure_material")),
      64         120 :     _pressure_factor(parameters.isParamSetByUser("pressure_factor")
      65         255 :                          ? getParam<Real>("pressure_factor")
      66         225 :                      : parameters.isParamSetByUser("factor") ? getParam<Real>("factor")
      67             :                                                              : 1.0),
      68         360 :     _out_of_plane_direction(getParam<MooseEnum>("out_of_plane_direction"))
      69             : {
      70         240 :   if (parameters.isParamSetByUser("out_of_plane_pressure_function") &&
      71         135 :       parameters.isParamSetByUser("out_of_plane_pressure"))
      72           0 :     paramError("out_of_plane_pressure_function",
      73             :                "Cannot specify both 'out_of_plane_pressure_function' and "
      74             :                "'out_of_plane_pressure'");
      75         135 :   if (parameters.isParamSetByUser("pressure_factor") && parameters.isParamSetByUser("factor"))
      76           0 :     paramError("pressure_factor", "Cannot specify both 'pressure_factor' and 'factor'");
      77         120 : }
      78             : 
      79             : void
      80         120 : ADGeneralizedPlaneStrain::initialSetup()
      81             : {
      82         120 :   if (getBlockCoordSystem() == Moose::COORD_RZ)
      83          21 :     _out_of_plane_direction = 1;
      84          99 :   else if (getBlockCoordSystem() != Moose::COORD_XYZ)
      85           0 :     paramError("out_of_plane_direction",
      86             :                "Generalized plane strain supports only Cartesian and axisymmetric coordinate "
      87             :                "systems");
      88         120 : }
      89             : 
      90             : ADReal
      91           0 : ADGeneralizedPlaneStrain::computeQpResidual()
      92             : {
      93           0 :   return 0;
      94             : }
      95             : 
      96             : ADReal
      97      158196 : ADGeneralizedPlaneStrain::computeScalarQpResidual()
      98             : {
      99             :   const Real out_of_plane_pressure =
     100      158196 :       ((_out_of_plane_pressure_function ? _out_of_plane_pressure_function->value(_t, _q_point[_qp])
     101      158196 :                                         : 0.0) +
     102      158196 :        _out_of_plane_pressure_material[_qp]) *
     103      158196 :       _pressure_factor;
     104             : 
     105      158196 :   return _stress[_qp](_out_of_plane_direction, _out_of_plane_direction) + out_of_plane_pressure;
     106             : }

Generated by: LCOV version 1.14