https://mooseframework.inl.gov
LinearFVAdvectionDiffusionExtrapolatedBC.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.addClassDescription(
19  "Adds a boundary condition which calculates the face values and face gradients assuming one "
20  "or two term expansions from the cell centroid. This kernel is only compatible "
21  "with advection-diffusion problems.");
22  params.addParam<bool>(
23  "use_two_term_expansion",
24  false,
25  "If an approximate linear expansion should be used to compute the face value.");
26  return params;
27 }
28 
30  const InputParameters & parameters)
31  : LinearFVAdvectionDiffusionBC(parameters),
32  _two_term_expansion(getParam<bool>("use_two_term_expansion"))
33 {
36 }
37 
38 Real
40 {
41  // We allow internal boundaries too so we need to check which side we are on
45 
46  // By default we approximate the boundary value with the neighboring cell value
47  auto boundary_value = _var.getElemValue(*elem_info, determineState());
48 
49  // If we request linear extrapolation, we add the gradient term as well
51  boundary_value += _var.gradSln(*elem_info) * computeCellToFaceVector();
52 
53  return boundary_value;
54 }
55 
56 Real
58 {
59  // By default we assume that the face value is the same as the cell center value so we
60  // have a zero gradient.
61  Real normal_gradient = 0.0;
62 
63  // If we request linear extrapolation, we will have a gradient. We use
65  {
69  normal_gradient = _var.gradSln(*elem_info) * _current_face_info->normal();
70  }
71  return normal_gradient;
72 }
73 
74 Real
76 {
77  return 1.0;
78 }
79 
80 Real
82 {
83  // If we approximate the face value with the cell value, we
84  // don't need to add anything to the right hand side
85  Real contribution = 0.0;
86 
87  // If we have linear extrapolation, we chose to add the linear term to
88  // the right hand side instead of the system matrix.
90  {
94  contribution = _var.gradSln(*elem_info) * computeCellToFaceVector();
95  }
96 
97  return contribution;
98 }
99 
100 Real
102 {
103  return 1.0 / computeCellToFaceDistance();
104 }
105 
106 Real
108 {
110 }
const bool _two_term_expansion
Switch for enabling linear extrapolation for the boundary face value.
RealVectorValue computeCellToFaceVector() const
Computes the vector connecting the cell and boundary face centers.
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.
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:86
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
registerMooseObject("MooseApp", LinearFVAdvectionDiffusionExtrapolatedBC)
const ElemInfo * elemInfo() const
Definition: FaceInfo.h:85
Base class for boundary conditions that are valid for advection diffusion problems.
FaceInfo::VarFaceNeighbors _current_face_type
Face ownership information for the current face.
virtual Real computeBoundaryValueMatrixContribution() const override
Computes the boundary value&#39;s contribution to the linear system matrix.
const Point & normal() const
Returns the unit normal vector for the face oriented outward from the face&#39;s elem element...
Definition: FaceInfo.h:68
MooseLinearVariableFV< Real > & _var
Reference to the linear finite volume variable object.
virtual Real computeBoundaryGradientMatrixContribution() const override
Computes the boundary gradient&#39;s contribution to the linear system matrix.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real computeBoundaryGradientRHSContribution() const override
Computes the boundary gradient&#39;s contribution to the linear system right hand side.
const FaceInfo * _current_face_info
Pointer to the face info we are operating on right now.
virtual Real computeBoundaryValue() const override
Computes the boundary value of this 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...
const VectorValue< Real > gradSln(const ElemInfo &elem_info) const
Get the variable gradient at a cell center.
virtual Real computeBoundaryNormalGradient() const override
Computes the normal gradient (often used in diffusion terms) on the boundary.
Class implementing an extrapolated boundary condition for linear finite volume variables.
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...
void computeCellGradients()
Switch to request cell gradient computations.
LinearFVAdvectionDiffusionExtrapolatedBC(const InputParameters &parameters)
Class constructor.