LCOV - code coverage report
Current view: top level - src/bcs - VectorCurlPenaltyDirichletBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 27 28 96.4 %
Date: 2026-05-29 20:35:17 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          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        3205 : VectorCurlPenaltyDirichletBC::validParams()
      17             : {
      18        3205 :   InputParameters params = VectorIntegratedBC::validParams();
      19       12820 :   params.addRequiredParam<Real>("penalty", "The penalty coefficient");
      20       12820 :   params.addParam<FunctionName>("function",
      21             :                                 "The boundary condition vector function, "
      22             :                                 "use as an alternative to a component-wise specification");
      23       12820 :   params.addParam<FunctionName>("function_x", 0, "The function for the x component");
      24       12820 :   params.addParam<FunctionName>("function_y", 0, "The function for the y component");
      25       12820 :   params.addParam<FunctionName>("function_z", 0, "The function for the z component");
      26        3205 :   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        3205 :   return params;
      30           0 : }
      31             : 
      32          75 : VectorCurlPenaltyDirichletBC::VectorCurlPenaltyDirichletBC(const InputParameters & parameters)
      33             :   : VectorIntegratedBC(parameters),
      34          75 :     _penalty(getParam<Real>("penalty")),
      35         274 :     _function(isParamValid("function") ? &getFunction("function") : nullptr),
      36         150 :     _function_x(getFunction("function_x")),
      37         150 :     _function_y(getFunction("function_y")),
      38         225 :     _function_z(getFunction("function_z"))
      39             : {
      40          75 : }
      41             : 
      42             : Real
      43     3388160 : VectorCurlPenaltyDirichletBC::computeQpResidual()
      44             : {
      45     3388160 :   RealVectorValue u_exact;
      46     3388160 :   if (_function)
      47     3367680 :     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     3388160 :   RealVectorValue Ncu = (_u[_qp] - u_exact).cross(_normals[_qp]);
      53     3388160 :   return _penalty * Ncu * _test[_i][_qp].cross(_normals[_qp]);
      54             : }
      55             : 
      56             : Real
      57      829440 : VectorCurlPenaltyDirichletBC::computeQpJacobian()
      58             : {
      59      829440 :   return _penalty * _phi[_j][_qp].cross(_normals[_qp]) * _test[_i][_qp].cross(_normals[_qp]);
      60             : }

Generated by: LCOV version 1.14