LCOV - code coverage report
Current view: top level - src/kernels - INSADMomentumPressure.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 26 27 96.3 %
Date: 2025-08-14 10:14:56 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 "INSADMomentumPressure.h"
      11             : #include "Assembly.h"
      12             : #include "INSADObjectTracker.h"
      13             : #include "FEProblemBase.h"
      14             : #include "NS.h"
      15             : 
      16             : registerMooseObject("NavierStokesApp", INSADMomentumPressure);
      17             : 
      18             : InputParameters
      19        2896 : INSADMomentumPressure::validParams()
      20             : {
      21        2896 :   InputParameters params = ADVectorKernel::validParams();
      22        2896 :   params.addClassDescription("Adds the pressure term to the INS momentum equation");
      23        2896 :   params.addRequiredCoupledVar(NS::pressure, "The pressure");
      24        5792 :   params.addParam<bool>(
      25        5792 :       "integrate_p_by_parts", true, "Whether to integrate the pressure term by parts");
      26        2896 :   return params;
      27           0 : }
      28             : 
      29        1577 : INSADMomentumPressure::INSADMomentumPressure(const InputParameters & parameters)
      30             :   : ADVectorKernel(parameters),
      31        1577 :     _integrate_p_by_parts(getParam<bool>("integrate_p_by_parts")),
      32        1577 :     _p(adCoupledValue(NS::pressure)),
      33        1577 :     _grad_p(adCoupledGradient(NS::pressure)),
      34        1577 :     _coord_sys(_assembly.coordSystem()),
      35        3154 :     _rz_radial_coord(_mesh.getAxisymmetricRadialCoord())
      36             : {
      37             :   // Bypass the UserObjectInterface method because it requires a UserObjectName param which we
      38             :   // don't need
      39             :   auto & obj_tracker = const_cast<INSADObjectTracker &>(
      40        1577 :       _fe_problem.getUserObject<INSADObjectTracker>("ins_ad_object_tracker"));
      41        3176 :   for (const auto block_id : blockIDs())
      42        3198 :     obj_tracker.set("integrate_p_by_parts", _integrate_p_by_parts, block_id);
      43        1577 : }
      44             : 
      45             : ADReal
      46   328260462 : INSADMomentumPressure::computeQpResidual()
      47             : {
      48   328260462 :   if (_integrate_p_by_parts)
      49             :   {
      50   314801322 :     ADReal residual = -_p[_qp] * _grad_test[_i][_qp].tr();
      51   314801322 :     if (_coord_sys == Moose::COORD_RZ)
      52             :     {
      53    73538352 :       const auto r_component_residual = -_p[_qp] / _ad_q_point[_qp](_rz_radial_coord);
      54             :       ADRealVectorValue rz_residual;
      55    36769176 :       rz_residual(_rz_radial_coord) = r_component_residual;
      56    36769176 :       residual += rz_residual * _test[_i][_qp];
      57             :     }
      58   314801322 :     return residual;
      59             :   }
      60             :   else
      61    13459140 :     return _test[_i][_qp] * _grad_p[_qp];
      62             : }

Generated by: LCOV version 1.14