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  const auto state = determineState();
46 
47  // By default we approximate the boundary value with the neighboring cell value
48  auto boundary_value = _var.getElemValue(*elem_info, state);
49 
50  // If we request linear extrapolation, we add the gradient term as well
52  boundary_value += _var.gradSln(*elem_info, state) * computeCellToFaceVector();
53 
54  return boundary_value;
55 }
56 
57 Real
59 {
60  // By default we assume that the face value is the same as the cell center value so we
61  // have a zero gradient.
62  Real normal_gradient = 0.0;
63 
64  // If we request linear extrapolation, we will have a gradient. We use
66  {
70  normal_gradient = _var.gradSln(*elem_info, determineState()) * _current_face_info->normal();
71  }
72  return normal_gradient;
73 }
74 
75 Real
77 {
78  return 1.0;
79 }
80 
81 Real
83 {
84  // If we approximate the face value with the cell value, we
85  // don't need to add anything to the right hand side
86  Real contribution = 0.0;
87 
88  // If we have linear extrapolation, we chose to add the linear term to
89  // the right hand side instead of the system matrix.
91  {
95  contribution = _var.gradSln(*elem_info, determineState()) * computeCellToFaceVector();
96  }
97 
98  return contribution;
99 }
100 
101 Real
103 {
104  return 1.0 / computeCellToFaceDistance();
105 }
106 
107 Real
109 {
111 }
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:90
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:89
VectorValue< Real > gradSln(const ElemInfo &elem_info, const StateArg &state) const
Get the variable gradient at a cell center.
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:72
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...
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.