https://mooseframework.inl.gov
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.");
26  params.addClassDescription(
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 
40 Real
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 
63 Real
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 
95 Real
97 {
101  return computeBoundaryValue() - _var.getElemValue(*elem_info, determineState());
102 }
RealVectorValue computeCellToFaceVector() const
Computes the vector connecting the cell and boundary face centers.
LinearFVAnisotropicDiffusionFunctorNeumannBC(const InputParameters &parameters)
Class constructor.
virtual Real computeBoundaryValueRHSContribution() const override
Computes the boundary value&#39;s contribution to the linear system right hand side.
Real computeCellToFaceDistance() const
Compute the distance between the cell center and the face.
registerMooseObject("MooseApp", LinearFVAnisotropicDiffusionFunctorNeumannBC)
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
const ElemInfo * neighborInfo() const
Definition: FaceInfo.h:90
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:165
const ElemInfo * elemInfo() const
Definition: FaceInfo.h:89
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 suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn&#39;t required or valid in the derived class...
VectorValue< Real > gradSln(const ElemInfo &elem_info, const StateArg &state) const
Get the variable gradient at a cell center.
const bool _two_term_expansion
Whether to reconstruct the boundary value with the prescribed flux and cell gradient.
FaceInfo::VarFaceNeighbors _current_face_type
Face ownership information for the current face.
Class implementing a Neumann boundary condition for linear finite volume variables.
virtual Real computeBoundaryValue() const override
Computes the boundary value of this object.
const Point & normal() const
Returns the unit normal vector for the face oriented outward from the face&#39;s elem element...
Definition: FaceInfo.h:72
MooseLinearVariableFV< Real > & _var
Reference to the linear finite volume variable object.
virtual Real computeBoundaryNormalGradient() const override
Computes the normal gradient (often used in diffusion terms) on the boundary.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const FaceInfo * _current_face_info
Pointer to the face info we are operating on right now.
const Moose::Functor< Real > & _functor
The functor for this BC (can be variable, function, etc)
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...
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:271
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...
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.
const Moose::Functor< RealVectorValue > & _diffusion_tensor
The functor for the diagonal diffusion tensor.
A Neumann boundary condition for linear finite volume anisotropic diffusion problems.