16#include <unordered_map>
19#include "libmesh/petsc_vector.h"
53 template <
typename VarType>
66 const std::vector<std::unique_ptr<NumericVector<Number>>> &
HbyAComponents()
const;
69 const std::vector<std::unique_ptr<NumericVector<Number>>> &
AinvComponents()
const;
83 return *
_vel[component];
109 bool subtract_mesh_velocity)
const override;
171 const std::vector<unsigned int> & momentum_system_numbers);
181 template <
typename GradientComponent>
205 const std::vector<std::unique_ptr<NumericVector<Number>>> & raw_Ainv);
228 std::vector<MooseLinearVariableFVReal *>
_vel;
245 std::vector<std::unique_ptr<NumericVector<Number>>>
_HbyA_raw;
257 std::vector<std::unique_ptr<NumericVector<Number>>>
_Ainv_raw;
259 std::unique_ptr<NumericVector<Number>>
_A_avg;
323template <
typename VarType>
327 const auto & var_blocks = var.blockIDs();
328 const auto & uo_blocks =
blockIDs();
331 std::set<SubdomainID> uo_blocks_minus_var_blocks;
332 std::set_difference(uo_blocks.begin(),
336 std::inserter(uo_blocks_minus_var_blocks, uo_blocks_minus_var_blocks.end()));
337 if (uo_blocks_minus_var_blocks.size() > 0)
338 mooseError(
"Block restriction of interpolator user object '",
342 ") includes blocks not in the block restriction of variable '",
349 std::set<SubdomainID> var_blocks_minus_uo_blocks;
350 std::set_difference(var_blocks.begin(),
354 std::inserter(var_blocks_minus_uo_blocks, var_blocks_minus_uo_blocks.end()));
358 for (
auto & block_id : var_blocks_minus_uo_blocks)
361 std::set<SubdomainID> connected_blocks_on_uo;
362 std::set_intersection(connected_blocks.begin(),
363 connected_blocks.end(),
366 std::inserter(connected_blocks_on_uo, connected_blocks_on_uo.end()));
367 if (connected_blocks_on_uo.size() > 0)
368 mooseError(
"Block restriction of interpolator user object '",
372 ") doesn't match the block restriction of variable '",
virtual const std::set< SubdomainID > & blockIDs() const
const std::vector< SubdomainName > & blocks() const
Gradient method that reconstructs and relaxes the pressure gradient used for Rhie-Chow momentum-press...
A functor whose evaluation relies on querying a map where the keys are face info ids and the values c...
Pressure correction diffusion kernel for the linear finite volume SIMPLE algorithm.
const std::string & name() const
void mooseError(Args &&... args) const
const std::set< SubdomainID > & getBlockConnectedBlocks(const SubdomainID subdomain_id) const
User object responsible for determining the face fluxes using the Rhie-Chow interpolation in a segreg...
const MooseMesh & _moose_mesh
The MooseMesh that this user object operates on.
void updateCellVelocity(const std::vector< GradientComponent > &pressure_gradient)
Update cell velocity from the supplied momentum-coupling pressure gradient.
const Moose::FV::InterpMethod _pressure_diffusion_interp_method
Interpolation method used for the pressure diffusion coefficient on faces.
const LinearSystem & momentumSystem(unsigned int component) const
Momentum linear system for one spatial component.
MooseLinearVariableFVReal & velocityVariable(unsigned int component)
Velocity variable for one spatial component.
const LinearFVGradientReader & basePressureGradientField() const
Get the base pressure gradient field used to seed reconstructed gradient updates.
std::vector< std::unique_ptr< NumericVector< Number > > > _grad_p_current
Coupling pressure gradient captured before the current momentum predictor is assembled.
virtual bool supportMeshVelocity() const override
Returns whether the UO can support mesh velocity advection.
virtual void computeHbyA(bool verbose)
Computes the inverse of the diagonal (1/A) of the system matrix plus the H/A components for the press...
const LinearFVGradientReader * _pressure_gradient_field
Registered pressure gradient field used by Rhie-Chow and compatible momentum pressure kernels.
virtual void linkMomentumPressureSystems(const std::vector< LinearSystem * > &momentum_systems, LinearSystem &pressure_system, const std::vector< unsigned int > &momentum_system_numbers)
Update the momentum system-related information.
const LinearSystem & pressureSystem() const
Pressure linear system.
virtual void initFaceMassFlux()
Initialize the container for face velocities.
LinearFVPressureCorrectionDiffusion * _p_diffusion_kernel
Pointer to the pressure diffusion term in the pressure Poisson equation.
const std::vector< NumericVector< Number > * > & pressureGradientComponents() const
Get the registered pressure gradient component vectors.
Real velocityBoundaryValue(unsigned int component, const FaceInfo &fi, const Moose::FaceArg &boundary_face) const
Get the prescribed velocity value on a Dirichlet boundary face.
const libMesh::MeshBase & _mesh
The libMesh mesh that this object acts on.
std::vector< unsigned int > _momentum_system_numbers
Numbers of the momentum system(s)
virtual void initialize() override
virtual void timestepSetup() override
Prepare reconstructed-gradient state once per attempted time step.
unsigned int _global_pressure_system_number
Global number of the pressure system.
const MooseLinearVariableFVReal *const _p
The thread 0 copy of the pressure variable.
Real getMassFlux(const FaceInfo &fi) const
Get the face velocity times density (used in advection terms)
std::vector< LinearSystem * > _momentum_systems
Pointers to the linear system(s) in moose corresponding to the momentum equation(s)
std::unique_ptr< NumericVector< Number > > _A_avg
void finalizePressureCorrector()
After pressure relaxation, refresh every registered pressure gradient and publish relaxed reconstruct...
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.
void preparePISOCorrector()
Capture the lagged velocity gradient for another corrector using the current predictor.
virtual void meshChanged() override
void populateCouplingFunctors(const std::vector< std::unique_ptr< NumericVector< Number > > > &raw_hbya, const std::vector< std::unique_ptr< NumericVector< Number > > > &raw_Ainv)
Populate the face values of the H/A and 1/A fields.
virtual void initialSetup() override
Real getVolumetricFaceFlux(const FaceInfo &fi) const
Get the volumetric face flux (used in advection terms)
std::vector< MooseLinearVariableFVReal * > _vel
Thread 0 copies of the velocity variables; non-const to allow writing cell velocities in updateCellVe...
void checkReconstructedPressureGradientCompatibility() const
Check the single-variable system layout assumed by reconstructed pressure-gradient vector ops.
void finalizeMomentumPredictor()
Capture the lagged velocity gradients computed while assembling the momentum predictor.
const MooseLinearVariableFVReal & velocityVariable(unsigned int component) const
Velocity variable for one spatial component.
LinearSystem * _pressure_system
Pointer to the pressure system.
dof_id_type _face_mass_flux_generation
Producer counter for the conservative face mass flux: incremented every time computeFaceMassFlux() ru...
virtual void computeFaceMassFlux()
Update the values of the face velocities in the containers.
std::vector< std::unique_ptr< NumericVector< Number > > > _Ainv_raw
We hold on to the cell-based 1/A vectors so that we can easily reconstruct the cell velocities as wel...
const std::vector< std::unique_ptr< NumericVector< Number > > > & HbyAComponents() const
Get the momentum-layout H/A component vectors.
std::vector< const FaceInfo * > _flow_face_info
The subset of the FaceInfo objects that actually cover the subdomains which the flow field is defined...
dof_id_type faceMassFluxGeneration() const
Producer counter for the conservative face mass flux: incremented every time computeFaceMassFlux() ru...
void initPressureGradient()
Compute every registered pressure gradient once, before the first momentum predictor of a SIMPLE iter...
std::vector< std::unique_ptr< NumericVector< Number > > > _HbyA_raw
We hold on to the cell-based HbyA vectors so that we can easily reconstruct the cell velocities as we...
void checkBlocks(const VarType &var) const
Check the block consistency between the passed in var and us.
LinearSystem & momentumSystem(unsigned int component)
Momentum linear system for one spatial component.
FVReconstructedPressureGradient & reconstructedGradientMethod()
Access the reconstructed gradient method when it is selected.
void setupMeshInformation()
Compute the cell volumes on the mesh.
const Moose::Functor< Real > & _rho
Functor describing the density of the fluid.
std::vector< libMesh::LinearImplicitSystem * > _momentum_implicit_systems
Pointers to the momentum equation implicit system(s) from libmesh.
virtual void execute() override
unsigned int pressureVariableNumber() const
Variable number of the pressure variable reconstructed by this object.
virtual void initCouplingField()
Initialize the coupling fields (HbyA and Ainv)
void preparePressureRelaxation()
Before pressure relaxation, form the conservative reconstructed candidate from the corrected face flu...
const std::vector< NumericVector< Number > * > & basePressureGradientComponents() const
Get the base-pressure gradient component vectors used to seed reconstructed updates.
FaceCenteredMapFunctor< RealVectorValue, std::unordered_map< dof_id_type, RealVectorValue > > _Ainv
A map functor from faces to $(1/A)_f$.
bool usingReconstructedPressureGradientMethod() const
Whether the registered pressure gradient field is produced by the reconstructed method.
virtual void finalize() override
const LinearFVGradientReader * _base_pressure_gradient_field
Base pressure gradient field used to seed reconstructed gradient updates.
void prepareMomentumPredictor()
Snapshot the fields read by the next momentum predictor.
const unsigned int _dim
The dimension of the mesh, e.g. 3 for hexes and tets, 2 for quads and tris.
const std::vector< std::unique_ptr< NumericVector< Number > > > & AinvComponents() const
Get the momentum-layout 1/A component vectors.
FaceCenteredMapFunctor< Real, std::unordered_map< dof_id_type, Real > > & _face_mass_flux
A map functor from faces to mass fluxes which are used in the advection terms.
const LinearFVGradientReader & pressureGradientField() const
Get the registered pressure gradient field used by compatible momentum pressure kernels.
static InputParameters validParams()
FaceCenteredMapFunctor< Real, std::unordered_map< dof_id_type, Real > > _HbyA_flux
A map functor from faces to $HbyA_{ij} = (A_{offdiag}*\mathrm{(predicted~velocity)} - \mathrm{Source}...
std::unique_ptr< NumericVector< Number > > _cell_fluid_volumes
Fluid volume of each cell, used to rapidly scale the pressure-gradient force in H/A and 1/A.
unsigned int dimension() const
Number of spatial dimensions of the coupled momentum/pressure systems.
const MooseEnum _pressure_projection_method
Enumerator for the method used for pressure projection.
std::vector< unsigned int > _global_momentum_system_numbers
Global numbers of the momentum system(s)
Real computeFacePressureGradientFlux(const FaceInfo &fi, PetscVectorReader &p_reader)
Compute the pressure-gradient flux contribution for a single face.
std::string stringify(const T &t)
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...