https://mooseframework.inl.gov
DiffusionFluxFVAux.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 
10 #include "DiffusionFluxFVAux.h"
11 #include "Assembly.h"
12 
13 registerMooseObject("SubChannelApp", DiffusionFluxFVAux);
14 
17 {
19  MooseEnum component("x y z normal");
20  params.addClassDescription("Compute components of flux vector for diffusion problems "
21  "$(\\vec{J} = -D \\nabla C)$.");
22  params.addRequiredParam<MooseEnum>("component", component, "The desired component of flux.");
23  params.addRequiredCoupledVar("diffusion_variable", "The name of the variable");
24  params.addRequiredParam<MaterialPropertyName>(
25  "diffusivity",
26  "The name of the diffusivity material property that will be used in the flux computation.");
27  return params;
28 }
29 
31  : AuxKernel(parameters),
32  _use_normal(getParam<MooseEnum>("component") == "normal"),
33  _component(getParam<MooseEnum>("component")),
34  _diffusion_var(dynamic_cast<const MooseVariableFVReal *>(getFieldVar("diffusion_variable", 0))),
35  _diffusion_coef(hasMaterialProperty<Real>("diffusivity")
36  ? &getMaterialProperty<Real>("diffusivity")
37  : nullptr),
38  _ad_diffusion_coef(!_diffusion_coef ? &getADMaterialProperty<Real>("diffusivity") : nullptr),
39  _normals(_assembly.normals())
40 {
41  if (_use_normal && !isParamValid("boundary"))
42  paramError("boundary", "A boundary must be provided if using the normal component!");
43 }
44 
45 Real
47 {
48  const auto _vec_grad = raw_value(_diffusion_var->adGradSln(_current_elem, determineState()));
49  const Real gradient = _use_normal ? _vec_grad * _normals[_qp] : _vec_grad(_component);
50  const Real diffusion_coef = _diffusion_coef ? (*_diffusion_coef)[_qp]
52  return -diffusion_coef * gradient;
53 }
const bool _use_normal
Whether the normal component has been selected.
const MaterialProperty< Real > *const _diffusion_coef
Holds the diffusivity from the material system if non-AD.
static const std::string component
Definition: NS.h:153
Moose::StateArg determineState() const
auto raw_value(const Eigen::Map< T > &in)
virtual Real computeValue()
const int _component
Will hold 0, 1, or 2 corresponding to x, y, or z.
DiffusionFluxFVAux(const InputParameters &parameters)
void addRequiredParam(const std::string &name, const std::string &doc_string)
bool isParamValid(const std::string &name) const
registerMooseObject("SubChannelApp", DiffusionFluxFVAux)
void paramError(const std::string &param, Args... args) const
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const MooseArray< Point > & _normals
normals at quadrature points at the interface
virtual const OutputTools< Real >::VariableGradient & gradient()
const ADMaterialProperty< Real > *const _ad_diffusion_coef
Holds the diffusivity from the material system if AD.
const Elem *const & _current_elem
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
static InputParameters validParams()
const MooseVariableFVReal *const _diffusion_var
Holds the solution functor for which to compute the gradient.
const ADTemplateVariableGradient< Real > & adGradSln() const override
Auxiliary kernel responsible for computing the components of the flux vector in diffusion problems us...