LCOV - code coverage report
Current view: top level - src/fvkernels - FVAdvection.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 29 32 90.6 %
Date: 2025-08-08 20:01:16 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       15833 : FVAdvection::validParams()
      18             : {
      19       15833 :   InputParameters params = FVFluxKernel::validParams();
      20       15833 :   params.addClassDescription(
      21             :       "Residual contribution from advection operator for finite volume method.");
      22       15833 :   params.addRequiredParam<RealVectorValue>("velocity", "Constant advection velocity");
      23       15833 :   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       15833 :   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        2320 :       { FVRelationshipManagerInterface::setRMParamsAdvection(obj_params, rm_params, 2); });
      33             : 
      34       15833 :   return params;
      35           0 : }
      36             : 
      37         792 : FVAdvection::FVAdvection(const InputParameters & params)
      38         792 :   : FVFluxKernel(params), _velocity(getParam<RealVectorValue>("velocity"))
      39             : {
      40             :   const bool need_more_ghosting =
      41         792 :       Moose::FV::setInterpolationMethod(*this, _advected_interp_method, "advected_interp_method");
      42         792 :   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         306 :         ->setErrorOnJacobianNonzeroReallocation(false);
      48             : 
      49         792 :   if (dynamic_cast<Steady *>(_app.getExecutioner()))
      50             :   {
      51         350 :     const MooseEnum not_available_with_steady("sou min_mod vanLeer quick venkatakrishnan");
      52             :     const std::string chosen_scheme =
      53         350 :         static_cast<std::string>(getParam<MooseEnum>("advected_interp_method"));
      54         350 :     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         350 :   }
      58         792 : }
      59             : 
      60             : ADReal
      61    15017162 : FVAdvection::computeQpResidual()
      62             : {
      63    15017162 :   const auto state = determineState();
      64    15017162 :   const auto & limiter_time = _subproblem.isTransient()
      65    15017162 :                                   ? Moose::StateArg(1, Moose::SolutionIterationType::Time)
      66    15017162 :                                   : Moose::StateArg(1, Moose::SolutionIterationType::Nonlinear);
      67             : 
      68    15017162 :   const bool elem_is_upwind = _velocity * _normal >= 0;
      69    15017162 :   const auto face = makeFace(*_face_info,
      70             :                              Moose::FV::limiterType(_advected_interp_method),
      71             :                              elem_is_upwind,
      72             :                              false,
      73             :                              &limiter_time);
      74    15017162 :   ADReal u_interface = _var(face, state);
      75             : 
      76    30034324 :   return _normal * _velocity * u_interface;
      77    15017162 : }

Generated by: LCOV version 1.14