Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
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 
13 namespace Moose
14 {
15 namespace FV
16 {
17 ADReal
18 gradUDotNormal(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 
27 bool
28 onBoundary(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 
81 selectInterpolationMethod(const std::string & interp_method)
82 {
83  if (interp_method == "average")
84  return InterpMethod::Average;
85  else if (interp_method == "harmonic")
87  else if (interp_method == "skewness-corrected")
89  else if (interp_method == "upwind")
90  return InterpMethod::Upwind;
91  else if (interp_method == "rc")
93  else if (interp_method == "vanLeer")
94  return InterpMethod::VanLeer;
95  else if (interp_method == "min_mod")
96  return InterpMethod::MinMod;
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 
109 bool
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 }
gc*elem+(1-gc)*neighbor
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
const Elem & elem() const
Definition: FaceInfo.h:81
1/(gc/elem+(1-gc)/neighbor)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:47
MooseEnum interpolationMethods()
Returns an enum with all the currently supported interpolation methods and the current default for FV...
Definition: MathFVUtils.C:61
InputParameters emptyInputParameters()
This data structure is used to store geometric and variable related metadata about each cell face in ...
Definition: FaceInfo.h:36
const Elem * neighborPtr() const
Definition: FaceInfo.h:84
InputParameters advectedInterpolationParameter()
Definition: MathFVUtils.C:68
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:28
const Elem & neighbor() const
Definition: FaceInfo.h:216
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
const Point & normal() const
Returns the unit normal vector for the face oriented outward from the face&#39;s elem element...
Definition: FaceInfo.h:68
bool onBoundary(const SubdomainRestrictable &obj, const FaceInfo &fi)
Return whether the supplied face is on a boundary of the object&#39;s execution.
Definition: MathFVUtils.h:1169
(gc*elem+(1-gc)*neighbor)+gradient*(rf-rf&#39;)
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 selectInterpolationMethod(const std::string &interp_method)
Definition: MathFVUtils.C:81
State argument for evaluating functors.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
InterpMethod
This codifies a set of available ways to interpolate with elem+neighbor solution information to calcu...
Definition: MathFVUtils.h:35
bool setInterpolationMethod(const MooseObject &obj, Moose::FV::InterpMethod &interp_method, const std::string &param_name)
Sets one interpolation method.
Definition: MathFVUtils.C:110
const ADTemplateVariableGradient< OutputType > & adGradSln() const override
AD grad solution getter.