LCOV - code coverage report
Current view: top level - src/fvkernels - FVAdvection.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 29 32 90.6 %
Date: 2026-05-29 20:35:17 Functions: 4 4 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 "FVAdvection.h"
      11             : #include "Steady.h"
      12             : #include "FEProblemBase.h"
      13             : 
      14             : registerADMooseObject("MooseApp", FVAdvection);
      15             : 
      16             : InputParameters
      17        4092 : FVAdvection::validParams()
      18             : {
      19        4092 :   InputParameters params = FVFluxKernel::validParams();
      20        8184 :   params.addClassDescription(
      21             :       "Residual contribution from advection operator for finite volume method.");
      22       12276 :   params.addRequiredParam<RealVectorValue>("velocity", "Constant advection velocity");
      23        4092 :   params += Moose::FV::advectedInterpolationParameter();
      24             : 
      25             :   // We add the relationship manager here, this will select the right number of
      26             :   // ghosting layers depending on the chosen interpolation method
      27       12276 :   params.addRelationshipManager(
      28             :       "ElementSideNeighborLayers",
      29             :       Moose::RelationshipManagerType::GEOMETRIC | Moose::RelationshipManagerType::ALGEBRAIC |
      30             :           Moose::RelationshipManagerType::COUPLING,
      31           0 :       [](const InputParameters & obj_params, InputParameters & rm_params)
      32        1515 :       { FVRelationshipManagerInterface::setRMParamsAdvection(obj_params, rm_params, 2); });
      33             : 
      34        4092 :   return params;
      35           0 : }
      36             : 
      37         524 : FVAdvection::FVAdvection(const InputParameters & params)
      38        1572 :   : FVFluxKernel(params), _velocity(getParam<RealVectorValue>("velocity"))
      39             : {
      40             :   const bool need_more_ghosting =
      41         524 :       Moose::FV::setInterpolationMethod(*this, _advected_interp_method, "advected_interp_method");
      42         524 :   if (need_more_ghosting && _tid == 0)
      43             :     // If we need more ghosting, then we are a second-order nonlinear limiting scheme whose stencil
      44             :     // is liable to change upon wind-direction change. Consequently we need to tell our problem that
      45             :     // it's ok to have new nonzeros which may crop-up after PETSc has shrunk the matrix memory
      46             :     getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")
      47        1200 :         ->setErrorOnJacobianNonzeroReallocation(false);
      48             : 
      49         524 :   if (dynamic_cast<Steady *>(_app.getExecutioner()))
      50             :   {
      51         618 :     const MooseEnum not_available_with_steady("sou min_mod vanLeer quick venkatakrishnan");
      52             :     const std::string chosen_scheme =
      53         412 :         static_cast<std::string>(getParam<MooseEnum>("advected_interp_method"));
      54         206 :     if (not_available_with_steady.find(chosen_scheme) != not_available_with_steady.items().end())
      55           0 :       paramError("advected_interp_method",
      56             :                  "The given advected interpolation cannot be used with steady-state runs!");
      57         206 :   }
      58         524 : }
      59             : 
      60             : ADReal
      61     5798502 : FVAdvection::computeQpResidual()
      62             : {
      63     5798502 :   const auto state = determineState();
      64     5798502 :   const auto & limiter_time = _subproblem.isTransient()
      65     5798502 :                                   ? Moose::StateArg(1, Moose::SolutionIterationType::Time)
      66     5798502 :                                   : Moose::StateArg(1, Moose::SolutionIterationType::Nonlinear);
      67             : 
      68     5798502 :   const bool elem_is_upwind = _velocity * _normal >= 0;
      69     5798502 :   const auto face = makeFace(*_face_info,
      70             :                              Moose::FV::limiterType(_advected_interp_method),
      71             :                              elem_is_upwind,
      72             :                              false,
      73             :                              &limiter_time);
      74     5798502 :   ADReal u_interface = _var(face, state);
      75             : 
      76    11597004 :   return _normal * _velocity * u_interface;
      77     5798502 : }

Generated by: LCOV version 1.14