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 "VectorDivPenaltyDirichletBC.h" 11 : #include "Function.h" 12 : 13 : registerMooseObject("MooseApp", VectorDivPenaltyDirichletBC); 14 : 15 : InputParameters 16 14565 : VectorDivPenaltyDirichletBC::validParams() 17 : { 18 14565 : InputParameters params = VectorIntegratedBC::validParams(); 19 14565 : params.addRequiredParam<Real>("penalty", "The penalty coefficient"); 20 14565 : params.addParam<FunctionName>("function", 21 : "The boundary condition vector function, " 22 : "use as an alternative to a component-wise specification"); 23 14565 : params.addParam<FunctionName>("function_x", 0, "The function for the x component"); 24 14565 : params.addParam<FunctionName>("function_y", 0, "The function for the y component"); 25 14565 : params.addParam<FunctionName>("function_z", 0, "The function for the z component"); 26 14565 : params.addClassDescription("Enforces, in a weak sense, a Dirichlet boundary condition on the " 27 : "divergence of a nonlinear vector variable by applying a penalty to " 28 : "the difference between the current solution and the Dirichlet data."); 29 14565 : return params; 30 0 : } 31 : 32 156 : VectorDivPenaltyDirichletBC::VectorDivPenaltyDirichletBC(const InputParameters & parameters) 33 : : VectorIntegratedBC(parameters), 34 156 : _penalty(getParam<Real>("penalty")), 35 156 : _function(isParamValid("function") ? &getFunction("function") : nullptr), 36 156 : _function_x(getFunction("function_x")), 37 156 : _function_y(getFunction("function_y")), 38 312 : _function_z(getFunction("function_z")) 39 : { 40 156 : } 41 : 42 : Real 43 314880 : VectorDivPenaltyDirichletBC::computeQpResidual() 44 : { 45 314880 : RealVectorValue u_exact; 46 314880 : if (_function) 47 314880 : u_exact = _function->vectorValue(_t, _q_point[_qp]); 48 : else 49 0 : u_exact = {_function_x.value(_t, _q_point[_qp]), 50 0 : _function_y.value(_t, _q_point[_qp]), 51 0 : _function_z.value(_t, _q_point[_qp])}; 52 : 53 314880 : return _penalty * ((_u[_qp] - u_exact) * _normals[_qp]) * (_test[_i][_qp] * _normals[_qp]); 54 : } 55 : 56 : Real 57 1420800 : VectorDivPenaltyDirichletBC::computeQpJacobian() 58 : { 59 1420800 : return _penalty * (_phi[_j][_qp] * _normals[_qp]) * (_test[_i][_qp] * _normals[_qp]); 60 : }