LCOV - code coverage report
Current view: top level - src/fvkernels - INSFVMomentumViscousSourceRZ.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #32971 (54bef8) with base c6cf66 Lines: 26 33 78.8 %
Date: 2026-05-29 20:37:52 Functions: 4 5 80.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 "INSFVMomentumViscousSourceRZ.h"
      11             : 
      12             : #include "NS.h"
      13             : #include "SystemBase.h"
      14             : 
      15             : registerMooseObject("NavierStokesApp", INSFVMomentumViscousSourceRZ);
      16             : 
      17             : InputParameters
      18         171 : INSFVMomentumViscousSourceRZ::validParams()
      19             : {
      20         171 :   InputParameters params = INSFVElementalKernel::validParams();
      21         171 :   params.addClassDescription("Adds the -\\mu u_r / r^2 viscous source term (sign for RHS) that "
      22             :                              "appears in the cylindrical form of the "
      23             :                              "Navier-Stokes momentum equations (axisymmetric, no swirl).");
      24         171 :   params.addRequiredParam<MooseFunctorName>(
      25             :       NS::mu, "The dynamic viscosity that multiplies the viscous source term.");
      26         342 :   params.addParam<bool>("complete_expansion",
      27         342 :                         false,
      28             :                         "Mirror of the INSFVMomentumDiffusion 'complete_expansion' switch. When "
      29             :                         "true, the viscous contribution is multiplied by 2.");
      30         171 :   return params;
      31           0 : }
      32             : 
      33          87 : INSFVMomentumViscousSourceRZ::INSFVMomentumViscousSourceRZ(const InputParameters & params)
      34             :   : INSFVElementalKernel(params),
      35         174 :     _mu(getFunctor<ADReal>(NS::mu)),
      36          87 :     _rz_radial_coord(_subproblem.getAxisymmetricRadialCoord()),
      37         288 :     _expansion_multiplier(getParam<bool>("complete_expansion") ? 2.0 : 1.0)
      38             : {
      39          87 :   if (getBlockCoordSystem() != Moose::COORD_RZ)
      40           0 :     mooseError(name(), " is only valid on blocks that use an RZ coordinate system.");
      41             : 
      42          87 :   if (_index != _rz_radial_coord)
      43           0 :     paramError("momentum_component",
      44             :                "INSFVMomentumViscousSourceRZ only applies to the radial momentum component in an "
      45             :                "axisymmetric coordinate system.");
      46          87 : }
      47             : 
      48             : ADReal
      49       44376 : INSFVMomentumViscousSourceRZ::computeCoefficient(const Moose::ElemArg & elem_arg,
      50             :                                                  const Moose::StateArg & state) const
      51             : {
      52             :   mooseAssert(elem_arg.elem, "The element pointer must be valid for INSFVMomentumViscousSourceRZ.");
      53       44376 :   const auto radius = elem_arg.elem->vertex_average()(_rz_radial_coord);
      54             :   mooseAssert(radius > 0.0, "Axisymmetric radial coordinate should be positive inside a cell.");
      55       44376 :   return _expansion_multiplier * _mu(elem_arg, state) / (radius * radius);
      56             : }
      57             : 
      58             : ADReal
      59           0 : INSFVMomentumViscousSourceRZ::computeSegregatedContribution()
      60             : {
      61           0 :   const auto elem_arg = makeElemArg(_current_elem);
      62           0 :   const auto state = determineState();
      63           0 :   return computeCoefficient(elem_arg, state) * _u_functor(elem_arg, state);
      64             : }
      65             : 
      66             : void
      67       44376 : INSFVMomentumViscousSourceRZ::gatherRCData(const Elem & elem)
      68             : {
      69       44376 :   const auto elem_arg = makeElemArg(&elem);
      70       44376 :   const auto state = determineState();
      71       44376 :   const auto coefficient = computeCoefficient(elem_arg, state);
      72       44376 :   const auto volume_coefficient = coefficient * _assembly.elementVolume(&elem);
      73       44376 :   _rc_uo.addToA(&elem, _index, volume_coefficient);
      74             : 
      75       44376 :   const auto dof_number = elem.dof_number(_sys.number(), _var.number(), 0);
      76       88752 :   addResidualAndJacobian(volume_coefficient * _u_functor(elem_arg, state), dof_number);
      77       44376 : }

Generated by: LCOV version 1.14