LCOV - code coverage report
Current view: top level - src/fvbcs - INSFVOutletPressureBC.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 21 26 80.8 %
Date: 2025-08-14 10:14:56 Functions: 6 6 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 "INSFVOutletPressureBC.h"
      11             : #include "INSFVPressureVariable.h"
      12             : #include "Function.h"
      13             : 
      14             : registerMooseObject("NavierStokesApp", INSFVOutletPressureBC);
      15             : 
      16             : template <class T>
      17             : InputParameters
      18       12220 : INSFVOutletPressureBCTempl<T>::validParams()
      19             : {
      20       12220 :   InputParameters params = FVDirichletBCBase::validParams();
      21       12220 :   params += T::validParams();
      22             : 
      23             :   // Value may be specified by a AD functor (typically a variable), a function or a postprocessor
      24       24440 :   params.addParam<FunctionName>("function", "The boundary pressure as a regular function");
      25       24440 :   params.addParam<MooseFunctorName>("functor", "The boundary pressure as an AD functor");
      26       24440 :   params.addParam<PostprocessorName>("postprocessor", "The boundary pressure as a postprocessor");
      27             : 
      28       12220 :   return params;
      29           0 : }
      30             : 
      31             : template <class T>
      32        6418 : INSFVOutletPressureBCTempl<T>::INSFVOutletPressureBCTempl(const InputParameters & params)
      33             :   : FVDirichletBCBase(params),
      34             :     T(params),
      35        9804 :     _functor(isParamValid("functor") ? &this->template getFunctor<ADReal>("functor") : nullptr),
      36       17561 :     _function(isParamValid("function") ? &getFunction("function") : nullptr),
      37       19254 :     _pp_value(isParamValid("postprocessor") ? &getPostprocessorValue("postprocessor") : nullptr)
      38             : {
      39        6418 :   if (!dynamic_cast<INSFVPressureVariable *>(&_var))
      40           0 :     paramError(
      41             :         "variable",
      42             :         "The variable argument to INSFVOutletPressureBC must be of type INSFVPressureVariable");
      43             : 
      44             :   // Check parameters
      45        6418 :   if ((_functor && (_pp_value || _function)) || (_function && _pp_value) ||
      46        4725 :       (!_functor && !_pp_value && !_function))
      47           0 :     mooseError("One and only one of function/functor/postprocessor may be specified for the outlet "
      48             :                "pressure");
      49        6418 : }
      50             : 
      51             : template <class T>
      52             : ADReal
      53     1854833 : INSFVOutletPressureBCTempl<T>::boundaryValue(const FaceInfo & fi,
      54             :                                              const Moose::StateArg & state) const
      55             : {
      56     1854833 :   if (_functor)
      57      236643 :     return (*_functor)(singleSidedFaceArg(&fi), state);
      58     1618190 :   else if (_function)
      59             :   {
      60     1618190 :     if (state.state != 0 && state.iteration_type == Moose::SolutionIterationType::Time)
      61             :     {
      62             :       mooseAssert(state.state == 1, "We cannot access values beyond the previous time step.");
      63           0 :       return _function->value(_t_old, fi.faceCentroid());
      64             :     }
      65             :     else
      66     1618190 :       return _function->value(_t, fi.faceCentroid());
      67             :   }
      68             :   else
      69           0 :     return *_pp_value;
      70             : }
      71             : 
      72             : template class INSFVOutletPressureBCTempl<INSFVFlowBC>;
      73             : template class INSFVOutletPressureBCTempl<INSFVFullyDevelopedFlowBC>;

Generated by: LCOV version 1.14