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 350 : PenaltyInclinedNoDisplacementBCTempl<is_ad>::validParams() 20 : { 21 350 : InputParameters params = PenaltyInclinedNoDisplacementBCParent<is_ad>::validParams(); 22 700 : params.addRequiredParam<Real>("penalty", "Penalty parameter"); 23 700 : params.addRequiredParam<unsigned int>( 24 : "component", "An integer corresponding to the direction (0 for x, 1 for y, 2 for z)"); 25 700 : params.addRequiredCoupledVar("displacements", 26 : "The string of displacements suitable for the problem statement"); 27 350 : params.addClassDescription("Penalty Enforcement of an inclined boundary condition"); 28 350 : return params; 29 0 : } 30 : 31 : template <bool is_ad> 32 175 : PenaltyInclinedNoDisplacementBCTempl<is_ad>::PenaltyInclinedNoDisplacementBCTempl( 33 : const InputParameters & parameters) 34 : : PenaltyInclinedNoDisplacementBCParent<is_ad>(parameters), 35 175 : _component(this->template getParam<unsigned int>("component")), 36 175 : _ndisp(this->coupledComponents("displacements")), 37 175 : _disp(this->template coupledGenericValues<is_ad>("displacements")), 38 175 : _disp_var(this->coupledIndices("displacements")), 39 525 : _penalty(this->template getParam<Real>("penalty")) 40 : { 41 175 : } 42 : 43 : template <bool is_ad> 44 : GenericReal<is_ad> 45 1800384 : PenaltyInclinedNoDisplacementBCTempl<is_ad>::computeQpResidual() 46 : { 47 787200 : GenericReal<is_ad> v = 0; 48 7148352 : for (unsigned int i = 0; i < _ndisp; ++i) 49 7709568 : v += (*_disp[i])[_qp] * _normals[_qp](i); 50 : 51 2587584 : return _penalty * _test[_i][_qp] * v * _normals[_qp](_component); 52 : } 53 : 54 : Real 55 2141184 : PenaltyInclinedNoDisplacementBC::computeQpJacobian() 56 : { 57 2141184 : return _penalty * _phi[_j][_qp] * _normals[_qp](_component) * _normals[_qp](_component) * 58 2141184 : _test[_i][_qp]; 59 : } 60 : 61 : Real 62 4230144 : PenaltyInclinedNoDisplacementBC::computeQpOffDiagJacobian(unsigned int jvar) 63 : { 64 8434176 : for (unsigned int coupled_component = 0; coupled_component < _ndisp; ++coupled_component) 65 8434176 : if (jvar == _disp_var[coupled_component]) 66 : { 67 4230144 : return _penalty * _phi[_j][_qp] * _normals[_qp](coupled_component) * 68 4230144 : _normals[_qp](_component) * _test[_i][_qp]; 69 : } 70 : 71 : return 0.0; 72 : } 73 : 74 : template class PenaltyInclinedNoDisplacementBCTempl<false>; 75 : template class PenaltyInclinedNoDisplacementBCTempl<true>;