https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LinearFVAnisotropicDiffusionFunctorNeumannBC.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{
18 params.suppressParameter<MooseFunctorName>("diffusion_coeff");
19 params.addRequiredParam<MooseFunctorName>("diffusion_tensor",
20 "Functor describing a diagonal diffusion tensor.");
21 params.addParam<bool>(
22 "use_two_term_expansion",
23 true,
24 "Whether to reconstruct the boundary value using the prescribed flux and cell gradient. If "
25 "false, the boundary value is approximated by the adjacent cell value.");
27 "Adds a prescribed anisotropic diffusive flux boundary condition to a linear finite "
28 "volume system and reconstructs the boundary value using a diagonal diffusion tensor.");
29 return params;
30}
31
33 const InputParameters & parameters)
35 _two_term_expansion(getParam<bool>("use_two_term_expansion")),
36 _diffusion_tensor(getFunctor<RealVectorValue>("diffusion_tensor"))
37{
38}
39
40Real
42{
43 const auto state = determineState();
47 const auto cell_value = _var.getElemValue(*elem_info, state);
48
50 return cell_value;
51
52 const auto boundary_normal =
55 const auto cell_to_face = computeCellToFaceVector();
56 const auto tangential_cell_to_face =
57 cell_to_face - (cell_to_face * boundary_normal) * boundary_normal;
58
60 _var.gradSln(*elem_info, state) * tangential_cell_to_face;
61}
62
63Real
65{
67 return 0.0;
68
69 const auto state = determineState();
73 const auto boundary_normal =
76 const auto diffusion_tensor = _diffusion_tensor(singleSidedFaceArg(_current_face_info), state);
77
78 RealVectorValue normal_scaled_diffusion;
79 for (const auto i : make_range(Moose::dim))
80 normal_scaled_diffusion(i) = boundary_normal(i) * diffusion_tensor(i);
81
82 const Real normal_diffusion = normal_scaled_diffusion * boundary_normal;
83 if (normal_diffusion <= 0.0)
84 mooseError("The boundary-normal diffusion coefficient must be positive, but its value is ",
85 normal_diffusion,
86 ".");
87
88 const auto tangential_diffusion = normal_scaled_diffusion - normal_diffusion * boundary_normal;
89 const Real tangential_flux = tangential_diffusion * _var.gradSln(*elem_info, state);
90
91 return (_functor(singleSidedFaceArg(_current_face_info), state) - tangential_flux) /
92 normal_diffusion;
93}
94
95Real
registerMooseObject("MooseApp", LinearFVAnisotropicDiffusionFunctorNeumannBC)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
const Point & normal() const
Returns the unit normal vector for the face oriented outward from the face's elem element.
Definition FaceInfo.h:72
const ElemInfo * elemInfo() const
Definition FaceInfo.h:89
const ElemInfo * neighborInfo() const
Definition FaceInfo.h:90
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn't required or valid in the derived class...
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 addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
Class implementing a Neumann boundary condition for linear finite volume variables.
const Moose::Functor< Real > & _functor
The functor for this BC (can be variable, function, etc)
A Neumann boundary condition for linear finite volume anisotropic diffusion problems.
virtual Real computeBoundaryNormalGradient() const override
Computes the normal gradient (often used in diffusion terms) on the boundary.
const Moose::Functor< RealVectorValue > & _diffusion_tensor
The functor for the diagonal diffusion tensor.
virtual Real computeBoundaryValueRHSContribution() const override
Computes the boundary value's contribution to the linear system right hand side.
LinearFVAnisotropicDiffusionFunctorNeumannBC(const InputParameters &parameters)
Class constructor.
const bool _two_term_expansion
Whether to reconstruct the boundary value with the prescribed flux and cell gradient.
virtual Real computeBoundaryValue() const override
Computes the boundary value of this object.
const FaceInfo * _current_face_info
Pointer to the face info we are operating on right now.
Moose::FaceArg singleSidedFaceArg(const FaceInfo *fi, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false) const
Determine the single sided face argument when evaluating a functor on a face.
Real computeCellToFaceDistance() const
Compute the distance between the cell center and the face.
FaceInfo::VarFaceNeighbors _current_face_type
Face ownership information for the current face.
RealVectorValue computeCellToFaceVector() const
Computes the vector connecting the cell and boundary face centers.
MooseLinearVariableFV< Real > & _var
Reference to the linear finite volume variable object.
Real getElemValue(const ElemInfo &elem_info, const StateArg &state) const
Get the solution value for the provided element and seed the derivative for the corresponding dof ind...
VectorValue< Real > gradSln(const ElemInfo &elem_info, const StateArg &state) const
Get the variable gradient at a cell center.
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition Moose.h:165