Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://www.mooseframework.org 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("TensorMechanicsApp", PenaltyInclinedNoDisplacementBC); 15 : registerMooseObject("TensorMechanicsApp", ADPenaltyInclinedNoDisplacementBC); 16 : 17 : template <bool is_ad> 18 : InputParameters 19 132 : PenaltyInclinedNoDisplacementBCTempl<is_ad>::validParams() 20 : { 21 132 : InputParameters params = PenaltyInclinedNoDisplacementBCParent<is_ad>::validParams(); 22 264 : params.addRequiredParam<Real>("penalty", "Penalty parameter"); 23 264 : params.addRequiredParam<unsigned int>( 24 : "component", "An integer corresponding to the direction (0 for x, 1 for y, 2 for z)"); 25 264 : params.addRequiredCoupledVar("displacements", 26 : "The string of displacements suitable for the problem statement"); 27 132 : params.addClassDescription("Penalty Enforcement of an inclined boundary condition"); 28 132 : return params; 29 0 : } 30 : 31 : template <bool is_ad> 32 66 : PenaltyInclinedNoDisplacementBCTempl<is_ad>::PenaltyInclinedNoDisplacementBCTempl( 33 : const InputParameters & parameters) 34 : : PenaltyInclinedNoDisplacementBCParent<is_ad>(parameters), 35 66 : _component(this->template getParam<unsigned int>("component")), 36 66 : _ndisp(this->coupledComponents("displacements")), 37 66 : _disp(this->template coupledGenericValues<is_ad>("displacements")), 38 66 : _disp_var(this->coupledIndices("displacements")), 39 198 : _penalty(this->template getParam<Real>("penalty")) 40 : { 41 66 : } 42 : 43 : template <bool is_ad> 44 : GenericReal<is_ad> 45 675072 : PenaltyInclinedNoDisplacementBCTempl<is_ad>::computeQpResidual() 46 : { 47 314880 : GenericReal<is_ad> v = 0; 48 2678016 : for (unsigned int i = 0; i < _ndisp; ++i) 49 2947584 : v += (*_disp[i])[_qp] * _normals[_qp](i); 50 : 51 989952 : return _penalty * _test[_i][_qp] * v * _normals[_qp](_component); 52 : } 53 : 54 : Real 55 634368 : PenaltyInclinedNoDisplacementBC::computeQpJacobian() 56 : { 57 634368 : return _penalty * _phi[_j][_qp] * _normals[_qp](_component) * _normals[_qp](_component) * 58 634368 : _test[_i][_qp]; 59 : } 60 : 61 : Real 62 1248768 : PenaltyInclinedNoDisplacementBC::computeQpOffDiagJacobian(unsigned int jvar) 63 : { 64 2487552 : for (unsigned int coupled_component = 0; coupled_component < _ndisp; ++coupled_component) 65 2487552 : if (jvar == _disp_var[coupled_component]) 66 : { 67 1248768 : return _penalty * _phi[_j][_qp] * _normals[_qp](coupled_component) * 68 1248768 : _normals[_qp](_component) * _test[_i][_qp]; 69 : } 70 : 71 : return 0.0; 72 : } 73 : 74 : template class PenaltyInclinedNoDisplacementBCTempl<false>; 75 : template class PenaltyInclinedNoDisplacementBCTempl<true>;