LCOV - code coverage report
Current view: top level - src/kernels - INSTemperature.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #32971 (54bef8) with base c6cf66 Lines: 41 44 93.2 %
Date: 2026-05-29 20:37:52 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 "INSTemperature.h"
      11             : #include "MooseMesh.h"
      12             : 
      13             : registerMooseObject("NavierStokesApp", INSTemperature);
      14             : 
      15             : InputParameters
      16          62 : INSTemperature::validParams()
      17             : {
      18          62 :   InputParameters params = Kernel::validParams();
      19             : 
      20          62 :   params.addClassDescription("This class computes the residual and Jacobian contributions for the "
      21             :                              "incompressible Navier-Stokes temperature (energy) equation.");
      22             :   // Coupled variables
      23         124 :   params.addRequiredCoupledVar("u", "x-velocity");
      24         124 :   params.addCoupledVar("v", "y-velocity"); // only required in 2D and 3D
      25         124 :   params.addCoupledVar("w", "z-velocity"); // only required in 3D
      26             : 
      27             :   // Optional parameters
      28         124 :   params.addParam<MaterialPropertyName>("rho_name", "rho", "density name");
      29         124 :   params.addParam<MaterialPropertyName>("k_name", "k", "thermal conductivity name");
      30         124 :   params.addParam<MaterialPropertyName>("cp_name", "cp", "specific heat name");
      31             : 
      32          62 :   return params;
      33           0 : }
      34             : 
      35          33 : INSTemperature::INSTemperature(const InputParameters & parameters)
      36             :   : Kernel(parameters),
      37             : 
      38             :     // Coupled variables
      39          33 :     _u_vel(coupledValue("u")),
      40          33 :     _v_vel(_mesh.dimension() >= 2 ? coupledValue("v") : _zero),
      41          33 :     _w_vel(_mesh.dimension() == 3 ? coupledValue("w") : _zero),
      42             : 
      43             :     // Variable numberings
      44          33 :     _u_vel_var_number(coupled("u")),
      45          33 :     _v_vel_var_number(_mesh.dimension() >= 2 ? coupled("v") : libMesh::invalid_uint),
      46          33 :     _w_vel_var_number(_mesh.dimension() == 3 ? coupled("w") : libMesh::invalid_uint),
      47             : 
      48             :     // Material Properties
      49          66 :     _rho(getMaterialProperty<Real>("rho_name")),
      50          66 :     _k(getMaterialProperty<Real>("k_name")),
      51          99 :     _cp(getMaterialProperty<Real>("cp_name"))
      52             : {
      53          33 : }
      54             : 
      55             : Real
      56     4355123 : INSTemperature::computeQpResidual()
      57             : {
      58             :   // The convection part, rho * cp u.grad(T) * v.
      59             :   // Note: _u is the temperature variable, _grad_u is its gradient.
      60     4355123 :   Real convective_part = _rho[_qp] * _cp[_qp] *
      61     4355123 :                          (_u_vel[_qp] * _grad_u[_qp](0) + _v_vel[_qp] * _grad_u[_qp](1) +
      62     4355123 :                           _w_vel[_qp] * _grad_u[_qp](2)) *
      63     4355123 :                          _test[_i][_qp];
      64             : 
      65             :   // Thermal conduction part, k * grad(T) * grad(v)
      66     4355123 :   Real conduction_part = _k[_qp] * _grad_u[_qp] * _grad_test[_i][_qp];
      67             : 
      68     4355123 :   return convective_part + conduction_part;
      69             : }
      70             : 
      71             : Real
      72    28299033 : INSTemperature::computeQpJacobian()
      73             : {
      74    28299033 :   RealVectorValue U(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
      75             : 
      76    28299033 :   Real convective_part = _rho[_qp] * _cp[_qp] * (U * _grad_phi[_j][_qp]) * _test[_i][_qp];
      77    28299033 :   Real conduction_part = _k[_qp] * (_grad_phi[_j][_qp] * _grad_test[_i][_qp]);
      78             : 
      79    28299033 :   return convective_part + conduction_part;
      80             : }
      81             : 
      82             : Real
      83    69232374 : INSTemperature::computeQpOffDiagJacobian(unsigned jvar)
      84             : {
      85    69232374 :   if (jvar == _u_vel_var_number)
      86             :   {
      87    28296153 :     Real convective_part = _rho[_qp] * _cp[_qp] * _phi[_j][_qp] * _grad_u[_qp](0) * _test[_i][_qp];
      88    28296153 :     return convective_part;
      89             :   }
      90             : 
      91    40936221 :   else if (jvar == _v_vel_var_number)
      92             :   {
      93    28296153 :     Real convective_part = _rho[_qp] * _cp[_qp] * _phi[_j][_qp] * _grad_u[_qp](1) * _test[_i][_qp];
      94    28296153 :     return convective_part;
      95             :   }
      96             : 
      97    12640068 :   else if (jvar == _w_vel_var_number)
      98             :   {
      99           0 :     Real convective_part = _rho[_qp] * _cp[_qp] * _phi[_j][_qp] * _grad_u[_qp](2) * _test[_i][_qp];
     100           0 :     return convective_part;
     101             :   }
     102             :   else
     103             :     return 0;
     104             : }

Generated by: LCOV version 1.14