https://mooseframework.inl.gov
Loading...
Searching...
No Matches
LinearFVAdvection.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
10#include "LinearFVAdvection.h"
11#include "Assembly.h"
12#include "SubProblem.h"
14
16
19{
21 params.addClassDescription("Represents the matrix and right hand side contributions of an "
22 "advection term in a partial differential equation.");
23 params.addRequiredParam<RealVectorValue>("velocity", "Constant advection velocity");
24 params.addRequiredParam<InterpolationMethodName>(
25 "advected_interp_method_name",
26 "Name of the FVInterpolationMethod to use for the advected quantity.");
27 return params;
28}
29
31 : LinearFVFluxKernel(params),
33 _velocity(getParam<RealVectorValue>("velocity")),
34 _adv_interp_method(getFVAdvectedInterpolationMethod(
35 getParam<InterpolationMethodName>("advected_interp_method_name")))
36
37{
40}
41
42void
44{
47
48 // Only internal faces need advected interpolation results; boundary contributions are handled
49 // through the linear FV boundary conditions.
51 return;
52
53 const auto state = determineState();
54 const auto & elem_info = *_current_face_info->elemInfo();
55 const auto & neighbor_info = *_current_face_info->neighborInfo();
56
57 const Real elem_value = _var.getElemValue(elem_info, state);
58 const Real neighbor_value = _var.getElemValue(neighbor_info, state);
60 {
61 const auto limiter_type = _adv_interp_method.gradientLimiter();
62 _elem_grad_storage = _var.gradSln(elem_info, state, limiter_type);
63 _neighbor_grad_storage = _var.gradSln(neighbor_info, state, limiter_type);
64 }
65
67 elem_value,
68 neighbor_value,
72}
73
74void
76{
77 for (const auto bc : _var.getBoundaryConditionMap())
78 if (!dynamic_cast<const LinearFVAdvectionDiffusionBC *>(bc.second))
80 bc.second->type(), " is not a compatible boundary condition with ", this->type(), "!");
81}
82
83Real
89
90Real
96
97Real
102
103Real
108
109Real
111{
112 const auto * const adv_bc = static_cast<const LinearFVAdvectionDiffusionBC *>(&bc);
113 mooseAssert(adv_bc, "This should be a valid BC!");
114
115 const auto boundary_value_matrix_contrib = adv_bc->computeBoundaryValueMatrixContribution();
116
117 // We support internal boundaries too so we have to make sure the normal points always outward
118 const auto factor = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM) ? 1.0 : -1.0;
119
120 return boundary_value_matrix_contrib * factor * _adv_face_flux * _current_face_area;
121}
122
123Real
125{
126 const auto * const adv_bc = static_cast<const LinearFVAdvectionDiffusionBC *>(&bc);
127 mooseAssert(adv_bc, "This should be a valid BC!");
128
129 // We support internal boundaries too so we have to make sure the normal points always outward
130 const auto factor = (_current_face_type == FaceInfo::VarFaceNeighbors::ELEM ? 1.0 : -1.0);
131
132 const auto boundary_value_rhs_contrib = adv_bc->computeBoundaryValueRHSContribution();
133 return -boundary_value_rhs_contrib * factor * _adv_face_flux * _current_face_area;
134}
registerMooseObject("MooseApp", LinearFVAdvection)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
virtual Moose::FV::GradientLimiterType gradientLimiter() const
Limiter used by interpolations that require limited gradients.
virtual AdvectedSystemContribution advectedInterpolate(const FaceInfo &face, Real elem_value, Real neighbor_value, const VectorValue< Real > *elem_grad, const VectorValue< Real > *neighbor_grad, Real mass_flux) const =0
Compute the matrix weights for the advected face value.
virtual bool needsGradients() const
Whether advected interpolation requires adjacent-cell gradients.
Helper interface for objects that need access to FVInterpolationMethod instances.
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition FaceInfo.h:38
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 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.
Base class for boundary conditions that are valid for advection diffusion problems.
Kernel that adds contributions from an advection term discretized using the finite volume method to a...
VectorValue< Real > _neighbor_grad_storage
virtual Real computeBoundaryRHSContribution(const LinearFVBoundaryCondition &bc) override
Computes the right hand side contribution from a boundary face.
virtual Real computeElemMatrixContribution() override
Computes the system matrix contribution from an element side on an internal face.
VectorValue< Real > _elem_grad_storage
Reusable gradient storage used when advected interpolation requires gradients.
virtual Real computeElemRightHandSideContribution() override
Computes the right hand side contribution from the element side on an internal face.
virtual Real computeNeighborMatrixContribution() override
Computes the system matrix contribution from the neighbor side on an internal face.
const RealVectorValue _velocity
Constant advecting velocity vector.
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
FVAdvectedInterpolationMethod::AdvectedSystemContribution _adv_interp_result
Cached weights/correction for the current face (refreshed in setupFaceData)
virtual Real computeNeighborRightHandSideContribution() override
Computes the right hand side contribution from the neighbor side on an internal face.
virtual void setupFaceData(const FaceInfo *face_info) override
Set the current FaceInfo object.
static InputParameters validParams()
LinearFVAdvection(const InputParameters &params)
Class constructor.
virtual Real computeBoundaryMatrixContribution(const LinearFVBoundaryCondition &bc) override
Computes the matrix contribution from a boundary face.
const FVAdvectedInterpolationMethod & _adv_interp_method
The interpolation method to use for the advected quantity.
Base class for boundary conditions for linear FV systems.
Finite volume kernel that contributes approximations of discretized face flux terms to the matrix and...
FaceInfo::VarFaceNeighbors _current_face_type
Face ownership information for the current face.
virtual void setupFaceData(const FaceInfo *face_info)
Set the current FaceInfo object.
Real _current_face_area
The current, coordinate system specific face area.
const FaceInfo * _current_face_info
Pointer to the face info we are operating on right now.
static InputParameters validParams()
MooseLinearVariableFV< Real > & _var
Reference to the linear finite volume variable.
const std::string & type() const
Get the type of this class.
Definition MooseBase.h:93
void computeCellGradients()
Switch to request cell gradient computations.
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 std::unordered_map< BoundaryID, LinearFVBoundaryCondition * > & getBoundaryConditionMap() const
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.