Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
FVAdvection.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 "FVAdvection.h"
11 #include "Steady.h"
12 #include "FEProblemBase.h"
13 
15 
18 {
20  params.addClassDescription(
21  "Residual contribution from advection operator for finite volume method.");
22  params.addRequiredParam<RealVectorValue>("velocity", "Constant advection velocity");
24 
25  // We add the relationship manager here, this will select the right number of
26  // ghosting layers depending on the chosen interpolation method
27  params.addRelationshipManager(
28  "ElementSideNeighborLayers",
31  [](const InputParameters & obj_params, InputParameters & rm_params)
32  { FVRelationshipManagerInterface::setRMParamsAdvection(obj_params, rm_params, 2); });
33 
34  return params;
35 }
36 
38  : FVFluxKernel(params), _velocity(getParam<RealVectorValue>("velocity"))
39 {
40  const bool need_more_ghosting =
41  Moose::FV::setInterpolationMethod(*this, _advected_interp_method, "advected_interp_method");
42  if (need_more_ghosting && _tid == 0)
43  // If we need more ghosting, then we are a second-order nonlinear limiting scheme whose stencil
44  // is liable to change upon wind-direction change. Consequently we need to tell our problem that
45  // it's ok to have new nonzeros which may crop-up after PETSc has shrunk the matrix memory
46  getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")
47  ->setErrorOnJacobianNonzeroReallocation(false);
48 
49  if (dynamic_cast<Steady *>(_app.getExecutioner()))
50  {
51  const MooseEnum not_available_with_steady("sou min_mod vanLeer quick venkatakrishnan");
52  const std::string chosen_scheme =
53  static_cast<std::string>(getParam<MooseEnum>("advected_interp_method"));
54  if (not_available_with_steady.find(chosen_scheme) != not_available_with_steady.items().end())
55  paramError("advected_interp_method",
56  "The given advected interpolation cannot be used with steady-state runs!");
57  }
58 }
59 
60 ADReal
62 {
63  const auto state = determineState();
64  const auto & limiter_time = _subproblem.isTransient()
67 
68  const bool elem_is_upwind = _velocity * _normal >= 0;
69  const auto face = makeFace(*_face_info,
71  elem_is_upwind,
72  false,
73  &limiter_time);
74  ADReal u_interface = _var(face, state);
75 
76  return _normal * _velocity * u_interface;
77 }
const std::set< MooseEnumItem > & items() const
Return the complete set of available flags.
Definition: MooseEnumBase.h:93
virtual ADReal computeQpResidual() override
This is the primary function that must be implemented for flux kernel terms.
Definition: FVAdvection.C:61
const FaceInfo * _face_info
This is holds meta-data for geometric information relevant to the current face including elem+neighbo...
Definition: FVFluxKernel.h:89
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static void setRMParamsAdvection(const InputParameters &obj_params, InputParameters &rm_params, const unsigned short conditional_extended_layers)
Helper function to set the relationship manager parameters for advection-related kernels.
RealVectorValue _normal
This is the outward unit normal vector for the face the kernel is currently operating on...
Definition: FVFluxKernel.h:85
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:47
THREAD_ID _tid
The thread ID for this kernel.
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...
static InputParameters validParams()
Definition: FVFluxKernel.C:22
LimiterType limiterType(InterpMethod interp_method)
Return the limiter type associated with the supplied interpolation method.
Definition: Limiter.C:63
InputParameters advectedInterpolationParameter()
Definition: MathFVUtils.C:68
registerADMooseObject("MooseApp", FVAdvection)
SubProblem & _subproblem
Reference to this kernel&#39;s SubProblem.
virtual bool isTransient() const =0
static InputParameters validParams()
Definition: FVAdvection.C:17
const RealVectorValue _velocity
Definition: FVAdvection.h:23
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
Moose::FV::InterpMethod _advected_interp_method
The interpolation method to use for the advected quantity.
Definition: FVAdvection.h:26
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:84
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition: MooseApp.C:2047
FVAdvection(const InputParameters &params)
Definition: FVAdvection.C:37
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...
State argument for evaluating functors.
MooseVariableFV< Real > & _var
Definition: FVFluxKernel.h:73
FVFluxKernel is used for calculating residual contributions from numerical fluxes from surface integr...
Definition: FVFluxKernel.h:30
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.
bool setInterpolationMethod(const MooseObject &obj, Moose::FV::InterpMethod &interp_method, const std::string &param_name)
Sets one interpolation method.
Definition: MathFVUtils.C:110
Moose::FaceArg makeFace(const FaceInfo &fi, const Moose::FV::LimiterType limiter_type, const bool elem_is_upwind, const bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
Create a functor face argument from provided component arguments.