https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes | List of all members
RhieChowMassFlux Class Reference

User object responsible for determining the face fluxes using the Rhie-Chow interpolation in a segregated solver that uses the linear FV formulation. More...

#include <RhieChowMassFlux.h>

Inheritance diagram for RhieChowMassFlux:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 RhieChowMassFlux (const InputParameters &params)
 
Real getMassFlux (const FaceInfo &fi) const
 Get the face velocity times density (used in advection terms) More...
 
Real getVolumetricFaceFlux (const FaceInfo &fi) const
 Get the volumetric face flux (used in advection terms) More...
 
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. More...
 
void initFaceMassFlux ()
 Initialize the container for face velocities. More...
 
void initCouplingField ()
 Initialize the coupling fields (HbyA and Ainv) More...
 
void computeFaceMassFlux ()
 Update the values of the face velocities in the containers. More...
 
void computeCellVelocity ()
 Update the cell values of the velocity variables. More...
 
virtual void meshChanged () override
 
virtual void initialize () override
 
virtual void execute () override
 
virtual void finalize () override
 
virtual void initialSetup () override
 
void linkMomentumPressureSystems (const std::vector< LinearSystem *> &momentum_systems, const LinearSystem &pressure_system, const std::vector< unsigned int > &momentum_system_numbers)
 Update the momentum system-related information. More...
 
void computeHbyA (const bool with_updated_pressure, const bool verbose)
 Computes the inverse of the diagonal (1/A) of the system matrix plus the H/A components for the pressure equation plus Rhie-Chow interpolation. More...
 
bool hasFaceSide (const FaceInfo &fi, const bool fi_elem_side) const override
 
SubProblemgetSubProblem () const
 
bool shouldDuplicateInitialExecution () const
 
virtual Real spatialValue (const Point &) const
 
virtual const std::vector< Point > spatialPoints () const
 
void gatherSum (T &value)
 
void gatherMax (T &value)
 
void gatherMin (T &value)
 
void gatherProxyValueMax (T1 &proxy, T2 &value)
 
void gatherProxyValueMin (T1 &proxy, T2 &value)
 
void setPrimaryThreadCopy (UserObject *primary)
 
UserObjectprimaryThreadCopy ()
 
std::set< UserObjectName > getDependObjects () const
 
virtual bool needThreadedCopy () const
 
const std::set< std::string > & getRequestedItems () override
 
const std::set< std::string > & getSuppliedItems () override
 
unsigned int systemNumber () const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
bool isKokkosObject (IsKokkosObjectKey &&) const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParametersparameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
virtual void timestepSetup ()
 
virtual void jacobianSetup ()
 
virtual void residualSetup ()
 
virtual void customSetup (const ExecFlagType &)
 
const ExecFlagEnumgetExecuteOnEnum () const
 
UserObjectName getUserObjectName (const std::string &param_name) const
 
const T & getUserObject (const std::string &param_name, bool is_dependency=true) const
 
const T & getUserObjectByName (const UserObjectName &object_name, bool is_dependency=true) const
 
const UserObjectgetUserObjectBase (const std::string &param_name, bool is_dependency=true) const
 
const UserObjectgetUserObjectBaseByName (const UserObjectName &object_name, bool is_dependency=true) const
 
const std::vector< MooseVariableScalar *> & getCoupledMooseScalarVars ()
 
const std::set< TagID > & getScalarVariableCoupleableVectorTags () const
 
