https://mooseframework.inl.gov
PenaltyInclinedNoDisplacementBC.C
Go to the documentation of this file.
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 
11 #include "Function.h"
12 #include "Coupleable.h"
13 
14 registerMooseObject("SolidMechanicsApp", PenaltyInclinedNoDisplacementBC);
15 registerMooseObject("SolidMechanicsApp", ADPenaltyInclinedNoDisplacementBC);
16 
17 template <bool is_ad>
20 {
22  params.addRequiredParam<Real>("penalty", "Penalty parameter");
23  params.addRequiredParam<unsigned int>(
24  "component", "An integer corresponding to the direction (0 for x, 1 for y, 2 for z)");
25  params.addRequiredCoupledVar("displacements",
26  "The string of displacements suitable for the problem statement");
27  params.addClassDescription("Penalty Enforcement of an inclined boundary condition");
28  return params;
29 }
30 
31 template <bool is_ad>
32 PenaltyInclinedNoDisplacementBCTempl<is_ad>::PenaltyInclinedNoDisplacementBCTempl(
33  const InputParameters & parameters)
34  : PenaltyInclinedNoDisplacementBCParent<is_ad>(parameters),
35  _component(this->template getParam<unsigned int>("component")),
36  _ndisp(this->coupledComponents("displacements")),
37  _disp(this->template coupledGenericValues<is_ad>("displacements")),
38  _disp_var(this->coupledIndices("displacements")),
39  _penalty(this->template getParam<Real>("penalty"))
40 {
41 }
42 
43 template <bool is_ad>
45 PenaltyInclinedNoDisplacementBCTempl<is_ad>::computeQpResidual()
46 {
48  for (unsigned int i = 0; i < _ndisp; ++i)
49  v += (*_disp[i])[_qp] * _normals[_qp](i);
50 
51  return _penalty * _test[_i][_qp] * v * _normals[_qp](_component);
52 }
53 
54 Real
55 PenaltyInclinedNoDisplacementBC::computeQpJacobian()
56 {
57  return _penalty * _phi[_j][_qp] * _normals[_qp](_component) * _normals[_qp](_component) *
58  _test[_i][_qp];
59 }
60 
61 Real
62 PenaltyInclinedNoDisplacementBC::computeQpOffDiagJacobian(unsigned int jvar)
63 {
64  for (unsigned int coupled_component = 0; coupled_component < _ndisp; ++coupled_component)
65  if (jvar == _disp_var[coupled_component])
66  {
67  return _penalty * _phi[_j][_qp] * _normals[_qp](coupled_component) *
68  _normals[_qp](_component) * _test[_i][_qp];
69  }
70 
71  return 0.0;
72 }
73 
74 template class PenaltyInclinedNoDisplacementBCTempl<false>;
75 template class PenaltyInclinedNoDisplacementBCTempl<true>;
Moose::GenericType< Real, is_ad > GenericReal
void addRequiredParam(const std::string &name, const std::string &doc_string)
InputParameters validParams()
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
registerMooseObject("SolidMechanicsApp", PenaltyInclinedNoDisplacementBC)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:84
void addClassDescription(const std::string &doc_string)
void ErrorVector unsigned int