https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
28template <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");
42 "Computes the integral of the diffusive flux over the specified boundary");
43 return params;
44}
45
46template <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"))
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
64template <bool is_ad, typename T>
65Real
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
78template <bool is_ad, typename T>
79Real
81{
82 return -diffusivityGradientProduct(_grad_u[_qp],
83 MetaPhysicL::raw_value((*_diffusion_coef)[_qp])) *
84 _normals[_qp];
85}
86
87template <bool is_ad, typename T>
88RealVectorValue
90 const Real diffusivity)
91{
92 return grad_u * diffusivity;
93}
94
95template <bool is_ad, typename T>
96RealVectorValue
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
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
registerMooseObjectRenamed("MooseApp", SideFluxIntegral, "06/30/2021 24:00", SideDiffusiveFluxIntegral)
registerMooseObject("MooseApp", SideDiffusiveFluxIntegral)
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition FaceInfo.h:38
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
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.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
This postprocessor computes a side integral of the mass flux.
SideDiffusiveFluxIntegralTempl(const InputParameters &parameters)
RealVectorValue diffusivityGradientProduct(const RealVectorValue &grad_u, Real diffusivity)
Routine to get the diffusive flux with a Real diffusivity.
Real computeFaceInfoIntegral(const FaceInfo *fi) override
This postprocessor computes a surface integral of the specified variable.
const bool _fv
Whether this is acting on a finite volume variable.
auto raw_value(const Eigen::Map< T > &in)
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition Moose.h:165