https://mooseframework.inl.gov
PINSFVEnergyAnisotropicDiffusion.C
Go to the documentation of this file.
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 
11 #include "INSFVEnergyVariable.h"
12 #include "NS.h"
13 
15 
18 {
19  auto params = FVFluxKernel::validParams();
20  params.addClassDescription(
21  "Anisotropic diffusion term in the porous media incompressible Navier-Stokes "
22  "equations : -div(kappa grad(T))");
23  params.addRequiredParam<MooseFunctorName>(NS::kappa, "Vector of effective thermal conductivity");
24  params.addRequiredParam<MooseFunctorName>(NS::porosity, "Porosity");
25  params.addParam<bool>(
26  "effective_diffusivity",
27  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  params.renameParam("effective_diffusivity", "effective_conductivity", "");
31  MooseEnum coeff_interp_method("average harmonic", "harmonic");
32  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  params.set<unsigned short>("ghost_layers") = 2;
38  return params;
39 }
40 
42  : FVFluxKernel(params),
43  _k(getFunctor<ADRealVectorValue>(NS::kappa)),
44  _eps(getFunctor<ADReal>(NS::porosity)),
45  _porosity_factored_in(getParam<bool>("effective_conductivity")),
46  _k_interp_method(
47  Moose::FV::selectInterpolationMethod(getParam<MooseEnum>("kappa_interp_method")))
48 {
49  if (!dynamic_cast<INSFVEnergyVariable *>(&_var))
50  mooseError(
51  "PINSFVEnergyAnisotropicDiffusion may only be used with a fluid temperature variable, "
52  "of variable type INSFVEnergyVariable.");
53 }
54 
55 ADReal
57 {
58  // Interpolate thermal conductivity times porosity on the face
59  ADRealVectorValue k_eps_face;
60  const auto state = determineState();
61  if (onBoundary(*_face_info))
62  {
63  const auto ssf = singleSidedFaceArg();
64  k_eps_face = _porosity_factored_in ? _k(ssf, state) : _k(ssf, state) * _eps(ssf, state);
65  }
66  else
67  {
68  const auto face_elem = elemArg();
69  const auto face_neighbor = neighborArg();
70 
71  const auto value1 = _porosity_factored_in ? _k(face_elem, state)
72  : _k(face_elem, state) * _eps(face_elem, state);
73  const auto value2 = _porosity_factored_in
74  ? _k(face_neighbor, state)
75  : _k(face_neighbor, state) * _eps(face_neighbor, state);
76 
77  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  const auto & grad_T = _var.adGradSln(*_face_info, state);
83  for (std::size_t i = 0; i < LIBMESH_DIM; i++)
84  kappa_grad_T(i) = k_eps_face(i) * grad_T(i);
85 
86  return -kappa_grad_T * _normal;
87 }
Moose::ElemArg elemArg(bool correct_skewness=false) const
const FaceInfo * _face_info
Moose::StateArg determineState() const
RealVectorValue _normal
DualNumber< Real, DNDerivativeType, true > ADReal
static const std::string porosity
Definition: NS.h:104
bool onBoundary(const FaceInfo &fi) const
static InputParameters validParams()
const Moose::Functor< ADReal > & _eps
the porosity
registerMooseObject("NavierStokesApp", PINSFVEnergyAnisotropicDiffusion)
const bool _porosity_factored_in
whether the diffusivity should be multiplied by porosity
A flux kernel for diffusion of energy in porous media across cell faces using a vector diffusion coef...
static const std::string kappa
Definition: NS.h:116
Moose::ElemArg neighborArg(bool correct_skewness=false) const
void mooseError(Args &&... args) const
Moose::FaceArg singleSidedFaceArg(const FaceInfo *fi=nullptr, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
InterpMethod selectInterpolationMethod(const std::string &interp_method)
MooseVariableFV< Real > & _var
const Moose::FV::InterpMethod _k_interp_method
The face interpolation method for the conductivity.
void interpolate(InterpMethod m, T &result, const T2 &value1, const T3 &value2, const FaceInfo &fi, const bool one_is_elem)
const Moose::Functor< ADRealVectorValue > & _k
the thermal conductivity
PINSFVEnergyAnisotropicDiffusion(const InputParameters &params)
const ADTemplateVariableGradient< Real > & adGradSln() const override