LCOV - code coverage report
Current view: top level - src/fvbcs - NSFVOutflowTemperatureBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #32971 (54bef8) with base c6cf66 Lines: 34 38 89.5 %
Date: 2026-05-29 20:37:52 Functions: 3 3 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 "NSFVOutflowTemperatureBC.h"
      11             : #include "SystemBase.h"
      12             : #include "NS.h"
      13             : 
      14             : registerMooseObject("NavierStokesApp", NSFVOutflowTemperatureBC);
      15             : 
      16             : InputParameters
      17          38 : NSFVOutflowTemperatureBC::validParams()
      18             : {
      19          38 :   InputParameters params = FVFluxBC::validParams();
      20          38 :   params.addClassDescription("Outflow velocity temperature advection boundary conditions for "
      21             :                              "finite volume method allowing for thermal backflow.");
      22          38 :   params.addRequiredParam<MooseFunctorName>(NS::density, "The name of the density");
      23          38 :   params.addRequiredParam<MooseFunctorName>(NS::cp, "The name of the specific heat");
      24          76 :   params.addRequiredParam<MooseFunctorName>("u", "The velocity in the x direction.");
      25          76 :   params.addParam<MooseFunctorName>("v", "The velocity in the y direction.");
      26          76 :   params.addParam<MooseFunctorName>("w", "The velocity in the z direction.");
      27          76 :   params.addRequiredParam<MooseFunctorName>("backflow_T",
      28             :                                             "The backflow temperature entering the domain.");
      29          38 :   return params;
      30           0 : }
      31             : 
      32          20 : NSFVOutflowTemperatureBC::NSFVOutflowTemperatureBC(const InputParameters & parameters)
      33             :   : FVFluxBC(parameters),
      34          20 :     _rho(getFunctor<ADReal>(NS::density)),
      35          20 :     _cp(getFunctor<ADReal>(NS::cp)),
      36          40 :     _u(getFunctor<ADReal>("u")),
      37          80 :     _v(isParamValid("v") ? &getFunctor<ADReal>("v") : nullptr),
      38          40 :     _w(isParamValid("w") ? &getFunctor<ADReal>("w") : nullptr),
      39          40 :     _backflow_T(getFunctor<ADReal>("backflow_T")),
      40          40 :     _dim(_subproblem.mesh().dimension())
      41             : {
      42          20 :   if (_dim >= 2 && !_v)
      43           0 :     mooseError(
      44             :         "In two or more dimensions, the v velocity must be supplied using the 'v' parameter");
      45          20 :   if (_dim >= 3 && !_w)
      46           0 :     mooseError("In threedimensions, the w velocity must be supplied using the 'w' parameter");
      47          20 : }
      48             : 
      49             : ADReal
      50       20985 : NSFVOutflowTemperatureBC::computeQpResidual()
      51             : {
      52       20985 :   const auto boundary_face = singleSidedFaceArg();
      53       20985 :   const auto state = determineState();
      54             : 
      55       41970 :   ADRealVectorValue v(_u(boundary_face, state));
      56       20985 :   if (_v)
      57       20985 :     v(1) = (*_v)(boundary_face, state);
      58       20985 :   if (_w)
      59           0 :     v(2) = (*_w)(boundary_face, state);
      60             : 
      61       20985 :   const auto vol_flux = v * _normal;
      62       20985 :   const auto rho_cp_face = _rho(boundary_face, state) * _cp(boundary_face, state);
      63             : 
      64       20985 :   if (vol_flux > 0)
      65       16618 :     return rho_cp_face * _var(boundary_face, state) * vol_flux;
      66             :   else
      67             :   {
      68       12676 :     auto backflow_T = _backflow_T(boundary_face, state);
      69       12676 :     return rho_cp_face * backflow_T * vol_flux;
      70             :   }
      71             : }

Generated by: LCOV version 1.14