https://mooseframework.inl.gov
Loading...
Searching...
No Matches
INSFVAdvectionKernel.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#include "NS.h"
12#include "MooseVariableFV.h"
13#include "RelationshipManager.h"
14#include "NSFVUtils.h"
16#include "Limiter.h"
17#include "Steady.h"
18
21{
24 params.addRequiredParam<UserObjectName>("rhie_chow_user_object", "The rhie-chow user-object");
25 // We need 2 ghost layers for the Rhie-Chow interpolation
26 params.set<unsigned short>("ghost_layers") = 2;
27
28 // We currently do not have a need for this, boundary conditions tell us where to execute
29 // advection kernels
30 params.suppressParameter<bool>("force_boundary_execution");
31
32 // We add the relationship manager here, this will select the right number of
33 // ghosting layers depending on the chosen interpolation method
35 "ElementSideNeighborLayers",
36 Moose::RelationshipManagerType::GEOMETRIC | Moose::RelationshipManagerType::ALGEBRAIC |
37 Moose::RelationshipManagerType::COUPLING,
38 [](const InputParameters & obj_params, InputParameters & rm_params)
39 { FVRelationshipManagerInterface::setRMParamsAdvection(obj_params, rm_params, 3); });
40
41 return params;
42}
43
45 : FVFluxKernel(params),
46 _rc_vel_provider(getUserObject<RhieChowInterpolatorBase>("rhie_chow_user_object"))
47{
48 const bool need_more_ghosting =
50 if (need_more_ghosting && _tid == 0)
51 {
52 // If we need more ghosting, then we are a second-order nonlinear limiting scheme whose stencil
53 // is liable to change upon wind-direction change. Consequently we need to tell our problem that
54 // it's ok to have new nonzeros which may crop-up after PETSc has shrunk the matrix memory
55 getCheckedPointerParam<FEProblemBase *>("_fe_problem_base")
56 ->setErrorOnJacobianNonzeroReallocation(false);
57 }
58
59 auto param_check = [&params, this](const auto & param_name)
60 {
61 if (params.isParamSetByUser(param_name))
63 param_name, "This parameter is not honored by INSFVAdvectionKernels like '", name(), "'");
64 };
65
66 param_check("force_boundary_execution");
67
69 !(_advected_interp_method == Moose::FV::InterpMethod::Upwind ||
70 _advected_interp_method == Moose::FV::InterpMethod::Average ||
71 _advected_interp_method == Moose::FV::InterpMethod::HarmonicAverage ||
72 _advected_interp_method == Moose::FV::InterpMethod::SkewCorrectedAverage))
74 "Second order upwind limiting is not supported when `two_term_boundary_expansion "
75 "= true` for the limited variable. Use at your own risk or please consider "
76 "setting `two_term_boundary_expansion = false` in the advected variable parameters or "
77 "changing your "
78 "'advected_interp_method' of the kernel to first order methods (`upwind`, `average`)");
79
80 if (dynamic_cast<Steady *>(_app.getExecutioner()))
81 {
82 const MooseEnum not_available_with_steady("sou min_mod vanLeer quick venkatakrishnan");
83 const std::string chosen_scheme =
84 static_cast<std::string>(getParam<MooseEnum>("advected_interp_method"));
85 if (not_available_with_steady.find(chosen_scheme) != not_available_with_steady.items().end())
86 paramError("advected_interp_method",
87 "The given advected interpolation cannot be used with steady-state runs!");
88 }
89}
90
91void
96
97bool
99{
100 // Boundaries to avoid come first, since they are always obeyed
101 if (avoidBoundary(fi))
102 return true;
103
104 // We get this to check if we are on a kernel boundary or not
105 const bool on_boundary = onBoundary(fi);
106
107 // We are either on a kernel boundary or on an internal sideset
108 // which is handled as a boundary
109 if (on_boundary || !fi.boundaryIDs().empty())
110 {
111 // Selected boundaries to force
112 for (const auto bnd_to_force : _boundaries_to_force)
113 if (fi.boundaryIDs().count(bnd_to_force))
114 return false;
115
116 // If we have flux bcs then we do skip
117 const auto & [have_flux_bcs, flux_bcs] = _var.getFluxBCs(fi);
118 libmesh_ignore(have_flux_bcs);
119 for (const auto * const flux_bc : flux_bcs)
120 // If we have something like an average-value pressure constraint on a flow boundary, then we
121 // still want to execute this advection kernel on the boundary to ensure we're enforcing local
122 // conservation (mass in this example)
123 if (!dynamic_cast<const FVBoundaryScalarLagrangeMultiplierConstraint *>(flux_bc))
124 return true;
125
126 // If we have a flow boundary without a replacement flux BC, then we must not skip. Mass and
127 // momentum are transported via advection across boundaries
128 for (const auto bc_id : fi.boundaryIDs())
129 if (_flow_boundaries.find(bc_id) != _flow_boundaries.end())
130 return false;
131 }
132
133 // If not a flow boundary, then there should be no advection/flow in the normal direction, e.g. we
134 // should not contribute any advective flux. If we are on an internal face though, we still
135 // execute.
136 return on_boundary;
137}
static InputParameters validParams()
bool onBoundary(const FaceInfo &fi) const
MooseVariableFV< Real > & _var
bool avoidBoundary(const FaceInfo &fi) const
std::unordered_set< BoundaryID > _boundaries_to_force
static void setRMParamsAdvection(const InputParameters &obj_params, InputParameters &rm_params, const unsigned short conditional_extended_layers)
const std::set< BoundaryID > & boundaryIDs() const
bool skipForBoundary(const FaceInfo &fi) const override
INSFVAdvectionKernel(const InputParameters &params)
Moose::FV::InterpMethod _velocity_interp_method
The interpolation method to use for the velocity.
Moose::FV::InterpMethod _advected_interp_method
The interpolation method to use for the advected quantity.
static InputParameters validParams()
std::set< BoundaryID > _flow_boundaries
Flow Boundary IDs.
void initialSetup(T &insfv_fk)
setup all the boundary condition member information
void suppressParameter(const std::string &name)
bool isParamSetByUser(const std::string &name) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addRelationshipManager(const std::string &name, Moose::RelationshipManagerType rm_type, Moose::RelationshipManagerInputParameterCallback input_parameter_callback=nullptr)
T & set(const std::string &name, bool quiet_mode=false)
Executioner * getExecutioner() const
const std::string & name() const
void paramError(const std::string &param, Args... args) const
void mooseWarning(Args &&... args) const
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
const std::set< MooseEnumItem > & items() const
MooseApp & _app
const bool & getTwoTermBoundaryExpansion() const
std::pair< bool, std::vector< const FVFluxBC * > > getFluxBCs(const FaceInfo &fi) const
THREAD_ID _tid
bool setInterpolationMethods(const MooseObject &obj, Moose::FV::InterpMethod &advected_interp_method, Moose::FV::InterpMethod &velocity_interp_method)
Sets the advection and velocity interpolation methods.
Definition NSFVUtils.C:25
InputParameters interpolationParameters()
Definition NSFVUtils.C:44