https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FVAnisotropicDiffusion.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
13
16{
20 "Computes residual for anisotropic diffusion operator for finite volume method.");
21 params.addRequiredParam<MooseFunctorName>("coeff",
22 "The diagonal coefficients of a diffusion tensor.");
23 MooseEnum coeff_interp_method("average harmonic", "harmonic");
24 params.addParam<MooseEnum>(
25 "coeff_interp_method",
26 coeff_interp_method,
27 "Switch that can select face interpolation method for diffusion coefficients.");
28 params.set<unsigned short>("ghost_layers") = 2;
29
30 // We add the relationship manager here, this will select the right number of
31 // ghosting layers depending on the chosen interpolation method
33 "ElementSideNeighborLayers",
36 [](const InputParameters & obj_params, InputParameters & rm_params)
37 { FVRelationshipManagerInterface::setRMParamsDiffusion(obj_params, rm_params, 3); });
38
39 return params;
40}
41
43 : FVFluxKernel(params),
45 _coeff(getFunctor<ADRealVectorValue>("coeff")),
46 _coeff_interp_method(
47 Moose::FV::selectInterpolationMethod(getParam<MooseEnum>("coeff_interp_method")))
48{
49}
50
53{
54 const auto state = determineState();
55 const auto & grad_T = _var.adGradSln(*_face_info, state, _correct_skewness);
56
58 // If we are on internal faces, we interpolate the diffusivity as usual
60 interpolate(_coeff_interp_method,
61 coeff,
62 _coeff(elemArg(), state),
63 _coeff(neighborArg(), state),
65 true);
66 // Else we just use the boundary values (which depend on how the diffusion
67 // coefficient is constructed)
68 else
69 {
70 const auto face = singleSidedFaceArg();
71 coeff = _coeff(face, state);
72 }
73
74 ADReal r = 0;
75 for (const auto i : make_range(Moose::dim))
76 r += _normal(i) * coeff(i) * grad_T(i);
77 return -r;
78}
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("MooseApp", FVAnisotropicDiffusion)
FVAnisotropicDiffusion implements a standard diffusion term but with a diagonal tensor diffusion coef...
const Moose::FV::InterpMethod _coeff_interp_method
Decides if a geometric arithmetic or harmonic average is used for the face interpolation of the diffu...
static InputParameters validParams()
FVAnisotropicDiffusion(const InputParameters &params)
virtual ADReal computeQpResidual() override
This is the primary function that must be implemented for flux kernel terms.
const Moose::Functor< ADRealVectorValue > & _coeff
Functor returning the diagonal coefficients of a diffusion tensor.
Interface function that holds the member variables and functions related to the interpolation schemes...
const bool _correct_skewness
Just a convenience member for using skewness correction.
FVFluxKernel is used for calculating residual contributions from numerical fluxes from surface integr...
Moose::ElemArg neighborArg(bool correct_skewness=false) const
Moose::ElemArg elemArg(bool correct_skewness=false) const
static InputParameters validParams()
RealVectorValue _normal
This is the outward unit normal vector for the face the kernel is currently operating on.
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
Determine the single sided face argument when evaluating a functor on a face.
const FaceInfo * _face_info
This is holds meta-data for geometric information relevant to the current face including elem+neighbo...
static void setRMParamsDiffusion(const InputParameters &obj_params, InputParameters &rm_params, const unsigned short conditional_extended_layers)
Helper function to set the relationship manager parameters for diffusion-related kernels.
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 addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
void addRelationshipManager(const std::string &name, Moose::RelationshipManagerType rm_type, Moose::RelationshipManagerInputParameterCallback input_parameter_callback=nullptr)
Tells MOOSE about a RelationshipManager that this object needs.
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.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
const ADTemplateVariableGradient< OutputType > & adGradSln() const override
AD grad solution getter.
bool isInternalFace(const FaceInfo &) const
Returns true if the face is an internal face.
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
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