https://mooseframework.inl.gov
Loading...
Searching...
No Matches
RhieChowInterpolatorBase.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 "INSFVAttributes.h"
14#include "SubProblem.h"
15#include "MooseMesh.h"
16#include "SystemBase.h"
17#include "NS.h"
18#include "Assembly.h"
23#include "FVElementalKernel.h"
24
27{
31
32 params.addClassDescription(
33 "Computes the Rhie-Chow velocity based on gathered 'a' coefficient data.");
34
35 // Avoid uninitialized residual objects
36 params.suppressParameter<bool>("force_preic");
37
38 params.addRequiredParam<VariableName>(NS::pressure, "The pressure variable.");
39 params.addRequiredParam<VariableName>("u", "The x-component of velocity");
40 params.addParam<VariableName>("v", "The y-component of velocity");
41 params.addParam<VariableName>("w", "The z-component of velocity");
42
43 MooseEnum velocity_interp_method("average rc", "rc");
44 params.addParam<MooseEnum>(
45 "velocity_interp_method",
46 velocity_interp_method,
47 "The interpolation to use for the velocity. Options are "
48 "'average' and 'rc' which stands for Rhie-Chow. The default is Rhie-Chow.");
49
50 return params;
51}
52
55 TaggingInterface(this),
57 _moose_mesh(UserObject::_subproblem.mesh()),
58 _mesh(_moose_mesh.getMesh()),
59 _dim(blocksMaxDimension()),
60 _p(dynamic_cast<INSFVPressureVariable *>(
61 &UserObject::_subproblem.getVariable(0, getParam<VariableName>(NS::pressure)))),
62 _u(dynamic_cast<INSFVVelocityVariable *>(
63 &UserObject::_subproblem.getVariable(0, getParam<VariableName>("u")))),
64 _v(isParamValid("v") ? dynamic_cast<INSFVVelocityVariable *>(
65 &UserObject::_subproblem.getVariable(0, getParam<VariableName>("v")))
66 : nullptr),
67 _w(isParamValid("w") ? dynamic_cast<INSFVVelocityVariable *>(
68 &UserObject::_subproblem.getVariable(0, getParam<VariableName>("w")))
69 : nullptr),
70 _ps(libMesh::n_threads(), nullptr),
71 _us(libMesh::n_threads(), nullptr),
72 _vs(libMesh::n_threads(), nullptr),
73 _ws(libMesh::n_threads(), nullptr),
74 _displaced(dynamic_cast<DisplacedProblem *>(&(UserObject::_subproblem)))
75{
76 if (!_p)
77 paramError(NS::pressure, "the pressure must be a INSFVPressureVariable.");
79
80 if (!_u)
81 paramError("u", "the u velocity must be an INSFVVelocityVariable.");
83 _var_numbers.push_back(_u->number());
84
85 if (_dim >= 2)
86 {
87 if (!_v)
88 mooseError("In two or more dimensions, the v velocity must be supplied and it must be an "
89 "INSFVVelocityVariable.");
91 _var_numbers.push_back(_v->number());
92 }
93
94 if (_dim >= 3)
95 {
96 if (!_w)
97 mooseError("In three-dimensions, the w velocity must be supplied and it must be an "
98 "INSFVVelocityVariable.");
100 _var_numbers.push_back(_w->number());
101 }
102
104 fillContainer("u", _us);
105
106 if (_dim >= 2)
107 {
108 fillContainer("v", _vs);
110 mooseError("x and y velocity component face interpolation methods do not match");
111
112 if (_dim >= 3)
113 {
114 fillContainer("w", _ws);
116 mooseError("x and z velocity component face interpolation methods do not match");
117 }
118 }
119
121 mooseError("Different subproblems in RhieChowInterpolatorBase!");
122
123 const auto & velocity_interp_method = params.get<MooseEnum>("velocity_interp_method");
124 if (velocity_interp_method == "average")
125 _velocity_interp_method = Moose::FV::InterpMethod::Average;
126 else if (velocity_interp_method == "rc")
127 _velocity_interp_method = Moose::FV::InterpMethod::RhieChow;
128}
129
130Real
132 const FaceInfo & fi,
133 const Moose::StateArg & time,
134 const THREAD_ID tid,
135 bool subtract_mesh_velocity) const
136{
137 return raw_value(this->getVelocity(m, fi, time, tid, subtract_mesh_velocity)) * fi.normal();
138}
unsigned int THREAD_ID
static InputParameters validParams()
const Point & normal() const
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
unsigned int number() const
Moose::FV::InterpMethod faceInterpolationMethod() const
static InputParameters validParams()
INSFVPressureVariable *const _p
The thread 0 copy of the pressure variable.
Moose::FV::InterpMethod _velocity_interp_method
The interpolation method to use for the velocity.
INSFVVelocityVariable *const _w
The thread 0 copy of the z-velocity variable (null if the problem is not 3D)
std::vector< MooseVariableFVReal * > _ws
All the thread copies of the z-velocity variable.
void fillContainer(const std::string &var_name, Container &container)
Fill the passed-in variable container with the thread copies of var_name.
RhieChowInterpolatorBase(const InputParameters &params)
std::vector< unsigned int > _var_numbers
The velocity variable numbers.
std::vector< MooseVariableFVReal * > _vs
All the thread copies of the y-velocity variable.
virtual Real getVolumetricFaceFlux(const Moose::FV::InterpMethod m, const FaceInfo &fi, const Moose::StateArg &time, const THREAD_ID tid, bool subtract_mesh_velocity) const override
Retrieve the volumetric face flux, will not include derivatives.
static InputParameters validParams()
void checkBlocks(const VarType &var) const
Check the block consistency between the passed in var and us.
INSFVVelocityVariable *const _v
The thread 0 copy of the y-velocity variable (null if the problem is 1D)
virtual VectorValue< ADReal > getVelocity(const Moose::FV::InterpMethod m, const FaceInfo &fi, const Moose::StateArg &time, const THREAD_ID tid, bool subtract_mesh_velocity) const =0
Retrieve a face velocity.
std::vector< MooseVariableFVReal * > _us
All the thread copies of the x-velocity variable.
INSFVVelocityVariable *const _u
The thread 0 copy of the x-velocity variable.
const unsigned int _dim
The dimension of the mesh, e.g. 3 for hexes and tets, 2 for quads and tris.
std::vector< MooseVariableFVReal * > _ps
All the thread copies of the pressure variable.
SubProblem & _subproblem
static InputParameters validParams()
SubProblem & _subproblem
MeshBase & mesh
static const std::string pressure
Definition NS.h:57
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...