LCOV - code coverage report
Current view: top level - src/linearfvkernels - LinearFVEnergyAdvection.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 41 43 95.3 %
Date: 2025-08-14 10:14:56 Functions: 9 9 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 "LinearFVEnergyAdvection.h"
      11             : #include "MooseLinearVariableFV.h"
      12             : #include "NSFVUtils.h"
      13             : #include "NS.h"
      14             : 
      15             : registerMooseObject("NavierStokesApp", LinearFVEnergyAdvection);
      16             : 
      17             : InputParameters
      18         520 : LinearFVEnergyAdvection::validParams()
      19             : {
      20         520 :   InputParameters params = LinearFVFluxKernel::validParams();
      21         520 :   params.addClassDescription("Represents the matrix and right hand side contributions of an "
      22             :                              "advection term for the energy e.g. h=int(cp dT). A user may still "
      23             :                              "override what quantity is advected, but the default is temperature.");
      24        1040 :   MooseEnum advected_quantity("enthalpy temperature", "enthalpy");
      25        1040 :   params.addParam<MooseEnum>("advected_quantity", advected_quantity, "The advected quantity");
      26        1040 :   params.addParam<Real>("cp", "Constant specific heat value");
      27        1040 :   params.addRequiredParam<UserObjectName>(
      28             :       "rhie_chow_user_object",
      29             :       "The rhie-chow user-object which is used to determine the face velocity.");
      30         520 :   params += Moose::FV::advectedInterpolationParameter();
      31         520 :   return params;
      32         520 : }
      33             : 
      34         260 : LinearFVEnergyAdvection::LinearFVEnergyAdvection(const InputParameters & params)
      35             :   : LinearFVFluxKernel(params),
      36         260 :     _advected_quantity(getParam<MooseEnum>("advected_quantity").getEnum<AdvectedQuantityEnum>()),
      37         888 :     _cp(isParamValid("cp") ? getParam<Real>("cp") : 1.0),
      38         260 :     _mass_flux_provider(getUserObject<RhieChowMassFlux>("rhie_chow_user_object")),
      39         260 :     _advected_interp_coeffs(std::make_pair<Real, Real>(0, 0)),
      40         260 :     _face_mass_flux(0.0)
      41             : {
      42         260 :   Moose::FV::setInterpolationMethod(*this, _advected_interp_method, "advected_interp_method");
      43             : 
      44         780 :   if (isParamValid("cp") && _advected_quantity == AdvectedQuantityEnum::ENTHALPY)
      45           0 :     paramError("cp", "cp should not be specified for enthalpy advection");
      46             : 
      47         780 :   if (!isParamValid("cp") && _advected_quantity == AdvectedQuantityEnum::TEMPERATURE)
      48           0 :     paramError("cp", "cp should be specified for temperature advection");
      49         260 : }
      50             : 
      51             : Real
      52     7077554 : LinearFVEnergyAdvection::computeElemMatrixContribution()
      53             : {
      54     7077554 :   return _cp * _advected_interp_coeffs.first * _face_mass_flux * _current_face_area;
      55             : }
      56             : 
      57             : Real
      58     7077554 : LinearFVEnergyAdvection::computeNeighborMatrixContribution()
      59             : {
      60     7077554 :   return _cp * _advected_interp_coeffs.second * _face_mass_flux * _current_face_area;
      61             : }
      62             : 
      63             : Real
      64     7077554 : LinearFVEnergyAdvection::computeElemRightHandSideContribution()
      65             : {
      66     7077554 :   return 0.0;
      67             : }
      68             : 
      69             : Real
      70     7077554 : LinearFVEnergyAdvection::computeNeighborRightHandSideContribution()
      71             : {
      72     7077554 :   return 0.0;
      73             : }
      74             : 
      75             : Real
      76      796140 : LinearFVEnergyAdvection::computeBoundaryMatrixContribution(const LinearFVBoundaryCondition & bc)
      77             : {
      78             :   const auto * const adv_bc = static_cast<const LinearFVAdvectionDiffusionBC *>(&bc);
      79             :   mooseAssert(adv_bc, "This should be a valid BC!");
      80             : 
      81      796140 :   const auto boundary_value_matrix_contrib = adv_bc->computeBoundaryValueMatrixContribution();
      82             : 
      83             :   // We support internal boundaries too so we have to make sure the normal points always outward
      84      796140 :   const auto factor = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM) ? 1.0 : -1.0;
      85             : 
      86      796140 :   return _cp * boundary_value_matrix_contrib * factor * _face_mass_flux * _current_face_area;
      87             : }
      88             : 
      89             : Real
      90      796140 : LinearFVEnergyAdvection::computeBoundaryRHSContribution(const LinearFVBoundaryCondition & bc)
      91             : {
      92             :   const auto * const adv_bc = static_cast<const LinearFVAdvectionDiffusionBC *>(&bc);
      93             :   mooseAssert(adv_bc, "This should be a valid BC!");
      94             : 
      95             :   // We support internal boundaries too so we have to make sure the normal points always outward
      96      796140 :   const auto factor = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM ? 1.0 : -1.0);
      97             : 
      98      796140 :   const auto boundary_value_rhs_contrib = adv_bc->computeBoundaryValueRHSContribution();
      99      796140 :   return -_cp * boundary_value_rhs_contrib * factor * _face_mass_flux * _current_face_area;
     100             : }
     101             : 
     102             : void
     103     7873694 : LinearFVEnergyAdvection::setupFaceData(const FaceInfo * face_info)
     104             : {
     105     7873694 :   LinearFVFluxKernel::setupFaceData(face_info);
     106             : 
     107             :   // Caching the mass flux on the face which will be reused in the advection term's matrix and right
     108             :   // hand side contributions
     109     7873694 :   _face_mass_flux = _mass_flux_provider.getMassFlux(*face_info);
     110             : 
     111             :   // Caching the interpolation coefficients so they will be reused for the matrix and right hand
     112             :   // side terms
     113             :   _advected_interp_coeffs =
     114     7873694 :       interpCoeffs(_advected_interp_method, *_current_face_info, true, _face_mass_flux);
     115     7873694 : }

Generated by: LCOV version 1.14