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
 
virtual Real spatialValue (const Point &) const
 
virtual const std::vector< Point > spatialPoints () const
 
void setPrimaryThreadCopy (UserObject *primary)
 
UserObjectprimaryThreadCopy ()
 
SubProblemgetSubProblem () const
 
bool shouldDuplicateInitialExecution () 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)
 
std::set< UserObjectName > getDependObjects () const
 
const std::set< std::string > & getRequestedItems () override
 
const std::set< std::string > & getSuppliedItems () override
 
unsigned int systemNumber () const
 
virtual bool needThreadedCopy () const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
bool isKokkosObject () 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 TgetParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const TqueryParam (const std::string &name) const
 
const TgetRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T 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 mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) 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 TgetUserObject (const std::string &param_name, bool is_dependency=true) const
 
const TgetUserObjectByName (const UserObjectName &object_name, bool is_dependency=true) const
 
const UserObjectBasegetUserObjectBase (const std::string &param_name, bool is_dependency=true) const
 
const UserObjectBasegetUserObjectBaseByName (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)
 
std::pair< Moose::Kokkos::MaterialProperty< T, dimension >, std::set< SubdomainID > > getKokkosBlockMaterialProperty (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
 
Moose::Kokkos::Function getKokkosFunction (const std::string &name) const
 
const TgetKokkosFunction (const std::string &name) const
 
Moose::Kokkos::Function getKokkosFunctionByName (const FunctionName &name) const
 
const TgetKokkosFunctionByName (const FunctionName &name) const
 
bool hasKokkosFunction (const std::string &param_name) const
 
bool hasKokkosFunctionByName (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
 
TgetSampler (const std::string &name)
 
SamplergetSampler (const std::string &name)
 
TgetSamplerByName (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 TgetDistribution (const std::string &name) const
 
const DistributiongetDistribution (const std::string &name) const
 
const TgetDistribution (const std::string &name) const
 
const DistributiongetDistributionByName (const DistributionName &name) const
 
const TgetDistributionByName (const std::string &name) const
 
const DistributiongetDistributionByName (const DistributionName &name) const
 
const TgetDistributionByName (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, const bool show_trace=true)
 
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, NameFunc &&name_func)
 
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 UserObjectBase &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
 
TdeclareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< TdeclareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const TgetRestartableData (const std::string &data_name) const
 
TdeclareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
TdeclareRecoverableData (const std::string &data_name, Args &&... args)
 
TdeclareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
TdeclareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 
std::string restartableName (const std::string &data_name) const
 
const TgetMeshProperty (const std::string &data_name, const std::string &prefix)
 
const TgetMeshProperty (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 TgetReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const TgetReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const TgetReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const TgetReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const TgetReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const TgetReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
const TgetReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const TgetReporterValueByName (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 ()
 
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 (Moose::Kokkos::ThreadID tid) const
 
KOKKOS_FUNCTION ContiguousElementID kokkosBlockNodeID (Moose::Kokkos::ThreadID tid) const
 
KOKKOS_FUNCTION auto kokkosBlockElementSideID (Moose::Kokkos::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)
 
const Moose::Functor< T > & getFunctorByName (const std::string &name)
 

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...
 
LinearFVPressureCorrectionDiffusion_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...
 
std::unique_ptr< NumericVector< Number > > _A_avg
 
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...
 
const Moose::FV::InterpMethod _pressure_diffusion_interp_method
 Interpolation method used for the pressure diffusion coefficient on faces. More...
 
const Moose::CoordinateSystemType_coord_sys
 
const THREAD_ID _tid
 
SubProblem_subproblem
 
FEProblemBase_fe_problem
 
SystemBase_sys
 
Assembly_assembly
 
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 75 of file RhieChowMassFlux.C.

76  : RhieChowFaceFluxProvider(params),
81  _p(dynamic_cast<MooseLinearVariableFVReal *>(
82  &UserObject::_subproblem.getVariable(0, getParam<VariableName>(NS::pressure)))),
83  _vel(_dim, nullptr),
84  _HbyA_flux(_moose_mesh, blockIDs(), "HbyA_flux"),
85  _Ainv(_moose_mesh, blockIDs(), "Ainv"),
87  declareRestartableData<FaceCenteredMapFunctor<Real, std::unordered_map<dof_id_type, Real>>>(
88  "face_flux", _moose_mesh, blockIDs(), "face_values")),
90  getParam<std::vector<std::vector<std::string>>>("body_force_kernel_names")),
91  _rho(getFunctor<Real>(NS::density)),
92  _pressure_projection_method(getParam<MooseEnum>("pressure_projection_method")),
93  _pressure_diffusion_interp_method(getParam<MooseEnum>("pressure_diffusion_interpolation") ==
94  "harmonic"
97 {
98  if (!_p)
99  paramError(NS::pressure, "the pressure must be a MooseLinearVariableFVReal.");
100  checkBlocks(*_p);
101 
102  std::vector<std::string> vel_names = {"u", "v", "w"};
103  for (const auto i : index_range(_vel))
104  {
105  _vel[i] = dynamic_cast<MooseLinearVariableFVReal *>(
106  &UserObject::_subproblem.getVariable(0, getParam<VariableName>(vel_names[i])));
107 
108  if (!_vel[i])
109  paramError(vel_names[i], "the velocity must be a MOOSELinearVariableFVReal.");
110  checkBlocks(*_vel[i]);
111  }
112 
113  // Register the elemental/face functors which will be queried in the pressure equation
114  for (const auto tid : make_range(libMesh::n_threads()))
115  {
118  }
119 
120  if (!dynamic_cast<SIMPLE *>(getMooseApp().getExecutioner()) &&
121  !dynamic_cast<PIMPLE *>(getMooseApp().getExecutioner()))
122  mooseError(this->name(),
123  " should only be used with a linear segregated thermal-hydraulics solver!");
124 }
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:34
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
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.
const Moose::FV::InterpMethod _pressure_diffusion_interp_method
Interpolation method used for the pressure diffusion coefficient on faces.
SubProblem & _subproblem
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:57
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 210 of file RhieChowMassFlux.h.

Referenced by RhieChowMassFlux().

211 {
212  const auto & var_blocks = var.blockIDs();
213  const auto & uo_blocks = blockIDs();
214 
215  // Error if this UO has any blocks that the variable does not
216  std::set<SubdomainID> uo_blocks_minus_var_blocks;
217  std::set_difference(uo_blocks.begin(),
218  uo_blocks.end(),
219  var_blocks.begin(),
220  var_blocks.end(),
221  std::inserter(uo_blocks_minus_var_blocks, uo_blocks_minus_var_blocks.end()));
222  if (uo_blocks_minus_var_blocks.size() > 0)
223  mooseError("Block restriction of interpolator user object '",
224  this->name(),
225  "' (",
227  ") includes blocks not in the block restriction of variable '",
228  var.name(),
229  "' (",
230  Moose::stringify(var.blocks()),
231  ")");
232 
233  // Get the blocks in the variable but not this UO
234  std::set<SubdomainID> var_blocks_minus_uo_blocks;
235  std::set_difference(var_blocks.begin(),
236  var_blocks.end(),
237  uo_blocks.begin(),
238  uo_blocks.end(),
239  std::inserter(var_blocks_minus_uo_blocks, var_blocks_minus_uo_blocks.end()));
240 
241  // For each block in the variable but not this UO, error if there is connection
242  // to any blocks on the UO.
243  for (auto & block_id : var_blocks_minus_uo_blocks)
244  {
245  const auto connected_blocks = _moose_mesh.getBlockConnectedBlocks(block_id);
246  std::set<SubdomainID> connected_blocks_on_uo;
247  std::set_intersection(connected_blocks.begin(),
248  connected_blocks.end(),
249  uo_blocks.begin(),
250  uo_blocks.end(),
251  std::inserter(connected_blocks_on_uo, connected_blocks_on_uo.end()));
252  if (connected_blocks_on_uo.size() > 0)
253  mooseError("Block restriction of interpolator user object '",
254  this->name(),
255  "' (",
256  Moose::stringify(uo_blocks),
257  ") doesn't match the block restriction of variable '",
258  var.name(),
259  "' (",
260  Moose::stringify(var_blocks),
261  ")");
262  }
263 }
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 404 of file RhieChowMassFlux.C.

Referenced by LinearAssemblySegregatedSolve::correctVelocity().

405 {
406  auto & pressure_gradient = _pressure_system->linearFVGradientContainer();
407 
408  // We set the dof value in the solution vector the same logic applies:
409  // u_C = -(H/A)_C - (1/A)_C*grad(p)_C where C is the cell index
410  for (const auto system_i : index_range(_momentum_implicit_systems))
411  {
412  auto working_vector = _Ainv_raw[system_i]->clone();
413  working_vector->pointwise_mult(*working_vector, *pressure_gradient[system_i]);
414  working_vector->add(*_HbyA_raw[system_i]);
415  working_vector->scale(-1.0);
416  (*_momentum_implicit_systems[system_i]->solution) = *working_vector;
417  _momentum_implicit_systems[system_i]->update();
418  _momentum_systems[system_i]->setSolution(
419  *_momentum_implicit_systems[system_i]->current_local_solution);
420  }
421 }
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.
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...
const std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > & linearFVGradientContainer() const

◆ computeFaceMassFlux()

void RhieChowMassFlux::computeFaceMassFlux ( )

Update the values of the face velocities in the containers.

Definition at line 334 of file RhieChowMassFlux.C.

Referenced by LinearAssemblySegregatedSolve::correctVelocity().

335 {
336  using namespace Moose::FV;
337 
338  const auto time_arg = Moose::currentState();
339 
340  // Petsc vector reader to make the repeated reading from the vector faster
342 
343  // We loop through the faces and compute the face fluxes using the pressure gradient
344  // and the momentum matrix/right hand side
345  for (auto & fi : _flow_face_info)
346  {
347  // Making sure the kernel knows which face we are on
349 
350  // We are setting this to 1.0 because we don't want to multiply the kernel contributions
351  // with the surface area yet. The surface area will be factored in in the advection kernels.
353 
354  Real p_grad_flux = 0.0;
355  if (_p->isInternalFace(*fi))
356  {
357  const auto & elem_info = *fi->elemInfo();
358  const auto & neighbor_info = *fi->neighborInfo();
359 
360  // Fetching the dof indices for the pressure variable
361  const auto elem_dof = elem_info.dofIndices()[_global_pressure_system_number][0];
362  const auto neighbor_dof = neighbor_info.dofIndices()[_global_pressure_system_number][0];
363 
364  // Fetching the values of the pressure for the element and the neighbor
365  const auto p_elem_value = p_reader(elem_dof);
366  const auto p_neighbor_value = p_reader(neighbor_dof);
367 
368  // Compute the elem matrix contributions for the face
369  const auto elem_matrix_contribution = _p_diffusion_kernel->computeElemMatrixContribution();
370  const auto neighbor_matrix_contribution =
372  const auto elem_rhs_contribution =
374 
375  // Compute the face flux from the matrix and right hand side contributions
376  p_grad_flux = (p_neighbor_value * neighbor_matrix_contribution +
377  p_elem_value * elem_matrix_contribution) -
378  elem_rhs_contribution;
379  }
380  else if (auto * bc_pointer = _p->getBoundaryCondition(*fi->boundaryIDs().begin()))
381  {
382  mooseAssert(fi->boundaryIDs().size() == 1, "We should only have one boundary on every face.");
383 
384  bc_pointer->setupFaceData(
385  fi, fi->faceType(std::make_pair(_p->number(), _global_pressure_system_number)));
386 
387  const ElemInfo & elem_info =
388  hasBlocks(fi->elemPtr()->subdomain_id()) ? *fi->elemInfo() : *fi->neighborInfo();
389  const auto p_elem_value = _p->getElemValue(elem_info, time_arg);
390  const auto matrix_contribution =
392  const auto rhs_contribution =
394 
395  // On the boundary, only the element side has a contribution
396  p_grad_flux = (p_elem_value * matrix_contribution - rhs_contribution);
397  }
398  // Compute the new face flux
399  _face_mass_flux[fi->id()] = -_HbyA_flux[fi->id()] + p_grad_flux;
400  }
401 }
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
LinearFVPressureCorrectionDiffusion * _p_diffusion_kernel
Pointer to the pressure diffusion term in the pressure Poisson equation.
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()
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 552 of file RhieChowMassFlux.C.

Referenced by LinearAssemblySegregatedSolve::correctVelocity().

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

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

299 {
300  return _face_mass_flux.evaluate(&fi);
301 }
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 304 of file RhieChowMassFlux.C.

Referenced by LinearFVScalarAdvection::setupFaceData().

305 {
306  const Moose::FaceArg face_arg{&fi,
308  /*elem_is_upwind=*/true,
309  /*correct_skewness=*/false,
310  &fi.elem(),
311  /*state_limiter*/ nullptr};
312  const Real face_rho = _rho(face_arg, Moose::currentState());
313  return libmesh_map_find(_face_mass_flux, fi.id()) / face_rho;
314 }
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 424 of file RhieChowMassFlux.C.

Referenced by LinearAssemblySegregatedSolve::linkRhieChowUserObject().

425 {
426  // We loop through the faces and populate the coupling fields (face H/A and 1/H)
427  // with 0s for now. Pressure corrector solves will always come after the
428  // momentum source so we expect these fields to change before the actual solve.
429  for (auto & fi : _fe_problem.mesh().faceInfo())
430  {
431  _Ainv[fi->id()];
432  _HbyA_flux[fi->id()];
433  }
434 }
FaceCenteredMapFunctor< RealVectorValue, std::unordered_map< dof_id_type, RealVectorValue > > _Ainv
A map functor from faces to $(1/A)_f$.
FEProblemBase & _fe_problem
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}$...
virtual MooseMesh & mesh() override

◆ initFaceMassFlux()

void RhieChowMassFlux::initFaceMassFlux ( )

Initialize the container for face velocities.

Definition at line 247 of file RhieChowMassFlux.C.

Referenced by LinearAssemblySegregatedSolve::linkRhieChowUserObject().

248 {
249  using namespace Moose::FV;
250 
251  const auto time_arg = Moose::currentState();
252 
253  // We loop through the faces and compute the resulting face fluxes from the
254  // initial conditions for velocity
255  for (auto & fi : _flow_face_info)
256  {
257  RealVectorValue density_times_velocity;
258 
259  // On internal face we do a regular interpolation with geometric weights
260  if (_vel[0]->isInternalFace(*fi))
261  {
262  const auto & elem_info = *fi->elemInfo();
263  const auto & neighbor_info = *fi->neighborInfo();
264 
265  Real elem_rho = _rho(makeElemArg(fi->elemPtr()), time_arg);
266  Real neighbor_rho = _rho(makeElemArg(fi->neighborPtr()), time_arg);
267 
268  for (const auto dim_i : index_range(_vel))
269  interpolate(InterpMethod::Average,
270  density_times_velocity(dim_i),
271  _vel[dim_i]->getElemValue(elem_info, time_arg) * elem_rho,
272  _vel[dim_i]->getElemValue(neighbor_info, time_arg) * neighbor_rho,
273  *fi,
274  true);
275  }
276  // On the boundary, we just take the boundary values
277  else
278  {
279  const bool elem_is_fluid = hasBlocks(fi->elemPtr()->subdomain_id());
280  const Elem * const boundary_elem = elem_is_fluid ? fi->elemPtr() : fi->neighborPtr();
281 
282  // We need this multiplier in case the face is an internal face and
283  const Real boundary_normal_multiplier = elem_is_fluid ? 1.0 : -1.0;
284  const Moose::FaceArg boundary_face{
285  fi, Moose::FV::LimiterType::CentralDifference, true, false, boundary_elem, nullptr};
286 
287  const Real face_rho = _rho(boundary_face, time_arg);
288  for (const auto dim_i : index_range(_vel))
289  density_times_velocity(dim_i) = boundary_normal_multiplier * face_rho *
290  raw_value((*_vel[dim_i])(boundary_face, time_arg));
291  }
292 
293  _face_mass_flux[fi->id()] = density_times_velocity * fi->normal();
294  }
295 }
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 237 of file RhieChowMassFlux.C.

238 {
239  for (const auto & pair : _HbyA_flux)
240  _HbyA_flux[pair.first] = 0;
241 
242  for (const auto & pair : _Ainv)
243  _Ainv[pair.first] = 0;
244 }
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 157 of file RhieChowMassFlux.C.

158 {
159  // We fetch the pressure diffusion kernel to ensure that the face flux correction
160  // is consistent with the pressure discretization in the Poisson equation.
161  std::vector<LinearFVFluxKernel *> flux_kernel;
162  auto base_query = _fe_problem.theWarehouse()
163  .query()
164  .template condition<AttribThread>(_tid)
165  .template condition<AttribSysNum>(_p->sys().number())
166  .template condition<AttribSystem>("LinearFVFluxKernel")
167  .template condition<AttribName>(getParam<std::string>("p_diffusion_kernel"))
168  .queryInto(flux_kernel);
169  if (flux_kernel.size() != 1)
170  paramError(
171  "p_diffusion_kernel",
172  "The kernel with the given name could not be found or multiple instances were identified.");
173  _p_diffusion_kernel = dynamic_cast<LinearFVPressureCorrectionDiffusion *>(flux_kernel[0]);
174  if (!_p_diffusion_kernel)
175  paramError("p_diffusion_kernel",
176  "The provided diffusion kernel should be of type "
177  "LinearFVPressureCorrectionDiffusion.");
178 
179  // We fetch the body forces kernel to ensure that the face flux correction
180  // is accurate.
181 
182  // Check if components match the dimension.
183 
184  if (!_body_force_kernel_names.empty())
185  {
186  if (_body_force_kernel_names.size() != _dim)
187  paramError("body_force_kernel_names",
188  "The dimension of the body force vector does not match the problem dimension.");
189 
190  _body_force_kernels.resize(_dim);
191 
192  for (const auto dim_i : make_range(_dim))
193  for (const auto & force_name : _body_force_kernel_names[dim_i])
194  {
195  std::vector<LinearFVElementalKernel *> temp_storage;
196  auto base_query_force = _fe_problem.theWarehouse()
197  .query()
198  .template condition<AttribThread>(_tid)
199  .template condition<AttribSysNum>(_vel[dim_i]->sys().number())
200  .template condition<AttribSystem>("LinearFVElementalKernel")
201  .template condition<AttribName>(force_name)
202  .queryInto(temp_storage);
203  if (temp_storage.size() != 1)
204  paramError("body_force_kernel_names",
205  "The kernel with the given name: " + force_name +
206  " could not be found or multiple instances were identified.");
207  _body_force_kernels[dim_i].push_back(temp_storage[0]);
208  }
209  }
210 }
const THREAD_ID _tid
void paramError(const std::string &param, Args... args) const
FEProblemBase & _fe_problem
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
LinearFVPressureCorrectionDiffusion * _p_diffusion_kernel
Pointer to the pressure diffusion term in the pressure Poisson equation.
Query query()
IntRange< T > make_range(T beg, T end)
Pressure correction diffusion kernel for the linear finite volume SIMPLE algorithm.
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 127 of file RhieChowMassFlux.C.

Referenced by LinearAssemblySegregatedSolve::linkRhieChowUserObject().

131 {
132  _momentum_systems = momentum_systems;
133  _momentum_system_numbers = momentum_system_numbers;
134  _pressure_system = &pressure_system;
136 
138  for (auto & system : _momentum_systems)
139  {
140  _global_momentum_system_numbers.push_back(system->number());
141  _momentum_implicit_systems.push_back(dynamic_cast<LinearImplicitSystem *>(&system->system()));
142  }
143 
145 }
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 148 of file RhieChowMassFlux.C.

149 {
150  _HbyA_flux.clear();
151  _Ainv.clear();
152  _face_mass_flux.clear();
154 }
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 437 of file RhieChowMassFlux.C.

Referenced by computeHbyA().

440 {
441  // We have the raw H/A and 1/A vectors in a petsc format. This function
442  // will create face functors from them
443  using namespace Moose::FV;
444  const auto time_arg = Moose::currentState();
445 
446  // Create the petsc vector readers for faster repeated access
447  std::vector<PetscVectorReader> hbya_reader;
448  for (const auto dim_i : index_range(raw_hbya))
449  hbya_reader.emplace_back(*raw_hbya[dim_i]);
450 
451  std::vector<PetscVectorReader> ainv_reader;
452  for (const auto dim_i : index_range(raw_Ainv))
453  ainv_reader.emplace_back(*raw_Ainv[dim_i]);
454 
455  // We loop through the faces and populate the coupling fields (face H/A and 1/A)
456  for (auto & fi : _flow_face_info)
457  {
458  Real face_rho = 0;
459  RealVectorValue face_hbya;
460 
461  // We do the lookup in advance
462  auto & Ainv = _Ainv[fi->id()];
463 
464  // If it is internal, we just interpolate (using geometric weights) to the face
465  if (_vel[0]->isInternalFace(*fi))
466  {
467  // Get the dof indices for the element and the neighbor
468  const auto & elem_info = *fi->elemInfo();
469  const auto & neighbor_info = *fi->neighborInfo();
470  const auto elem_dof = elem_info.dofIndices()[_global_momentum_system_numbers[0]][0];
471  const auto neighbor_dof = neighbor_info.dofIndices()[_global_momentum_system_numbers[0]][0];
472 
473  // Get the density values for the element and neighbor. We need this multiplication to make
474  // the coupling fields mass fluxes.
475  const Real elem_rho = _rho(makeElemArg(fi->elemPtr()), time_arg);
476  const Real neighbor_rho = _rho(makeElemArg(fi->neighborPtr()), time_arg);
477 
478  // Now we do the interpolation to the face
479  interpolate(Moose::FV::InterpMethod::Average, face_rho, elem_rho, neighbor_rho, *fi, true);
480  for (const auto dim_i : index_range(raw_hbya))
481  {
483  face_hbya(dim_i),
484  hbya_reader[dim_i](elem_dof),
485  hbya_reader[dim_i](neighbor_dof),
486  *fi,
487  true);
489  Ainv(dim_i),
490  elem_rho * ainv_reader[dim_i](elem_dof),
491  neighbor_rho * ainv_reader[dim_i](neighbor_dof),
492  *fi,
493  true);
494  }
495  }
496  else
497  {
498  const bool elem_is_fluid = hasBlocks(fi->elemPtr()->subdomain_id());
499 
500  // We need this multiplier in case the face is an internal face and
501  const Real boundary_normal_multiplier = elem_is_fluid ? 1.0 : -1.0;
502 
503  const ElemInfo & elem_info = elem_is_fluid ? *fi->elemInfo() : *fi->neighborInfo();
504  const auto elem_dof = elem_info.dofIndices()[_global_momentum_system_numbers[0]][0];
505 
506  // If it is a Dirichlet BC, we use the dirichlet value the make sure the face flux
507  // is consistent
508  if (_vel[0]->isDirichletBoundaryFace(*fi))
509  {
510  const Moose::FaceArg boundary_face{
511  fi, Moose::FV::LimiterType::CentralDifference, true, false, elem_info.elem(), nullptr};
512  face_rho = _rho(boundary_face, Moose::currentState());
513 
514  for (const auto dim_i : make_range(_dim))
515  {
516 
517  face_hbya(dim_i) =
518  -MetaPhysicL::raw_value((*_vel[dim_i])(boundary_face, Moose::currentState()));
519 
520  if (!_body_force_kernel_names.empty())
521  for (const auto & force_kernel : _body_force_kernels[dim_i])
522  {
523  force_kernel->setCurrentElemInfo(&elem_info);
524  face_hbya(dim_i) -=
525  force_kernel->computeRightHandSideContribution() * ainv_reader[dim_i](elem_dof) /
526  (elem_info.volume() * elem_info.coordFactor()); // zero-term expansion
527  }
528  face_hbya(dim_i) *= boundary_normal_multiplier;
529  }
530  }
531  // Otherwise we just do a one-term expansion (so we just use the element value)
532  else
533  {
534  const auto elem_dof = elem_info.dofIndices()[_global_momentum_system_numbers[0]][0];
535 
536  face_rho = _rho(makeElemArg(elem_info.elem()), time_arg);
537  for (const auto dim_i : make_range(_dim))
538  face_hbya(dim_i) = boundary_normal_multiplier * hbya_reader[dim_i](elem_dof);
539  }
540 
541  // We just do a one-term expansion for 1/A no matter what
542  const Real elem_rho = _rho(makeElemArg(elem_info.elem()), time_arg);
543  for (const auto dim_i : index_range(raw_Ainv))
544  Ainv(dim_i) = elem_rho * ainv_reader[dim_i](elem_dof);
545  }
546  // Lastly, we populate the face flux resulted by H/A
547  _HbyA_flux[fi->id()] = face_hbya * fi->normal() * face_rho;
548  }
549 }
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 Moose::FV::InterpMethod _pressure_diffusion_interp_method
Interpolation method used for the pressure diffusion coefficient on faces.
const std::vector< std::vector< dof_id_type > > & dofIndices() const
Real coordFactor() 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 734 of file RhieChowMassFlux.C.

