LCOV - code coverage report
Current view: top level - src/bcs - VectorPenaltyDirichletBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 21 22 95.5 %
Date: 2025-07-17 01:28:37 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 "VectorPenaltyDirichletBC.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("MooseApp", VectorPenaltyDirichletBC);
      14             : 
      15             : InputParameters
      16       14340 : VectorPenaltyDirichletBC::validParams()
      17             : {
      18       14340 :   InputParameters params = VectorIntegratedBC::validParams();
      19       14340 :   params.addRequiredParam<Real>("penalty", "The penalty coefficient");
      20       14340 :   params.addParam<FunctionName>("x_exact_sln", 0, "The exact solution for the x component");
      21       14340 :   params.addParam<FunctionName>("y_exact_sln", 0, "The exact solution for the y component");
      22       14340 :   params.addParam<FunctionName>("z_exact_sln", 0, "The exact solution for the z component");
      23       14340 :   params.addClassDescription("Enforces a Dirichlet boundary condition for "
      24             :                              "vector nonlinear variables in a weak sense by "
      25             :                              "applying a penalty to the difference in the "
      26             :                              "current solution and the Dirichlet data.");
      27       14340 :   return params;
      28           0 : }
      29             : 
      30          39 : VectorPenaltyDirichletBC::VectorPenaltyDirichletBC(const InputParameters & parameters)
      31             :   : VectorIntegratedBC(parameters),
      32          39 :     _penalty(getParam<Real>("penalty")),
      33          39 :     _exact_x(getFunction("x_exact_sln")),
      34          39 :     _exact_y(getFunction("y_exact_sln")),
      35          78 :     _exact_z(getFunction("z_exact_sln"))
      36             : {
      37          39 : }
      38             : 
      39             : Real
      40      271872 : VectorPenaltyDirichletBC::computeQpResidual()
      41             : {
      42      271872 :   RealVectorValue u_exact = {_exact_x.value(_t, _q_point[_qp]),
      43      271872 :                              _exact_y.value(_t, _q_point[_qp]),
      44      271872 :                              _exact_z.value(_t, _q_point[_qp])};
      45             : 
      46      271872 :   return _penalty * _test[_i][_qp] * (_u[_qp] - u_exact);
      47             : }
      48             : 
      49             : Real
      50     1892352 : VectorPenaltyDirichletBC::computeQpJacobian()
      51             : {
      52     1892352 :   return _penalty * _test[_i][_qp] * _phi[_j][_qp];
      53             : }

Generated by: LCOV version 1.14