https://mooseframework.inl.gov
SideDiffusiveFluxIntegral.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 "MathFVUtils.h"
12 
13 #include "metaphysicl/raw_type.h"
14 
21  "06/30/2021 24:00",
25  "06/30/2021 24:00",
27 
28 template <bool is_ad, typename T>
31 {
33  params.addParam<MaterialPropertyName>(
34  "diffusivity",
35  "The name of the diffusivity material property that will be used in the flux computation. "
36  "This must be provided if the variable is of finite element type");
37  params.addParam<MooseFunctorName>(
38  "functor_diffusivity",
39  "The name of the diffusivity functor that will be used in the flux computation. This must be "
40  "provided if the variable is of finite volume type");
41  params.addClassDescription(
42  "Computes the integral of the diffusive flux over the specified boundary");
43  return params;
44 }
45 
46 template <bool is_ad, typename T>
48  const InputParameters & parameters)
50  _diffusion_coef(isParamValid("diffusivity")
51  ? &getGenericMaterialProperty<T, is_ad>("diffusivity")
52  : nullptr),
53  _functor_diffusion_coef(isParamValid("functor_diffusivity")
54  ? &getFunctor<Moose::GenericType<T, is_ad>>("functor_diffusivity")
55  : nullptr)
56 {
57  if (_fv && !isParamValid("functor_diffusivity"))
58  mooseError(
59  "For a finite volume variable, the parameter 'functor_diffusivity' must be provided");
60  if (!_fv && !isParamValid("diffusivity"))
61  mooseError("For a finite element variable, the parameter 'diffusivity' must be provided");
62 }
63 
64 template <bool is_ad, typename T>
65 Real
67 {
68  // Get the gradient of the variable on the face
69  const auto grad_u =
70  MetaPhysicL::raw_value(_field_variable->gradient(makeCDFace(*fi), determineState()));
71 
72  return -diffusivityGradientProduct(grad_u,
73  MetaPhysicL::raw_value((*_functor_diffusion_coef)(
74  makeCDFace(*fi), determineState()))) *
75  _normals[_qp];
76 }
77 
78 template <bool is_ad, typename T>
79 Real
81 {
82  return -diffusivityGradientProduct(_grad_u[_qp],
83  MetaPhysicL::raw_value((*_diffusion_coef)[_qp])) *
84  _normals[_qp];
85 }
86 
87 template <bool is_ad, typename T>
90  const Real diffusivity)
91 {
92  return grad_u * diffusivity;
93 }
94 
95 template <bool is_ad, typename T>
98  const RealVectorValue & grad_u, const RealVectorValue & diffusivity)
99 {
100  RealVectorValue d_grad_u = grad_u;
101  for (const auto i : make_range(Moose::dim))
102  d_grad_u(i) *= diffusivity(i);
103 
104  return d_grad_u;
105 }
106 
Real computeFaceInfoIntegral(const FaceInfo *fi) override
registerMooseObject("MooseApp", SideDiffusiveFluxIntegral)
This postprocessor computes a side integral of the mass flux.
auto raw_value(const Eigen::Map< T > &in)
Definition: EigenADReal.h:73
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:159
typename std::conditional< is_ad, typename ADType< T >::type, T >::type GenericType
Definition: MooseTypes.h:645
const bool _fv
Whether this is acting on a finite volume variable.
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition: FaceInfo.h:36
SideDiffusiveFluxIntegralTempl(const InputParameters &parameters)
registerMooseObjectRenamed("MooseApp", SideFluxIntegral, "06/30/2021 24:00", SideDiffusiveFluxIntegral)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
RealVectorValue diffusivityGradientProduct(const RealVectorValue &grad_u, Real diffusivity)
Routine to get the diffusive flux with a Real diffusivity.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:195
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
This postprocessor computes a surface integral of the specified variable.