LCOV - code coverage report
Current view: top level - src/fvkernels - INSFVMeshAdvection.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: ba1ead Lines: 27 28 96.4 %
Date: 2025-08-13 06:50:25 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 "INSFVMeshAdvection.h"
      11             : #include "NS.h"
      12             : 
      13             : registerMooseObject("NavierStokesApp", INSFVMeshAdvection);
      14             : 
      15             : InputParameters
      16         403 : INSFVMeshAdvection::validParams()
      17             : {
      18         403 :   InputParameters params = FVElementalKernel::validParams();
      19         403 :   params.addClassDescription(
      20             :       "Implements a source/sink term for this object's variable/advected-quantity "
      21             :       "proportional to the divergence of the mesh velocity");
      22         403 :   params.addRequiredParam<MooseFunctorName>(NS::density, "The density. This should be constant");
      23         806 :   params.addRequiredParam<MooseFunctorName>("disp_x", "The x-displacement");
      24         806 :   params.addParam<MooseFunctorName>("disp_y", 0, "The y-displacement");
      25         806 :   params.addParam<MooseFunctorName>("disp_z", 0, "The z-displacement");
      26         806 :   params.addParam<MooseFunctorName>(
      27             :       "advected_quantity",
      28             :       "An optional parameter for a functor describing the advected quantity. If this is not "
      29             :       "provided, then the 'variable' will be used");
      30         403 :   return params;
      31           0 : }
      32             : 
      33         206 : INSFVMeshAdvection::INSFVMeshAdvection(const InputParameters & parameters)
      34             :   : FVElementalKernel(parameters),
      35         412 :     _rho(getFunctor<ADReal>(NS::density)),
      36         412 :     _disp_x(getFunctor<ADReal>("disp_x")),
      37         412 :     _disp_y(getFunctor<ADReal>("disp_y")),
      38         412 :     _disp_z(getFunctor<ADReal>("disp_z")),
      39         434 :     _adv_quant(isParamValid("advected_quantity") ? static_cast<const Moose::FunctorBase<ADReal> &>(
      40         250 :                                                        getFunctor<ADReal>("advected_quantity"))
      41         390 :                                                  : static_cast<Moose::FunctorBase<ADReal> &>(_var))
      42             : {
      43         206 : }
      44             : 
      45             : ADReal
      46       63020 : INSFVMeshAdvection::advQuantCoeff(const Moose::ElemArg & elem_arg,
      47             :                                   const Moose::StateArg & state) const
      48             : {
      49       63020 :   const auto div_mesh_velocity = _disp_x.gradDot(elem_arg, state)(0) +
      50       63020 :                                  _disp_y.gradDot(elem_arg, state)(1) +
      51       63020 :                                  _disp_z.gradDot(elem_arg, state)(2);
      52       63020 :   return _rho(elem_arg, state) * div_mesh_velocity;
      53             : }
      54             : 
      55             : ADReal
      56       49150 : INSFVMeshAdvection::computeQpResidual()
      57             : {
      58       49150 :   const auto elem_arg = makeElemArg(_current_elem);
      59       49150 :   const auto state = determineState();
      60       49150 :   return advQuantCoeff(elem_arg, state) * _adv_quant(elem_arg, state);
      61             : }

Generated by: LCOV version 1.14