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 "PenaltyDirichletBC.h" 11 : 12 : registerMooseObject("MooseApp", PenaltyDirichletBC); 13 : 14 : InputParameters 15 15021 : PenaltyDirichletBC::validParams() 16 : { 17 15021 : InputParameters params = IntegratedBC::validParams(); 18 15021 : params.addRequiredParam<Real>("penalty", "Penalty scalar"); 19 15021 : params.addParam<Real>("value", 0.0, "Boundary value of the variable"); 20 15021 : params.declareControllable("value"); 21 15021 : params.addClassDescription("Enforces a Dirichlet boundary condition " 22 : "in a weak sense by penalizing differences between the current " 23 : "solution and the Dirichlet data."); 24 15021 : return params; 25 0 : } 26 : 27 392 : PenaltyDirichletBC::PenaltyDirichletBC(const InputParameters & parameters) 28 392 : : IntegratedBC(parameters), _p(getParam<Real>("penalty")), _v(getParam<Real>("value")) 29 : { 30 392 : } 31 : 32 : Real 33 1875520 : PenaltyDirichletBC::computeQpResidual() 34 : { 35 1875520 : return _p * _test[_i][_qp] * (-_v + _u[_qp]); 36 : } 37 : 38 : Real 39 722438 : PenaltyDirichletBC::computeQpJacobian() 40 : { 41 722438 : return _p * _phi[_j][_qp] * _test[_i][_qp]; 42 : }