https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MathFVUtils.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 "MathFVUtils.h"
11#include "MooseVariableFV.h"
12
13namespace Moose
14{
15namespace FV
16{
18gradUDotNormal(const FaceInfo & face_info,
19 const MooseVariableFV<Real> & fv_var,
20 const Moose::StateArg & time,
21 bool correct_skewness)
22
23{
24 return fv_var.adGradSln(face_info, time, correct_skewness) * face_info.normal();
25}
26
27bool
28onBoundary(const std::set<SubdomainID> & subs, const FaceInfo & fi)
29{
30 if (!fi.neighborPtr())
31 // We're on the exterior boundary
32 return true;
33
34 if (subs.empty())
35 // The face is internal and our functor lives on all subdomains
36 return false;
37
38 const auto sub_count =
39 subs.count(fi.elem().subdomain_id()) + subs.count(fi.neighbor().subdomain_id());
40
41 switch (sub_count)
42 {
43 case 0:
44 mooseError("We should not be calling isExtrapolatedBoundaryFace on a functor that doesn't "
45 "live on either of the face information's neighboring elements");
46
47 case 1:
48 // We only live on one of the subs
49 return true;
50
51 case 2:
52 // We live on both of the subs
53 return false;
54
55 default:
56 mooseError("There should be no other sub_count options");
57 }
58}
59
62{
63 return MooseEnum("average upwind sou min_mod vanLeer quick venkatakrishnan skewness-corrected",
64 "upwind");
65}
66
69{
70 auto params = emptyInputParameters();
71 params.addParam<MooseEnum>("advected_interp_method",
73 "The interpolation to use for the advected quantity. Options are "
74 "'upwind', 'average', 'sou' (for second-order upwind), 'min_mod', "
75 "'vanLeer', 'quick', 'venkatakrishnan', and "
76 "'skewness-corrected' with the default being 'upwind'.");
77 return params;
78}
79
81selectInterpolationMethod(const std::string & interp_method)
82{
83 if (interp_method == "average")
85 else if (interp_method == "harmonic")
87 else if (interp_method == "skewness-corrected")
89 else if (interp_method == "upwind")
91 else if (interp_method == "rc")
93 else if (interp_method == "vanLeer")
95 else if (interp_method == "min_mod")
97 else if (interp_method == "sou")
98 return InterpMethod::SOU;
99 else if (interp_method == "quick")
100 return InterpMethod::QUICK;
101 else if (interp_method == "venkatakrishnan")
103 else
104 mooseError("Interpolation method ",
105 interp_method,
106 " is not currently an option in Moose::FV::selectInterpolationMethod");
107}
108
109bool
111 Moose::FV::InterpMethod & interp_method,
112 const std::string & param_name)
113{
114 bool need_more_ghosting = false;
115
116 const auto & interp_method_in = obj.getParam<MooseEnum>(param_name);
117 interp_method = selectInterpolationMethod(interp_method_in);
118
119 if (interp_method == InterpMethod::SOU || interp_method == InterpMethod::MinMod ||
120 interp_method == InterpMethod::VanLeer || interp_method == InterpMethod::QUICK ||
121 interp_method == InterpMethod::Venkatakrishnan)
122 need_more_ghosting = true;
123
124 return need_more_ghosting;
125}
126}
127}
DualNumber< Real, DNDerivativeType, true > ADReal
InputParameters emptyInputParameters()
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
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 Elem & elem() const
Definition FaceInfo.h:85
const Elem * neighborPtr() const
Definition FaceInfo.h:88
const Elem & neighbor() const
Definition FaceInfo.h:220
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition MooseBase.h:406
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31
This class provides variable solution values for other classes/objects to bind to when looping over f...
const ADTemplateVariableGradient< OutputType > & adGradSln() const override
AD grad solution getter.
bool setInterpolationMethod(const MooseObject &obj, Moose::FV::InterpMethod &interp_method, const std::string &param_name)
Sets one interpolation method.
ADReal gradUDotNormal(const FaceInfo &face_info, const MooseVariableFV< Real > &fv_var, const Moose::StateArg &time, bool correct_skewness=false)
Calculates and returns "grad_u dot normal" on the face to be used for diffusive terms.
Definition MathFVUtils.C:18
InterpMethod
This codifies a set of available ways to interpolate with elem+neighbor solution information to calcu...
Definition MathFVUtils.h:39
@ SkewCorrectedAverage
(gc*elem+(1-gc)*neighbor)+gradient*(rf-rf')
@ HarmonicAverage
1/(gc/elem+(1-gc)/neighbor)
@ Average
gc*elem+(1-gc)*neighbor
MooseEnum interpolationMethods()
Returns an enum with all the currently supported interpolation methods and the current default for FV...
Definition MathFVUtils.C:61
bool onBoundary(const SubdomainRestrictable &obj, const FaceInfo &fi)
Return whether the supplied face is on a boundary of the object's execution.
InputParameters advectedInterpolationParameter()
Definition MathFVUtils.C:68
InterpMethod selectInterpolationMethod(const std::string &interp_method)
Definition MathFVUtils.C:81
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
State argument for evaluating functors.