LCOV - code coverage report
Current view: top level - src/fvkernels - FVMatAdvection.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 29 33 87.9 %
Date: 2025-08-08 20:01:16 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       14774 : FVMatAdvection::validParams()
      16             : {
      17       14774 :   InputParameters params = FVFluxKernel::validParams();
      18       14774 :   params.addClassDescription("Computes the residual of advective term using finite volume method.");
      19       14774 :   params.addRequiredParam<MooseFunctorName>("vel", "advection velocity");
      20       14774 :   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       14774 :   MooseEnum advected_interp_method("average upwind skewness-corrected", "upwind");
      27       14774 :   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       29548 :   return params;
      33       14774 : }
      34             : 
      35         260 : FVMatAdvection::FVMatAdvection(const InputParameters & params)
      36             :   : FVFluxKernel(params),
      37         260 :     _vel(getFunctor<ADRealVectorValue>("vel")),
      38         411 :     _adv_quant(getFunctor<ADReal>(isParamValid("advected_quantity") ? "advected_quantity"
      39         411 :                                                                     : variable().name()))
      40             : {
      41             :   using namespace Moose::FV;
      42             : 
      43         260 :   const auto & advected_interp_method = getParam<MooseEnum>("advected_interp_method");
      44         260 :   if (advected_interp_method == "average")
      45         154 :     _advected_interp_method = InterpMethod::Average;
      46         106 :   else if (advected_interp_method == "skewness-corrected")
      47           0 :     _advected_interp_method = Moose::FV::InterpMethod::SkewCorrectedAverage;
      48         106 :   else if (advected_interp_method == "upwind")
      49         106 :     _advected_interp_method = InterpMethod::Upwind;
      50             :   else
      51           0 :     mooseError("Unrecognized interpolation type ",
      52           0 :                static_cast<std::string>(advected_interp_method));
      53         260 : }
      54             : 
      55             : ADReal
      56       87777 : FVMatAdvection::computeQpResidual()
      57             : {
      58             :   using namespace Moose::FV;
      59             : 
      60           0 :   const auto v = _vel(makeFace(*_face_info,
      61             :                                LimiterType::CentralDifference,
      62             :                                true,
      63       87777 :                                _advected_interp_method == InterpMethod::SkewCorrectedAverage),
      64      175554 :                       determineState());
      65             :   const auto adv_quant_interface =
      66       87777 :       _adv_quant(makeFace(*_face_info,
      67             :                           limiterType(_advected_interp_method),
      68       87777 :                           MetaPhysicL::raw_value(v) * _normal > 0,
      69       87777 :                           _advected_interp_method == InterpMethod::SkewCorrectedAverage),
      70      175554 :                  determineState());
      71             : 
      72      263331 :   return _normal * v * adv_quant_interface;
      73             :   ;
      74       87777 : }

Generated by: LCOV version 1.14