Referenced by computeHbyA().

735 {
736  if (updated_pressure)
737  {
738  _grad_p_current.clear();
740  _grad_p_current.push_back(component->clone());
741  }
742 
743  return _grad_p_current;
744 }
static const std::string component
Definition: NS.h:157
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.
const std::vector< std::unique_ptr< libMesh::NumericVector< libMesh::Number > > > & linearFVGradientContainer() const

◆ setupMeshInformation()

void RhieChowMassFlux::setupMeshInformation ( )
protected

Compute the cell volumes on the mesh.

Definition at line 213 of file RhieChowMassFlux.C.

Referenced by linkMomentumPressureSystems(), and meshChanged().

214 {
215  // We cache the cell volumes into a petsc vector for corrections here so we can use
216  // the optimized petsc operations for the normalization
218  for (const auto & elem_info : _fe_problem.mesh().elemInfoVector())
219  // We have to check this because the variable might not be defined on the given
220  // block
221  if (hasBlocks(elem_info->subdomain_id()))
222  {
223  const auto elem_dof = elem_info->dofIndices()[_global_pressure_system_number][0];
224  _cell_volumes->set(elem_dof, elem_info->volume() * elem_info->coordFactor());
225  }
226 
227  _cell_volumes->close();
228 
229  _flow_face_info.clear();
230  for (auto & fi : _fe_problem.mesh().faceInfo())
231  if (hasBlocks(fi->elemPtr()->subdomain_id()) ||
232  (fi->neighborPtr() && hasBlocks(fi->neighborPtr()->subdomain_id())))
233  _flow_face_info.push_back(fi);
234 }
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.
FEProblemBase & _fe_problem
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.
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 33 of file RhieChowMassFlux.C.

Referenced by WCNSLinearFVFlowPhysics::validParams().

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

Member Data Documentation

◆ _A_avg

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

Definition at line 152 of file RhieChowMassFlux.h.

◆ _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 162 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 160 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 194 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 157 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 205 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 182 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 191 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 168 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 185 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 179 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 176 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

LinearFVPressureCorrectionDiffusion* 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_diffusion_interp_method

const Moose::FV::InterpMethod RhieChowMassFlux::_pressure_diffusion_interp_method
protected

Interpolation method used for the pressure diffusion coefficient on faces.

Definition at line 200 of file RhieChowMassFlux.h.

Referenced by populateCouplingFunctors().

◆ _pressure_projection_method

const MooseEnum RhieChowMassFlux::_pressure_projection_method
protected

Enumerator for the method used for pressure projection.

Definition at line 197 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 173 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: