https://mooseframework.inl.gov
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 "MooseObject.h"
12 #include "InputParameters.h"
13 #include "MooseEnum.h"
14 #include "MooseUtils.h"
15 
16 namespace Moose
17 {
18 namespace FV
19 {
20 bool
22  Moose::FV::InterpMethod & advected_interp_method,
23  Moose::FV::InterpMethod & velocity_interp_method)
24 {
25  const bool need_more_ghosting =
26  setInterpolationMethod(obj, advected_interp_method, "advected_interp_method");
27 
28  const auto & velocity_interp_method_in = obj.getParam<MooseEnum>("velocity_interp_method");
29  if (velocity_interp_method_in == "average")
30  velocity_interp_method = InterpMethod::Average;
31  else if (velocity_interp_method_in == "rc")
32  velocity_interp_method = InterpMethod::RhieChow;
33  else
34  obj.mooseError("Unrecognized interpolation type ",
35  static_cast<std::string>(velocity_interp_method_in));
36 
37  return need_more_ghosting;
38 }
39 
42 {
43  auto params = advectedInterpolationParameter();
44  MooseEnum velocity_interp_method("average rc", "rc");
45  params.addParam<MooseEnum>(
46  "velocity_interp_method",
47  velocity_interp_method,
48  "The interpolation to use for the velocity. Options are "
49  "'average' and 'rc' which stands for Rhie-Chow. The default is Rhie-Chow.");
50  return params;
51 }
52 }
53 }
54 
55 namespace NS
56 {
57 std::tuple<bool, ADReal, ADReal>
59  const FaceInfo & fi,
60  const Moose::StateArg & time)
61 {
62  if (!fi.neighborPtr() || (fi.elem().subdomain_id() == fi.neighbor().subdomain_id()))
63  // We've agreed to only support porosity jump treatment at subdomain boundaries
64  return {false, 0, 0};
65 
66  mooseAssert(porosity.hasBlocks(fi.elem().subdomain_id()) &&
67  porosity.hasBlocks(fi.neighbor().subdomain_id()),
68  "Porosity should have blocks on both elem and neighbor");
69 
70  const Moose::FaceArg face_elem{
71  &fi, Moose::FV::LimiterType::CentralDifference, true, false, fi.elemPtr(), nullptr};
72  const Moose::FaceArg face_neighbor{
73  &fi, Moose::FV::LimiterType::CentralDifference, true, false, fi.neighborPtr(), nullptr};
74  const auto eps_elem = porosity(face_elem, time), eps_neighbor = porosity(face_neighbor, time);
75  return {!MooseUtils::relativeFuzzyEqual(eps_elem, eps_neighbor), eps_elem, eps_neighbor};
76 }
77 }
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:21
InputParameters interpolationParameters()
Definition: NSFVUtils.C:41
const Elem & elem() const
std::tuple< bool, ADReal, ADReal > isPorosityJumpFace(const Moose::Functor< ADReal > &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:58
static const std::string porosity
Definition: NS.h:104
const Elem * neighborPtr() const
InputParameters advectedInterpolationParameter()
const Elem & neighbor() const
const T & getParam(const std::string &name) const
const Elem * elemPtr() const
bool relativeFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
void mooseError(Args &&... args) const
bool setInterpolationMethod(const MooseObject &obj, Moose::FV::InterpMethod &interp_method, const std::string &param_name)