LCOV - code coverage report
Current view: top level - src/kernels - INSPressurePoisson.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 0 31 0.0 %
Date: 2025-08-14 10:14:56 Functions: 0 5 0.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 "INSPressurePoisson.h"
      11             : #include "MooseMesh.h"
      12             : 
      13             : registerMooseObject("NavierStokesApp", INSPressurePoisson);
      14             : 
      15             : InputParameters
      16           0 : INSPressurePoisson::validParams()
      17             : {
      18           0 :   InputParameters params = Kernel::validParams();
      19             : 
      20           0 :   params.addClassDescription("This class computes the pressure Poisson solve which is part of the "
      21             :                              "'split' scheme used for solving the incompressible Navier-Stokes "
      22             :                              "equations.");
      23             :   // Coupled variables
      24           0 :   params.addRequiredCoupledVar("a1", "x-acceleration");
      25           0 :   params.addCoupledVar("a2", "y-acceleration"); // only required in 2D and 3D
      26           0 :   params.addCoupledVar("a3", "z-acceleration"); // only required in 3D
      27             : 
      28             :   // Optional parameters
      29           0 :   params.addParam<MaterialPropertyName>("rho_name", "rho", "density_name");
      30             : 
      31           0 :   return params;
      32           0 : }
      33             : 
      34           0 : INSPressurePoisson::INSPressurePoisson(const InputParameters & parameters)
      35             :   : Kernel(parameters),
      36             : 
      37             :     // Gradients
      38           0 :     _grad_a1(coupledGradient("a1")),
      39           0 :     _grad_a2(_mesh.dimension() >= 2 ? coupledGradient("a2") : _grad_zero),
      40           0 :     _grad_a3(_mesh.dimension() == 3 ? coupledGradient("a3") : _grad_zero),
      41             : 
      42             :     // Variable numberings
      43           0 :     _a1_var_number(coupled("a1")),
      44           0 :     _a2_var_number(_mesh.dimension() >= 2 ? coupled("a2") : libMesh::invalid_uint),
      45           0 :     _a3_var_number(_mesh.dimension() == 3 ? coupled("a3") : libMesh::invalid_uint),
      46             : 
      47             :     // Material Properties
      48           0 :     _rho(getMaterialProperty<Real>("rho_name"))
      49             : {
      50           0 : }
      51             : 
      52             : Real
      53           0 : INSPressurePoisson::computeQpResidual()
      54             : {
      55             :   // Laplacian part
      56           0 :   Real laplacian_part = _grad_u[_qp] * _grad_test[_i][_qp];
      57             : 
      58             :   // Divergence part
      59             :   Real div_part =
      60           0 :       _rho[_qp] * (_grad_a1[_qp](0) + _grad_a2[_qp](1) + _grad_a3[_qp](2)) * _test[_i][_qp];
      61             : 
      62             :   // Return the result
      63           0 :   return laplacian_part + div_part;
      64             : }
      65             : 
      66             : Real
      67           0 : INSPressurePoisson::computeQpJacobian()
      68             : {
      69           0 :   return _grad_phi[_j][_qp] * _grad_test[_i][_qp];
      70             : }
      71             : 
      72             : Real
      73           0 : INSPressurePoisson::computeQpOffDiagJacobian(unsigned jvar)
      74             : {
      75           0 :   if (jvar == _a1_var_number)
      76           0 :     return _rho[_qp] * _grad_phi[_j][_qp](0) * _test[_i][_qp];
      77             : 
      78           0 :   else if (jvar == _a2_var_number)
      79           0 :     return _rho[_qp] * _grad_phi[_j][_qp](1) * _test[_i][_qp];
      80             : 
      81           0 :   else if (jvar == _a3_var_number)
      82           0 :     return _rho[_qp] * _grad_phi[_j][_qp](2) * _test[_i][_qp];
      83             : 
      84             :   else
      85             :     return 0;
      86             : }

Generated by: LCOV version 1.14