LCOV - code coverage report
Current view: top level - src/fvkernels - FVMatAdvection.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 29 33 87.9 %
Date: 2025-07-17 01:28:37 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 "FVMatAdvection.h"
      11             : 
      12             : registerADMooseObject("MooseApp", FVMatAdvection);
      13             : 
      14             : InputParameters
      15       14756 : FVMatAdvection::validParams()
      16             : {
      17       14756 :   InputParameters params = FVFluxKernel::validParams();
      18       14756 :   params.addClassDescription("Computes the residual of advective term using finite volume method.");
      19       14756 :   params.addRequiredParam<MooseFunctorName>("vel", "advection velocity");
      20       14756 :   params.addParam<MooseFunctorName>(
      21             :       "advected_quantity",
      22             :       "An optional parameter for specifying an advected quantity from a material property. If this "
      23             :       "is not specified, then the advected quantity will simply be the variable that this object "
      24             :       "is acting on");
      25             : 
      26       14756 :   MooseEnum advected_interp_method("average upwind skewness-corrected", "upwind");
      27       14756 :   params.addParam<MooseEnum>(
      28             :       "advected_interp_method",
      29             :       advected_interp_method,
      30             :       "The interpolation to use for the advected quantity. Options are "
      31             :       "'upwind', 'average', and 'skewness-corrected' with the default being 'upwind'.");
      32       29512 :   return params;
      33       14756 : }
      34             : 
      35         251 : FVMatAdvection::FVMatAdvection(const InputParameters & params)
      36             :   : FVFluxKernel(params),
      37         251 :     _vel(getFunctor<ADRealVectorValue>("vel")),
      38         396 :     _adv_quant(getFunctor<ADReal>(isParamValid("advected_quantity") ? "advected_quantity"
      39         396 :                                                                     : variable().name()))
      40             : {
      41             :   using namespace Moose::FV;
      42             : 
      43         251 :   const auto & advected_interp_method = getParam<MooseEnum>("advected_interp_method");
      44         251 :   if (advected_interp_method == "average")
      45         151 :     _advected_interp_method = InterpMethod::Average;
      46         100 :   else if (advected_interp_method == "skewness-corrected")
      47           0 :     _advected_interp_method = Moose::FV::InterpMethod::SkewCorrectedAverage;
      48         100 :   else if (advected_interp_method == "upwind")
      49         100 :     _advected_interp_method = InterpMethod::Upwind;
      50             :   else
      51           0 :     mooseError("Unrecognized interpolation type ",
      52           0 :                static_cast<std::string>(advected_interp_method));
      53         251 : }
      54             : 
      55             : ADReal
      56       85594 : FVMatAdvection::computeQpResidual()
      57             : {
      58             :   using namespace Moose::FV;
      59             : 
      60           0 :   const auto v = _vel(makeFace(*_face_info,
      61             :                                LimiterType::CentralDifference,
      62             :                                true,
      63       85594 :                                _advected_interp_method == InterpMethod::SkewCorrectedAverage),
      64      171188 :                       determineState());
      65             :   const auto adv_quant_interface =
      66       85594 :       _adv_quant(makeFace(*_face_info,
      67             :                           limiterType(_advected_interp_method),
      68       85594 :                           MetaPhysicL::raw_value(v) * _normal > 0,
      69       85594 :                           _advected_interp_method == InterpMethod::SkewCorrectedAverage),
      70      171188 :                  determineState());
      71             : 
      72      256782 :   return _normal * v * adv_quant_interface;
      73             :   ;
      74       85594 : }

Generated by: LCOV version 1.14