LCOV - code coverage report
Current view: top level - src/fvkernels - PINSFVEnergyAnisotropicDiffusion.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: ba1ead Lines: 38 39 97.4 %
Date: 2025-08-13 06:50:25 Functions: 3 3 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 "PINSFVEnergyAnisotropicDiffusion.h"
      11             : #include "INSFVEnergyVariable.h"
      12             : #include "NS.h"
      13             : 
      14             : registerMooseObject("NavierStokesApp", PINSFVEnergyAnisotropicDiffusion);
      15             : 
      16             : InputParameters
      17        1560 : PINSFVEnergyAnisotropicDiffusion::validParams()
      18             : {
      19        1560 :   auto params = FVFluxKernel::validParams();
      20        1560 :   params.addClassDescription(
      21             :       "Anisotropic diffusion term in the porous media incompressible Navier-Stokes "
      22             :       "equations : -div(kappa grad(T))");
      23        1560 :   params.addRequiredParam<MooseFunctorName>(NS::kappa, "Vector of effective thermal conductivity");
      24        1560 :   params.addRequiredParam<MooseFunctorName>(NS::porosity, "Porosity");
      25        3120 :   params.addParam<bool>(
      26             :       "effective_diffusivity",
      27        3120 :       true,
      28             :       "Whether the conductivity should be multiplied by porosity, or whether the provided "
      29             :       "conductivity is an effective conductivity taking porosity effects into account");
      30        3120 :   params.renameParam("effective_diffusivity", "effective_conductivity", "");
      31        3120 :   MooseEnum coeff_interp_method("average harmonic", "harmonic");
      32        3120 :   params.addParam<MooseEnum>(
      33             :       "kappa_interp_method",
      34             :       coeff_interp_method,
      35             :       "Switch that can select face interpolation method for the thermal conductivity.");
      36             : 
      37        1560 :   params.set<unsigned short>("ghost_layers") = 2;
      38        1560 :   return params;
      39        1560 : }
      40             : 
      41         132 : PINSFVEnergyAnisotropicDiffusion::PINSFVEnergyAnisotropicDiffusion(const InputParameters & params)
      42             :   : FVFluxKernel(params),
      43         132 :     _k(getFunctor<ADRealVectorValue>(NS::kappa)),
      44         132 :     _eps(getFunctor<ADReal>(NS::porosity)),
      45         264 :     _porosity_factored_in(getParam<bool>("effective_conductivity")),
      46         132 :     _k_interp_method(
      47         396 :         Moose::FV::selectInterpolationMethod(getParam<MooseEnum>("kappa_interp_method")))
      48             : {
      49         132 :   if (!dynamic_cast<INSFVEnergyVariable *>(&_var))
      50           0 :     mooseError(
      51             :         "PINSFVEnergyAnisotropicDiffusion may only be used with a fluid temperature variable, "
      52             :         "of variable type INSFVEnergyVariable.");
      53         132 : }
      54             : 
      55             : ADReal
      56      627507 : PINSFVEnergyAnisotropicDiffusion::computeQpResidual()
      57             : {
      58             :   // Interpolate thermal conductivity times porosity on the face
      59             :   ADRealVectorValue k_eps_face;
      60      627507 :   const auto state = determineState();
      61      627507 :   if (onBoundary(*_face_info))
      62             :   {
      63         243 :     const auto ssf = singleSidedFaceArg();
      64         729 :     k_eps_face = _porosity_factored_in ? _k(ssf, state) : _k(ssf, state) * _eps(ssf, state);
      65             :   }
      66             :   else
      67             :   {
      68      627264 :     const auto face_elem = elemArg();
      69      627264 :     const auto face_neighbor = neighborArg();
      70             : 
      71      627264 :     const auto value1 = _porosity_factored_in ? _k(face_elem, state)
      72      627264 :                                               : _k(face_elem, state) * _eps(face_elem, state);
      73      627264 :     const auto value2 = _porosity_factored_in
      74      627264 :                             ? _k(face_neighbor, state)
      75      627264 :                             : _k(face_neighbor, state) * _eps(face_neighbor, state);
      76             : 
      77      627264 :     Moose::FV::interpolate(_k_interp_method, k_eps_face, value1, value2, *_face_info, true);
      78             :   }
      79             : 
      80             :   // Compute the temperature gradient times the conductivity tensor
      81             :   ADRealVectorValue kappa_grad_T;
      82      627507 :   const auto & grad_T = _var.adGradSln(*_face_info, state);
      83     2510028 :   for (std::size_t i = 0; i < LIBMESH_DIM; i++)
      84     3765042 :     kappa_grad_T(i) = k_eps_face(i) * grad_T(i);
      85             : 
      86      627507 :   return -kappa_grad_T * _normal;
      87             : }

Generated by: LCOV version 1.14