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