const std::set< TagID > & getScalarVariableCoupleableMatrixTags () const
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialProperty (const std::string &name, MaterialData &material_data, const unsigned int state=0)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialProperty (const std::string &name, const unsigned int state=0)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialProperty (const std::string &name, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialProperty (const std::string &name, MaterialData &material_data, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialProperty (const std::string &name, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialProperty (const std::string &name, const unsigned int state=0)
 
const ADMaterialProperty< T > & getADMaterialProperty (const std::string &name, MaterialData &material_data)
 
const ADMaterialProperty< T > & getADMaterialProperty (const std::string &name)
 
const ADMaterialProperty< T > & getADMaterialProperty (const std::string &name)
 
const MaterialProperty< T > & getMaterialPropertyOld (const std::string &name, MaterialData &material_data)
 
const MaterialProperty< T > & getMaterialPropertyOld (const std::string &name)
 
const MaterialProperty< T > & getMaterialPropertyOld (const std::string &name)
 
const MaterialProperty< T > & getMaterialPropertyOlder (const std::string &name, MaterialData &material_data)
 
const MaterialProperty< T > & getMaterialPropertyOlder (const std::string &name)
 
const MaterialProperty< T > & getMaterialPropertyOlder (const std::string &name)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialPropertyByName (const MaterialPropertyName &name, MaterialData &material_data, const unsigned int state)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialPropertyByName (const MaterialPropertyName &name, MaterialData &material_data, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0)
 
const ADMaterialProperty< T > & getADMaterialPropertyByName (const MaterialPropertyName &name, MaterialData &material_data)
 
const ADMaterialProperty< T > & getADMaterialPropertyByName (const MaterialPropertyName &name)
 
const ADMaterialProperty< T > & getADMaterialPropertyByName (const MaterialPropertyName &name)
 
const MaterialProperty< T > & getMaterialPropertyOldByName (const MaterialPropertyName &name, MaterialData &material_data)
 
const MaterialProperty< T > & getMaterialPropertyOldByName (const MaterialPropertyName &name)
 
const MaterialProperty< T > & getMaterialPropertyOldByName (const MaterialPropertyName &name)
 
const MaterialProperty< T > & getMaterialPropertyOlderByName (const MaterialPropertyName &name, MaterialData &material_data)
 
const MaterialProperty< T > & getMaterialPropertyOlderByName (const MaterialPropertyName &name)
 
const MaterialProperty< T > & getMaterialPropertyOlderByName (const MaterialPropertyName &name)
 
Moose::Kokkos::MaterialProperty< T, dimension > getKokkosMaterialPropertyByName (const std::string &prop_name_in)
 
Moose::Kokkos::MaterialProperty< T, dimension > getKokkosMaterialPropertyOldByName (const std::string &prop_name)
 
Moose::Kokkos::MaterialProperty< T, dimension > getKokkosMaterialPropertyOlderByName (const std::string &prop_name)
 
Moose::Kokkos::MaterialProperty< T, dimension > getKokkosMaterialProperty (const std::string &name)
 
Moose::Kokkos::MaterialProperty< T, dimension > getKokkosMaterialPropertyOld (const std::string &name)
 
Moose::Kokkos::MaterialProperty< T, dimension > getKokkosMaterialPropertyOlder (const std::string &name)
 
std::pair< const MaterialProperty< T > *, std::set< SubdomainID > > getBlockMaterialProperty (const MaterialPropertyName &name)
 
const GenericMaterialProperty< T, is_ad > & getGenericZeroMaterialProperty (const std::string &name)
 
const GenericMaterialProperty< T, is_ad > & getGenericZeroMaterialProperty ()
 
const GenericMaterialProperty< T, is_ad > & getGenericZeroMaterialPropertyByName (const std::string &prop_name)
 
const MaterialProperty< T > & getZeroMaterialProperty (Ts... args)
 
std::set< SubdomainIDgetMaterialPropertyBlocks (const std::string &name)
 
std::vector< SubdomainName > getMaterialPropertyBlockNames (const std::string &name)
 
std::set< BoundaryIDgetMaterialPropertyBoundaryIDs (const std::string &name)
 
std::vector< BoundaryName > getMaterialPropertyBoundaryNames (const std::string &name)
 
void checkBlockAndBoundaryCompatibility (std::shared_ptr< MaterialBase > discrete)
 
std::unordered_map< SubdomainID, std::vector< MaterialBase *> > buildRequiredMaterials (bool allow_stateful=true)
 
void statefulPropertiesAllowed (bool)
 
virtual bool getMaterialPropertyCalled () const
 
virtual const std::unordered_set< unsigned int > & getMatPropDependencies () const
 
virtual void resolveOptionalProperties ()
 
const GenericMaterialProperty< T, is_ad > & getPossiblyConstantGenericMaterialPropertyByName (const MaterialPropertyName &prop_name, MaterialData &material_data, const unsigned int state)
 
bool isImplicit ()
 
Moose::StateArg determineState () const
 
virtual void threadJoin (const UserObject &) override
 
virtual void threadJoin (const UserObject &) override
 
virtual void subdomainSetup () override
 
virtual void subdomainSetup () override
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
const GenericOptionalMaterialProperty< T, is_ad > & getGenericOptionalMaterialProperty (const std::string &name, const unsigned int state=0)
 
const GenericOptionalMaterialProperty< T, is_ad > & getGenericOptionalMaterialProperty (const std::string &name, const unsigned int state=0)
 
const OptionalMaterialProperty< T > & getOptionalMaterialProperty (const std::string &name, const unsigned int state=0)
 
const OptionalMaterialProperty< T > & getOptionalMaterialProperty (const std::string &name, const unsigned int state=0)
 
const OptionalADMaterialProperty< T > & getOptionalADMaterialProperty (const std::string &name)
 
const OptionalADMaterialProperty< T > & getOptionalADMaterialProperty (const std::string &name)
 
const OptionalMaterialProperty< T > & getOptionalMaterialPropertyOld (const std::string &name)
 
const OptionalMaterialProperty< T > & getOptionalMaterialPropertyOld (const std::string &name)
 
const OptionalMaterialProperty< T > & getOptionalMaterialPropertyOlder (const std::string &name)
 
const OptionalMaterialProperty< T > & getOptionalMaterialPropertyOlder (const std::string &name)
 
MaterialBasegetMaterial (const std::string &name)
 
MaterialBasegetMaterial (const std::string &name)
 
MaterialBasegetMaterialByName (const std::string &name, bool no_warn=false)
 
MaterialBasegetMaterialByName (const std::string &name, bool no_warn=false)
 
bool hasMaterialProperty (const std::string &name)
 
bool hasMaterialProperty (const std::string &name)
 
bool hasMaterialPropertyByName (const std::string &name)
 
bool hasMaterialPropertyByName (const std::string &name)
 
bool hasADMaterialProperty (const std::string &name)
 
bool hasADMaterialProperty (const std::string &name)
 
bool hasADMaterialPropertyByName (const std::string &name)
 
bool hasADMaterialPropertyByName (const std::string &name)
 
bool hasKokkosMaterialProperty (const std::string &name)
 
bool hasKokkosMaterialProperty (const std::string &name)
 
bool hasKokkosMaterialPropertyByName (const std::string &name)
 
bool hasKokkosMaterialPropertyByName (const std::string &name)
 
bool hasGenericMaterialProperty (const std::string &name)
 
bool hasGenericMaterialProperty (const std::string &name)
 
bool hasGenericMaterialPropertyByName (const std::string &name)
 
bool hasGenericMaterialPropertyByName (const std::string &name)
 
const FunctiongetFunction (const std::string &name) const
 
const FunctiongetFunctionByName (const FunctionName &name) const
 
bool hasFunction (const std::string &param_name) const
 
bool hasFunctionByName (const FunctionName &name) const
 
bool isDefaultPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessor (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessorByName (const PostprocessorName &name) const
 
std::size_t coupledPostprocessors (const std::string &param_name) const
 
const PostprocessorName & getPostprocessorName (const std::string &param_name, const unsigned int index=0) const
 
const VectorPostprocessorValuegetVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool hasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
bool hasVectorPostprocessor (const std::string &param_name) const
 
bool hasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool hasVectorPostprocessorByName (const VectorPostprocessorName &name) const
 
const VectorPostprocessorName & getVectorPostprocessorName (const std::string &param_name) const
 
T & getSampler (const std::string &name)
 
SamplergetSampler (const std::string &name)
 
T & getSamplerByName (const SamplerName &name)
 
SamplergetSamplerByName (const SamplerName &name)
 
virtual void meshDisplaced ()
 
PerfGraphperfGraph ()
 
const PostprocessorValuegetPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
bool isVectorPostprocessorDistributed (const std::string &param_name) const
 
bool isVectorPostprocessorDistributed (const std::string &param_name) const
 
bool isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const
 
bool isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const
 
const DistributiongetDistribution (const std::string &name) const
 
const T & getDistribution (const std::string &name) const
 
const DistributiongetDistribution (const std::string &name) const
 
const T & getDistribution (const std::string &name) const
 
const DistributiongetDistributionByName (const DistributionName &name) const
 
const T & getDistributionByName (const std::string &name) const
 
const DistributiongetDistributionByName (const DistributionName &name) const
 
const T & getDistributionByName (const std::string &name) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
const std::vector< SubdomainName > & blocks () const
 
unsigned int numBlocks () const
 
virtual const std::set< SubdomainID > & blockIDs () const
 
unsigned int blocksMaxDimension () const
 
bool hasBlocks (const SubdomainName &name) const
 
bool hasBlocks (const std::vector< SubdomainName > &names) const
 
bool hasBlocks (const std::set< SubdomainName > &names) const
 
bool hasBlocks (SubdomainID id) const
 
bool hasBlocks (const std::vector< SubdomainID > &ids) const
 
bool hasBlocks (const std::set< SubdomainID > &ids) const
 
bool isBlockSubset (const std::set< SubdomainID > &ids) const
 
bool isBlockSubset (const std::vector< SubdomainID > &ids) const
 
bool hasBlockMaterialProperty (const std::string &prop_name)
 
const std::set< SubdomainID > & meshBlockIDs () const
 
virtual bool blockRestricted () const
 
virtual void checkVariable (const MooseVariableFieldBase &variable) const
 

Static Public Member Functions

static InputParameters validParams ()
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node)
 
static void sort (typename std::vector< T > &vector)
 
static void sortDFS (typename std::vector< T > &vector)
 
static void cyclicDependencyError (CyclicDependencyException< T2 > &e, const std::string &header)
 
static std::string deduceFunctorName (const std::string &name, const InputParameters &params)
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 
static constexpr PropertyValue::id_type default_property_id
 
static constexpr PropertyValue::id_type zero_property_id
 
static constexpr auto SYSTEM
 
static constexpr auto NAME
 

Protected Member Functions

std::vector< std::unique_ptr< NumericVector< Number > > > & selectPressureGradient (const bool updated_pressure)
 Select the right pressure gradient field and return a reference to the container. More...
 
void setupMeshInformation ()
 Compute the cell volumes on the mesh. More...
 
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. More...
 
template<typename VarType >
void checkBlocks (const VarType &var) const
 Check the block consistency between the passed in var and us. More...
 
virtual bool supportMeshVelocity () const override
 Returns whether the UO can support mesh velocity advection. More...
 
virtual void addPostprocessorDependencyHelper (const PostprocessorName &name) const override
 
virtual void addVectorPostprocessorDependencyHelper (const VectorPostprocessorName &name) const override
 
virtual void addUserObjectDependencyHelper (const UserObject &uo) const override
 
void addReporterDependencyHelper (const ReporterName &reporter_name) override
 
void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) const
 
const ReporterContextBasegetReporterContextBaseByName (const ReporterName &reporter_name) const
 
const ReporterNamegetReporterName (const std::string &param_name) const
 
T & declareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< T > declareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const T & getRestartableData (const std::string &data_name) const
 
T & declareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
T & declareRecoverableData (const std::string &data_name, Args &&... args)
 
T & declareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
T & declareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 
std::string restartableName (const std::string &data_name) const
 
const T & getMeshProperty (const std::string &data_name, const std::string &prefix)
 
const T & getMeshProperty (const std::string &data_name)
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name) const
 
bool hasMeshProperty (const std::string &data_name) const
 
std::string meshPropertyName (const std::string &data_name) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 
std::string timedSectionName (const std::string &section_name) const
 
bool isCoupledScalar (const std::string &var_name, unsigned int i=0) const
 
unsigned int coupledScalarComponents (const std::string &var_name) const
 
unsigned int coupledScalar (const std::string &var_name, unsigned int comp=0) const
 
libMesh::Order coupledScalarOrder (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarValue (const std::string &var_name, unsigned int comp=0) const
 
const ADVariableValueadCoupledScalarValue (const std::string &var_name, unsigned int comp=0) const
 
const GenericVariableValue< is_ad > & coupledGenericScalarValue (const std::string &var_name, unsigned int comp=0) const
 
const GenericVariableValue< false > & coupledGenericScalarValue (const std::string &var_name, const unsigned int comp) const
 
const GenericVariableValue< true > & coupledGenericScalarValue (const std::string &var_name, const unsigned int comp) const
 
const VariableValuecoupledVectorTagScalarValue (const std::string &var_name, TagID tag, unsigned int comp=0) const
 
const VariableValuecoupledMatrixTagScalarValue (const std::string &var_name, TagID tag, unsigned int comp=0) const
 
const VariableValuecoupledScalarValueOld (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarValueOlder (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDot (const std::string &var_name, unsigned int comp=0) const
 
const ADVariableValueadCoupledScalarDot (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDot (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotOld (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDotOld (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDu (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDotDu (const std::string &var_name, unsigned int comp=0) const
 
const MooseVariableScalargetScalarVar (const std::string &var_name, unsigned int comp) const
 
virtual void checkMaterialProperty (const std::string &name, const unsigned int state)
 
virtual void getKokkosMaterialPropertyHook (const std::string &, const unsigned int)
 
void markMatPropRequested (const std::string &)
 
MaterialPropertyName getMaterialPropertyName (const std::string &name) const
 
void checkExecutionStage ()
 
const T & getReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
const GenericMaterialProperty< T, is_ad > * defaultGenericMaterialProperty (const std::string &name)
 
const GenericMaterialProperty< T, is_ad > * defaultGenericMaterialProperty (const std::string &name)
 
const MaterialProperty< T > * defaultMaterialProperty (const std::string &name)
 
const MaterialProperty< T > * defaultMaterialProperty (const std::string &name)
 
const ADMaterialProperty< T > * defaultADMaterialProperty (const std::string &name)
 
const ADMaterialProperty< T > * defaultADMaterialProperty (const std::string &name)
 
virtual bool hasBlockMaterialPropertyHelper (const std::string &prop_name)
 
void initializeBlockRestrictable (const MooseObject *moose_object)
 
void initializeKokkosBlockRestrictable (const Moose::Kokkos::Mesh *mesh)
 
Moose::CoordinateSystemType getBlockCoordSystem ()
 
KOKKOS_FUNCTION dof_id_type numKokkosBlockElements () const
 
KOKKOS_FUNCTION dof_id_type numKokkosBlockNodes () const
 
KOKKOS_FUNCTION dof_id_type numKokkosBlockSides () const
 
KOKKOS_FUNCTION ContiguousElementID kokkosBlockElementID (ThreadID tid) const
 
KOKKOS_FUNCTION ContiguousElementID kokkosBlockNodeID (ThreadID tid) const
 
KOKKOS_FUNCTION auto kokkosBlockElementSideID (ThreadID tid) const
 
std::string deduceFunctorName (const std::string &name) const
 
const Moose::Functor< T > & getFunctor (const std::string &name)
 
const Moose::Functor< T > & getFunctor (const std::string &name, THREAD_ID tid)
 
const Moose::Functor< T > & getFunctor (const std::string &name, SubProblem &subproblem)
 
const Moose::Functor< T > & getFunctor (const std::string &name, SubProblem &subproblem, THREAD_ID tid)
 
bool isFunctor (const std::string &name) const
 
bool isFunctor (const std::string &name, const SubProblem &subproblem) const
 
Moose::ElemArg makeElemArg (const Elem *elem, bool correct_skewnewss=false) const
 
void checkFunctorSupportsSideIntegration (const std::string &name, bool qp_integration)
 

Static Protected Member Functions

static std::string meshPropertyName (const std::string &data_name, const std::string &prefix)
 

Protected Attributes

const MooseMesh_moose_mesh
 The MooseMesh that this user object operates on. More...
 
const libMesh::MeshBase_mesh
 The libMesh mesh that this object acts on. More...
 
const unsigned int _dim
 The dimension of the mesh, e.g. 3 for hexes and tets, 2 for quads and tris. More...
 
const MooseLinearVariableFVReal *const _p
 The thread 0 copy of the pressure variable. More...
 
std::vector< const MooseLinearVariableFVReal * > _vel
 The thread 0 copy of the x-velocity variable. More...
 
LinearFVAnisotropicDiffusion_p_diffusion_kernel
 Pointer to the pressure diffusion term in the pressure Poisson equation. More...
 
FaceCenteredMapFunctor< Real, std::unordered_map< dof_id_type, Real > > _HbyA_flux
 A map functor from faces to $HbyA_{ij} = (A_{offdiag}*{(predicted~velocity)} - {Source})_{ij}/A_{ij}$. More...
 
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 well. More...
 
FaceCenteredMapFunctor< RealVectorValue, std::unordered_map< dof_id_type, RealVectorValue > > _Ainv
 A map functor from faces to $(1/A)_f$. More...
 
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 well. More...
 
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. More...
 
std::vector< std::vector< LinearFVElementalKernel * > > _body_force_kernels
 Pointer to the body force terms. More...
 
std::vector< std::vector< std::string > > _body_force_kernel_names
 Vector of body force term names. More...
 
std::vector< std::unique_ptr< NumericVector< Number > > > _grad_p_current
 for a PISO iteration we need to hold on to the original pressure gradient field. More...
 
const Moose::Functor< Real > & _rho
 Functor describing the density of the fluid. More...
 
std::vector< LinearSystem * > _momentum_systems
 Pointers to the linear system(s) in moose corresponding to the momentum equation(s) More...
 
std::vector< unsigned int_momentum_system_numbers
 Numbers of the momentum system(s) More...
 
std::vector< unsigned int_global_momentum_system_numbers
 Global numbers of the momentum system(s) More...
 
std::vector< libMesh::LinearImplicitSystem * > _momentum_implicit_systems
 Pointers to the momentum equation implicit system(s) from libmesh. More...
 
const LinearSystem_pressure_system
 Pointer to the pressure system. More...
 
unsigned int _global_pressure_system_number
 Global number of the pressure system. More...
 
std::unique_ptr< NumericVector< Number > > _cell_volumes
 We will hold a vector of cell volumes to make sure we can do volume corrections rapidly. More...
 
const MooseEnum _pressure_projection_method
 Enumerator for the method used for pressure projection. More...
 
SubProblem_subproblem
 
FEProblemBase_fe_problem
 
SystemBase_sys
 
const THREAD_ID _tid
 
Assembly_assembly
 
const Moose::CoordinateSystemType_coord_sys
 
const bool _duplicate_initial_execution
 
std::set< std::string > _depend_uo
 
const bool & _enabled
 
MooseApp_app
 
Factory_factory
 
ActionFactory_action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters_pars
 
const ExecFlagEnum_execute_enum
 
const ExecFlagType_current_execute_flag
 
MooseApp_restartable_app
 
const std::string _restartable_system_name
 
const THREAD_ID _restartable_tid
 
const bool _restartable_read_only
 
FEProblemBase_mci_feproblem
 
FEProblemBase_mdi_feproblem
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
FEProblemBase_sc_fe_problem
 
const THREAD_ID _sc_tid
 
const Real_real_zero
 
const VariableValue_scalar_zero
 
const Point & _point_zero
 
const InputParameters_mi_params
 
const std::string _mi_name
 
const MooseObjectName _mi_moose_object_name
 
FEProblemBase_mi_feproblem
 
SubProblem_mi_subproblem
 
const THREAD_ID _mi_tid
 
const bool _is_kokkos_object
 
const Moose::MaterialDataType _material_data_type
 
MaterialData_material_data
 
bool _stateful_allowed
 
bool _get_material_property_called
 
std::vector< std::unique_ptr< PropertyValue > > _default_properties
 
std::unordered_set< unsigned int_material_property_dependencies
 
const MaterialPropertyName _get_suffix
 
const bool _use_interpolated_state
 
const InputParameters_ti_params
 
FEProblemBase_ti_feproblem
 
bool _is_implicit
 
Real_t
 
const Real_t_old
 
int_t_step
 
Real_dt
 
Real_dt_old
 
bool _is_transient
 
const Parallel::Communicator & _communicator
 
const MaterialData_blk_material_data
 

Static Protected Attributes

static const std::string _interpolated_old
 
static const std::string _interpolated_older
 

Private Attributes

std::vector< const FaceInfo * > _flow_face_info
 The subset of the FaceInfo objects that actually cover the subdomains which the flow field is defined on. More...
 

Detailed Description

User object responsible for determining the face fluxes using the Rhie-Chow interpolation in a segregated solver that uses the linear FV formulation.

Definition at line 37 of file RhieChowMassFlux.h.

Constructor & Destructor Documentation

◆ RhieChowMassFlux()

RhieChowMassFlux::RhieChowMassFlux ( const InputParameters params)

Definition at line 69 of file RhieChowMassFlux.C.

70  : RhieChowFaceFluxProvider(params),
75  _p(dynamic_cast<MooseLinearVariableFVReal *>(
76  &UserObject::_subproblem.getVariable(0, getParam<VariableName>(NS::pressure)))),
77  _vel(_dim, nullptr),
78  _HbyA_flux(_moose_mesh, blockIDs(), "HbyA_flux"),
79  _Ainv(_moose_mesh, blockIDs(), "Ainv"),
81  declareRestartableData<FaceCenteredMapFunctor<Real, std::unordered_map<dof_id_type, Real>>>(
82  "face_flux", _moose_mesh, blockIDs(), "face_values")),
84  getParam<std::vector<std::vector<std::string>>>("body_force_kernel_names")),
85  _rho(getFunctor<Real>(NS::density)),
86  _pressure_projection_method(getParam<MooseEnum>("pressure_projection_method"))
87 {
88  if (!_p)
89  paramError(NS::pressure, "the pressure must be a MooseLinearVariableFVReal.");
90  checkBlocks(*_p);
91 
92  std::vector<std::string> vel_names = {"u", "v", "w"};
93  for (const auto i : index_range(_vel))
94  {
95  _vel[i] = dynamic_cast<MooseLinearVariableFVReal *>(
96  &UserObject::_subproblem.getVariable(0, getParam<VariableName>(vel_names[i])));
97 
98  if (!_vel[i])
99  paramError(vel_names[i], "the velocity must be a MOOSELinearVariableFVReal.");
100  checkBlocks(*_vel[i]);
101  }
102 
103  // Register the elemental/face functors which will be queried in the pressure equation
104  for (const auto tid : make_range(libMesh::n_threads()))
105  {
108  }
109 
110  if (!dynamic_cast<SIMPLE *>(getMooseApp().getExecutioner()) &&
111  !dynamic_cast<PIMPLE *>(getMooseApp().getExecutioner()))
112  mooseError(this->name(),
113  " should only be used with a linear segregated thermal-hydraulics solver!");
114 }
unsigned int blocksMaxDimension() const
const MooseEnum _pressure_projection_method
Enumerator for the method used for pressure projection.
unsigned int n_threads()
A functor whose evaluation relies on querying a map where the keys are face info ids and the values c...
void paramError(const std::string &param, Args... args) const
const T & getParam(const std::string &name) const
void checkBlocks(const VarType &var) const
Check the block consistency between the passed in var and us.
RhieChowFaceFluxProvider(const InputParameters &params)
void addFunctor(const std::string &name, const Moose::FunctorBase< T > &functor, const THREAD_ID tid)
MeshBase & mesh
static const std::string density
Definition: NS.h:33
T & declareRestartableData(const std::string &data_name, Args &&... args)
FaceCenteredMapFunctor< RealVectorValue, std::unordered_map< dof_id_type, RealVectorValue > > _Ainv
A map functor from faces to $(1/A)_f$.
virtual const std::set< SubdomainID > & blockIDs() const
MooseApp & getMooseApp() const
SubProblem & _subproblem
const std::string & name() const
std::vector< std::vector< std::string > > _body_force_kernel_names
Vector of body force term names.
FaceCenteredMapFunctor< Real, std::unordered_map< dof_id_type, Real > > _HbyA_flux
A map functor from faces to $HbyA_{ij} = (A_{offdiag}*{(predicted~velocity)} - {Source})_{ij}/A_{ij}$...
MeshBase & getMesh()
std::vector< const MooseLinearVariableFVReal * > _vel
The thread 0 copy of the x-velocity variable.
const MooseLinearVariableFVReal *const _p
The thread 0 copy of the pressure variable.
const Moose::Functor< Real > & _rho
Functor describing the density of the fluid.
const MooseMesh & _moose_mesh
The MooseMesh that this user object operates on.
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const=0
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.
static const std::string pressure
Definition: NS.h:56
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
NonADFunctorInterface(const MooseObject *moose_object)
auto index_range(const T &sizable)
const libMesh::MeshBase & _mesh
The libMesh mesh that this object acts on.
const unsigned int _dim
The dimension of the mesh, e.g. 3 for hexes and tets, 2 for quads and tris.

Member Function Documentation

◆ checkBlocks()

template<typename VarType >
void RhieChowMassFlux::checkBlocks ( const VarType &  var) const
protected

Check the block consistency between the passed in var and us.

Definition at line 205 of file RhieChowMassFlux.h.

Referenced by RhieChowMassFlux().

206 {
207  const auto & var_blocks = var.blockIDs();
208  const auto & uo_blocks = blockIDs();
209 
210  // Error if this UO has any blocks that the variable does not
211  std::set<SubdomainID> uo_blocks_minus_var_blocks;
212  std::set_difference(uo_blocks.begin(),
213  uo_blocks.end(),
214  var_blocks.begin(),
215  var_blocks.end(),
216  std::inserter(uo_blocks_minus_var_blocks, uo_blocks_minus_var_blocks.end()));
217  if (uo_blocks_minus_var_blocks.size() > 0)
218  mooseError("Block restriction of interpolator user object '",
219  this->name(),
220  "' (",
222  ") includes blocks not in the block restriction of variable '",
223  var.name(),
224  "' (",
225  Moose::stringify(var.blocks()),
226  ")");
227 
228  // Get the blocks in the variable but not this UO
229  std::set<SubdomainID> var_blocks_minus_uo_blocks;
230  std::set_difference(var_blocks.begin(),
231  var_blocks.end(),
232  uo_blocks.begin(),
233  uo_blocks.end(),
234  std::inserter(var_blocks_minus_uo_blocks, var_blocks_minus_uo_blocks.end()));
235 
236  // For each block in the variable but not this UO, error if there is connection
237  // to any blocks on the UO.
238  for (auto & block_id : var_blocks_minus_uo_blocks)
239  {
240  const auto connected_blocks = _moose_mesh.getBlockConnectedBlocks(block_id);
241  std::set<SubdomainID> connected_blocks_on_uo;
242  std::set_intersection(connected_blocks.begin(),
243  connected_blocks.end(),
244  uo_blocks.begin(),
245  uo_blocks.end(),
246  std::inserter(connected_blocks_on_uo, connected_blocks_on_uo.end()));
247  if (connected_blocks_on_uo.size() > 0)
248  mooseError("Block restriction of interpolator user object '",
249  this->name(),
250  "' (",
251  Moose::stringify(uo_blocks),
252  ") doesn't match the block restriction of variable '",
253  var.name(),
254  "' (",
255  Moose::stringify(var_blocks),
256  ")");
257  }
258 }
const std::set< SubdomainID > & getBlockConnectedBlocks(const SubdomainID subdomain_id) const
virtual const std::set< SubdomainID > & blockIDs() const
const std::string & name() const
const MooseMesh & _moose_mesh
The MooseMesh that this user object operates on.
std::string stringify(const T &t)
const std::vector< SubdomainName > & blocks() const
void mooseError(Args &&... args) const

◆ computeCellVelocity()

void RhieChowMassFlux::computeCellVelocity ( )

Update the cell values of the velocity variables.

Definition at line 393 of file RhieChowMassFlux.C.

Referenced by LinearAssemblySegregatedSolve::correctVelocity().

394 {
395  auto & pressure_gradient = _pressure_system->gradientContainer();
396 
397  // We set the dof value in the solution vector the same logic applies:
398  // u_C = -(H/A)_C - (1/A)_C*grad(p)_C where C is the cell index
399  for (const auto system_i : index_range(_momentum_implicit_systems))
400  {
401  auto working_vector = _Ainv_raw[system_i]->clone();
402  working_vector->pointwise_mult(*working_vector, *pressure_gradient[system_i]);
403  working_vector->add(*_HbyA_raw[system_i]);
404  working_vector->scale(-1.0);
405  (*_momentum_implicit_systems[system_i]->solution) = *working_vector;
406  _momentum_implicit_systems[system_i]->update();
407  _momentum_systems[system_i]->setSolution(
408  *_momentum_implicit_systems[system_i]->current_local_solution);
409  }
410 }
std::vector< LinearSystem * > _momentum_systems
Pointers to the linear system(s) in moose corresponding to the momentum equation(s) ...
std::vector< libMesh::LinearImplicitSystem * > _momentum_implicit_systems
Pointers to the momentum equation implicit system(s) from libmesh.
const std::vector< std::unique_ptr< NumericVector< Number > > > & gradientContainer() const
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 LinearSystem * _pressure_system
Pointer to the pressure system.
auto index_range(const T &sizable)
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...

◆ computeFaceMassFlux()

void RhieChowMassFlux::computeFaceMassFlux ( )

Update the values of the face velocities in the containers.

Definition at line 323 of file RhieChowMassFlux.C.

Referenced by LinearAssemblySegregatedSolve::correctVelocity().

324 {
325  using namespace Moose::FV;
326 
327  const auto time_arg = Moose::currentState();
328 
329  // Petsc vector reader to make the repeated reading from the vector faster
331 
332  // We loop through the faces and compute the face fluxes using the pressure gradient
333  // and the momentum matrix/right hand side
334  for (auto & fi : _flow_face_info)
335  {
336  // Making sure the kernel knows which face we are on
338 
339  // We are setting this to 1.0 because we don't want to multiply the kernel contributions
340  // with the surface area yet. The surface area will be factored in in the advection kernels.
342 
343  Real p_grad_flux = 0.0;
344  if (_p->isInternalFace(*fi))
345  {
346  const auto & elem_info = *fi->elemInfo();
347  const auto & neighbor_info = *fi->neighborInfo();
348 
349  // Fetching the dof indices for the pressure variable
350  const auto elem_dof = elem_info.dofIndices()[_global_pressure_system_number][0];
351  const auto neighbor_dof = neighbor_info.dofIndices()[_global_pressure_system_number][0];
352 
353  // Fetching the values of the pressure for the element and the neighbor
354  const auto p_elem_value = p_reader(elem_dof);
355  const auto p_neighbor_value = p_reader(neighbor_dof);
356 
357  // Compute the elem matrix contributions for the face
358  const auto elem_matrix_contribution = _p_diffusion_kernel->computeElemMatrixContribution();
359  const auto neighbor_matrix_contribution =
361  const auto elem_rhs_contribution =
363 
364  // Compute the face flux from the matrix and right hand side contributions
365  p_grad_flux = (p_neighbor_value * neighbor_matrix_contribution +
366  p_elem_value * elem_matrix_contribution) -
367  elem_rhs_contribution;
368  }
369  else if (auto * bc_pointer = _p->getBoundaryCondition(*fi->boundaryIDs().begin()))
370  {
371  mooseAssert(fi->boundaryIDs().size() == 1, "We should only have one boundary on every face.");
372 
373  bc_pointer->setupFaceData(
374  fi, fi->faceType(std::make_pair(_p->number(), _global_pressure_system_number)));
375 
376  const ElemInfo & elem_info =
377  hasBlocks(fi->elemPtr()->subdomain_id()) ? *fi->elemInfo() : *fi->neighborInfo();
378  const auto p_elem_value = _p->getElemValue(elem_info, time_arg);
379  const auto matrix_contribution =
381  const auto rhs_contribution =
383 
384  // On the boundary, only the element side has a contribution
385  p_grad_flux = (p_elem_value * matrix_contribution - rhs_contribution);
386  }
387  // Compute the new face flux
388  _face_mass_flux[fi->id()] = -_HbyA_flux[fi->id()] + p_grad_flux;
389  }
390 }
unsigned int number() const
virtual Real computeElemMatrixContribution() override
virtual void setupFaceData(const FaceInfo *face_info)
const LinearSystem * _pressure_system
Pointer to the pressure system.
LinearFVBoundaryCondition * getBoundaryCondition(const BoundaryID bd_id) const
virtual Real computeBoundaryMatrixContribution(const LinearFVBoundaryCondition &bc) override
bool isInternalFace(const FaceInfo &) const
FaceCenteredMapFunctor< Real, std::unordered_map< dof_id_type, Real > > _HbyA_flux
A map functor from faces to $HbyA_{ij} = (A_{offdiag}*{(predicted~velocity)} - {Source})_{ij}/A_{ij}$...
const MooseLinearVariableFVReal *const _p
The thread 0 copy of the pressure variable.
unsigned int _global_pressure_system_number
Global number of the pressure system.
virtual Real computeElemRightHandSideContribution() override
virtual Real computeNeighborMatrixContribution() override
void setCurrentFaceArea(const Real area)
virtual Real computeBoundaryRHSContribution(const LinearFVBoundaryCondition &bc) override
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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real getElemValue(const ElemInfo &elem_info, const StateArg &state) const
std::unique_ptr< NumericVector< Number > > current_local_solution
std::vector< const FaceInfo * > _flow_face_info
The subset of the FaceInfo objects that actually cover the subdomains which the flow field is defined...
bool hasBlocks(const SubdomainName &name) const
StateArg currentState()
LinearFVAnisotropicDiffusion * _p_diffusion_kernel
Pointer to the pressure diffusion term in the pressure Poisson equation.
virtual System & system() override

◆ computeHbyA()

void RhieChowMassFlux::computeHbyA ( const bool  with_updated_pressure,
const bool  verbose 
)

Computes the inverse of the diagonal (1/A) of the system matrix plus the H/A components for the pressure equation plus Rhie-Chow interpolation.

Definition at line 541 of file RhieChowMassFlux.C.

Referenced by LinearAssemblySegregatedSolve::correctVelocity().

542 {
543  if (verbose)
544  {
545  _console << "************************************" << std::endl;
546  _console << "Computing HbyA" << std::endl;
547  _console << "************************************" << std::endl;
548  }
550  "The momentum system shall be linked before calling this function!");
551 
552  auto & pressure_gradient = selectPressureGradient(with_updated_pressure);
553 
554  _HbyA_raw.clear();
555  _Ainv_raw.clear();
556  for (auto system_i : index_range(_momentum_systems))
557  {
558  LinearImplicitSystem * momentum_system = _momentum_implicit_systems[system_i];
559 
560  NumericVector<Number> & rhs = *(momentum_system->rhs);
561  NumericVector<Number> & current_local_solution = *(momentum_system->current_local_solution);
562  NumericVector<Number> & solution = *(momentum_system->solution);
563  PetscMatrix<Number> * mmat = dynamic_cast<PetscMatrix<Number> *>(momentum_system->matrix);
564  mooseAssert(mmat,
565  "The matrices used in the segregated INSFVRhieChow objects need to be convertable "
566  "to PetscMatrix!");
567 
568  if (verbose)
569  {
570  _console << "Matrix in rc object" << std::endl;
571  mmat->print();
572  }
573 
574  // First, we extract the diagonal and we will hold on to it for a little while
575  _Ainv_raw.push_back(current_local_solution.zero_clone());
576  NumericVector<Number> & Ainv = *(_Ainv_raw.back());
577 
578  mmat->get_diagonal(Ainv);
579 
580  if (verbose)
581  {
582  _console << "Velocity solution in H(u)" << std::endl;
583  solution.print();
584  }
585 
586  // Time to create H(u) = M_{offdiag} * u - b_{nonpressure}
587  _HbyA_raw.push_back(current_local_solution.zero_clone());
588  NumericVector<Number> & HbyA = *(_HbyA_raw.back());
589 
590  // We start with the matrix product part, we will do
591  // M*u - A*u for 2 reasons:
592  // 1, We assume A*u petsc operation is faster than setting the matrix diagonal to 0
593  // 2, In PISO loops we need to reuse the matrix so we can't just set the diagonals to 0
594 
595  // We create a working vector to ease some of the operations, we initialize its values
596  // with the current solution values to have something for the A*u term
597  auto working_vector = momentum_system->current_local_solution->zero_clone();
598  PetscVector<Number> * working_vector_petsc =
599  dynamic_cast<PetscVector<Number> *>(working_vector.get());
600  mooseAssert(working_vector_petsc,
601  "The vectors used in the RhieChowMassFlux objects need to be convertable "
602  "to PetscVectors!");
603 
604  mmat->vector_mult(HbyA, solution);
605  working_vector_petsc->pointwise_mult(Ainv, solution);
606  HbyA.add(-1.0, *working_vector_petsc);
607 
608  if (verbose)
609  {
610  _console << " H(u)" << std::endl;
611  HbyA.print();
612  }
613 
614  // We continue by adding the momentum right hand side contributions
615  HbyA.add(-1.0, rhs);
616 
617  // Unfortunately, the pressure forces are included in the momentum RHS
618  // so we have to correct them back
619  working_vector_petsc->pointwise_mult(*pressure_gradient[system_i], *_cell_volumes);
620  HbyA.add(-1.0, *working_vector_petsc);
621 
622  if (verbose)
623  {
624  _console << "total RHS" << std::endl;
625  rhs.print();
626  _console << "pressure RHS" << std::endl;
627  pressure_gradient[system_i]->print();
628  _console << " H(u)-rhs-relaxation_source" << std::endl;
629  HbyA.print();
630  }
631 
632  // It is time to create element-wise 1/A-s based on the the diagonal of the momentum matrix
633  *working_vector_petsc = 1.0;
634  Ainv.pointwise_divide(*working_vector_petsc, Ainv);
635 
636  // Create 1/A*(H(u)-RHS)
637  HbyA.pointwise_mult(HbyA, Ainv);
638 
639  if (verbose)
640  {
641  _console << " (H(u)-rhs)/A" << std::endl;
642  HbyA.print();
643  }
644 
645  if (_pressure_projection_method == "consistent")
646  {
647 
648  // Consistent Corrections to SIMPLE
649  // 1. Ainv_old = 1/a_p <- Ainv = 1/(a_p + \sum_n a_n)
650  // 2. H(u) <- H(u*) + H(u') = H(u*) - (Ainv - Ainv_old) * grad(p) * Vc
651 
652  if (verbose)
653  _console << "Performing SIMPLEC projection." << std::endl;
654 
655  // Lambda function to calculate the sum of diagonal and neighbor coefficients
656  auto get_row_sum = [mmat](NumericVector<Number> & sum_vector)
657  {
658  // Ensure the sum_vector is zeroed out
659  sum_vector.zero();
660 
661  // Local row size
662  const auto local_size = mmat->local_m();
663 
664  for (const auto row_i : make_range(local_size))
665  {
666  // Get all non-zero components of the row of the matrix
667  const auto global_index = mmat->row_start() + row_i;
668  std::vector<numeric_index_type> indices;
669  std::vector<Real> values;
670  mmat->get_row(global_index, indices, values);
671 
672  // Sum row elements (no absolute values)
673  const Real row_sum = std::accumulate(values.cbegin(), values.cend(), 0.0);
674 
675  // Add the sum of diagonal and elements to the sum_vector
676  sum_vector.add(global_index, row_sum);
677  }
678  sum_vector.close();
679  };
680 
681  // Create a temporary vector to store the sum of diagonal and neighbor coefficients
682  auto row_sum = current_local_solution.zero_clone();
683  get_row_sum(*row_sum);
684 
685  // Create vector with new inverse projection matrix
686  auto Ainv_full = current_local_solution.zero_clone();
687  *working_vector_petsc = 1.0;
688  Ainv_full->pointwise_divide(*working_vector_petsc, *row_sum);
689  const auto Ainv_full_old = Ainv_full->clone();
690 
691  // Correct HbyA
692  Ainv_full->add(-1.0, Ainv);
693  working_vector_petsc->pointwise_mult(*Ainv_full, *pressure_gradient[system_i]);
694  working_vector_petsc->pointwise_mult(*working_vector_petsc, *_cell_volumes);
695  HbyA.add(-1.0, *working_vector_petsc);
696 
697  // Correct Ainv
698  Ainv = *Ainv_full_old;
699  }
700 
701  Ainv.pointwise_mult(Ainv, *_cell_volumes);
702  }
703 
704  // We fill the 1/A and H/A functors
706 
707  if (verbose)
708  {
709  _console << "************************************" << std::endl;
710  _console << "DONE Computing HbyA " << std::endl;
711  _console << "************************************" << std::endl;
712  }
713 }
std::vector< LinearSystem * > _momentum_systems
Pointers to the linear system(s) in moose corresponding to the momentum equation(s) ...
const MooseEnum _pressure_projection_method
Enumerator for the method used for pressure projection.
virtual numeric_index_type local_m() const final
std::vector< libMesh::LinearImplicitSystem * > _momentum_implicit_systems
Pointers to the momentum equation implicit system(s) from libmesh.
void vector_mult(NumericVector< T > &dest, const NumericVector< T > &arg) const
virtual std::unique_ptr< NumericVector< T > > zero_clone() const=0
NumericVector< Number > * rhs
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...
virtual void pointwise_divide(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
virtual void pointwise_mult(const NumericVector< T > &vec1, const NumericVector< T > &vec2) override
std::unique_ptr< NumericVector< Number > > solution
virtual void print(std::ostream &os=libMesh::out) const
virtual void get_row(numeric_index_type i, std::vector< numeric_index_type > &indices, std::vector< T > &values) const override
std::vector< std::unique_ptr< NumericVector< Number > > > & selectPressureGradient(const bool updated_pressure)
Select the right pressure gradient field and return a reference to the container. ...
virtual void pointwise_mult(const NumericVector< T > &vec1, const NumericVector< T > &vec2)=0
virtual void get_diagonal(NumericVector< T > &dest) const override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
SparseMatrix< Number > * matrix
IntRange< T > make_range(T beg, T end)
virtual numeric_index_type row_start() const override
std::unique_ptr< NumericVector< Number > > current_local_solution
const ConsoleStream _console
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 add(const numeric_index_type i, const T value)=0
auto index_range(const T &sizable)
void print(std::ostream &os=libMesh::out, const bool sparse=false) const
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...
virtual void pointwise_divide(const NumericVector< T > &vec1, const NumericVector< T > &vec2)=0
std::unique_ptr< NumericVector< Number > > _cell_volumes
We will hold a vector of cell volumes to make sure we can do volume corrections rapidly.

◆ execute()

virtual void RhieChowMassFlux::execute ( )
inlineoverridevirtual

Implements GeneralUserObject.

Definition at line 66 of file RhieChowMassFlux.h.

66 {}

◆ finalize()

virtual void RhieChowMassFlux::finalize ( )
inlineoverridevirtual

Implements GeneralUserObject.

Definition at line 67 of file RhieChowMassFlux.h.

67 {}

◆ getMassFlux()

Real RhieChowMassFlux::getMassFlux ( const FaceInfo fi) const

Get the face velocity times density (used in advection terms)

Definition at line 287 of file RhieChowMassFlux.C.

Referenced by LinearFVEnergyAdvection::setupFaceData(), LinearFVTurbulentAdvection::setupFaceData(), LinearWCNSFV2PMomentumDriftFlux::setupFaceData(), and LinearWCNSFVMomentumFlux::setupFaceData().

288 {
289  return _face_mass_flux.evaluate(&fi);
290 }
ValueType evaluate(const FaceInfo *const fi) const
Evaluate the face functor using a FaceInfo argument.
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.

◆ getVolumetricFaceFlux() [1/2]

Real RhieChowMassFlux::getVolumetricFaceFlux ( const FaceInfo fi) const

Get the volumetric face flux (used in advection terms)

Definition at line 293 of file RhieChowMassFlux.C.

Referenced by LinearFVScalarAdvection::setupFaceData().

294 {
295  const Moose::FaceArg face_arg{&fi,
297  /*elem_is_upwind=*/true,
298  /*correct_skewness=*/false,
299  &fi.elem(),
300  /*state_limiter*/ nullptr};
301  const Real face_rho = _rho(face_arg, Moose::currentState());
302  return libmesh_map_find(_face_mass_flux, fi.id()) / face_rho;
303 }
const Elem & elem() const
const Moose::Functor< Real > & _rho
Functor describing the density of the fluid.
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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
dof_id_type id() const
StateArg currentState()

◆ getVolumetricFaceFlux() [2/2]

virtual Real RhieChowMassFlux::getVolumetricFaceFlux ( const Moose::FV::InterpMethod  m,
const FaceInfo fi,
const Moose::StateArg time,
const THREAD_ID  tid,
bool  subtract_mesh_velocity 
) const
overridevirtual

Retrieve the volumetric face flux, will not include derivatives.

Parameters
mThe velocity interpolation method. This is either Rhie-Chow or Average. Rhie-Chow is recommended as it avoids checkerboards in the pressure field
fiThe face that we wish to retrieve the velocity for
tidThe thread ID
Returns
The face velocity

Implements RhieChowFaceFluxProvider.

◆ hasFaceSide()

bool RhieChowFaceFluxProvider::hasFaceSide ( const FaceInfo fi,
const bool  fi_elem_side 
) const
overridevirtualinherited

Implements FaceArgInterface.

Definition at line 29 of file RhieChowFaceFluxProvider.C.

30 {
31  if (fi_elem_side)
32  return hasBlocks(fi.elem().subdomain_id());
33  else
34  return fi.neighborPtr() && hasBlocks(fi.neighbor().subdomain_id());
35 }
const Elem & elem() const
const Elem * neighborPtr() const
const Elem & neighbor() const
subdomain_id_type subdomain_id() const
bool hasBlocks(const SubdomainName &name) const

◆ initCouplingField()

void RhieChowMassFlux::initCouplingField ( )

Initialize the coupling fields (HbyA and Ainv)

Definition at line 413 of file RhieChowMassFlux.C.

Referenced by LinearAssemblySegregatedSolve::linkRhieChowUserObject().

414 {
415  // We loop through the faces and populate the coupling fields (face H/A and 1/H)
416  // with 0s for now. Pressure corrector solves will always come after the
417  // momentum source so we expect these fields to change before the actual solve.
418  for (auto & fi : _fe_problem.mesh().faceInfo())
419  {
420  _Ainv[fi->id()];
421  _HbyA_flux[fi->id()];
422  }
423 }
FaceCenteredMapFunctor< RealVectorValue, std::unordered_map< dof_id_type, RealVectorValue > > _Ainv
A map functor from faces to $(1/A)_f$.
const std::vector< const FaceInfo *> & faceInfo() const
FaceCenteredMapFunctor< Real, std::unordered_map< dof_id_type, Real > > _HbyA_flux
A map functor from faces to $HbyA_{ij} = (A_{offdiag}*{(predicted~velocity)} - {Source})_{ij}/A_{ij}$...
FEProblemBase & _fe_problem
virtual MooseMesh & mesh() override

◆ initFaceMassFlux()

void RhieChowMassFlux::initFaceMassFlux ( )

Initialize the container for face velocities.

Definition at line 236 of file RhieChowMassFlux.C.

Referenced by LinearAssemblySegregatedSolve::linkRhieChowUserObject().

237 {
238  using namespace Moose::FV;
239 
240  const auto time_arg = Moose::currentState();
241 
242  // We loop through the faces and compute the resulting face fluxes from the
243  // initial conditions for velocity
244  for (auto & fi : _flow_face_info)
245  {
246  RealVectorValue density_times_velocity;
247 
248  // On internal face we do a regular interpolation with geometric weights
249  if (_vel[0]->isInternalFace(*fi))
250  {
251  const auto & elem_info = *fi->elemInfo();
252  const auto & neighbor_info = *fi->neighborInfo();
253 
254  Real elem_rho = _rho(makeElemArg(fi->elemPtr()), time_arg);
255  Real neighbor_rho = _rho(makeElemArg(fi->neighborPtr()), time_arg);
256 
257  for (const auto dim_i : index_range(_vel))
258  interpolate(InterpMethod::Average,
259  density_times_velocity(dim_i),
260  _vel[dim_i]->getElemValue(elem_info, time_arg) * elem_rho,
261  _vel[dim_i]->getElemValue(neighbor_info, time_arg) * neighbor_rho,
262  *fi,
263  true);
264  }
265  // On the boundary, we just take the boundary values
266  else
267  {
268  const bool elem_is_fluid = hasBlocks(fi->elemPtr()->subdomain_id());
269  const Elem * const boundary_elem = elem_is_fluid ? fi->elemPtr() : fi->neighborPtr();
270 
271  // We need this multiplier in case the face is an internal face and
272  const Real boundary_normal_multiplier = elem_is_fluid ? 1.0 : -1.0;
273  const Moose::FaceArg boundary_face{
274  fi, Moose::FV::LimiterType::CentralDifference, true, false, boundary_elem, nullptr};
275 
276  const Real face_rho = _rho(boundary_face, time_arg);
277  for (const auto dim_i : index_range(_vel))
278  density_times_velocity(dim_i) = boundary_normal_multiplier * face_rho *
279  raw_value((*_vel[dim_i])(boundary_face, time_arg));
280  }
281 
282  _face_mass_flux[fi->id()] = density_times_velocity * fi->normal();
283  }
284 }
auto raw_value(const Eigen::Map< T > &in)
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
std::vector< const MooseLinearVariableFVReal * > _vel
The thread 0 copy of the x-velocity variable.
const Moose::Functor< Real > & _rho
Functor describing the density of the fluid.
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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< const FaceInfo * > _flow_face_info
The subset of the FaceInfo objects that actually cover the subdomains which the flow field is defined...
bool hasBlocks(const SubdomainName &name) const
void interpolate(InterpMethod m, T &result, const T2 &value1, const T3 &value2, const FaceInfo &fi, const bool one_is_elem)
StateArg currentState()
auto index_range(const T &sizable)

◆ initialize()

void RhieChowMassFlux::initialize ( )
overridevirtual

Implements GeneralUserObject.

Definition at line 226 of file RhieChowMassFlux.C.

227 {
228  for (const auto & pair : _HbyA_flux)
229  _HbyA_flux[pair.first] = 0;
230 
231  for (const auto & pair : _Ainv)
232  _Ainv[pair.first] = 0;
233 }
FaceCenteredMapFunctor< RealVectorValue, std::unordered_map< dof_id_type, RealVectorValue > > _Ainv
A map functor from faces to $(1/A)_f$.
FaceCenteredMapFunctor< Real, std::unordered_map< dof_id_type, Real > > _HbyA_flux
A map functor from faces to $HbyA_{ij} = (A_{offdiag}*{(predicted~velocity)} - {Source})_{ij}/A_{ij}$...

◆ initialSetup()

void RhieChowMassFlux::initialSetup ( )
overridevirtual

Reimplemented from GeneralUserObject.

Definition at line 147 of file RhieChowMassFlux.C.

148 {
149  // We fetch the pressure diffusion kernel to ensure that the face flux correction
150  // is consistent with the pressure discretization in the Poisson equation.
151  std::vector<LinearFVFluxKernel *> flux_kernel;
152  auto base_query = _fe_problem.theWarehouse()
153  .query()
154  .template condition<AttribThread>(_tid)
155  .template condition<AttribSysNum>(_p->sys().number())
156  .template condition<AttribSystem>("LinearFVFluxKernel")
157  .template condition<AttribName>(getParam<std::string>("p_diffusion_kernel"))
158  .queryInto(flux_kernel);
159  if (flux_kernel.size() != 1)
160  paramError(
161  "p_diffusion_kernel",
162  "The kernel with the given name could not be found or multiple instances were identified.");
163  _p_diffusion_kernel = dynamic_cast<LinearFVAnisotropicDiffusion *>(flux_kernel[0]);
164  if (!_p_diffusion_kernel)
165  paramError("p_diffusion_kernel",
166  "The provided diffusion kernel should of type LinearFVAnisotropicDiffusion!");
167 
168  // We fetch the body forces kernel to ensure that the face flux correction
169  // is accurate.
170 
171  // Check if components match the dimension.
172 
173  if (!_body_force_kernel_names.empty())
174  {
175  if (_body_force_kernel_names.size() != _dim)
176  paramError("body_force_kernel_names",
177  "The dimension of the body force vector does not match the problem dimension.");
178 
179  _body_force_kernels.resize(_dim);
180 
181  for (const auto dim_i : make_range(_dim))
182  for (const auto & force_name : _body_force_kernel_names[dim_i])
183  {
184  std::vector<LinearFVElementalKernel *> temp_storage;
185  auto base_query_force = _fe_problem.theWarehouse()
186  .query()
187  .template condition<AttribThread>(_tid)
188  .template condition<AttribSysNum>(_vel[dim_i]->sys().number())
189  .template condition<AttribSystem>("LinearFVElementalKernel")
190  .template condition<AttribName>(force_name)
191  .queryInto(temp_storage);
192  if (temp_storage.size() != 1)
193  paramError("body_force_kernel_names",
194  "The kernel with the given name: " + force_name +
195  " could not be found or multiple instances were identified.");
196  _body_force_kernels[dim_i].push_back(temp_storage[0]);
197  }
198  }
199 }
void paramError(const std::string &param, Args... args) const
std::vector< std::vector< std::string > > _body_force_kernel_names
Vector of body force term names.
std::vector< std::vector< LinearFVElementalKernel * > > _body_force_kernels
Pointer to the body force terms.
TheWarehouse & theWarehouse() const
std::vector< const MooseLinearVariableFVReal * > _vel
The thread 0 copy of the x-velocity variable.
const MooseLinearVariableFVReal *const _p
The thread 0 copy of the pressure variable.
unsigned int number() const
FEProblemBase & _fe_problem
Query query()
const THREAD_ID _tid
IntRange< T > make_range(T beg, T end)
LinearFVAnisotropicDiffusion * _p_diffusion_kernel
Pointer to the pressure diffusion term in the pressure Poisson equation.
const unsigned int _dim
The dimension of the mesh, e.g. 3 for hexes and tets, 2 for quads and tris.

◆ linkMomentumPressureSystems()

void RhieChowMassFlux::linkMomentumPressureSystems ( const std::vector< LinearSystem *> &  momentum_systems,
const LinearSystem pressure_system,
const std::vector< unsigned int > &  momentum_system_numbers 
)

Update the momentum system-related information.

Parameters
momentum_systemsPointers to the momentum systems which are solved for the momentum vector components
pressure_systemReference to the pressure system
momentum_system_numbersThe numbers of these systems

Definition at line 117 of file RhieChowMassFlux.C.

Referenced by LinearAssemblySegregatedSolve::linkRhieChowUserObject().

121 {
122  _momentum_systems = momentum_systems;
123  _momentum_system_numbers = momentum_system_numbers;
124  _pressure_system = &pressure_system;
126 
128  for (auto & system : _momentum_systems)
129  {
130  _global_momentum_system_numbers.push_back(system->number());
131  _momentum_implicit_systems.push_back(dynamic_cast<LinearImplicitSystem *>(&system->system()));
132  }
133 
135 }
std::vector< LinearSystem * > _momentum_systems
Pointers to the linear system(s) in moose corresponding to the momentum equation(s) ...
void setupMeshInformation()
Compute the cell volumes on the mesh.
std::vector< libMesh::LinearImplicitSystem * > _momentum_implicit_systems
Pointers to the momentum equation implicit system(s) from libmesh.
const LinearSystem * _pressure_system
Pointer to the pressure system.
std::vector< unsigned int > _momentum_system_numbers
Numbers of the momentum system(s)
std::vector< unsigned int > _global_momentum_system_numbers
Global numbers of the momentum system(s)
unsigned int _global_pressure_system_number
Global number of the pressure system.
unsigned int number() const

◆ meshChanged()

void RhieChowMassFlux::meshChanged ( )
overridevirtual

Reimplemented from GeneralUserObject.

Definition at line 138 of file RhieChowMassFlux.C.

139 {
140  _HbyA_flux.clear();
141  _Ainv.clear();
142  _face_mass_flux.clear();
144 }
void setupMeshInformation()
Compute the cell volumes on the mesh.
FaceCenteredMapFunctor< RealVectorValue, std::unordered_map< dof_id_type, RealVectorValue > > _Ainv
A map functor from faces to $(1/A)_f$.
FaceCenteredMapFunctor< Real, std::unordered_map< dof_id_type, Real > > _HbyA_flux
A map functor from faces to $HbyA_{ij} = (A_{offdiag}*{(predicted~velocity)} - {Source})_{ij}/A_{ij}$...
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.

◆ populateCouplingFunctors()

void RhieChowMassFlux::populateCouplingFunctors ( const std::vector< std::unique_ptr< NumericVector< Number >>> &  raw_hbya,
const std::vector< std::unique_ptr< NumericVector< Number >>> &  raw_Ainv 
)
protected

Populate the face values of the H/A and 1/A fields.

Definition at line 426 of file RhieChowMassFlux.C.

Referenced by computeHbyA().

429 {
430  // We have the raw H/A and 1/A vectors in a petsc format. This function
431  // will create face functors from them
432  using namespace Moose::FV;
433  const auto time_arg = Moose::currentState();
434 
435  // Create the petsc vector readers for faster repeated access
436  std::vector<PetscVectorReader> hbya_reader;
437  for (const auto dim_i : index_range(raw_hbya))
438  hbya_reader.emplace_back(*raw_hbya[dim_i]);
439 
440  std::vector<PetscVectorReader> ainv_reader;
441  for (const auto dim_i : index_range(raw_Ainv))
442  ainv_reader.emplace_back(*raw_Ainv[dim_i]);
443 
444  // We loop through the faces and populate the coupling fields (face H/A and 1/H)
445  for (auto & fi : _flow_face_info)
446  {
447  Real face_rho = 0;
448  RealVectorValue face_hbya;
449 
450  // We do the lookup in advance
451  auto & Ainv = _Ainv[fi->id()];
452 
453  // If it is internal, we just interpolate (using geometric weights) to the face
454  if (_vel[0]->isInternalFace(*fi))
455  {
456  // Get the dof indices for the element and the neighbor
457  const auto & elem_info = *fi->elemInfo();
458  const auto & neighbor_info = *fi->neighborInfo();
459  const auto elem_dof = elem_info.dofIndices()[_global_momentum_system_numbers[0]][0];
460  const auto neighbor_dof = neighbor_info.dofIndices()[_global_momentum_system_numbers[0]][0];
461 
462  // Get the density values for the element and neighbor. We need this multiplication to make
463  // the coupling fields mass fluxes.
464  const Real elem_rho = _rho(makeElemArg(fi->elemPtr()), time_arg);
465  const Real neighbor_rho = _rho(makeElemArg(fi->neighborPtr()), time_arg);
466 
467  // Now we do the interpolation to the face
468  interpolate(Moose::FV::InterpMethod::Average, face_rho, elem_rho, neighbor_rho, *fi, true);
469  for (const auto dim_i : index_range(raw_hbya))
470  {
472  face_hbya(dim_i),
473  hbya_reader[dim_i](elem_dof),
474  hbya_reader[dim_i](neighbor_dof),
475  *fi,
476  true);
477  interpolate(InterpMethod::Average,
478  Ainv(dim_i),
479  elem_rho * ainv_reader[dim_i](elem_dof),
480  neighbor_rho * ainv_reader[dim_i](neighbor_dof),
481  *fi,
482  true);
483  }
484  }
485  else
486  {
487  const bool elem_is_fluid = hasBlocks(fi->elemPtr()->subdomain_id());
488 
489  // We need this multiplier in case the face is an internal face and
490  const Real boundary_normal_multiplier = elem_is_fluid ? 1.0 : -1.0;
491 
492  const ElemInfo & elem_info = elem_is_fluid ? *fi->elemInfo() : *fi->neighborInfo();
493  const auto elem_dof = elem_info.dofIndices()[_global_momentum_system_numbers[0]][0];
494 
495  // If it is a Dirichlet BC, we use the dirichlet value the make sure the face flux
496  // is consistent
497  if (_vel[0]->isDirichletBoundaryFace(*fi))
498  {
499  const Moose::FaceArg boundary_face{
500  fi, Moose::FV::LimiterType::CentralDifference, true, false, elem_info.elem(), nullptr};
501  face_rho = _rho(boundary_face, Moose::currentState());
502 
503  for (const auto dim_i : make_range(_dim))
504  {
505 
506  face_hbya(dim_i) =
507  -MetaPhysicL::raw_value((*_vel[dim_i])(boundary_face, Moose::currentState()));
508 
509  if (!_body_force_kernel_names.empty())
510  for (const auto & force_kernel : _body_force_kernels[dim_i])
511  {
512  force_kernel->setCurrentElemInfo(&elem_info);
513  face_hbya(dim_i) -= force_kernel->computeRightHandSideContribution() *
514  ainv_reader[dim_i](elem_dof) /
515  elem_info.volume(); // zero-term expansion
516  }
517  face_hbya(dim_i) *= boundary_normal_multiplier;
518  }
519  }
520  // Otherwise we just do a one-term expansion (so we just use the element value)
521  else
522  {
523  const auto elem_dof = elem_info.dofIndices()[_global_momentum_system_numbers[0]][0];
524 
525  face_rho = _rho(makeElemArg(elem_info.elem()), time_arg);
526  for (const auto dim_i : make_range(_dim))
527  face_hbya(dim_i) = boundary_normal_multiplier * hbya_reader[dim_i](elem_dof);
528  }
529 
530  // We just do a one-term expansion for 1/A no matter what
531  const Real elem_rho = _rho(makeElemArg(elem_info.elem()), time_arg);
532  for (const auto dim_i : index_range(raw_Ainv))
533  Ainv(dim_i) = elem_rho * ainv_reader[dim_i](elem_dof);
534  }
535  // Lastly, we populate the face flux resulted by H/A
536  _HbyA_flux[fi->id()] = face_hbya * fi->normal() * face_rho;
537  }
538 }
const Elem * elem() const
auto raw_value(const Eigen::Map< T > &in)
FaceCenteredMapFunctor< RealVectorValue, std::unordered_map< dof_id_type, RealVectorValue > > _Ainv
A map functor from faces to $(1/A)_f$.
std::vector< unsigned int > _global_momentum_system_numbers
Global numbers of the momentum system(s)
Moose::ElemArg makeElemArg(const Elem *elem, bool correct_skewnewss=false) const
std::vector< std::vector< std::string > > _body_force_kernel_names
Vector of body force term names.
FaceCenteredMapFunctor< Real, std::unordered_map< dof_id_type, Real > > _HbyA_flux
A map functor from faces to $HbyA_{ij} = (A_{offdiag}*{(predicted~velocity)} - {Source})_{ij}/A_{ij}$...
std::vector< std::vector< LinearFVElementalKernel * > > _body_force_kernels
Pointer to the body force terms.
std::vector< const MooseLinearVariableFVReal * > _vel
The thread 0 copy of the x-velocity variable.
const Moose::Functor< Real > & _rho
Functor describing the density of the fluid.
const std::vector< std::vector< dof_id_type > > & dofIndices() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
std::vector< const FaceInfo * > _flow_face_info
The subset of the FaceInfo objects that actually cover the subdomains which the flow field is defined...
bool hasBlocks(const SubdomainName &name) const
void interpolate(InterpMethod m, T &result, const T2 &value1, const T3 &value2, const FaceInfo &fi, const bool one_is_elem)
StateArg currentState()
auto index_range(const T &sizable)
Real volume() const
const unsigned int _dim
The dimension of the mesh, e.g. 3 for hexes and tets, 2 for quads and tris.

◆ selectPressureGradient()

std::vector< std::unique_ptr< NumericVector< Number > > > & RhieChowMassFlux::selectPressureGradient ( const bool  updated_pressure)
protected

Select the right pressure gradient field and return a reference to the container.

Definition at line 716 of file RhieChowMassFlux.C.

Referenced by computeHbyA().

717 {
718  if (updated_pressure)
719  {
720  _grad_p_current.clear();
721  for (const auto & component : _pressure_system->gradientContainer())
722  _grad_p_current.push_back(component->clone());
723  }
724 
725  return _grad_p_current;
726 }
const std::vector< std::unique_ptr< NumericVector< Number > > > & gradientContainer() const
static const std::string component
Definition: NS.h:153
const LinearSystem * _pressure_system
Pointer to the pressure system.
std::vector< std::unique_ptr< NumericVector< Number > > > _grad_p_current
for a PISO iteration we need to hold on to the original pressure gradient field.

◆ setupMeshInformation()

void RhieChowMassFlux::setupMeshInformation ( )
protected

Compute the cell volumes on the mesh.

Definition at line 202 of file RhieChowMassFlux.C.

Referenced by linkMomentumPressureSystems(), and meshChanged().

203 {
204  // We cache the cell volumes into a petsc vector for corrections here so we can use
205  // the optimized petsc operations for the normalization
207  for (const auto & elem_info : _fe_problem.mesh().elemInfoVector())
208  // We have to check this because the variable might not be defined on the given
209  // block
210  if (hasBlocks(elem_info->subdomain_id()))
211  {
212  const auto elem_dof = elem_info->dofIndices()[_global_pressure_system_number][0];
213  _cell_volumes->set(elem_dof, elem_info->volume() * elem_info->coordFactor());
214  }
215 
216  _cell_volumes->close();
217 
218  _flow_face_info.clear();
219  for (auto & fi : _fe_problem.mesh().faceInfo())
220  if (hasBlocks(fi->elemPtr()->subdomain_id()) ||
221  (fi->neighborPtr() && hasBlocks(fi->neighborPtr()->subdomain_id())))
222  _flow_face_info.push_back(fi);
223 }
const std::vector< const ElemInfo *> & elemInfoVector() const
virtual std::unique_ptr< NumericVector< T > > zero_clone() const=0
const LinearSystem * _pressure_system
Pointer to the pressure system.
const std::vector< const FaceInfo *> & faceInfo() const
virtual const NumericVector< Number > *const & currentSolution() const override final
unsigned int _global_pressure_system_number
Global number of the pressure system.
FEProblemBase & _fe_problem
virtual MooseMesh & mesh() override
std::vector< const FaceInfo * > _flow_face_info
The subset of the FaceInfo objects that actually cover the subdomains which the flow field is defined...
bool hasBlocks(const SubdomainName &name) const
std::unique_ptr< NumericVector< Number > > _cell_volumes
We will hold a vector of cell volumes to make sure we can do volume corrections rapidly.

◆ supportMeshVelocity()

virtual bool RhieChowMassFlux::supportMeshVelocity ( ) const
inlineoverrideprotectedvirtual

Returns whether the UO can support mesh velocity advection.

Reimplemented from RhieChowFaceFluxProvider.

Definition at line 106 of file RhieChowMassFlux.h.

106 { return false; }

◆ validParams()

InputParameters RhieChowMassFlux::validParams ( )
static

Definition at line 32 of file RhieChowMassFlux.C.

33 {
36 
37  params.addClassDescription("Computes H/A and 1/A together with face mass fluxes for segregated "
38  "momentum-pressure equations using linear systems.");
39 
40  params.addRequiredParam<VariableName>(NS::pressure, "The pressure variable.");
41  params.addRequiredParam<VariableName>("u", "The x-component of velocity");
42  params.addParam<VariableName>("v", "The y-component of velocity");
43  params.addParam<VariableName>("w", "The z-component of velocity");
44  params.addRequiredParam<std::string>("p_diffusion_kernel",
45  "The diffusion kernel acting on the pressure.");
46  params.addParam<std::vector<std::vector<std::string>>>(
47  "body_force_kernel_names",
48  {},
49  "The body force kernel names."
50  "this double vector would have size index_x_dim: 'f1x f2x; f1y f2y; f1z f2z'");
51 
52  params.addRequiredParam<MooseFunctorName>(NS::density, "Density functor");
53 
54  // We disable the execution of this, should only provide functions
55  // for the SIMPLE executioner
56  ExecFlagEnum & exec_enum = params.set<ExecFlagEnum>("execute_on", true);
57  exec_enum.addAvailableFlags(EXEC_NONE);
58  exec_enum = {EXEC_NONE};
59  params.suppressParameter<ExecFlagEnum>("execute_on");
60 
61  // Pressure projection
62  params.addParam<MooseEnum>("pressure_projection_method",
63  MooseEnum("standard consistent", "standard"),
64  "The method to use in the pressure projection for Ainv - "
65  "standard (SIMPLE) or consistent (SIMPLEC)");
66  return params;
67 }
const ExecFlagType EXEC_NONE
static const std::string density
Definition: NS.h:33
void addAvailableFlags(const ExecFlagType &flag, Args... flags)
static InputParameters validParams()
static const std::string pressure
Definition: NS.h:56
static InputParameters validParams()

Member Data Documentation

◆ _Ainv

FaceCenteredMapFunctor<RealVectorValue, std::unordered_map<dof_id_type, RealVectorValue> > RhieChowMassFlux::_Ainv
protected

A map functor from faces to $(1/A)_f$.

Where $A_i$ is the diagonal of the system matrix for the momentum equation.

Definition at line 144 of file RhieChowMassFlux.h.

Referenced by initCouplingField(), initialize(), meshChanged(), populateCouplingFunctors(), and RhieChowMassFlux().

◆ _Ainv_raw

std::vector<std::unique_ptr<NumericVector<Number> > > RhieChowMassFlux::_Ainv_raw
protected

We hold on to the cell-based 1/A vectors so that we can easily reconstruct the cell velocities as well.

Definition at line 150 of file RhieChowMassFlux.h.

Referenced by computeCellVelocity(), and computeHbyA().

◆ _body_force_kernel_names

std::vector<std::vector<std::string> > RhieChowMassFlux::_body_force_kernel_names
protected

Vector of body force term names.

Definition at line 160 of file RhieChowMassFlux.h.

Referenced by initialSetup(), and populateCouplingFunctors().

◆ _body_force_kernels

std::vector<std::vector<LinearFVElementalKernel *> > RhieChowMassFlux::_body_force_kernels
protected

Pointer to the body force terms.

Definition at line 158 of file RhieChowMassFlux.h.

Referenced by initialSetup(), and populateCouplingFunctors().

◆ _cell_volumes

std::unique_ptr<NumericVector<Number> > RhieChowMassFlux::_cell_volumes
protected

We will hold a vector of cell volumes to make sure we can do volume corrections rapidly.

Definition at line 192 of file RhieChowMassFlux.h.

Referenced by computeHbyA(), and setupMeshInformation().

◆ _dim

const unsigned int RhieChowMassFlux::_dim
protected

The dimension of the mesh, e.g. 3 for hexes and tets, 2 for quads and tris.

Definition at line 115 of file RhieChowMassFlux.h.

Referenced by initialSetup(), and populateCouplingFunctors().

◆ _face_mass_flux

FaceCenteredMapFunctor<Real, std::unordered_map<dof_id_type, Real> >& RhieChowMassFlux::_face_mass_flux
protected

A map functor from faces to mass fluxes which are used in the advection terms.

Definition at line 155 of file RhieChowMassFlux.h.

Referenced by computeFaceMassFlux(), getMassFlux(), getVolumetricFaceFlux(), initFaceMassFlux(), and meshChanged().

◆ _flow_face_info

std::vector<const FaceInfo *> RhieChowMassFlux::_flow_face_info
private

The subset of the FaceInfo objects that actually cover the subdomains which the flow field is defined on.

Cached for performance optimization.

Definition at line 200 of file RhieChowMassFlux.h.

Referenced by computeFaceMassFlux(), initFaceMassFlux(), populateCouplingFunctors(), and setupMeshInformation().

◆ _global_momentum_system_numbers

std::vector<unsigned int> RhieChowMassFlux::_global_momentum_system_numbers
protected

Global numbers of the momentum system(s)

Definition at line 180 of file RhieChowMassFlux.h.

Referenced by linkMomentumPressureSystems(), and populateCouplingFunctors().

◆ _global_pressure_system_number

unsigned int RhieChowMassFlux::_global_pressure_system_number
protected

Global number of the pressure system.

Definition at line 189 of file RhieChowMassFlux.h.

Referenced by computeFaceMassFlux(), linkMomentumPressureSystems(), and setupMeshInformation().

◆ _grad_p_current

std::vector<std::unique_ptr<NumericVector<Number> > > RhieChowMassFlux::_grad_p_current
protected

for a PISO iteration we need to hold on to the original pressure gradient field.

Should not be used in other conditions.

Definition at line 166 of file RhieChowMassFlux.h.

Referenced by selectPressureGradient().

◆ _HbyA_flux

FaceCenteredMapFunctor<Real, std::unordered_map<dof_id_type, Real> > RhieChowMassFlux::_HbyA_flux
protected

A map functor from faces to $HbyA_{ij} = (A_{offdiag}*{(predicted~velocity)} - {Source})_{ij}/A_{ij}$.

So this contains the off-diagonal part of the system matrix multiplied by the predicted velocity minus the source terms from the right hand side of the linearized momentum predictor step.

Definition at line 132 of file RhieChowMassFlux.h.

Referenced by computeFaceMassFlux(), initCouplingField(), initialize(), meshChanged(), populateCouplingFunctors(), and RhieChowMassFlux().

◆ _HbyA_raw

std::vector<std::unique_ptr<NumericVector<Number> > > RhieChowMassFlux::_HbyA_raw
protected

We hold on to the cell-based HbyA vectors so that we can easily reconstruct the cell velocities as well.

Definition at line 138 of file RhieChowMassFlux.h.

Referenced by computeCellVelocity(), and computeHbyA().

◆ _mesh

const libMesh::MeshBase& RhieChowMassFlux::_mesh
protected

The libMesh mesh that this object acts on.

Definition at line 112 of file RhieChowMassFlux.h.

◆ _momentum_implicit_systems

std::vector<libMesh::LinearImplicitSystem *> RhieChowMassFlux::_momentum_implicit_systems
protected

Pointers to the momentum equation implicit system(s) from libmesh.

Definition at line 183 of file RhieChowMassFlux.h.

Referenced by computeCellVelocity(), computeHbyA(), and linkMomentumPressureSystems().

◆ _momentum_system_numbers

std::vector<unsigned int> RhieChowMassFlux::_momentum_system_numbers
protected

Numbers of the momentum system(s)

Definition at line 177 of file RhieChowMassFlux.h.

Referenced by linkMomentumPressureSystems().

◆ _momentum_systems

std::vector<LinearSystem *> RhieChowMassFlux::_momentum_systems
protected

Pointers to the linear system(s) in moose corresponding to the momentum equation(s)

Definition at line 174 of file RhieChowMassFlux.h.

Referenced by computeCellVelocity(), computeHbyA(), and linkMomentumPressureSystems().

◆ _moose_mesh

const MooseMesh& RhieChowMassFlux::_moose_mesh
protected

The MooseMesh that this user object operates on.

Definition at line 109 of file RhieChowMassFlux.h.

Referenced by checkBlocks().

◆ _p

const MooseLinearVariableFVReal* const RhieChowMassFlux::_p
protected

The thread 0 copy of the pressure variable.

Definition at line 118 of file RhieChowMassFlux.h.

Referenced by computeFaceMassFlux(), initialSetup(), and RhieChowMassFlux().

◆ _p_diffusion_kernel

LinearFVAnisotropicDiffusion* RhieChowMassFlux::_p_diffusion_kernel
protected

Pointer to the pressure diffusion term in the pressure Poisson equation.

Definition at line 124 of file RhieChowMassFlux.h.

Referenced by computeFaceMassFlux(), and initialSetup().

◆ _pressure_projection_method

const MooseEnum RhieChowMassFlux::_pressure_projection_method
protected

Enumerator for the method used for pressure projection.

Definition at line 195 of file RhieChowMassFlux.h.

Referenced by computeHbyA().

◆ _pressure_system

const LinearSystem* RhieChowMassFlux::_pressure_system
protected

◆ _rho

const Moose::Functor<Real>& RhieChowMassFlux::_rho
protected

Functor describing the density of the fluid.

Definition at line 171 of file RhieChowMassFlux.h.

Referenced by getVolumetricFaceFlux(), initFaceMassFlux(), and populateCouplingFunctors().

◆ _vel

std::vector<const MooseLinearVariableFVReal *> RhieChowMassFlux::_vel
protected

The thread 0 copy of the x-velocity variable.

Definition at line 121 of file RhieChowMassFlux.h.

Referenced by initFaceMassFlux(), initialSetup(), populateCouplingFunctors(), and RhieChowMassFlux().


The documentation for this class was generated from the following files: