https://mooseframework.inl.gov
INSFVRhieChowInterpolator.h
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 #pragma once
11 
13 #include "CellCenteredMapFunctor.h"
14 #include "VectorComponentFunctor.h"
15 #include "VectorCompositeFunctor.h"
16 
17 #include <unordered_map>
18 #include <set>
19 #include <unordered_set>
20 
21 class MooseMesh;
24 namespace libMesh
25 {
26 class Elem;
27 class MeshBase;
28 }
29 
39 {
40 public:
46 
50  static std::vector<std::string> listOfCommonParams();
51 
54 
61  virtual void
62  addToA(const libMesh::Elem * elem, unsigned int component, const ADReal & value) override;
63 
75  virtual VectorValue<ADReal> getVelocity(const Moose::FV::InterpMethod m,
76  const FaceInfo & fi,
77  const Moose::StateArg & time,
78  const THREAD_ID tid,
79  bool subtract_mesh_velocity) const override;
80 
81  virtual void initialSetup() override;
82  virtual void meshChanged() override;
83 
84  virtual void initialize() override;
85  virtual void execute() override;
86  virtual void finalize() override;
87 
88  virtual bool segregated() const override { return false; };
89 
93  virtual void ghostADataOnBoundary(const BoundaryID boundary_id) override;
94 
100 
108  bool velocitySkewCorrection(THREAD_ID tid) const;
109 
114  bool pressureSkewCorrection(THREAD_ID tid) const;
115 
116 protected:
120  void insfvSetup();
121 
123  std::vector<std::unique_ptr<PiecewiseByBlockLambdaFunctor<ADRealVectorValue>>> _vel;
124 
126  std::vector<MooseVariableField<Real> *> _disp_xs;
127 
129  std::vector<MooseVariableField<Real> *> _disp_ys;
130 
132  std::vector<MooseVariableField<Real> *> _disp_zs;
133 
135  std::vector<std::unique_ptr<Moose::VectorCompositeFunctor<ADReal>>> _disps;
136 
138  std::unique_ptr<ConstElemRange> _elem_range;
139 
142 
152 
155 
159 
161  const unsigned int _momentum_sys_number;
162 
163 private:
168  void fillARead();
169 
173  bool needAComputation() const;
174 
176  std::unordered_set<const Elem *> _elements_to_push_pull;
177 
179  const VectorValue<ADReal> _example;
180 
182  Threads::spin_mutex _a_mutex;
183 
186  std::vector<const Moose::FunctorBase<VectorValue<ADReal>> *> _a_read;
187 
191  std::vector<std::unique_ptr<Moose::FunctorBase<VectorValue<ADReal>>>> _a_aux;
192 
197 
200 
202  const bool & _bool_correct_vf;
203 
206 
208  const std::vector<MooseFunctorName> * _volumetric_force_functors;
209 
211  std::vector<const Moose::Functor<Real> *> _volumetric_force;
212 
215 
218 };
219 
220 inline void
221 INSFVRhieChowInterpolator::addToA(const Elem * const elem,
222  const unsigned int component,
223  const ADReal & value)
224 {
225  Threads::spin_mutex::scoped_lock lock(_a_mutex);
226 
227  if (elem->processor_id() != this->processor_id())
228  _elements_to_push_pull.insert(elem);
229 
230  _a[elem->id()](component) += value;
231 }
232 
233 inline bool
235 {
236  // We dont check for "a"s being in another nonlinear system here, only being auxiliary
238 }
239 
240 inline bool
242 {
243  const auto * const u = _us[tid];
244  return (u->faceInterpolationMethod() == Moose::FV::InterpMethod::SkewCorrectedAverage);
245 }
246 
247 inline bool
249 {
250  const auto * const p = _ps[tid];
251  return (p->faceInterpolationMethod() == Moose::FV::InterpMethod::SkewCorrectedAverage);
252 }
virtual void initialize() override
bool needAComputation() const
Whether we need &#39;a&#39; coefficient computation.
std::vector< MooseVariableFVReal * > _ps
All the thread copies of the pressure variable.
std::vector< const Moose::Functor< Real > * > _volumetric_force
Values of the functors storing the volumetric forces.
CellCenteredMapFunctor< ADRealVectorValue, std::unordered_map< dof_id_type, ADRealVectorValue > > _a
A map from element IDs to &#39;a&#39; coefficient data.
virtual bool segregated() const override
Bool of the Rhie Chow user object is used in monolithic/segregated approaches.
virtual void ghostADataOnBoundary(const BoundaryID boundary_id) override
makes sure coefficient data gets communicated on both sides of a given boundary
static const std::string component
Definition: NS.h:153
std::vector< MooseVariableField< Real > * > _disp_xs
All the thread copies of the x-displacement variable.
std::vector< MooseVariableField< Real > * > _disp_ys
All the thread copies of the y-displacement variable.
const Moose::ConstantFunctor< ADReal > _zero_functor
A zero functor potentially used in _a_read.
bool _pull_all_nonlocal
Whether we want to pull all nonlocal &#39;a&#39; coefficient data.
Moose::VectorComponentFunctor< ADReal > _az
The z-component of &#39;a&#39;.
const std::vector< MooseFunctorName > * _volumetric_force_functors
Names of the functors storing the volumetric forces.
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
DualNumber< Real, DNDerivativeType, true > ADReal
std::vector< MooseVariableFVReal * > _us
All the thread copies of the x-velocity variable.
bool pressureSkewCorrection(THREAD_ID tid) const
Whether central differencing face interpolations of pressure should include a skewness correction...
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 override
Retrieve a face velocity.
static InputParameters uniqueParams()
Parameters of this object that should be added to the NSFV action that are unique to this object...
virtual void addToA(const libMesh::Elem *elem, unsigned int component, const ADReal &value) override
API that momentum residual objects that have on-diagonals for velocity call.
Moose::VectorComponentFunctor< ADReal > _ay
The y-component of &#39;a&#39;.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
static InputParameters validParams()
boundary_id_type BoundaryID
void insfvSetup()
perform the setup of this object
std::unordered_set< const Elem * > _elements_to_push_pull
Non-local elements that we should push and pull data for across processes.
void fillARead()
Fills the _a_read data member at construction time with the appropriate functors. ...
Moose::FV::InterpMethod _velocity_interp_method
The interpolation method to use for the velocity.
const MooseEnum _volume_force_correction_method
– Method used for computing the properties average
static std::vector< std::string > listOfCommonParams()
std::vector< const Moose::FunctorBase< VectorValue< ADReal > > * > _a_read
A vector sized according to the number of threads that holds the &#39;a&#39; data we will read from when comp...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void meshChanged() override
Threads::spin_mutex _a_mutex
Mutex that prevents multiple threads from saving into the &#39;a&#39; coefficients at the same time...
const VectorValue< ADReal > _example
An example datum used to help communicate AD vector information in parallel.
Real _baseline_volume_force
Minimum absolute RC force over the domain.
std::unique_ptr< ConstElemRange > _elem_range
All the active and elements local to this process that exist on this object&#39;s subdomains.
std::vector< std::unique_ptr< Moose::VectorCompositeFunctor< ADReal > > > _disps
A functor for computing the displacement.
std::vector< MooseVariableField< Real > * > _disp_zs
All the thread copies of the z-displacement variable.
const bool & _bool_correct_vf
Correct Rhie-Chow coefficients for volumetric force flag.
virtual void initialSetup() override
This user-object gathers &#39;a&#39; (on-diagonal velocity coefficients) data.
Moose::VectorComponentFunctor< ADReal > _ax
bool _a_data_provided
Whether &#39;a&#39; data has been provided by the user.
bool velocitySkewCorrection(THREAD_ID tid) const
Whether central differencing face interpolations of velocity should include a skewness correction Als...
virtual void finalize() override
void pullAllNonlocal()
Whether to pull all &#39;a&#39; coefficient data from the owning process for all nonlocal elements we have ac...
processor_id_type processor_id() const
INSFVRhieChowInterpolator(const InputParameters &params)
std::vector< std::unique_ptr< Moose::FunctorBase< VectorValue< ADReal > > > > _a_aux
A vector sized according to the number of threads that holds vector composites of &#39;a&#39; component funct...
std::vector< std::unique_ptr< PiecewiseByBlockLambdaFunctor< ADRealVectorValue > > > _vel
A functor for computing the (non-RC corrected) velocity.
unsigned int THREAD_ID
const unsigned int _momentum_sys_number
The number of the nonlinear system in which the monolithic momentum and continuity equations are loca...
A functor whose evaluation relies on querying a map where the keys are element ids and the values cor...