https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
16
17#include <unordered_map>
18#include <set>
19#include <unordered_set>
20
21class MooseMesh;
24namespace libMesh
25{
26class Elem;
27class MeshBase;
28}
29
39{
40public:
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
116protected:
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
163private:
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
220inline void
221INSFVRhieChowInterpolator::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
233inline bool
235{
236 // We dont check for "a"s being in another nonlinear system here, only being auxiliary
237 return !_a_data_provided && _velocity_interp_method == Moose::FV::InterpMethod::RhieChow;
238}
239
240inline bool
242{
243 const auto * const u = _us[tid];
244 return (u->faceInterpolationMethod() == Moose::FV::InterpMethod::SkewCorrectedAverage);
245}
246
247inline bool
249{
250 const auto * const p = _ps[tid];
251 return (p->faceInterpolationMethod() == Moose::FV::InterpMethod::SkewCorrectedAverage);
252}
DualNumber< Real, DNDerivativeType, true > ADReal
boundary_id_type BoundaryID
const Real p
unsigned int THREAD_ID
A functor whose evaluation relies on querying a map where the keys are element ids and the values cor...
This user-object gathers 'a' (on-diagonal velocity coefficients) data.
std::vector< std::unique_ptr< PiecewiseByBlockLambdaFunctor< ADRealVectorValue > > > _vel
A functor for computing the (non-RC corrected) velocity.
void pullAllNonlocal()
Whether to pull all 'a' coefficient data from the owning process for all nonlocal elements we have ac...
virtual void ghostADataOnBoundary(const BoundaryID boundary_id) override
makes sure coefficient data gets communicated on both sides of a given boundary
bool pressureSkewCorrection(THREAD_ID tid) const
Whether central differencing face interpolations of pressure should include a skewness correction.
virtual void initialSetup() override
std::unordered_set< const Elem * > _elements_to_push_pull
Non-local elements that we should push and pull data for across processes.
std::vector< std::unique_ptr< Moose::VectorCompositeFunctor< ADReal > > > _disps
A functor for computing the displacement.
Moose::VectorComponentFunctor< ADReal > _ax
std::vector< MooseVariableField< Real > * > _disp_zs
All the thread copies of the z-displacement variable.
std::vector< MooseVariableField< Real > * > _disp_ys
All the thread copies of the y-displacement variable.
std::unique_ptr< ConstElemRange > _elem_range
All the active and elements local to this process that exist on this object's subdomains.
std::vector< MooseVariableField< Real > * > _disp_xs
All the thread copies of the x-displacement variable.
static InputParameters validParams()
const MooseEnum _volume_force_correction_method
– Method used for computing the properties average
const bool & _bool_correct_vf
Correct Rhie-Chow coefficients for volumetric force flag.
const unsigned int _momentum_sys_number
The number of the nonlinear system in which the monolithic momentum and continuity equations are loca...
bool velocitySkewCorrection(THREAD_ID tid) const
Whether central differencing face interpolations of velocity should include a skewness correction Als...
bool _a_data_provided
Whether 'a' data has been provided by the user.
Moose::VectorComponentFunctor< ADReal > _ay
The y-component of 'a'.
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 'a' component funct...
static InputParameters uniqueParams()
Parameters of this object that should be added to the NSFV action that are unique to this object.
Moose::VectorComponentFunctor< ADReal > _az
The z-component of 'a'.
bool needAComputation() const
Whether we need 'a' coefficient computation.
std::vector< const Moose::Functor< Real > * > _volumetric_force
Values of the functors storing the volumetric forces.
virtual void meshChanged() override
const std::vector< MooseFunctorName > * _volumetric_force_functors
Names of the functors storing the volumetric forces.
std::vector< const Moose::FunctorBase< VectorValue< ADReal > > * > _a_read
A vector sized according to the number of threads that holds the 'a' data we will read from when comp...
virtual bool segregated() const override
Bool of the Rhie Chow user object is used in monolithic/segregated approaches.
Threads::spin_mutex _a_mutex
Mutex that prevents multiple threads from saving into the 'a' coefficients at the same time.
CellCenteredMapFunctor< ADRealVectorValue, std::unordered_map< dof_id_type, ADRealVectorValue > > _a
A map from element IDs to 'a' coefficient data.
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.
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.
Real _baseline_volume_force
Minimum absolute RC force over the domain.
const VectorValue< ADReal > _example
An example datum used to help communicate AD vector information in parallel.
void insfvSetup()
perform the setup of this object
bool _pull_all_nonlocal
Whether we want to pull all nonlocal 'a' coefficient data.
void fillARead()
Fills the _a_read data member at construction time with the appropriate functors.
static std::vector< std::string > listOfCommonParams()
const Moose::ConstantFunctor< ADReal > _zero_functor
A zero functor potentially used in _a_read.
Moose::FV::InterpMethod _velocity_interp_method
The interpolation method to use for the velocity.
std::vector< MooseVariableFVReal * > _us
All the thread copies of the x-velocity variable.
std::vector< MooseVariableFVReal * > _ps
All the thread copies of the pressure variable.
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...