LCOV - code coverage report
Current view: top level - src/bcs - PenaltyInclinedNoDisplacementBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose solid_mechanics: f45d79 Lines: 27 28 96.4 %
Date: 2025-07-25 05:00:39 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 "PenaltyInclinedNoDisplacementBC.h"
      11             : #include "Function.h"
      12             : #include "Coupleable.h"
      13             : 
      14             : registerMooseObject("SolidMechanicsApp", PenaltyInclinedNoDisplacementBC);
      15             : registerMooseObject("SolidMechanicsApp", ADPenaltyInclinedNoDisplacementBC);
      16             : 
      17             : template <bool is_ad>
      18             : InputParameters
      19         300 : PenaltyInclinedNoDisplacementBCTempl<is_ad>::validParams()
      20             : {
      21         300 :   InputParameters params = PenaltyInclinedNoDisplacementBCParent<is_ad>::validParams();
      22         600 :   params.addRequiredParam<Real>("penalty", "Penalty parameter");
      23         600 :   params.addRequiredParam<unsigned int>(
      24             :       "component", "An integer corresponding to the direction (0 for x, 1 for y, 2 for z)");
      25         600 :   params.addRequiredCoupledVar("displacements",
      26             :                                "The string of displacements suitable for the problem statement");
      27         300 :   params.addClassDescription("Penalty Enforcement of an inclined boundary condition");
      28         300 :   return params;
      29           0 : }
      30             : 
      31             : template <bool is_ad>
      32         150 : PenaltyInclinedNoDisplacementBCTempl<is_ad>::PenaltyInclinedNoDisplacementBCTempl(
      33             :     const InputParameters & parameters)
      34             :   : PenaltyInclinedNoDisplacementBCParent<is_ad>(parameters),
      35         150 :     _component(this->template getParam<unsigned int>("component")),
      36         150 :     _ndisp(this->coupledComponents("displacements")),
      37         150 :     _disp(this->template coupledGenericValues<is_ad>("displacements")),
      38         150 :     _disp_var(this->coupledIndices("displacements")),
      39         450 :     _penalty(this->template getParam<Real>("penalty"))
      40             : {
      41         150 : }
      42             : 
      43             : template <bool is_ad>
      44             : GenericReal<is_ad>
      45     1361664 : PenaltyInclinedNoDisplacementBCTempl<is_ad>::computeQpResidual()
      46             : {
      47      606720 :   GenericReal<is_ad> v = 0;
      48     5405952 :   for (unsigned int i = 0; i < _ndisp; ++i)
      49     5864448 :     v += (*_disp[i])[_qp] * _normals[_qp](i);
      50             : 
      51     1968384 :   return _penalty * _test[_i][_qp] * v * _normals[_qp](_component);
      52             : }
      53             : 
      54             : Real
      55     1575936 : PenaltyInclinedNoDisplacementBC::computeQpJacobian()
      56             : {
      57     1575936 :   return _penalty * _phi[_j][_qp] * _normals[_qp](_component) * _normals[_qp](_component) *
      58     1575936 :          _test[_i][_qp];
      59             : }
      60             : 
      61             : Real
      62     3111936 : PenaltyInclinedNoDisplacementBC::computeQpOffDiagJacobian(unsigned int jvar)
      63             : {
      64     6203904 :   for (unsigned int coupled_component = 0; coupled_component < _ndisp; ++coupled_component)
      65     6203904 :     if (jvar == _disp_var[coupled_component])
      66             :     {
      67     3111936 :       return _penalty * _phi[_j][_qp] * _normals[_qp](coupled_component) *
      68     3111936 :              _normals[_qp](_component) * _test[_i][_qp];
      69             :     }
      70             : 
      71             :   return 0.0;
      72             : }
      73             : 
      74             : template class PenaltyInclinedNoDisplacementBCTempl<false>;
      75             : template class PenaltyInclinedNoDisplacementBCTempl<true>;

Generated by: LCOV version 1.14