LCOV - code coverage report
Current view: top level - src/kernels - ADDistributedLoadShell.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: #31405 (292dce) with base fef103 Lines: 33 36 91.7 %
Date: 2025-09-04 07:57:23 Functions: 4 8 50.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 "ADDistributedLoadShell.h"
      11             : #include "Assembly.h"
      12             : #include "Function.h"
      13             : #include "MooseError.h"
      14             : #include "FEProblemBase.h"
      15             : #include "MooseMesh.h"
      16             : 
      17             : registerMooseObject("SolidMechanicsApp", ADDistributedLoadShell);
      18             : registerMooseObject("SolidMechanicsApp", ADDistributedLoadShell);
      19             : 
      20             : template <bool is_ad>
      21             : InputParameters
      22         112 : ADDistributedLoadShellTempl<is_ad>::validParams()
      23             : {
      24             :   InputParameters params = GenericKernel<is_ad>::validParams();
      25         112 :   params.addClassDescription(
      26             :       "Applies a distributed load (specified in units of force per area) on the shell plane in a "
      27             :       "given direction (e.g. self_weight, wind load) or normal to the shell plan (e.g. pressure "
      28             :       "loads)");
      29         224 :   params.addRequiredCoupledVar("displacements",
      30             :                                "The string of displacements suitable for the problem statement");
      31         224 :   params.addParam<bool>(
      32         224 :       "project_load_to_normal", false, "Whether to apply the distributed load normal to the shell");
      33         224 :   params.addRequiredParam<FunctionName>(
      34             :       "function",
      35             :       "The function that describes the distributed load specified in units of force per area ");
      36         112 :   return params;
      37           0 : }
      38             : 
      39             : template <bool is_ad>
      40          56 : ADDistributedLoadShellTempl<is_ad>::ADDistributedLoadShellTempl(const InputParameters & parameters)
      41             :   : GenericKernel<is_ad>(parameters),
      42          56 :     _ndisp(this->coupledComponents("displacements")),
      43          56 :     _component(libMesh::invalid_uint),
      44          56 :     _function(&this->getFunction("function")),
      45         112 :     _project_load_to_normal(parameters.isParamSetByUser("project_load_to_normal")
      46         140 :                                 ? this->template getParam<bool>("project_load_to_normal")
      47             :                                 : false),
      48         112 :     _nodes(4)
      49             : {
      50          56 :   if (_ndisp != 3)
      51           0 :     mooseError("ADDistributedLoadShell: parameter 'displacements' needs to have exactly three "
      52             :                "components.");
      53             : 
      54         224 :   for (unsigned int i = 0; i < _ndisp; ++i)
      55             :   {
      56         168 :     _disp_var.push_back(this->coupled("displacements", i));
      57         168 :     if (_var.number() == _disp_var[i])
      58             :     {
      59          56 :       _component = i;
      60             :     }
      61             :   }
      62          56 :   if (_component == libMesh::invalid_uint)
      63           0 :     mooseError("Problem with displacements in " + _name);
      64          98 : }
      65             : 
      66             : template <bool is_ad>
      67             : GenericReal<is_ad>
      68      480192 : ADDistributedLoadShellTempl<is_ad>::computeQpResidual()
      69             : {
      70     2400960 :   for (unsigned int i = 0; i < 4; ++i)
      71     1920768 :     _nodes[i] = _current_elem->node_ptr(i);
      72             : 
      73      480192 :   _v1 = (*_nodes[1] - *_nodes[0]);
      74      480192 :   _v2 = (*_nodes[2] - *_nodes[0]);
      75             : 
      76      480192 :   _normal = _v1.cross(_v2);
      77      480192 :   _normal /= _normal.norm();
      78             : 
      79      480192 :   if (_project_load_to_normal)
      80      437760 :     return computeFactor() * (_normal(_component) * _test[_i][_qp]);
      81             :   else
      82       42432 :     return computeFactor() * (_test[_i][_qp]);
      83             : }
      84             : 
      85             : template <bool is_ad>
      86             : GenericReal<is_ad>
      87      480192 : ADDistributedLoadShellTempl<is_ad>::computeFactor() const
      88             : {
      89      480192 :   return _function->value(_t, _q_point[_qp]);
      90             : }
      91             : 
      92             : template class ADDistributedLoadShellTempl<false>;
      93             : template class ADDistributedLoadShellTempl<true>;

Generated by: LCOV version 1.14