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