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 887 : PINSFVEnergyAnisotropicDiffusion::validParams() 18 : { 19 887 : auto params = FVFluxKernel::validParams(); 20 887 : params.addClassDescription( 21 : "Anisotropic diffusion term in the porous media incompressible Navier-Stokes " 22 : "equations : -div(kappa grad(T))"); 23 887 : params.addRequiredParam<MooseFunctorName>(NS::kappa, "Vector of effective thermal conductivity"); 24 887 : params.addRequiredParam<MooseFunctorName>(NS::porosity, "Porosity"); 25 1774 : params.addParam<bool>( 26 : "effective_diffusivity", 27 1774 : 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 1774 : params.renameParam("effective_diffusivity", "effective_conductivity", ""); 31 1774 : MooseEnum coeff_interp_method("average harmonic", "harmonic"); 32 1774 : 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 887 : params.set<unsigned short>("ghost_layers") = 2; 38 887 : return params; 39 887 : } 40 : 41 60 : PINSFVEnergyAnisotropicDiffusion::PINSFVEnergyAnisotropicDiffusion(const InputParameters & params) 42 : : FVFluxKernel(params), 43 60 : _k(getFunctor<ADRealVectorValue>(NS::kappa)), 44 60 : _eps(getFunctor<ADReal>(NS::porosity)), 45 120 : _porosity_factored_in(getParam<bool>("effective_conductivity")), 46 60 : _k_interp_method( 47 180 : Moose::FV::selectInterpolationMethod(getParam<MooseEnum>("kappa_interp_method"))) 48 : { 49 60 : 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 60 : } 54 : 55 : ADReal 56 418338 : PINSFVEnergyAnisotropicDiffusion::computeQpResidual() 57 : { 58 : // Interpolate thermal conductivity times porosity on the face 59 : ADRealVectorValue k_eps_face; 60 418338 : const auto state = determineState(); 61 418338 : if (onBoundary(*_face_info)) 62 : { 63 162 : const auto ssf = singleSidedFaceArg(); 64 486 : k_eps_face = _porosity_factored_in ? _k(ssf, state) : _k(ssf, state) * _eps(ssf, state); 65 : } 66 : else 67 : { 68 418176 : const auto face_elem = elemArg(); 69 418176 : const auto face_neighbor = neighborArg(); 70 : 71 418176 : const auto value1 = _porosity_factored_in ? _k(face_elem, state) 72 418176 : : _k(face_elem, state) * _eps(face_elem, state); 73 418176 : const auto value2 = _porosity_factored_in 74 418176 : ? _k(face_neighbor, state) 75 418176 : : _k(face_neighbor, state) * _eps(face_neighbor, state); 76 : 77 418176 : 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 418338 : const auto & grad_T = _var.adGradSln(*_face_info, state); 83 1673352 : for (std::size_t i = 0; i < LIBMESH_DIM; i++) 84 2510028 : kappa_grad_T(i) = k_eps_face(i) * grad_T(i); 85 : 86 418338 : return -kappa_grad_T * _normal; 87 : }