LCOV - code coverage report
Current view: top level - src/bcs - MassFluxPenaltyBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 27 29 93.1 %
Date: 2025-08-14 10:14:56 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 "MassFluxPenaltyBC.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("NavierStokesApp", MassFluxPenaltyBC);
      14             : 
      15             : InputParameters
      16         284 : MassFluxPenaltyBC::validParams()
      17             : {
      18         284 :   InputParameters params = ADIntegratedBC::validParams();
      19         568 :   params.addRequiredCoupledVar("u", "The x-velocity");
      20         568 :   params.addRequiredCoupledVar("v", "The y-velocity");
      21         568 :   params.addRequiredParam<unsigned short>("component",
      22             :                                           "The velocity component this object is being applied to");
      23         568 :   params.addParam<Real>("gamma", 1, "The penalty to multiply the jump with");
      24         284 :   params.addClassDescription("Adds the exterior boundary contribution of penalized jumps in the "
      25             :                              "velocity variable in one component of the momentum equations.");
      26         568 :   params.addRequiredParam<FunctionName>("dirichlet_value",
      27             :                                         "The velocity Dirichlet value on the boundary");
      28         284 :   return params;
      29           0 : }
      30             : 
      31         156 : MassFluxPenaltyBC::MassFluxPenaltyBC(const InputParameters & parameters)
      32             :   : ADIntegratedBC(parameters),
      33         156 :     _vel_x(adCoupledValue("u")),
      34         156 :     _vel_y(adCoupledValue("v")),
      35         312 :     _comp(getParam<unsigned short>("component")),
      36         312 :     _matrix_only(getParam<bool>("matrix_only")),
      37         312 :     _gamma(getParam<Real>("gamma")),
      38         624 :     _dirichlet_func(isParamValid("dirichlet_value") ? &getFunction("dirichlet_value") : nullptr)
      39             : {
      40         156 :   if (_mesh.dimension() > 2)
      41           0 :     mooseError("This class only supports 2D simulations at this time");
      42         156 : }
      43             : 
      44             : void
      45       15040 : MassFluxPenaltyBC::computeResidual()
      46             : {
      47       15040 :   if (!_matrix_only)
      48       12160 :     ADIntegratedBC::computeResidual();
      49       15040 : }
      50             : 
      51             : ADReal
      52      144960 : MassFluxPenaltyBC::computeQpResidual()
      53             : {
      54      144960 :   ADRealVectorValue soln_jump(_vel_x[_qp], _vel_y[_qp], 0);
      55      144960 :   if (_dirichlet_func)
      56      289920 :     soln_jump -= _dirichlet_func->vectorValue(_t, _q_point[_qp]);
      57             : 
      58      289920 :   return _gamma * soln_jump * _normals[_qp] * _test[_i][_qp] * _normals[_qp](_comp);
      59             : }

Generated by: LCOV version 1.14