https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
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
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
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}
DualNumber< Real, DNDerivativeType, true > ADReal
registerADMooseObject("MooseApp", FVAdvection)
static InputParameters validParams()
Definition FVAdvection.C:17
virtual ADReal computeQpResidual() override
This is the primary function that must be implemented for flux kernel terms.
Definition FVAdvection.C:61
FVAdvection(const InputParameters &params)
Definition FVAdvection.C:37
Moose::FV::InterpMethod _advected_interp_method
The interpolation method to use for the advected quantity.
Definition FVAdvection.h:26
const RealVectorValue _velocity
Definition FVAdvection.h:23
FVFluxKernel is used for calculating residual contributions from numerical fluxes from surface integr...
static InputParameters validParams()
RealVectorValue _normal
This is the outward unit normal vector for the face the kernel is currently operating on.
MooseVariableFV< Real > & _var
const FaceInfo * _face_info
This is holds meta-data for geometric information relevant to the current face including elem+neighbo...
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.
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.
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 addRelationshipManager(const std::string &name, Moose::RelationshipManagerType rm_type, Moose::RelationshipManagerInputParameterCallback input_parameter_callback=nullptr)
Tells MOOSE about a RelationshipManager that this object needs.
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.
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition MooseApp.C:2015
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 ...
Definition MooseBase.h:457
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.
const std::set< MooseEnumItem > & items() const
Return the complete set of available flags.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
THREAD_ID _tid
The thread ID for this kernel.
SubProblem & _subproblem
Reference to this kernel's SubProblem.
Steady executioners usually only call "solve()" on the NonlinearSystem once.
Definition Steady.h:18
virtual bool isTransient() const =0
Moose::StateArg determineState() const
Create a functor state argument that corresponds to the implicit state of this object.
LimiterType limiterType(InterpMethod interp_method)
Return the limiter type associated with the supplied interpolation method.
Definition Limiter.C:63
bool setInterpolationMethod(const MooseObject &obj, Moose::FV::InterpMethod &interp_method, const std::string &param_name)
Sets one interpolation method.
InputParameters advectedInterpolationParameter()
Definition MathFVUtils.C:68
State argument for evaluating functors.