https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NSFVUtils.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 "NSFVUtils.h"
11#include "FEProblemBase.h"
12#include "Factory.h"
13#include "MooseObject.h"
14#include "InputParameters.h"
15#include "MooseEnum.h"
16#include "MooseError.h"
17#include "MooseTypes.h"
18#include "MooseUtils.h"
19
20namespace Moose
21{
22namespace FV
23{
24bool
26 Moose::FV::InterpMethod & advected_interp_method,
27 Moose::FV::InterpMethod & velocity_interp_method)
28{
29 const bool need_more_ghosting =
30 setInterpolationMethod(obj, advected_interp_method, "advected_interp_method");
31
32 const auto & velocity_interp_method_in = obj.getParam<MooseEnum>("velocity_interp_method");
33 if (velocity_interp_method_in == "average")
34 velocity_interp_method = InterpMethod::Average;
35 else if (velocity_interp_method_in == "rc")
36 velocity_interp_method = InterpMethod::RhieChow;
37 else
38 obj.mooseError("Unrecognized interpolation type ", std::string(velocity_interp_method_in));
39
40 return need_more_ghosting;
41}
42
45{
46 auto params = advectedInterpolationParameter();
47 MooseEnum velocity_interp_method("average rc", "rc");
48 params.addParam<MooseEnum>(
49 "velocity_interp_method",
50 velocity_interp_method,
51 "The interpolation to use for the velocity. Options are "
52 "'average' and 'rc' which stands for Rhie-Chow. The default is Rhie-Chow.");
53 return params;
54}
55}
56}
57
58namespace NS
59{
62{
63 return MooseEnum("average upwind vanLeer min_mod venkatakrishnan", "upwind");
64}
65
66std::string
67fvAdvectedInterpolationMethodType(const MooseEnum & interpolation_method)
68{
69 const std::string method_name = interpolation_method;
70 if (interpolation_method == "average")
71 return "FVGeometricAverage";
72 if (interpolation_method == "upwind")
73 return "FVAdvectedUpwind";
74 if (interpolation_method == "vanLeer")
75 return "FVAdvectedVanLeerWeightBased";
76 if (interpolation_method == "min_mod")
77 return "FVAdvectedMinmodWeightBased";
78 if (interpolation_method == "venkatakrishnan")
79 return "FVAdvectedVenkatakrishnanDeferredCorrection";
80
81 mooseError("Unsupported linear FV advected interpolation method '", method_name, "'.");
82}
83
86{
87 return MooseEnum("average harmonic");
88}
89
90std::string
91fvFaceInterpolationMethodType(const MooseEnum & interpolation_method)
92{
93 const std::string method_name = interpolation_method;
94 if (interpolation_method == "average")
95 return "FVGeometricAverage";
96 if (interpolation_method == "harmonic")
97 return "FVHarmonicAverage";
98
99 mooseError("Unsupported linear FV face interpolation method '", method_name, "'.");
100}
101
102void
104 Factory & factory,
105 const MooseEnum & interpolation_method)
106{
107 const std::string method_name = interpolation_method;
108 if (problem.hasFVInterpolationMethod(method_name))
109 return;
110
111 const auto method_type = fvFaceInterpolationMethodType(interpolation_method);
112
113 InputParameters params = factory.getValidParams(method_type);
114 problem.addFVInterpolationMethod(method_type, method_name, params);
115}
116
117template <class T>
118std::tuple<bool, T, T>
120 const FaceInfo & fi,
121 const Moose::StateArg & time)
122{
123 if (!fi.neighborPtr() || (fi.elem().subdomain_id() == fi.neighbor().subdomain_id()))
124 // We've agreed to only support porosity jump treatment at subdomain boundaries
125 return {false, 0, 0};
126
127 mooseAssert(porosity.hasBlocks(fi.elem().subdomain_id()) &&
128 porosity.hasBlocks(fi.neighbor().subdomain_id()),
129 "Porosity should have blocks on both elem and neighbor");
130
131 const Moose::FaceArg face_elem{
132 &fi, Moose::FV::LimiterType::CentralDifference, true, false, fi.elemPtr(), nullptr};
133 const Moose::FaceArg face_neighbor{
134 &fi, Moose::FV::LimiterType::CentralDifference, true, false, fi.neighborPtr(), nullptr};
135 const auto eps_elem = porosity(face_elem, time), eps_neighbor = porosity(face_neighbor, time);
136 return {!MooseUtils::relativeFuzzyEqual(eps_elem, eps_neighbor), eps_elem, eps_neighbor};
137}
138
139template std::tuple<bool, Real, Real> isPorosityJumpFace<Real>(
140 const Moose::FunctorBase<Real> & porosity, const FaceInfo & fi, const Moose::StateArg & time);
141template std::tuple<bool, ADReal, ADReal> isPorosityJumpFace<ADReal>(
142 const Moose::FunctorBase<ADReal> & porosity, const FaceInfo & fi, const Moose::StateArg & time);
143}
void mooseError(Args &&... args)
bool hasFVInterpolationMethod(const InterpolationMethodName &name) const
virtual void addFVInterpolationMethod(const std::string &method_type, const std::string &name, InputParameters &parameters)
const Elem & elem() const
const Elem * neighborPtr() const
const Elem * elemPtr() const
const Elem & neighbor() const
InputParameters getValidParams(const std::string &name) const
void mooseError(Args &&... args) const
const T & getParam(const std::string &name) const
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
bool setInterpolationMethod(const MooseObject &obj, Moose::FV::InterpMethod &interp_method, const std::string &param_name)
InputParameters interpolationParameters()
Definition NSFVUtils.C:44
InputParameters advectedInterpolationParameter()
std::tuple< bool, T, T > isPorosityJumpFace(const Moose::FunctorBase< T > &porosity, const FaceInfo &fi, const Moose::StateArg &time)
Checks to see whether the porosity value jumps from one side to the other of the provided face.
Definition NSFVUtils.C:119
std::string fvFaceInterpolationMethodType(const MooseEnum &interpolation_method)
Gets the FVInterpolationMethod object type for a face interpolation method name.
Definition NSFVUtils.C:91
MooseEnum fvFaceInterpolationMethods()
Enum of the interpolation methods supported by FVInterpolationMethod objects.
Definition NSFVUtils.C:85
std::string fvAdvectedInterpolationMethodType(const MooseEnum &interpolation_method)
Gets the FVInterpolationMethod object type for an advected interpolation method.
Definition NSFVUtils.C:67
template std::tuple< bool, ADReal, ADReal > isPorosityJumpFace< ADReal >(const Moose::FunctorBase< ADReal > &porosity, const FaceInfo &fi, const Moose::StateArg &time)
static const std::string porosity
Definition NS.h:108
template std::tuple< bool, Real, Real > isPorosityJumpFace< Real >(const Moose::FunctorBase< Real > &porosity, const FaceInfo &fi, const Moose::StateArg &time)
void addFVFaceInterpolationMethod(FEProblemBase &problem, Factory &factory, const MooseEnum &interpolation_method)
Add the FVInterpolationMethod object for a face interpolation method name, if absent.
Definition NSFVUtils.C:103
MooseEnum fvAdvectedInterpolationMethods()
Enum of the advected interpolation methods supported by FVInterpolationMethod objects.
Definition NSFVUtils.C:61