LCOV - code coverage report
Current view: top level - src/fvkernels - WCNSFVMomentumTimeDerivative.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: ba1ead Lines: 26 27 96.3 %
Date: 2025-08-13 06:50:25 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 "WCNSFVMomentumTimeDerivative.h"
      11             : #include "SystemBase.h"
      12             : #include "NS.h"
      13             : 
      14             : registerMooseObject("NavierStokesApp", WCNSFVMomentumTimeDerivative);
      15             : 
      16             : InputParameters
      17        1359 : WCNSFVMomentumTimeDerivative::validParams()
      18             : {
      19        1359 :   InputParameters params = INSFVTimeKernel::validParams();
      20        1359 :   params.addClassDescription(
      21             :       "Adds the time derivative term to the incompressible Navier-Stokes momentum equation.");
      22        1359 :   params.addRequiredParam<MooseFunctorName>(NS::density, "The density material property");
      23        4077 :   params.addRequiredParam<MooseFunctorName>(NS::time_deriv(NS::density),
      24             :                                             "The time derivative of the density material property");
      25        1359 :   return params;
      26           0 : }
      27             : 
      28         814 : WCNSFVMomentumTimeDerivative::WCNSFVMomentumTimeDerivative(const InputParameters & params)
      29             :   : INSFVTimeKernel(params),
      30         814 :     _rho(getFunctor<ADReal>(NS::density)),
      31        1628 :     _rho_dot(getFunctor<ADReal>(NS::time_deriv(NS::density)))
      32             : {
      33         814 : }
      34             : 
      35             : void
      36     2237276 : WCNSFVMomentumTimeDerivative::gatherRCData(const Elem & elem)
      37             : {
      38             :   // _rho and _rho_dot could ultimately be functions of the nonlinear variables making our residual
      39             :   // nonlinear so we cannot do the simple treatment that is done in
      40             :   // INSFVMomentumTimeDerivative::gatherRCData
      41             : 
      42     2237276 :   const auto elem_arg = makeElemArg(&elem);
      43     2237276 :   const auto state = determineState();
      44     2237276 :   const auto rho_dot = _rho_dot(elem_arg, state);
      45     2237276 :   const auto var_dot = _var.dot(elem_arg, state);
      46     2237276 :   const auto rho = _rho(elem_arg, state);
      47     2237276 :   const auto var = _var(elem_arg, state);
      48             : 
      49     2237276 :   const auto dof_number = elem.dof_number(_sys.number(), _var.number(), 0);
      50             :   mooseAssert(var.derivatives()[dof_number] == 1.,
      51             :               "This is an implicit assumption in our coefficient calculation.");
      52             : 
      53     2237276 :   const auto strong_resid = rho_dot * var + rho * var_dot;
      54             : 
      55             :   // For the first term in the above strong residual we know that var.derivatives()[dof_number] = 1
      56             :   // so there is no need to explicitly index here
      57     2237276 :   ADReal a = rho_dot;
      58             :   // but there is a need here
      59     2237276 :   a += rho * var_dot.derivatives()[dof_number];
      60             : 
      61     2237276 :   const auto volume = _assembly.elementVolume(&elem);
      62     2237276 :   if (_contribute_to_rc_coeffs)
      63     4474552 :     _rc_uo.addToA(&elem, _index, a * volume);
      64     4474552 :   addResidualAndJacobian(strong_resid * volume, dof_number);
      65     2237276 : }

Generated by: LCOV version 1.14