LCOV - code coverage report
Current view: top level - src/kernels - PressureGradient.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 34 35 97.1 %
Date: 2025-08-14 10:14:56 Functions: 5 5 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 "PressureGradient.h"
      11             : #include "NS.h"
      12             : 
      13             : registerMooseObject("NavierStokesApp", PressureGradient);
      14             : 
      15             : InputParameters
      16        2244 : PressureGradient::validParams()
      17             : {
      18        2244 :   InputParameters params = Kernel::validParams();
      19        2244 :   params.addRequiredCoupledVar(NS::pressure, "pressure");
      20        4488 :   params.addRequiredParam<unsigned int>("component", "number of component (0 = x, 1 = y, 2 = z)");
      21        2244 :   params.addClassDescription(
      22             :       "Implements the pressure gradient term for one of the Navier Stokes momentum equations.");
      23        4488 :   params.addParam<bool>(
      24        4488 :       "integrate_p_by_parts", true, "Whether to integrate the pressure term by parts");
      25             : 
      26        2244 :   return params;
      27           0 : }
      28             : 
      29        1134 : PressureGradient::PressureGradient(const InputParameters & parameters)
      30             :   : Kernel(parameters),
      31        1134 :     _integrate_p_by_parts(getParam<bool>("integrate_p_by_parts")),
      32        2268 :     _component(getParam<unsigned int>("component")),
      33        1134 :     _pressure(coupledValue(NS::pressure)),
      34        1134 :     _grad_pressure(coupledGradient(NS::pressure)),
      35        1134 :     _pressure_id(coupled(NS::pressure)),
      36        1134 :     _coord_sys(_assembly.coordSystem()),
      37        2268 :     _rz_radial_coord(_mesh.getAxisymmetricRadialCoord())
      38             : {
      39        1134 : }
      40             : 
      41             : Real
      42    58612632 : PressureGradient::computeQpResidual()
      43             : {
      44    58612632 :   if (_integrate_p_by_parts)
      45             :   {
      46    32959080 :     auto residual = -_pressure[_qp] * _grad_test[_i][_qp](_component);
      47    32959080 :     if (_coord_sys == Moose::COORD_RZ && (_rz_radial_coord == _component))
      48    16479540 :       residual -= _pressure[_qp] / _q_point[_qp](_rz_radial_coord) * _test[_i][_qp];
      49    32959080 :     return residual;
      50             :   }
      51             :   else
      52    25653552 :     return _test[_i][_qp] * _grad_pressure[_qp](_component);
      53             : }
      54             : 
      55             : Real
      56    98376984 : PressureGradient::computeQpJacobian()
      57             : {
      58    98376984 :   return 0.;
      59             : }
      60             : 
      61             : Real
      62   229718196 : PressureGradient::computeQpOffDiagJacobian(const unsigned int jvar)
      63             : {
      64   229718196 :   if (jvar == _pressure_id)
      65             :   {
      66    72373212 :     if (_integrate_p_by_parts)
      67             :     {
      68     6112260 :       auto residual = -_phi[_j][_qp] * _grad_test[_i][_qp](_component);
      69     6112260 :       if (_coord_sys == Moose::COORD_RZ && (_rz_radial_coord == _component))
      70     3056130 :         residual -= _phi[_j][_qp] / _q_point[_qp](_rz_radial_coord) * _test[_i][_qp];
      71     6112260 :       return residual;
      72             :     }
      73             :     else
      74    66260952 :       return _test[_i][_qp] * _grad_phi[_j][_qp](_component);
      75             :   }
      76             :   else
      77             :     return 0;
      78             : }

Generated by: LCOV version 1.14