LCOV - code coverage report
Current view: top level - src/kernels - INSChorinCorrector.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 36 37 97.3 %
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 "INSChorinCorrector.h"
      11             : #include "MooseMesh.h"
      12             : #include "NS.h"
      13             : 
      14             : registerMooseObject("NavierStokesApp", INSChorinCorrector);
      15             : 
      16             : InputParameters
      17          82 : INSChorinCorrector::validParams()
      18             : {
      19          82 :   InputParameters params = Kernel::validParams();
      20             : 
      21          82 :   params.addClassDescription("This class computes the 'Chorin' Corrector equation in "
      22             :                              "fully-discrete (both time and space) form.");
      23             :   // Coupled variables
      24         164 :   params.addRequiredCoupledVar("u_star", "star x-velocity");
      25         164 :   params.addCoupledVar("v_star", "star y-velocity"); // only required in 2D and 3D
      26         164 :   params.addCoupledVar("w_star", "star z-velocity"); // only required in 3D
      27          82 :   params.addRequiredCoupledVar(NS::pressure, "pressure");
      28             : 
      29             :   // Required parameters
      30         164 :   params.addRequiredParam<unsigned>(
      31             :       "component",
      32             :       "0,1,2 depending on if we are solving the x,y,z component of the Corrector equation");
      33             : 
      34             :   // Optional parameters
      35         164 :   params.addParam<MaterialPropertyName>("rho_name", "rho", "density name");
      36             : 
      37          82 :   return params;
      38           0 : }
      39             : 
      40          44 : INSChorinCorrector::INSChorinCorrector(const InputParameters & parameters)
      41             :   : Kernel(parameters),
      42             : 
      43             :     // Current velocities
      44          44 :     _u_vel_star(coupledValue("u_star")),
      45          44 :     _v_vel_star(_mesh.dimension() >= 2 ? coupledValue("v_star") : _zero),
      46          44 :     _w_vel_star(_mesh.dimension() == 3 ? coupledValue("w_star") : _zero),
      47             : 
      48             :     // Pressure gradient
      49          44 :     _grad_p(coupledGradient(NS::pressure)),
      50             : 
      51             :     // Variable numberings
      52          44 :     _u_vel_star_var_number(coupled("u_star")),
      53          44 :     _v_vel_star_var_number(_mesh.dimension() >= 2 ? coupled("v_star") : libMesh::invalid_uint),
      54          44 :     _w_vel_star_var_number(_mesh.dimension() == 3 ? coupled("w_star") : libMesh::invalid_uint),
      55          44 :     _p_var_number(coupled(NS::pressure)),
      56             : 
      57             :     // Required parameters
      58          88 :     _component(getParam<unsigned>("component")),
      59             : 
      60             :     // Material properties
      61         132 :     _rho(getMaterialProperty<Real>("rho_name"))
      62             : {
      63          44 : }
      64             : 
      65             : Real
      66    11776000 : INSChorinCorrector::computeQpResidual()
      67             : {
      68             :   // Vector object for U_star
      69    11776000 :   RealVectorValue U_star(_u_vel_star[_qp], _v_vel_star[_qp], _w_vel_star[_qp]);
      70             : 
      71             :   // The symmetric part
      72    11776000 :   Real symmetric_part = (_u[_qp] - U_star(_component)) * _test[_i][_qp];
      73             : 
      74             :   // The pressure part, don't forget to multiply by dt!
      75    11776000 :   Real pressure_part = (_dt / _rho[_qp]) * _grad_p[_qp](_component) * _test[_i][_qp];
      76             : 
      77    11776000 :   return symmetric_part + pressure_part;
      78             : }
      79             : 
      80             : Real
      81    47104000 : INSChorinCorrector::computeQpJacobian()
      82             : {
      83             :   // The on-diagonal Jacobian contribution is just the mass matrix entry.
      84    47104000 :   return _phi[_j][_qp] * _test[_i][_qp];
      85             : }
      86             : 
      87             : Real
      88   150732800 : INSChorinCorrector::computeQpOffDiagJacobian(unsigned jvar)
      89             : {
      90   150732800 :   if (((jvar == _u_vel_star_var_number) && (_component == 0)) ||
      91   131891200 :       ((jvar == _v_vel_star_var_number) && (_component == 1)) ||
      92   113049600 :       ((jvar == _w_vel_star_var_number) && (_component == 2)))
      93             :   {
      94             :     // The symmetric term's Jacobian is only non-zero when the
      95             :     // component of 'u_star' being differentiated is the same as _component.
      96    37683200 :     return -_phi[_j][_qp] * _test[_i][_qp];
      97             :   }
      98             : 
      99   113049600 :   else if (jvar == _p_var_number)
     100    37683200 :     return (_dt / _rho[_qp]) * _grad_phi[_j][_qp](_component) * _test[_i][_qp];
     101             : 
     102             :   else
     103             :     return 0;
     104             : }

Generated by: LCOV version 1.14