https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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))
51 "PINSFVEnergyAnisotropicDiffusion may only be used with a fluid temperature variable, "
52 "of variable type INSFVEnergyVariable.");
53}
54
57{
58 // Interpolate thermal conductivity times porosity on the face
59 ADRealVectorValue k_eps_face;
60 const auto state = determineState();
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}
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("NavierStokesApp", PINSFVEnergyAnisotropicDiffusion)
Moose::ElemArg neighborArg(bool correct_skewness=false) const
Moose::ElemArg elemArg(bool correct_skewness=false) const
static InputParameters validParams()
RealVectorValue _normal
bool onBoundary(const FaceInfo &fi) const
MooseVariableFV< Real > & _var
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
const FaceInfo * _face_info
void mooseError(Args &&... args) const
const ADTemplateVariableGradient< OutputType > & adGradSln() const override
A flux kernel for diffusion of energy in porous media across cell faces using a vector diffusion coef...
const bool _porosity_factored_in
whether the diffusivity should be multiplied by porosity
const Moose::FV::InterpMethod _k_interp_method
The face interpolation method for the conductivity.
PINSFVEnergyAnisotropicDiffusion(const InputParameters &params)
const Moose::Functor< ADRealVectorValue > & _k
the thermal conductivity
const Moose::Functor< ADReal > & _eps
the porosity
Moose::StateArg determineState() const
void interpolate(InterpMethod m, T &result, const T2 &value1, const T3 &value2, const FaceInfo &fi, const bool one_is_elem)
static const std::string kappa
Definition NS.h:120
static const std::string porosity
Definition NS.h:108