LCOV - code coverage report
Current view: top level - src/materials - INSAD3Eqn.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: #32971 (54bef8) with base c6cf66 Lines: 65 66 98.5 %
Date: 2026-05-29 20:37:52 Functions: 4 4 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 "INSAD3Eqn.h"
      11             : #include "INSADObjectTracker.h"
      12             : #include "Function.h"
      13             : 
      14             : registerMooseObject("NavierStokesApp", INSAD3Eqn);
      15             : 
      16             : InputParameters
      17        1323 : INSAD3Eqn::validParams()
      18             : {
      19        1323 :   InputParameters params = INSADMaterial::validParams();
      20        1323 :   params.addClassDescription("This material computes properties needed for stabilized formulations "
      21             :                              "of the mass, momentum, and energy equations.");
      22        2646 :   params.addRequiredCoupledVar("temperature", "The temperature");
      23        2646 :   params.addParam<MaterialPropertyName>("cp_name", "cp", "The name of the specific heat capacity");
      24        1323 :   return params;
      25           0 : }
      26             : 
      27        1032 : INSAD3Eqn::INSAD3Eqn(const InputParameters & parameters)
      28             :   : INSADMaterial(parameters),
      29        1032 :     _temperature(adCoupledValue("temperature")),
      30        1032 :     _grad_temperature(adCoupledGradient("temperature")),
      31        2064 :     _cp(getADMaterialProperty<Real>("cp_name")),
      32        1032 :     _temperature_advective_strong_residual(
      33        1032 :         declareADProperty<Real>("temperature_advective_strong_residual")),
      34        1032 :     _temperature_td_strong_residual(declareADProperty<Real>("temperature_td_strong_residual")),
      35        1032 :     _temperature_ambient_convection_strong_residual(
      36        1032 :         declareADProperty<Real>("temperature_ambient_convection_strong_residual")),
      37        1032 :     _temperature_source_strong_residual(
      38        1032 :         declareADProperty<Real>("temperature_source_strong_residual")),
      39        1032 :     _temperature_advected_mesh_strong_residual(
      40        2064 :         declareADProperty<Real>("temperature_advected_mesh_strong_residual"))
      41             : {
      42        1032 : }
      43             : 
      44             : void
      45      336644 : INSAD3Eqn::subdomainSetup()
      46             : {
      47      336644 :   INSADMaterial::subdomainSetup();
      48             : 
      49      673288 :   if ((_has_energy_transient =
      50      336644 :            _object_tracker->get<bool>("has_energy_transient", _current_subdomain_id)))
      51       93653 :     _temperature_dot = &adCoupledDot("temperature");
      52             :   else
      53      242991 :     _temperature_dot = nullptr;
      54             : 
      55      673288 :   if ((_has_ambient_convection =
      56      336644 :            _object_tracker->get<bool>("has_ambient_convection", _current_subdomain_id)))
      57             :   {
      58         849 :     _ambient_convection_alpha =
      59         849 :         _object_tracker->get<Real>("ambient_convection_alpha", _current_subdomain_id);
      60         849 :     _ambient_temperature = _object_tracker->get<Real>("ambient_temperature", _current_subdomain_id);
      61             :   }
      62             :   else
      63             :   {
      64      335795 :     _ambient_convection_alpha = 0;
      65      335795 :     _ambient_temperature = 0;
      66             :   }
      67             : 
      68      336644 :   if ((_has_heat_source = _object_tracker->get<bool>("has_heat_source", _current_subdomain_id)))
      69             :   {
      70        2264 :     if (_object_tracker->isTrackerParamValid("heat_source_var", _current_subdomain_id))
      71             :     {
      72         566 :       _heat_source_var = &_subproblem
      73         566 :                               .getStandardVariable(_tid,
      74         566 :                                                    _object_tracker->get<std::string>(
      75         566 :                                                        "heat_source_var", _current_subdomain_id))
      76         566 :                               .adSln();
      77         566 :       _heat_source_function = nullptr;
      78             :     }
      79        1132 :     else if (_object_tracker->isTrackerParamValid("heat_source_function", _current_subdomain_id))
      80             :     {
      81         566 :       _heat_source_function = &_fe_problem.getFunction(
      82         566 :           _object_tracker->get<FunctionName>("heat_source_function", _current_subdomain_id), _tid);
      83         566 :       _heat_source_var = nullptr;
      84             :     }
      85             :   }
      86             :   else
      87             :   {
      88      335512 :     _heat_source_var = nullptr;
      89      335512 :     _heat_source_function = nullptr;
      90             :   }
      91      336644 : }
      92             : 
      93             : void
      94    16711838 : INSAD3Eqn::computeQpProperties()
      95             : {
      96    16711838 :   INSADMaterial::computeQpProperties();
      97             : 
      98             :   // For the remaining terms we make individual properties so they can be consumed by non-SUPG
      99             :   // kernels. This avoids double calculation for the non-supg and supg parts of the residual. We
     100             :   // don't need an individual property for the conductive term because the corresponding non-supg
     101             :   // contribution is integrated by parts and hence there is no double calculation (the 'weak' and
     102             :   // 'strong' terms are diferent in this case)
     103             : 
     104    16711838 :   _temperature_advective_strong_residual[_qp] =
     105    33423676 :       _rho[_qp] * _cp[_qp] * _velocity[_qp] * _grad_temperature[_qp];
     106             : 
     107    16711838 :   if (_has_energy_transient)
     108             :   {
     109             :     mooseAssert(_temperature_dot, "The temperature time derivative is null");
     110     7498652 :     _temperature_td_strong_residual[_qp] = _cp[_qp] * _rho[_qp] * (*_temperature_dot)[_qp];
     111             :   }
     112             : 
     113    16711838 :   if (_has_ambient_convection)
     114      165888 :     _temperature_ambient_convection_strong_residual[_qp] =
     115      331776 :         _ambient_convection_alpha * (_temperature[_qp] - _ambient_temperature);
     116             : 
     117    16711838 :   if (_has_heat_source)
     118             :   {
     119      221184 :     if (_heat_source_var)
     120      110592 :       _temperature_source_strong_residual[_qp] = -(*_heat_source_var)[_qp];
     121             :     else
     122             :     {
     123             :       mooseAssert(_heat_source_function,
     124             :                   "Either the heat source var or the heat source function must be non-null in "
     125             :                   "'INSAD3Eqn'");
     126      110592 :       _temperature_source_strong_residual[_qp] = -_heat_source_function->value(_t, _q_point[_qp]);
     127             :     }
     128             :   }
     129             : 
     130    16711838 :   if (_has_advected_mesh)
     131      463018 :     _temperature_advected_mesh_strong_residual[_qp] =
     132      926036 :         -_rho[_qp] * _cp[_qp] * _mesh_velocity[_qp] * _grad_temperature[_qp];
     133    16711838 : }

Generated by: LCOV version 1.14