LCOV - code coverage report
Current view: top level - src/bcs - NSImposedVelocityDirectionBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 0 20 0.0 %
Date: 2025-08-14 10:14:56 Functions: 0 3 0.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             : // Navier-Stokes includes
      11             : #include "NSImposedVelocityDirectionBC.h"
      12             : #include "NS.h"
      13             : 
      14             : // MOOSE includes
      15             : #include "MooseMesh.h"
      16             : 
      17             : // Full specialization of the validParams function for this object
      18             : registerMooseObject("NavierStokesApp", NSImposedVelocityDirectionBC);
      19             : 
      20             : InputParameters
      21           0 : NSImposedVelocityDirectionBC::validParams()
      22             : {
      23             :   // Initialize the params object from the base class
      24           0 :   InputParameters params = NodalBC::validParams();
      25             : 
      26           0 :   params.addClassDescription("This class imposes a velocity direction component as a Dirichlet "
      27             :                              "condition on the appropriate momentum equation.");
      28             :   // Coupled variables
      29           0 :   params.addRequiredCoupledVar(NS::density, "density");
      30           0 :   params.addRequiredCoupledVar(NS::velocity_x, "x-velocity");
      31           0 :   params.addCoupledVar(NS::velocity_y, "y-velocity"); // only required in >= 2D
      32           0 :   params.addCoupledVar(NS::velocity_z, "z-velocity"); // only required in 3D
      33             : 
      34             :   // Coupled parameters
      35           0 :   params.addRequiredParam<Real>("desired_unit_velocity_component", "");
      36             : 
      37           0 :   return params;
      38           0 : }
      39             : 
      40           0 : NSImposedVelocityDirectionBC::NSImposedVelocityDirectionBC(const InputParameters & parameters)
      41             :   : NodalBC(parameters),
      42           0 :     _rho(coupledValue(NS::density)),
      43           0 :     _u_vel(coupledValue(NS::velocity_x)),
      44           0 :     _v_vel(_mesh.dimension() == 2 ? coupledValue(NS::velocity_y) : _zero),
      45           0 :     _w_vel(_mesh.dimension() == 3 ? coupledValue(NS::velocity_z) : _zero),
      46           0 :     _desired_unit_velocity_component(getParam<Real>("desired_unit_velocity_component"))
      47             : {
      48           0 : }
      49             : 
      50             : Real
      51           0 : NSImposedVelocityDirectionBC::computeQpResidual()
      52             : {
      53             :   // The velocity vector
      54           0 :   RealVectorValue vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
      55             : 
      56             :   // Specify desired velocity component
      57           0 :   return _u[_qp] - _rho[_qp] * _desired_unit_velocity_component * vel.norm();
      58             : }

Generated by: LCOV version 1.14