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

Quadrilateral subchannel solver. More...

#include <QuadSubChannel1PhaseProblem.h>

Inheritance diagram for QuadSubChannel1PhaseProblem:
[legend]

Public Types

enum  Direction { Direction::TO_EXTERNAL_APP, Direction::FROM_EXTERNAL_APP }
 
enum  CoverageCheckMode {
  CoverageCheckMode::FALSE, CoverageCheckMode::TRUE, CoverageCheckMode::OFF, CoverageCheckMode::ON,
  CoverageCheckMode::SKIP_LIST, CoverageCheckMode::ONLY_LIST
}
 
typedef DataFileName DataFileParameterType
 

Public Member Functions

 QuadSubChannel1PhaseProblem (const InputParameters &params)
 
virtual void externalSolve () override
 
virtual void syncSolutions (Direction direction) override
 
virtual bool solverSystemConverged (const unsigned int) override
 
virtual void initialSetup () override
 
virtual void solve (unsigned int nl_sys_num=0) override final
 
virtual void addExternalVariables ()
 
virtual libMesh::EquationSystemses () override
 
virtual MooseMeshmesh () override
 
virtual const MooseMeshmesh () const override
 
const MooseMeshmesh (bool use_displaced) const override
 
void setCoordSystem (const std::vector< SubdomainName > &blocks, const MultiMooseEnum &coord_sys)
 
void setAxisymmetricCoordAxis (const MooseEnum &rz_coord_axis)
 
void setCoupling (Moose::CouplingType type)
 
Moose::CouplingType coupling () const
 
void setCouplingMatrix (std::unique_ptr< libMesh::CouplingMatrix > cm, const unsigned int nl_sys_num)
 
void setCouplingMatrix (libMesh::CouplingMatrix *cm, const unsigned int nl_sys_num)
 
const libMesh::CouplingMatrixcouplingMatrix (const unsigned int nl_sys_num) const override
 
void setNonlocalCouplingMatrix ()
 
bool areCoupled (const unsigned int ivar, const unsigned int jvar, const unsigned int nl_sys_num) const
 
bool hasUOAuxStateCheck () const
 
bool checkingUOAuxState () const
 
void trustUserCouplingMatrix ()
 
std::vector< std::pair< MooseVariableFEBase *, MooseVariableFEBase *> > & couplingEntries (const THREAD_ID tid, const unsigned int nl_sys_num)
 
std::vector< std::pair< MooseVariableFEBase *, MooseVariableFEBase *> > & nonlocalCouplingEntries (const THREAD_ID tid, const unsigned int nl_sys_num)
 
virtual bool hasVariable (const std::string &var_name) const override
 
bool hasSolverVariable (const std::string &var_name) const
 
virtual const MooseVariableFieldBasegetVariable (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 override
 
virtual const MooseVariableFieldBasegetVariable (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
 
virtual MooseVariableFieldBasegetVariable (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)
 
virtual MooseVariableFieldBasegetVariable (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)
 
MooseVariableFieldBasegetActualFieldVariable (const THREAD_ID tid, const std::string &var_name) override
 
virtual MooseVariablegetStandardVariable (const THREAD_ID tid, const std::string &var_name) override
 
virtual VectorMooseVariablegetVectorVariable (const THREAD_ID tid, const std::string &var_name) override
 
virtual ArrayMooseVariablegetArrayVariable (const THREAD_ID tid, const std::string &var_name) override
 
virtual bool hasScalarVariable (const std::string &var_name) const override
 
virtual MooseVariableScalargetScalarVariable (const THREAD_ID tid, const std::string &var_name) override
 
virtual libMesh::SystemgetSystem (const std::string &var_name) override
 
virtual void setActiveElementalMooseVariables (const std::set< MooseVariableFEBase * > &moose_vars, const THREAD_ID tid) override
 
virtual void clearActiveElementalMooseVariables (const THREAD_ID tid) override
 
virtual void clearActiveFEVariableCoupleableMatrixTags (const THREAD_ID tid) override
 
virtual void clearActiveFEVariableCoupleableVectorTags (const THREAD_ID tid) override
 
virtual void setActiveFEVariableCoupleableVectorTags (std::set< TagID > &vtags, const THREAD_ID tid) override
 
virtual void setActiveFEVariableCoupleableMatrixTags (std::set< TagID > &mtags, const THREAD_ID tid) override
 
virtual void clearActiveScalarVariableCoupleableMatrixTags (const THREAD_ID tid) override
 
virtual void clearActiveScalarVariableCoupleableVectorTags (const THREAD_ID tid) override
 
virtual void setActiveScalarVariableCoupleableVectorTags (std::set< TagID > &vtags, const THREAD_ID tid) override
 
virtual void setActiveScalarVariableCoupleableMatrixTags (std::set< TagID > &mtags, const THREAD_ID tid) override
 
virtual void createQRules (libMesh::QuadratureType type, libMesh::Order order, libMesh::Order volume_order=libMesh::INVALID_ORDER, libMesh::Order face_order=libMesh::INVALID_ORDER, SubdomainID block=Moose::ANY_BLOCK_ID, bool allow_negative_qweights=true)
 
void bumpVolumeQRuleOrder (libMesh::Order order, SubdomainID block)
 
void bumpAllQRuleOrder (libMesh::Order order, SubdomainID block)
 
unsigned int getMaxQps () const
 
libMesh::Order getMaxScalarOrder () const
 
void checkNonlocalCoupling ()
 
void checkUserObjectJacobianRequirement (THREAD_ID tid)
 
void setVariableAllDoFMap (const std::vector< const MooseVariableFEBase * > &moose_vars)
 
const std::vector< const MooseVariableFEBase *> & getUserObjectJacobianVariables (const THREAD_ID tid) const
 
virtual Assemblyassembly (const THREAD_ID tid, const unsigned int sys_num) override
 
virtual const Assemblyassembly (const THREAD_ID tid, const unsigned int sys_num) const override
 
virtual std::vector< VariableName > getVariableNames ()
 
void checkDuplicatePostprocessorVariableNames ()
 
void timestepSetup () override
 
void customSetup (const ExecFlagType &exec_type) override
 
void residualSetup () override
 
void jacobianSetup () override
 
virtual void prepare (const Elem *elem, const THREAD_ID tid) override
 
virtual void prepare (const Elem *elem, unsigned int ivar, unsigned int jvar, const std::vector< dof_id_type > &dof_indices, const THREAD_ID tid) override
 
virtual void prepareFace (const Elem *elem, const THREAD_ID tid) override
 
virtual void setCurrentSubdomainID (const Elem *elem, const THREAD_ID tid) override
 
virtual void setNeighborSubdomainID (const Elem *elem, unsigned int side, const THREAD_ID tid) override
 
virtual void setNeighborSubdomainID (const Elem *elem, const THREAD_ID tid)
 
virtual void prepareAssembly (const THREAD_ID tid) override
 
virtual void addGhostedElem (dof_id_type elem_id) override
 
virtual void addGhostedBoundary (BoundaryID boundary_id) override
 
virtual void ghostGhostedBoundaries () override
 
virtual void sizeZeroes (unsigned int size, const THREAD_ID tid)
 
virtual bool reinitDirac (const Elem *elem, const THREAD_ID tid) override
 
virtual void reinitElem (const Elem *elem, const THREAD_ID tid) override
 
virtual void reinitElemPhys (const Elem *elem, const std::vector< Point > &phys_points_in_elem, const THREAD_ID tid) override
 
void reinitElemFace (const Elem *elem, unsigned int side, BoundaryID, const THREAD_ID tid)
 
virtual void reinitElemFace (const Elem *elem, unsigned int side, const THREAD_ID tid) override
 
virtual void reinitLowerDElem (const Elem *lower_d_elem, const THREAD_ID tid, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr) override
 
virtual void reinitNode (const Node *node, const THREAD_ID tid) override
 
virtual void reinitNodeFace (const Node *node, BoundaryID bnd_id, const THREAD_ID tid) override
 
virtual void reinitNodes (const std::vector< dof_id_type > &nodes, const THREAD_ID tid) override
 
virtual void reinitNodesNeighbor (const std::vector< dof_id_type > &nodes, const THREAD_ID tid) override
 
virtual void reinitNeighbor (const Elem *elem, unsigned int side, const THREAD_ID tid) override
 
virtual void reinitNeighborPhys (const Elem *neighbor, unsigned int neighbor_side, const std::vector< Point > &physical_points, const THREAD_ID tid) override
 
virtual void reinitNeighborPhys (const Elem *neighbor, const std::vector< Point > &physical_points, const THREAD_ID tid) override
 
virtual void reinitElemNeighborAndLowerD (const Elem *elem, unsigned int side, const THREAD_ID tid) override
 
virtual void reinitScalars (const THREAD_ID tid, bool reinit_for_derivative_reordering=false) override
 
virtual void reinitOffDiagScalars (const THREAD_ID tid) override
 
virtual void getDiracElements (std::set< const Elem * > &elems) override
 
virtual void clearDiracInfo () override
 
virtual void subdomainSetup (SubdomainID subdomain, const THREAD_ID tid)
 
virtual void neighborSubdomainSetup (SubdomainID subdomain, const THREAD_ID tid)
 
virtual void newAssemblyArray (std::vector< std::shared_ptr< SolverSystem >> &solver_systems)
 
virtual void initNullSpaceVectors (const InputParameters &parameters, std::vector< std::shared_ptr< NonlinearSystemBase >> &nl)
 
virtual void init () override
 
virtual void solveLinearSystem (const unsigned int linear_sys_num, const Moose::PetscSupport::PetscOptions *po=nullptr)
 
virtual void setException (const std::string &message)
 
virtual bool hasException ()
 
virtual void checkExceptionAndStopSolve (bool print_message=true)
 
virtual unsigned int nNonlinearIterations (const unsigned int nl_sys_num) const override
 
virtual unsigned int nLinearIterations (const unsigned int nl_sys_num) const override
 
virtual Real finalNonlinearResidual (const unsigned int nl_sys_num) const override
 
virtual bool computingPreSMOResidual (const unsigned int nl_sys_num) const override
 
virtual std::string solverTypeString (unsigned int solver_sys_num=0)
 
virtual bool startedInitialSetup ()
 
virtual void onTimestepBegin () override
 
virtual void onTimestepEnd () override
 
virtual Realtime () const
 
virtual RealtimeOld () const
 
virtual inttimeStep () const
 
virtual Realdt () const
 
virtual RealdtOld () const
 
Real getTimeFromStateArg (const Moose::StateArg &state) const
 
virtual void transient (bool trans)
 
virtual bool isTransient () const override
 
virtual void addTimeIntegrator (const std::string &type, const std::string &name, InputParameters &parameters)
 
virtual void addPredictor (const std::string &type, const std::string &name, InputParameters &parameters)
 
virtual void copySolutionsBackwards ()
 
virtual void advanceState ()
 
virtual void restoreSolutions ()
 
virtual void saveOldSolutions ()
 
virtual void restoreOldSolutions ()
 
void needSolutionState (unsigned int oldest_needed, Moose::SolutionIterationType iteration_type)
 
virtual void outputStep (ExecFlagType type)
 
virtual void postExecute ()
 
void forceOutput ()
 
virtual void initPetscOutputAndSomeSolverSettings ()
 
Moose::PetscSupport::PetscOptionsgetPetscOptions ()
 
void logAdd (const std::string &system, const std::string &name, const std::string &type, const InputParameters &params) const
 
virtual void addFunction (const std::string &type, const std::string &name, InputParameters &parameters)
 
virtual bool hasFunction (const std::string &name, const THREAD_ID tid=0)
 
virtual FunctiongetFunction (const std::string &name, const THREAD_ID tid=0)
 
virtual void addMeshDivision (const std::string &type, const std::string &name, InputParameters &params)
 
MeshDivisiongetMeshDivision (const std::string &name, const THREAD_ID tid=0) const
 
virtual void addConvergence (const std::string &type, const std::string &name, InputParameters &parameters)
 
virtual ConvergencegetConvergence (const std::string &name, const THREAD_ID tid=0) const
 
virtual const std::vector< std::shared_ptr< Convergence > > & getConvergenceObjects (const THREAD_ID tid=0) const
 
virtual bool hasConvergence (const std::string &name, const THREAD_ID tid=0) const
 
bool needToAddDefaultNonlinearConvergence () const
 
bool needToAddDefaultMultiAppFixedPointConvergence () const
 
void setNeedToAddDefaultNonlinearConvergence ()
 
void setNeedToAddDefaultMultiAppFixedPointConvergence ()
 
bool hasSetMultiAppFixedPointConvergenceName () const
 
virtual void addDefaultNonlinearConvergence (const InputParameters &params)
 
virtual bool onlyAllowDefaultNonlinearConvergence () const
 
void addDefaultMultiAppFixedPointConvergence (const InputParameters &params)
 
virtual void addLineSearch (const InputParameters &)
 
virtual void lineSearch ()
 
LineSearchgetLineSearch () override
 
virtual void addDistribution (const std::string &type, const std::string &name, InputParameters &parameters)
 
virtual DistributiongetDistribution (const std::string &name)
 
virtual void addSampler (const std::string &type, const std::string &name, InputParameters &parameters)
 
virtual SamplergetSampler (const std::string &name, const THREAD_ID tid=0)
 
NonlinearSystemBasegetNonlinearSystemBase (const unsigned int sys_num)
 
const NonlinearSystemBasegetNonlinearSystemBase (const unsigned int sys_num) const
 
void setCurrentNonlinearSystem (const unsigned int nl_sys_num)
 
NonlinearSystemBasecurrentNonlinearSystem ()
 
const NonlinearSystemBasecurrentNonlinearSystem () const
 
virtual const SystemBasesystemBaseNonlinear (const unsigned int sys_num) const override
 
virtual SystemBasesystemBaseNonlinear (const unsigned int sys_num) override
 
virtual const SystemBasesystemBaseSolver (const unsigned int sys_num) const override
 
virtual SystemBasesystemBaseSolver (const unsigned int sys_num) override
 
virtual const SystemBasesystemBaseAuxiliary () const override
 
virtual SystemBasesystemBaseAuxiliary () override
 
virtual NonlinearSystemgetNonlinearSystem (const unsigned int sys_num)
 
virtual const SystemBasegetSystemBase (const unsigned int sys_num) const
 
virtual SystemBasegetSystemBase (const unsigned int sys_num)
 
LinearSystemgetLinearSystem (unsigned int sys_num)
 
const LinearSystemgetLinearSystem (unsigned int sys_num) const
 
SolverSystemgetSolverSystem (unsigned int sys_num)
 
const SolverSystemgetSolverSystem (unsigned int sys_num) const
 
void setCurrentLinearSystem (unsigned int sys_num)
 
LinearSystemcurrentLinearSystem ()
 
const LinearSystemcurrentLinearSystem () const
 
virtual const SystemBasesystemBaseLinear (unsigned int sys_num) const override
 
virtual SystemBasesystemBaseLinear (unsigned int sys_num) override
 
virtual void addVariable (const std::string &var_type, const std::string &var_name, InputParameters &params)
 
virtual void addKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 
virtual void addHDGKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 
virtual void addNodalKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 
virtual void addScalarKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 
virtual void addBoundaryCondition (const std::string &bc_name, const std::string &name, InputParameters &parameters)
 
virtual void addConstraint (const std::string &c_name, const std::string &name, InputParameters &parameters)
 
virtual void setInputParametersFEProblem (InputParameters &parameters)
 
virtual void addAuxVariable (const std::string &var_type, const std::string &var_name, InputParameters &params)
 
virtual void addAuxVariable (const std::string &var_name, const libMesh::FEType &type, const std::set< SubdomainID > *const active_subdomains=NULL)
 
virtual void addAuxArrayVariable (const std::string &var_name, const libMesh::FEType &type, unsigned int components, const std::set< SubdomainID > *const active_subdomains=NULL)
 
virtual void addAuxScalarVariable (const std::string &var_name, libMesh::Order order, Real scale_factor=1., const std::set< SubdomainID > *const active_subdomains=NULL)
 
virtual void addAuxKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 
virtual void addAuxScalarKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 
AuxiliarySystemgetAuxiliarySystem ()
 
virtual void addDiracKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 
virtual void addDGKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 
virtual void addFVKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 
virtual void addLinearFVKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 
virtual void addFVBC (const std::string &fv_bc_name, const std::string &name, InputParameters &parameters)
 
virtual void addLinearFVBC (const std::string &fv_bc_name, const std::string &name, InputParameters &parameters)
 
virtual void addFVInterfaceKernel (const std::string &fv_ik_name, const std::string &name, InputParameters &parameters)
 
virtual void addInterfaceKernel (const std::string &kernel_name, const std::string &name, InputParameters &parameters)
 
virtual void addInitialCondition (const std::string &ic_name, const std::string &name, InputParameters &parameters)
 
virtual void addFVInitialCondition (const std::string &ic_name, const std::string &name, InputParameters &parameters)
 
void projectSolution ()
 
unsigned short getCurrentICState ()
 
void projectInitialConditionOnCustomRange (libMesh::ConstElemRange &elem_range, ConstBndNodeRange &bnd_node_range)
 
virtual void addMaterial (const std::string &material_name, const std::string &name, InputParameters &parameters)
 
virtual void addMaterialHelper (std::vector< MaterialWarehouse * > warehouse, const std::string &material_name, const std::string &name, InputParameters &parameters)
 
virtual void addInterfaceMaterial (const std::string &material_name, const std::string &name, InputParameters &parameters)
 
virtual void addFunctorMaterial (const std::string &functor_material_name, const std::string &name, InputParameters &parameters)
 
void prepareMaterials (const std::unordered_set< unsigned int > &consumer_needed_mat_props, const SubdomainID blk_id, const THREAD_ID tid)
 
void reinitMaterials (SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true)
 
void reinitMaterialsFace (SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase * > *reinit_mats=nullptr)
 
void reinitMaterialsNeighbor (SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase * > *reinit_mats=nullptr)
 
void reinitMaterialsBoundary (BoundaryID boundary_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase * > *reinit_mats=nullptr)
 
void reinitMaterialsInterface (BoundaryID boundary_id, const THREAD_ID tid, bool swap_stateful=true)
 
virtual void swapBackMaterials (const THREAD_ID tid)
 
virtual void swapBackMaterialsFace (const THREAD_ID tid)
 
virtual void swapBackMaterialsNeighbor (const THREAD_ID tid)
 
void setActiveMaterialProperties (const std::unordered_set< unsigned int > &mat_prop_ids, const THREAD_ID tid)
 
bool hasActiveMaterialProperties (const THREAD_ID tid) const
 
void clearActiveMaterialProperties (const THREAD_ID tid)
 
std::vector< std::shared_ptr< T > > addObject (const std::string &type, const std::string &name, InputParameters &parameters, const bool threaded=true, const std::string &var_param_name="variable")
 
virtual void addPostprocessor (const std::string &pp_name, const std::string &name, InputParameters &parameters)
 
virtual void addVectorPostprocessor (const std::string &pp_name, const std::string &name, InputParameters &parameters)
 
virtual void addReporter (const std::string &type, const std::string &name, InputParameters &parameters)
 
const ReporterDatagetReporterData () const
 
ReporterDatagetReporterData (ReporterData::WriteKey)
 
virtual std::vector< std::shared_ptr< UserObject > > addUserObject (const std::string &user_object_name, const std::string &name, InputParameters &parameters)
 
const ExecuteMooseObjectWarehouse< UserObject > & getUserObjects () const
 
T & getUserObject (const std::string &name, unsigned int tid=0) const
 
const UserObjectgetUserObjectBase (const std::string &name, const THREAD_ID tid=0) const
 
const PositionsgetPositionsObject (const std::string &name) const
 
bool hasUserObject (const std::string &name) const
 
bool hasPostprocessorValueByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name, std::size_t t_index=0) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
void setPostprocessorValueByName (const PostprocessorName &name, const PostprocessorValue &value, std::size_t t_index=0)
 
bool hasPostprocessor (const std::string &name) const
 
bool hasPostprocessor (const std::string &param_name, const unsigned int index=0) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueByName (const std::string &object_name, const std::string &vector_name, std::size_t t_index=0) const
 
void setVectorPostprocessorValueByName (const std::string &object_name, const std::string &vector_name, const VectorPostprocessorValue &value, std::size_t t_index=0)
 
const VectorPostprocessorgetVectorPostprocessorObjectByName (const std::string &object_name, const THREAD_ID tid=0) const
 
virtual void addDamper (const std::string &damper_name, const std::string &name, InputParameters &parameters)
 
void setupDampers ()
 
bool hasDampers ()
 
virtual void addIndicator (const std::string &indicator_name, const std::string &name, InputParameters &parameters)
 
virtual void addMarker (const std::string &marker_name, const std::string &name, InputParameters &parameters)
 
virtual void addMultiApp (const std::string &multi_app_name, const std::string &name, InputParameters &parameters)
 
std::shared_ptr< MultiAppgetMultiApp (const std::string &multi_app_name) const
 
std::vector< std::shared_ptr< Transfer > > getTransfers (ExecFlagType type, Transfer::DIRECTION direction) const
 
std::vector< std::shared_ptr< Transfer > > getTransfers (Transfer::DIRECTION direction) const
 
const ExecuteMooseObjectWarehouse< Transfer > & getMultiAppTransferWarehouse (Transfer::DIRECTION direction) const
 
void execMultiAppTransfers (ExecFlagType type, Transfer::DIRECTION direction)
 
bool execMultiApps (ExecFlagType type, bool auto_advance=true)
 
void finalizeMultiApps ()
 
void incrementMultiAppTStep (ExecFlagType type)
 
void advanceMultiApps (ExecFlagType type)
 
void finishMultiAppStep (ExecFlagType type, bool recurse_through_multiapp_levels=false)
 
void backupMultiApps (ExecFlagType type)
 
void restoreMultiApps (ExecFlagType type, bool force=false)
 
Real computeMultiAppsDT (ExecFlagType type)
 
virtual void addTransfer (const std::string &transfer_name, const std::string &name, InputParameters &parameters)
 
void execTransfers (ExecFlagType type)
 
Real computeResidualL2Norm (NonlinearSystemBase &sys)
 
Real computeResidualL2Norm (LinearSystem &sys)
 
virtual Real computeResidualL2Norm ()
 
virtual void computeResidualSys (libMesh::NonlinearImplicitSystem &sys, const NumericVector< libMesh::Number > &soln, NumericVector< libMesh::Number > &residual)
 
void computeResidual (libMesh::NonlinearImplicitSystem &sys, const NumericVector< libMesh::Number > &soln, NumericVector< libMesh::Number > &residual)
 
virtual void computeResidual (const NumericVector< libMesh::Number > &soln, NumericVector< libMesh::Number > &residual, const unsigned int nl_sys_num)
 
void computeResidualAndJacobian (const NumericVector< libMesh::Number > &soln, NumericVector< libMesh::Number > &residual, libMesh::SparseMatrix< libMesh::Number > &jacobian)
 
virtual void computeResidualTag (const NumericVector< libMesh::Number > &soln, NumericVector< libMesh::Number > &residual, TagID tag)
 
virtual void computeResidualType (const NumericVector< libMesh::Number > &soln, NumericVector< libMesh::Number > &residual, TagID tag)
 
virtual void computeResidualInternal (const NumericVector< libMesh::Number > &soln, NumericVector< libMesh::Number > &residual, const std::set< TagID > &tags)
 
virtual void computeResidualTags (const std::set< TagID > &tags)
 
virtual void computeJacobianSys (libMesh::NonlinearImplicitSystem &sys, const NumericVector< libMesh::Number > &soln, libMesh::SparseMatrix< libMesh::Number > &jacobian)
 
virtual void computeJacobian (const NumericVector< libMesh::Number > &soln, libMesh::SparseMatrix< libMesh::Number > &jacobian, const unsigned int nl_sys_num)
 
virtual void computeJacobianTag (const NumericVector< libMesh::Number > &soln, libMesh::SparseMatrix< libMesh::Number > &jacobian, TagID tag)
 
virtual void computeJacobianInternal (const NumericVector< libMesh::Number > &soln, libMesh::SparseMatrix< libMesh::Number > &jacobian, const std::set< TagID > &tags)
 
virtual void computeJacobianTags (const std::set< TagID > &tags)
 
virtual void computeJacobianBlocks (std::vector< JacobianBlock * > &blocks, const unsigned int nl_sys_num)
 
virtual void computeJacobianBlock (libMesh::SparseMatrix< libMesh::Number > &jacobian, libMesh::System &precond_system, unsigned int ivar, unsigned int jvar)
 
virtual void computeLinearSystemSys (libMesh::LinearImplicitSystem &sys, libMesh::SparseMatrix< libMesh::Number > &system_matrix, NumericVector< libMesh::Number > &rhs, const bool compute_gradients=true)
 
void computeLinearSystemTags (const NumericVector< libMesh::Number > &soln, const std::set< TagID > &vector_tags, const std::set< TagID > &matrix_tags, const bool compute_gradients=true)
 
virtual Real computeDamping (const NumericVector< libMesh::Number > &soln, const NumericVector< libMesh::Number > &update)
 
virtual bool shouldUpdateSolution ()
 
virtual bool updateSolution (NumericVector< libMesh::Number > &vec_solution, NumericVector< libMesh::Number > &ghosted_solution)
 
virtual void predictorCleanup (NumericVector< libMesh::Number > &ghosted_solution)
 
virtual void computeBounds (libMesh::NonlinearImplicitSystem &sys, NumericVector< libMesh::Number > &lower, NumericVector< libMesh::Number > &upper)
 
virtual void computeNearNullSpace (libMesh::NonlinearImplicitSystem &sys, std::vector< NumericVector< libMesh::Number > * > &sp)
 
virtual void computeNullSpace (libMesh::NonlinearImplicitSystem &sys, std::vector< NumericVector< libMesh::Number > * > &sp)
 
virtual void computeTransposeNullSpace (libMesh::NonlinearImplicitSystem &sys, std::vector< NumericVector< libMesh::Number > * > &sp)
 
virtual void computePostCheck (libMesh::NonlinearImplicitSystem &sys, const NumericVector< libMesh::Number > &old_soln, NumericVector< libMesh::Number > &search_direction, NumericVector< libMesh::Number > &new_soln, bool &changed_search_direction, bool &changed_new_soln)
 
virtual void computeIndicatorsAndMarkers ()
 
virtual void computeIndicators ()
 
virtual void computeMarkers ()
 
virtual void addResidual (const THREAD_ID tid) override
 
virtual void addResidualNeighbor (const THREAD_ID tid) override
 
virtual void addResidualLower (const THREAD_ID tid) override
 
virtual void addResidualScalar (const THREAD_ID tid=0)
 
virtual void cacheResidual (const THREAD_ID tid) override
 
virtual void cacheResidualNeighbor (const THREAD_ID tid) override
 
virtual void addCachedResidual (const THREAD_ID tid) override
 
virtual void addCachedResidualDirectly (NumericVector< libMesh::Number > &residual, const THREAD_ID tid)
 
virtual void setResidual (NumericVector< libMesh::Number > &residual, const THREAD_ID tid) override
 
virtual void setResidual (libMesh::NumericVector< libMesh::Number > &residual, const THREAD_ID tid)=0
 
virtual void setResidualNeighbor (NumericVector< libMesh::Number > &residual, const THREAD_ID tid) override
 
virtual void setResidualNeighbor (libMesh::NumericVector< libMesh::Number > &residual, const THREAD_ID tid)=0
 
virtual void addJacobian (const THREAD_ID tid) override
 
virtual void addJacobianNeighbor (const THREAD_ID tid) override
 
virtual void addJacobianNeighbor (libMesh::SparseMatrix< libMesh::Number > &jacobian, unsigned int ivar, unsigned int jvar, const DofMap &dof_map, std::vector< dof_id_type > &dof_indices, std::vector< dof_id_type > &neighbor_dof_indices, const std::set< TagID > &tags, const THREAD_ID tid) override
 
virtual void addJacobianNeighbor (libMesh::SparseMatrix< libMesh::Number > &jacobian, unsigned int ivar, unsigned int jvar, const libMesh::DofMap &dof_map, std::vector< dof_id_type > &dof_indices, std::vector< dof_id_type > &neighbor_dof_indices, const std::set< TagID > &tags, const THREAD_ID tid)=0
 
virtual void addJacobianNeighborLowerD (const THREAD_ID tid) override
 
virtual void addJacobianLowerD (const THREAD_ID tid) override
 
virtual void addJacobianBlockTags (libMesh::SparseMatrix< libMesh::Number > &jacobian, unsigned int ivar, unsigned int jvar, const DofMap &dof_map, std::vector< dof_id_type > &dof_indices, const std::set< TagID > &tags, const THREAD_ID tid)
 
virtual void addJacobianScalar (const THREAD_ID tid=0)
 
virtual void addJacobianOffDiagScalar (unsigned int ivar, const THREAD_ID tid=0)
 
virtual void cacheJacobian (const THREAD_ID tid) override
 
virtual void cacheJacobianNeighbor (const THREAD_ID tid) override
 
virtual void addCachedJacobian (const THREAD_ID tid) override
 
virtual void prepareShapes (unsigned int var, const THREAD_ID tid) override
 
virtual void prepareFaceShapes (unsigned int var, const THREAD_ID tid) override
 
virtual void prepareNeighborShapes (unsigned int var, const THREAD_ID tid) override
 
virtual void addDisplacedProblem (std::shared_ptr< DisplacedProblem > displaced_problem)
 
virtual std::shared_ptr< const DisplacedProblemgetDisplacedProblem () const
 
virtual std::shared_ptr< DisplacedProblemgetDisplacedProblem ()
 
virtual void updateGeomSearch (GeometricSearchData::GeometricSearchType type=GeometricSearchData::ALL) override
 
virtual void updateMortarMesh ()
 
void createMortarInterface (const std::pair< BoundaryID, BoundaryID > &primary_secondary_boundary_pair, const std::pair< SubdomainID, SubdomainID > &primary_secondary_subdomain_pair, bool on_displaced, bool periodic, const bool debug, const bool correct_edge_dropping, const Real minimum_projection_angle)
 
const std::unordered_map< std::pair< BoundaryID, BoundaryID >, AutomaticMortarGeneration > & getMortarInterfaces (bool on_displaced) const
 
virtual void possiblyRebuildGeomSearchPatches ()
 
virtual GeometricSearchDatageomSearchData () override
 
void setRestartFile (const std::string &file_name)
 
const MaterialPropertyRegistrygetMaterialPropertyRegistry () const
 
const InitialConditionWarehousegetInitialConditionWarehouse () const
 
const FVInitialConditionWarehousegetFVInitialConditionWarehouse () const
 
SolverParamssolverParams (unsigned int solver_sys_num=0)
 
const SolverParamssolverParams (unsigned int solver_sys_num=0) const
 
Adaptivityadaptivity ()
 
virtual void initialAdaptMesh ()
 
virtual bool adaptMesh ()
 
unsigned int getNumCyclesCompleted ()
 
bool hasInitialAdaptivity () const
 
bool hasInitialAdaptivity () const
 
void initXFEM (std::shared_ptr< XFEMInterface > xfem)
 
std::shared_ptr< XFEMInterfacegetXFEM ()
 
bool haveXFEM ()
 
virtual bool updateMeshXFEM ()
 
virtual void meshChanged (bool intermediate_change, bool contract_mesh, bool clean_refinement_flags)
 
void notifyWhenMeshChanges (MeshChangedInterface *mci)
 
void notifyWhenMeshDisplaces (MeshDisplacedInterface *mdi)
 
void initElementStatefulProps (const libMesh::ConstElemRange &elem_range, const bool threaded)
 
virtual void checkProblemIntegrity ()
 
void registerRandomInterface (RandomInterface &random_interface, const std::string &name)
 
void setConstJacobian (bool state)
 
void setKernelCoverageCheck (CoverageCheckMode mode)
 
void setKernelCoverageCheck (bool flag)
 
void setKernelCoverageCheck (CoverageCheckMode mode)
 
void setMaterialCoverageCheck (CoverageCheckMode mode)
 
void setMaterialCoverageCheck (bool flag)
 
void setMaterialCoverageCheck (CoverageCheckMode mode)
 
void setParallelBarrierMessaging (bool flag)
 
void setVerboseProblem (bool verbose)
 
bool verboseMultiApps () const
 
void parentOutputPositionChanged ()
 
unsigned int subspaceDim (const std::string &prefix) const
 
const MaterialWarehousegetMaterialWarehouse () const
 
const MaterialWarehousegetRegularMaterialsWarehouse () const
 
const MaterialWarehousegetDiscreteMaterialWarehouse () const
 
const MaterialWarehousegetInterfaceMaterialsWarehouse () const
 
std::shared_ptr< MaterialBasegetMaterial (std::string name, Moose::MaterialDataType type, const THREAD_ID tid=0, bool no_warn=false)
 
MaterialDatagetMaterialData (Moose::MaterialDataType type, const THREAD_ID tid=0) const
 
bool restoreOriginalNonzeroPattern () const
 
bool errorOnJacobianNonzeroReallocation () const
 
void setErrorOnJacobianNonzeroReallocation (bool state)
 
bool preserveMatrixSparsityPattern () const
 
void setPreserveMatrixSparsityPattern (bool preserve)
 
bool ignoreZerosInJacobian () const
 
void setIgnoreZerosInJacobian (bool state)
 
bool acceptInvalidSolution () const
 
bool allowInvalidSolution () const
 
bool showInvalidSolutionConsole () const
 
bool immediatelyPrintInvalidSolution () const
 
bool hasTimeIntegrator () const
 
virtual void execute (const ExecFlagType &exec_type)
 
virtual void executeAllObjects (const ExecFlagType &exec_type)
 
virtual ExecutorgetExecutor (const std::string &name)
 
virtual void computeUserObjects (const ExecFlagType &type, const Moose::AuxGroup &group)
 
virtual void computeUserObjectByName (const ExecFlagType &type, const Moose::AuxGroup &group, const std::string &name)
 
void needsPreviousNewtonIteration (bool state)
 
bool needsPreviousNewtonIteration () const
 
ExecuteMooseObjectWarehouse< Control > & getControlWarehouse ()
 
void executeControls (const ExecFlagType &exec_type)
 
void executeSamplers (const ExecFlagType &exec_type)
 
virtual void updateActiveObjects ()
 
void reportMooseObjectDependency (MooseObject *a, MooseObject *b)
 
ExecuteMooseObjectWarehouse< MultiApp > & getMultiAppWarehouse ()
 
bool hasJacobian () const
 
bool constJacobian () const
 
void addOutput (const std::string &, const std::string &, InputParameters &)
 
TheWarehousetheWarehouse () const
 
void setSNESMFReuseBase (bool reuse, bool set_by_user)
 
bool useSNESMFReuseBase ()
 
void skipExceptionCheck (bool skip_exception_check)
 
bool isSNESMFReuseBaseSetbyUser ()
 
bool & petscOptionsInserted ()
 
PetscOptions & petscOptionsDatabase ()
 
virtual void setUDotRequested (const bool u_dot_requested)
 
virtual void setUDotDotRequested (const bool u_dotdot_requested)
 
virtual void setUDotOldRequested (const bool u_dot_old_requested)
 
virtual void setUDotDotOldRequested (const bool u_dotdot_old_requested)
 
virtual bool uDotRequested ()
 
virtual bool uDotDotRequested ()
 
virtual bool uDotOldRequested ()
 
virtual bool uDotDotOldRequested ()
 
void haveADObjects (bool have_ad_objects) override
 
virtual void haveADObjects (bool have_ad_objects)
 
bool haveADObjects () const
 
bool haveADObjects () const
 
bool shouldSolve () const
 
const MortarDatamortarData () const
 
MortarDatamortarData ()
 
virtual bool hasNeighborCoupling () const
 
virtual bool hasMortarCoupling () const
 
void computingNonlinearResid (bool computing_nonlinear_residual) final
 
bool computingNonlinearResid () const
 
virtual void computingNonlinearResid (const bool computing_nonlinear_residual)
 
bool computingNonlinearResid () const
 
void setCurrentlyComputingResidual (bool currently_computing_residual) final
 
void numGridSteps (unsigned int num_grid_steps)
 
void uniformRefine ()
 
void automaticScaling (bool automatic_scaling) override
 
virtual void automaticScaling (bool automatic_scaling)
 
bool automaticScaling () const
 
bool automaticScaling () const
 
virtual void reinitElemFaceRef (const Elem *elem, unsigned int side, Real tolerance, const std::vector< Point > *const pts, const std::vector< Real > *const weights=nullptr, const THREAD_ID tid=0) override
 
virtual void reinitNeighborFaceRef (const Elem *neighbor_elem, unsigned int neighbor_side, Real tolerance, const std::vector< Point > *const pts, const std::vector< Real > *const weights=nullptr, const THREAD_ID tid=0) override
 
bool fvBCsIntegrityCheck () const
 
void fvBCsIntegrityCheck (bool fv_bcs_integrity_check)
 
void getFVMatsAndDependencies (SubdomainID block_id, std::vector< std::shared_ptr< MaterialBase >> &face_materials, std::vector< std::shared_ptr< MaterialBase >> &neighbor_materials, std::set< MooseVariableFieldBase * > &variables, const THREAD_ID tid)
 
void resizeMaterialData (Moose::MaterialDataType data_type, unsigned int nqp, const THREAD_ID tid)
 
bool haveDisplaced () const override final
 
bool hasLinearConvergenceObjects () const
 
void setNonlinearConvergenceNames (const std::vector< ConvergenceName > &convergence_names)
 
void setLinearConvergenceNames (const std::vector< ConvergenceName > &convergence_names)
 
void setMultiAppFixedPointConvergenceName (const ConvergenceName &convergence_name)
 
const std::vector< ConvergenceName > & getNonlinearConvergenceNames () const
 
const std::vector< ConvergenceName > & getLinearConvergenceNames () const
 
const ConvergenceName & getMultiAppFixedPointConvergenceName () const
 
void computingScalingJacobian (bool computing_scaling_jacobian)
 
bool computingScalingJacobian () const override final
 
void computingScalingResidual (bool computing_scaling_residual)
 
bool computingScalingResidual () const override final
 
MooseAppCoordTransformcoordTransform ()
 
virtual std::size_t numNonlinearSystems () const override
 
virtual std::size_t numLinearSystems () const override
 
virtual std::size_t numSolverSystems () const override
 
bool isSolverSystemNonlinear (const unsigned int sys_num)
 
virtual unsigned int currentNlSysNum () const override
 
virtual unsigned int currentLinearSysNum () const override
 
virtual unsigned int nlSysNum (const NonlinearSystemName &nl_sys_name) const override
 
unsigned int linearSysNum (const LinearSystemName &linear_sys_name) const override
 
unsigned int solverSysNum (const SolverSystemName &solver_sys_name) const override
 
unsigned int systemNumForVariable (const VariableName &variable_name) const
 
bool getFailNextNonlinearConvergenceCheck () const
 
bool getFailNextSystemConvergenceCheck () const
 
void setFailNextNonlinearConvergenceCheck ()
 
void setFailNextSystemConvergenceCheck ()
 
void resetFailNextNonlinearConvergenceCheck ()
 
void resetFailNextSystemConvergenceCheck ()
 
void setExecutionPrinting (const ExecFlagEnum &print_exec)
 
bool shouldPrintExecution (const THREAD_ID tid) const
 
void reinitMortarUserObjects (BoundaryID primary_boundary_id, BoundaryID secondary_boundary_id, bool displaced)
 
virtual const std::vector< VectorTag > & currentResidualVectorTags () const override
 
void setCurrentResidualVectorTags (const std::set< TagID > &vector_tags)
 
void clearCurrentResidualVectorTags ()
 
void clearCurrentJacobianMatrixTags ()
 
virtual void needFV () override
 
virtual bool haveFV () const override
 
virtual bool hasNonlocalCoupling () const override
 
bool identifyVariableGroupsInNL () const
 
virtual void setCurrentLowerDElem (const Elem *const lower_d_elem, const THREAD_ID tid) override
 
virtual void setCurrentBoundaryID (BoundaryID bid, const THREAD_ID tid) override
 
const std::vector< NonlinearSystemName > & getNonlinearSystemNames () const
 
const std::vector< LinearSystemName > & getLinearSystemNames () const
 
const std::vector< SolverSystemName > & getSolverSystemNames () const
 
virtual const libMesh::CouplingMatrixnonlocalCouplingMatrix (const unsigned i) const override
 
virtual bool checkNonlocalCouplingRequirement () const override
 
virtual Moose::FEBackend feBackend () const
 
const bool & currentlyComputingResidual () const
 
const bool & currentlyComputingResidual () const
 
virtual bool nlConverged (const unsigned int nl_sys_num)
 
virtual bool converged (const unsigned int sys_num)
 
bool defaultGhosting ()
 
virtual TagID addVectorTag (const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
 
void addNotZeroedVectorTag (const TagID tag)
 
bool vectorTagNotZeroed (const TagID tag) const
 
virtual const VectorTaggetVectorTag (const TagID tag_id) const
 
std::vector< VectorTaggetVectorTags (const std::set< TagID > &tag_ids) const
 
virtual const std::vector< VectorTag > & getVectorTags (const Moose::VectorTagType type=Moose::VECTOR_TAG_ANY) const
 
virtual TagID getVectorTagID (const TagName &tag_name) const
 
virtual TagName vectorTagName (const TagID tag) const
 
virtual bool vectorTagExists (const TagID tag_id) const
 
virtual bool vectorTagExists (const TagName &tag_name) const
 
virtual unsigned int numVectorTags (const Moose::VectorTagType type=Moose::VECTOR_TAG_ANY) const
 
virtual Moose::VectorTagType vectorTagType (const TagID tag_id) const
 
virtual TagID addMatrixTag (TagName tag_name)
 
virtual TagID getMatrixTagID (const TagName &tag_name) const
 
virtual TagName matrixTagName (TagID tag)
 
virtual bool matrixTagExists (const TagName &tag_name) const
 
virtual bool matrixTagExists (TagID tag_id) const
 
virtual unsigned int numMatrixTags () const
 
virtual std::map< TagName, TagID > & getMatrixTags ()
 
virtual bool hasLinearVariable (const std::string &var_name) const
 
virtual bool hasAuxiliaryVariable (const std::string &var_name) const
 
virtual const std::set< MooseVariableFieldBase *> & getActiveElementalMooseVariables (const THREAD_ID tid) const
 
virtual bool hasActiveElementalMooseVariables (const THREAD_ID tid) const
 
Moose::CoordinateSystemType getCoordSystem (SubdomainID sid) const
 
unsigned int getAxisymmetricRadialCoord () const
 
virtual DiracKernelInfodiracKernelInfo ()
 
void reinitNeighborLowerDElem (const Elem *elem, const THREAD_ID tid=0)
 
void reinitMortarElem (const Elem *elem, const THREAD_ID tid=0)
 
virtual void storeSubdomainMatPropName (SubdomainID block_id, const std::string &name)
 
virtual void storeBoundaryMatPropName (BoundaryID boundary_id, const std::string &name)
 
virtual void storeSubdomainZeroMatProp (SubdomainID block_id, const MaterialPropertyName &name)
 
virtual void storeBoundaryZeroMatProp (BoundaryID boundary_id, const MaterialPropertyName &name)
 
virtual void storeSubdomainDelayedCheckMatProp (const std::string &requestor, SubdomainID block_id, const std::string &name)
 
virtual void storeBoundaryDelayedCheckMatProp (const std::string &requestor, BoundaryID boundary_id, const std::string &name)
 
virtual void checkBlockMatProps ()
 
virtual void checkBoundaryMatProps ()
 
virtual void markMatPropRequested (const std::string &)
 
virtual bool isMatPropRequested (const std::string &prop_name) const
 
void addConsumedPropertyName (const MooseObjectName &obj_name, const std::string &prop_name)
 
const std::map< MooseObjectName, std::set< std::string > > & getConsumedPropertyMap () const
 
virtual std::set< SubdomainIDgetMaterialPropertyBlocks (const std::string &prop_name)
 
virtual std::vector< SubdomainName > getMaterialPropertyBlockNames (const std::string &prop_name)
 
virtual bool hasBlockMaterialProperty (SubdomainID block_id, const std::string &prop_name)
 
virtual std::set< BoundaryIDgetMaterialPropertyBoundaryIDs (const std::string &prop_name)
 
virtual std::vector< BoundaryName > getMaterialPropertyBoundaryNames (const std::string &prop_name)
 
virtual bool hasBoundaryMaterialProperty (BoundaryID boundary_id, const std::string &prop_name)
 
virtual std::set< dof_id_type > & ghostedElems ()
 
const bool & currentlyComputingJacobian () const
 
void setCurrentlyComputingJacobian (const bool currently_computing_jacobian)
 
const bool & currentlyComputingResidualAndJacobian () const
 
void setCurrentlyComputingResidualAndJacobian (bool currently_computing_residual_and_jacobian)
 
virtual bool safeAccessTaggedMatrices () const
 
virtual bool safeAccessTaggedVectors () const
 
const std::set< TagID > & getActiveScalarVariableCoupleableVectorTags (const THREAD_ID tid) const
 
const std::set< TagID > & getActiveScalarVariableCoupleableMatrixTags (const THREAD_ID tid) const
 
const std::set< TagID > & getActiveFEVariableCoupleableVectorTags (const THREAD_ID tid) const
 
const std::set< TagID > & getActiveFEVariableCoupleableMatrixTags (const THREAD_ID tid) const
 
void addAlgebraicGhostingFunctor (libMesh::GhostingFunctor &algebraic_gf, bool to_mesh=true)
 
void addCouplingGhostingFunctor (libMesh::GhostingFunctor &coupling_gf, bool to_mesh=true)
 
void removeAlgebraicGhostingFunctor (libMesh::GhostingFunctor &algebraic_gf)
 
void removeCouplingGhostingFunctor (libMesh::GhostingFunctor &coupling_gf)
 
void hasScalingVector (const unsigned int nl_sys_num)
 
void clearAllDofIndices ()
 
const Moose::Functor< T > & getFunctor (const std::string &name, const THREAD_ID tid, const std::string &requestor_name, bool requestor_is_ad)
 
bool hasFunctor (const std::string &name, const THREAD_ID tid) const
 
bool hasFunctorWithType (const std::string &name, const THREAD_ID tid) const
 
void addFunctor (const std::string &name, const Moose::FunctorBase< T > &functor, const THREAD_ID tid)
 
const Moose::FunctorBase< T > & addPiecewiseByBlockLambdaFunctor (const std::string &name, PolymorphicLambda my_lammy, const std::set< ExecFlagType > &clearance_schedule, const MooseMesh &mesh, const std::set< SubdomainID > &block_ids, const THREAD_ID tid)
 
void setFunctorOutput (bool set_output)
 
void registerUnfilledFunctorRequest (T *functor_interface, const std::string &functor_name, const THREAD_ID tid)
 
void reinitFVFace (const THREAD_ID tid, const FaceInfo &fi)
 
void preparePRefinement ()
 
bool doingPRefinement () const
 
bool havePRefinement () const
 
MooseVariableFEBasegetVariableHelper (const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type, Moose::VarFieldType expected_var_field_type, const std::vector< T > &systems, const SystemBase &aux) const
 
void _setCLIOption ()
 
virtual void terminateSolve ()
 
virtual bool isSolveTerminationRequested () const
 
const ConsoleStreamconsole () const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &nm) const
 
void paramError (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
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) 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
 
PerfGraphperfGraph ()
 
const libMesh::ConstElemRangegetEvaluableElementRange ()
 
const libMesh::ConstElemRangegetEvaluableElementRange ()
 
const libMesh::ConstElemRangegetNonlinearEvaluableElementRange ()
 
const libMesh::ConstElemRangegetNonlinearEvaluableElementRange ()
 
const libMesh::ConstElemRangegetCurrentAlgebraicElementRange ()
 
const libMesh::ConstElemRangegetCurrentAlgebraicElementRange ()
 
const libMesh::ConstNodeRangegetCurrentAlgebraicNodeRange ()
 
const libMesh::ConstNodeRangegetCurrentAlgebraicNodeRange ()
 
const ConstBndNodeRangegetCurrentAlgebraicBndNodeRange ()
 
const ConstBndNodeRangegetCurrentAlgebraicBndNodeRange ()
 
void setCurrentAlgebraicElementRange (libMesh::ConstElemRange *range)
 
void setCurrentAlgebraicElementRange (libMesh::ConstElemRange *range)
 
void setCurrentAlgebraicNodeRange (libMesh::ConstNodeRange *range)
 
void setCurrentAlgebraicNodeRange (libMesh::ConstNodeRange *range)
 
void setCurrentAlgebraicBndNodeRange (ConstBndNodeRange *range)
 
void setCurrentAlgebraicBndNodeRange (ConstBndNodeRange *range)
 
void allowOutput (bool state)
 
void allowOutput (bool state)
 
void allowOutput (bool state)
 
void allowOutput (bool state)
 
bool hasMultiApps () const
 
bool hasMultiApps (ExecFlagType type) const
 
bool hasMultiApps () const
 
bool hasMultiApps (ExecFlagType type) const
 
bool hasMultiApp (const std::string &name) const
 
bool hasMultiApp (const std::string &name) const
 
const AutomaticMortarGenerationgetMortarInterface (const std::pair< BoundaryID, BoundaryID > &primary_secondary_boundary_pair, const std::pair< SubdomainID, SubdomainID > &primary_secondary_subdomain_pair, bool on_displaced) const
 
AutomaticMortarGenerationgetMortarInterface (const std::pair< BoundaryID, BoundaryID > &primary_secondary_boundary_pair, const std::pair< SubdomainID, SubdomainID > &primary_secondary_subdomain_pair, bool on_displaced)
 
const AutomaticMortarGenerationgetMortarInterface (const std::pair< BoundaryID, BoundaryID > &primary_secondary_boundary_pair, const std::pair< SubdomainID, SubdomainID > &primary_secondary_subdomain_pair, bool on_displaced) const
 
AutomaticMortarGenerationgetMortarInterface (const std::pair< BoundaryID, BoundaryID > &primary_secondary_boundary_pair, const std::pair< SubdomainID, SubdomainID > &primary_secondary_subdomain_pair, bool on_displaced)
 
const MaterialPropertyStoragegetMaterialPropertyStorage ()
 
const MaterialPropertyStoragegetMaterialPropertyStorage ()
 
const MaterialPropertyStoragegetBndMaterialPropertyStorage ()
 
const MaterialPropertyStoragegetBndMaterialPropertyStorage ()
 
const MaterialPropertyStoragegetNeighborMaterialPropertyStorage ()
 
const MaterialPropertyStoragegetNeighborMaterialPropertyStorage ()
 
const MooseObjectWarehouse< Indicator > & getIndicatorWarehouse ()
 
const MooseObjectWarehouse< Indicator > & getIndicatorWarehouse ()
 
const MooseObjectWarehouse< InternalSideIndicatorBase > & getInternalSideIndicatorWarehouse ()
 
const MooseObjectWarehouse< InternalSideIndicatorBase > & getInternalSideIndicatorWarehouse ()
 
const MooseObjectWarehouse< Marker > & getMarkerWarehouse ()
 
const MooseObjectWarehouse< Marker > & getMarkerWarehouse ()
 
bool needBoundaryMaterialOnSide (BoundaryID bnd_id, const THREAD_ID tid)
 
bool needBoundaryMaterialOnSide (BoundaryID bnd_id, const THREAD_ID tid)
 
bool needInterfaceMaterialOnSide (BoundaryID bnd_id, const THREAD_ID tid)
 
bool needInterfaceMaterialOnSide (BoundaryID bnd_id, const THREAD_ID tid)
 
bool needSubdomainMaterialOnSide (SubdomainID subdomain_id, const THREAD_ID tid)
 
bool needSubdomainMaterialOnSide (SubdomainID subdomain_id, const THREAD_ID tid)
 
const ExecFlagTypegetCurrentExecuteOnFlag () const
 
const ExecFlagTypegetCurrentExecuteOnFlag () const
 
void setCurrentExecuteOnFlag (const ExecFlagType &)
 
void setCurrentExecuteOnFlag (const ExecFlagType &)
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
bool isDefaultPostprocessorValue (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 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
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 

Static Public Member Functions

static InputParameters validParams ()
 
static void selectVectorTagsFromSystem (const SystemBase &system, const std::vector< VectorTag > &input_vector_tags, std::set< TagID > &selected_tags)
 
static void selectMatrixTagsFromSystem (const SystemBase &system, const std::map< TagName, TagID > &input_matrix_tags, std::set< TagID > &selected_tags)
 
static void objectSetupHelper (const std::vector< T * > &objects, const ExecFlagType &exec_flag)
 
static void objectSetupHelper (const std::vector< T * > &objects, const ExecFlagType &exec_flag)
 
static void objectExecuteHelper (const std::vector< T * > &objects)
 
static void objectExecuteHelper (const std::vector< T * > &objects)
 

Public Attributes

std::map< std::string, std::vector< dof_id_type > > _var_dof_map
 
const ConsoleStream _console
 
std::vector< Real_real_zero
 
std::vector< VariableValue_scalar_zero
 
std::vector< VariableValue_zero
 
std::vector< VariablePhiValue_phi_zero
 
std::vector< MooseArray< ADReal > > _ad_zero
 
std::vector< VariableGradient_grad_zero
 
std::vector< MooseArray< ADRealVectorValue > > _ad_grad_zero
 
std::vector< VariablePhiGradient_grad_phi_zero
 
std::vector< VariableSecond_second_zero
 
std::vector< MooseArray< ADRealTensorValue > > _ad_second_zero
 
std::vector< VariablePhiSecond_second_phi_zero
 
std::vector< Point > _point_zero
 
std::vector< VectorVariableValue_vector_zero
 
std::vector< VectorVariableCurl_vector_curl_zero
 

Protected Member Functions

virtual void initializeSolution () override
 Function to initialize the solution & geometry fields. More...
 
virtual Real computeFrictionFactor (FrictionStruct friction_args) override
 Returns friction factor. More...
 
virtual Real computeAddedHeatPin (unsigned int i_ch, unsigned int iz) override
 Computes added heat for channel i_ch and cell iz. More...
 
virtual Real computeBeta (unsigned int i_gap, unsigned int iz) override
 Computes turbulent mixing coefficient. More...
 
virtual void computeh (int iblock) override
 Computes Enthalpy per channel for block iblock. More...
 
void computeWijFromSolve (int iblock)
 Computes diversion crossflow per gap for block iblock. More...
 
void computeSumWij (int iblock)
 Computes net diversion crossflow per channel for block iblock. More...
 
void computeMdot (int iblock)
 Computes mass flow per channel for block iblock. More...
 
void computeWijPrime (int iblock)
 Computes turbulent crossflow per gap for block iblock. More...
 
void computeDP (int iblock)
 Computes Pressure Drop per channel for block iblock. More...
 
void computeP (int iblock)
 Computes Pressure per channel for block iblock. More...
 
void computeT (int iblock)
 Computes Temperature per channel for block iblock. More...
 
void computeRho (int iblock)
 Computes Density per channel for block iblock. More...
 
void computeMu (int iblock)
 Computes Viscosity per channel for block iblock. More...
 
void computeWijResidual (int iblock)
 Computes Residual Matrix based on the lateral momentum conservation equation for block iblock. More...
 
Real computeAddedHeatDuct (unsigned int i_ch, unsigned int iz)
 Function that computes the heat flux added by the duct. More...
 
libMesh::DenseVector< RealresidualFunction (int iblock, libMesh::DenseVector< Real > solution)
 Computes Residual Vector based on the lateral momentum conservation equation for block iblock & updates flow variables based on current crossflow solution. More...
 
PetscErrorCode petscSnesSolver (int iblock, const libMesh::DenseVector< Real > &solution, libMesh::DenseVector< Real > &root)
 Computes solution of nonlinear equation using snes and provided a residual in a formFunction. More...
 
PetscErrorCode implicitPetscSolve (int iblock)
 Computes implicit solve using PetSc. More...
 
PetscScalar computeInterpolationCoefficients (PetscScalar Peclet=0.0)
 Functions that computes the interpolation scheme given the Peclet number. More...
 
PetscScalar computeInterpolatedValue (PetscScalar topValue, PetscScalar botValue, PetscScalar Peclet=0.0)
 
PetscErrorCode cleanUp ()
 
PetscErrorCode createPetscVector (Vec &v, PetscInt n)
 Petsc Functions. More...
 
PetscErrorCode createPetscMatrix (Mat &M, PetscInt n, PetscInt m)
 
template<class T >
PetscErrorCode populateVectorFromDense (Vec &x, const T &solution, const unsigned int first_axial_level, const unsigned int last_axial_level, const unsigned int cross_dimension)
 
template<class T >
PetscErrorCode populateDenseFromVector (const Vec &x, T &solution, const unsigned int first_axial_level, const unsigned int last_axial_level, const unsigned int cross_dimension)
 
template<class T >
PetscErrorCode populateVectorFromHandle (Vec &x, const T &solution, const unsigned int first_axial_level, const unsigned int last_axial_level, const unsigned int cross_dimension)
 
template<class T >
PetscErrorCode populateSolutionChan (const Vec &x, T &solution, const unsigned int first_axial_level, const unsigned int last_axial_level, const unsigned int cross_dimension)
 
template<class T >
PetscErrorCode populateSolutionGap (const Vec &x, T &solution, const unsigned int first_axial_level, const unsigned int last_axial_level, const unsigned int cross_dimension)
 
virtual void meshChanged ()
 
MooseVariableFieldBasegetVariableHelper (const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type, Moose::VarFieldType expected_var_field_type, const std::vector< T > &nls, const SystemBase &aux) const
 
void createTagVectors ()
 
void createTagSolutions ()
 
virtual void meshDisplaced ()
 
void computeSystems (const ExecFlagType &type)
 
bool duplicateVariableCheck (const std::string &var_name, const libMesh::FEType &type, bool is_aux, const std::set< SubdomainID > *const active_subdomains)
 
void computeUserObjectsInternal (const ExecFlagType &type, const Moose::AuxGroup &group, TheWarehouse::Query &query)
 
void checkDisplacementOrders ()
 
void checkUserObjects ()
 
void checkDependMaterialsHelper (const std::map< SubdomainID, std::vector< std::shared_ptr< MaterialBase >>> &materials_map)
 
void checkCoordinateSystems ()
 
void reinitBecauseOfGhostingOrNewGeomObjects (bool mortar_changed=false)
 
void addObjectParamsHelper (InputParameters &params, const std::string &object_name, const std::string &var_param_name="variable")
 
bool verifyVectorTags () const
 
void markFamilyPRefinement (const InputParameters &params)
 
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
 
T & declareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< T > declareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const T & getRestartableData (const std::string &data_name) const
 
T & declareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
T & declareRecoverableData (const std::string &data_name, Args &&... args)
 
T & declareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
T & declareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 
std::string restartableName (const std::string &data_name) const
 
virtual void addPostprocessorDependencyHelper (const PostprocessorName &) const
 

Protected Attributes

QuadSubChannelMesh_subchannel_mesh
 
const Real_beta
 Thermal diffusion coefficient used in turbulent crossflow. More...
 
const bool _default_friction_model
 Flag that activates one of the two friction models (default: f=a*Re^b, non-default: Todreas-Kazimi) More...
 
const bool _constant_beta
 Flag that activates the use of constant beta. More...
 
struct SubChannel1PhaseProblem::FrictionStruct _friction_args
 
unsigned int _n_blocks
 number of axial blocks More...
 
libMesh::DenseMatrix< Real > & _Wij
 
libMesh::DenseMatrix< Real_Wij_old
 
libMesh::DenseMatrix< Real_WijPrime
 
libMesh::DenseMatrix< Real_Wij_residual_matrix
 
const Real _g_grav
 
const Real_kij
 
unsigned int _n_cells
 
unsigned int _n_gaps
 
unsigned int _n_pins
 
unsigned int _n_channels
 
unsigned int _block_size
 
Real _outer_channels
 
std::vector< Real_z_grid
 axial location of nodes More...
 
Real _one
 
Real _TR
 Flag that activates or deactivates the transient parts of the equations we solve by multiplication. More...
 
const bool _compute_density
 Flag that activates or deactivates the calculation of density. More...
 
const bool _compute_viscosity
 Flag that activates or deactivates the calculation of viscosity. More...
 
const bool _compute_power
 Flag that informs if we need to solve the Enthalpy/Temperature equations or not. More...
 
const bool _pin_mesh_exist
 Flag that informs if there is a pin mesh or not. More...
 
const bool _duct_mesh_exist
 Flag that informs if there is a pin mesh or not. More...
 
bool _converged
 Variable that informs whether we exited external solve with a converged solution or not. More...
 
Real _dt
 Time step. More...
 
const PostprocessorValue_P_out
 Outlet Pressure. More...
 
const Real_CT
 Turbulent modeling parameter used in axial momentum equation. More...
 
const Real_P_tol
 Convergence tolerance for the pressure loop in external solve. More...
 
const Real_T_tol
 Convergence tolerance for the temperature loop in external solve. More...
 
const int_T_maxit
 Maximum iterations for the inner temperature loop. More...
 
const PetscReal & _rtol
 The relative convergence tolerance, (relative decrease) for the ksp linear solver. More...
 
const PetscReal & _atol
 The absolute convergence tolerance for the ksp linear solver. More...
 
const PetscReal & _dtol
 The divergence tolerance for the ksp linear solver. More...
 
const PetscInt & _maxit
 The maximum number of iterations to use for the ksp linear solver. More...
 
const MooseEnum _interpolation_scheme
 The interpolation method used in constructing the systems. More...
 
const bool _implicit_bool
 Flag to define the usage of a implicit or explicit solution. More...
 
const bool _staggered_pressure_bool
 Flag to define the usage of staggered or collocated pressure. More...
 
const bool _segregated_bool
 Segregated solve. More...
 
const bool _monolithic_thermal_bool
 Thermal monolithic bool. More...
 
const bool _verbose_subchannel
 Boolean to printout information related to subchannel solve. More...
 
const bool _deformation
 Flag that activates the effect of deformation (pin/duct) based on the auxvalues for displacement, Dpin. More...
 
const SinglePhaseFluidProperties_fp
 Solutions handles and link to TH tables properties. More...
 
std::unique_ptr< SolutionHandle_mdot_soln
 
std::unique_ptr< SolutionHandle_SumWij_soln
 
std::unique_ptr< SolutionHandle_P_soln
 
std::unique_ptr< SolutionHandle_DP_soln
 
std::unique_ptr< SolutionHandle_h_soln
 
std::unique_ptr< SolutionHandle_T_soln
 
std::unique_ptr< SolutionHandle_Tpin_soln
 
std::unique_ptr< SolutionHandle_Dpin_soln
 
std::unique_ptr< SolutionHandle_rho_soln
 
std::unique_ptr< SolutionHandle_mu_soln
 
std::unique_ptr< SolutionHandle_S_flow_soln
 
std::unique_ptr< SolutionHandle_w_perim_soln
 
std::unique_ptr< SolutionHandle_q_prime_soln
 
std::unique_ptr< SolutionHandle_q_prime_duct_soln
 
std::unique_ptr< SolutionHandle_Tduct_soln
 
std::unique_ptr< SolutionHandle_displacement_soln
 
Mat _mc_sumWij_mat
 Matrices and vectors to be used in implicit assembly Mass conservation Mass conservation - sum of cross fluxes. More...
 
Vec _Wij_vec
 
Vec _prod
 
Vec _prodp
 
Mat _mc_axial_convection_mat
 Mass conservation - axial convection. More...
 
Vec _mc_axial_convection_rhs
 
Mat _amc_turbulent_cross_flows_mat
 Mass conservation - density time derivative No implicit matrix. More...
 
Vec _amc_turbulent_cross_flows_rhs
 
Mat _amc_time_derivative_mat
 Axial momentum conservation - time derivative. More...
 
Vec _amc_time_derivative_rhs
 
Mat _amc_advective_derivative_mat
 Axial momentum conservation - advective (Eulerian) derivative. More...
 
Vec _amc_advective_derivative_rhs
 
Mat _amc_cross_derivative_mat
 Axial momentum conservation - cross flux derivative. More...
 
Vec _amc_cross_derivative_rhs
 
Mat _amc_friction_force_mat
 Axial momentum conservation - friction force. More...
 
Vec _amc_friction_force_rhs
 
Vec _amc_gravity_rhs
 Axial momentum conservation - buoyancy force No implicit matrix. More...
 
Mat _amc_pressure_force_mat
 Axial momentum conservation - pressure force. More...
 
Vec _amc_pressure_force_rhs
 
Mat _amc_sys_mdot_mat
 Axial momentum system matrix. More...
 
Vec _amc_sys_mdot_rhs
 
Mat _cmc_time_derivative_mat
 Cross momentum Cross momentum conservation - time derivative. More...
 
Vec _cmc_time_derivative_rhs
 
Mat _cmc_advective_derivative_mat
 Cross momentum conservation - advective (Eulerian) derivative. More...
 
Vec _cmc_advective_derivative_rhs
 
Mat _cmc_friction_force_mat
 Cross momentum conservation - friction force. More...
 
Vec _cmc_friction_force_rhs
 
Mat _cmc_pressure_force_mat
 Cross momentum conservation - pressure force. More...
 
Vec _cmc_pressure_force_rhs
 
Mat _cmc_sys_Wij_mat
 Lateral momentum system matrix. More...
 
Vec _cmc_sys_Wij_rhs
 
Mat _hc_time_derivative_mat
 Enthalpy Enthalpy conservation - time derivative. More...
 
Vec _hc_time_derivative_rhs
 
Mat _hc_advective_derivative_mat
 Enthalpy conservation - advective (Eulerian) derivative;. More...
 
Vec _hc_advective_derivative_rhs
 
Mat _hc_cross_derivative_mat
 Enthalpy conservation - cross flux derivative. More...
 
Vec _hc_cross_derivative_rhs
 
Vec _hc_added_heat_rhs
 Enthalpy conservation - source and sink. More...
 
Mat _hc_sys_h_mat
 System matrices. More...
 
Vec _hc_sys_h_rhs
 
PetscScalar _added_K = 0.0
 Added resistances for monolithic convergence. More...
 
PetscScalar _added_K_old = 1000.0
 
PetscScalar _max_sumWij
 
PetscScalar _max_sumWij_new
 
PetscScalar _correction_factor = 1.0
 
MooseMesh_mesh
 
bool _initialized
 
std::optional< std::vector< ConvergenceName > > _nonlinear_convergence_names
 
std::optional< std::vector< ConvergenceName > > _linear_convergence_names
 
std::optional< ConvergenceName > _multiapp_fixed_point_convergence_name
 
std::set< TagID_fe_vector_tags
 
std::set< TagID_fe_matrix_tags
 
std::set< TagID_linear_vector_tags
 
std::set< TagID_linear_matrix_tags
 
const bool & _solve
 
bool _transient
 
Real_time
 
Real_time_old
 
int_t_step
 
Real_dt_old
 
bool _need_to_add_default_nonlinear_convergence
 
bool _need_to_add_default_multiapp_fixed_point_convergence
 
const std::vector< LinearSystemName > _linear_sys_names
 
const std::size_t _num_linear_sys
 
std::vector< std::shared_ptr< LinearSystem > > _linear_systems
 
std::map< LinearSystemName, unsigned int_linear_sys_name_to_num
 
LinearSystem_current_linear_sys
 
const bool _using_default_nl
 
const std::vector< NonlinearSystemName > _nl_sys_names
 
const std::size_t _num_nl_sys
 
std::vector< std::shared_ptr< NonlinearSystemBase > > _nl
 
std::map< NonlinearSystemName, unsigned int_nl_sys_name_to_num
 
NonlinearSystemBase_current_nl_sys
 
SolverSystem_current_solver_sys
 
std::vector< std::shared_ptr< SolverSystem > > _solver_systems
 
std::map< SolverVariableName, unsigned int_solver_var_to_sys_num
 
std::map< SolverSystemName, unsigned int_solver_sys_name_to_num
 
std::vector< SolverSystemName > _solver_sys_names
 
std::shared_ptr< AuxiliarySystem_aux
 
Moose::CouplingType _coupling
 
std::vector< std::unique_ptr< libMesh::CouplingMatrix > > _cm
 
std::map< std::string, unsigned int_subspace_dim
 
std::vector< std::vector< std::unique_ptr< Assembly > > > _assembly
 
MooseObjectWarehouse< MeshDivision_mesh_divisions
 
MooseObjectWarehouse< Function_functions
 
MooseObjectWarehouse< Convergence_convergences
 
MooseObjectWarehouse< KernelBase_nonlocal_kernels
 
MooseObjectWarehouse< IntegratedBCBase_nonlocal_integrated_bcs
 
MaterialPropertyRegistry _material_prop_registry
 
MaterialPropertyStorage_material_props
 
MaterialPropertyStorage_bnd_material_props
 
MaterialPropertyStorage_neighbor_material_props
 
MooseObjectWarehouse< Marker_markers
 
ReporterData _reporter_data
 
ExecuteMooseObjectWarehouse< UserObject_all_user_objects
 
ExecuteMooseObjectWarehouse< MultiApp_multi_apps
 
ExecuteMooseObjectWarehouse< TransientMultiApp_transient_multi_apps
 
ExecuteMooseObjectWarehouse< Transfer_transfers
 
ExecuteMooseObjectWarehouse< Transfer_to_multi_app_transfers
 
ExecuteMooseObjectWarehouse< Transfer_from_multi_app_transfers
 
ExecuteMooseObjectWarehouse< Transfer_between_multi_app_transfers
 
std::map< std::string, std::unique_ptr< RandomData > > _random_data_objects
 
std::vector< std::unordered_map< SubdomainID, bool > > _block_mat_side_cache
 
std::vector< std::unordered_map< BoundaryID, bool > > _bnd_mat_side_cache
 
std::vector< std::unordered_map< BoundaryID, bool > > _interface_mat_side_cache
 
std::vector< MeshChangedInterface *> _notify_when_mesh_changes
 
std::vector< MeshDisplacedInterface *> _notify_when_mesh_displaces
 
Adaptivity _adaptivity
 
unsigned int _cycles_completed
 
std::shared_ptr< XFEMInterface_xfem
 
MooseMesh_displaced_mesh
 
std::shared_ptr< DisplacedProblem_displaced_problem
 
GeometricSearchData _geometric_search_data
 
MortarData _mortar_data
 
bool _reinit_displaced_elem
 
bool _reinit_displaced_face
 
bool _reinit_displaced_neighbor
 
bool _input_file_saved
 
bool _has_dampers
 
bool _has_constraints
 
bool _snesmf_reuse_base
 
bool _skip_exception_check
 
bool _snesmf_reuse_base_set_by_user
 
bool _has_initialized_stateful
 
bool _const_jacobian
 
bool _has_jacobian
 
bool _needs_old_newton_iter
 
bool _previous_nl_solution_required
 
bool _has_nonlocal_coupling
 
bool _calculate_jacobian_in_uo
 
std::vector< std::vector< const MooseVariableFEBase *> > _uo_jacobian_moose_vars
 
std::vector< unsigned char > _has_active_material_properties
 
std::vector< SolverParams_solver_params
 
CoverageCheckMode _kernel_coverage_check
 
std::vector< SubdomainName > _kernel_coverage_blocks
 
const bool _boundary_restricted_node_integrity_check
 
const bool _boundary_restricted_elem_integrity_check
 
CoverageCheckMode _material_coverage_check
 
std::vector< SubdomainName > _material_coverage_blocks
 
bool _fv_bcs_integrity_check
 
const bool _material_dependency_check
 
const bool _uo_aux_state_check
 
unsigned int _max_qps
 
libMesh::Order _max_scalar_order
 
bool _has_time_integrator
 
bool _has_exception
 
bool _parallel_barrier_messaging
 
MooseEnum _verbose_setup
 
bool _verbose_multiapps
 
bool _verbose_restore
 
std::string _exception_message
 
ExecFlagType _current_execute_on_flag
 
ExecuteMooseObjectWarehouse< Control_control_warehouse
 
Moose::PetscSupport::PetscOptions _petsc_options
 
PetscOptions _petsc_option_data_base
 
bool _is_petsc_options_inserted
 
std::shared_ptr< LineSearch_line_search
 
std::unique_ptr< libMesh::ConstElemRange_evaluable_local_elem_range
 
std::unique_ptr< libMesh::ConstElemRange_nl_evaluable_local_elem_range
 
std::unique_ptr< libMesh::ConstElemRange_aux_evaluable_local_elem_range
 
std::unique_ptr< libMesh::ConstElemRange_current_algebraic_elem_range
 
std::unique_ptr< libMesh::ConstNodeRange_current_algebraic_node_range
 
std::unique_ptr< ConstBndNodeRange_current_algebraic_bnd_node_range
 
bool _using_ad_mat_props
 
unsigned short _current_ic_state
 
const bool _use_hash_table_matrix_assembly
 
std::map< TagName, TagID_matrix_tag_name_to_tag_id
 
std::map< TagID, TagName > _matrix_tag_id_to_tag_name
 
Factory_factory
 
DiracKernelInfo _dirac_kernel_info
 
std::map< SubdomainID, std::set< std::string > > _map_block_material_props
 
std::map< BoundaryID, std::set< std::string > > _map_boundary_material_props
 
std::map< SubdomainID, std::set< MaterialPropertyName > > _zero_block_material_props
 
std::map< BoundaryID, std::set< MaterialPropertyName > > _zero_boundary_material_props
 
std::set< std::string > _material_property_requested
 
std::vector< std::set< MooseVariableFieldBase *> > _active_elemental_moose_variables
 
std::vector< unsigned int_has_active_elemental_moose_variables
 
std::vector< std::set< TagID > > _active_fe_var_coupleable_matrix_tags
 
std::vector< std::set< TagID > > _active_fe_var_coupleable_vector_tags
 
std::vector< std::set< TagID > > _active_sc_var_coupleable_matrix_tags
 
std::vector< std::set< TagID > > _active_sc_var_coupleable_vector_tags
 
bool _default_ghosting
 
std::set< dof_id_type_ghosted_elems
 
bool _currently_computing_jacobian
 
bool _currently_computing_residual_and_jacobian
 
bool _computing_nonlinear_residual
 
bool _currently_computing_residual
 
bool _safe_access_tagged_matrices
 
bool _safe_access_tagged_vectors
 
bool _have_ad_objects
 
std::unordered_set< TagID_not_zeroed_tagged_vectors
 
bool _cli_option_found
 
bool _color_output
 
bool _termination_requested
 
const bool & _enabled
 
MooseApp_app
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
ActionFactory_action_factory
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
MooseApp_restartable_app
 
const std::string _restartable_system_name
 
const THREAD_ID _restartable_tid
 
const bool _restartable_read_only
 
InitialConditionWarehouse _ics
 
FVInitialConditionWarehouse _fv_ics
 
ScalarInitialConditionWarehouse _scalar_ics
 
MaterialWarehouse _materials
 
MaterialWarehouse _interface_materials
 
MaterialWarehouse _discrete_materials
 
MaterialWarehouse _all_materials
 
MooseObjectWarehouse< Indicator_indicators
 
MooseObjectWarehouse< InternalSideIndicatorBase_internal_side_indicators
 
std::map< SubdomainID, std::multimap< std::string, std::string > > _map_block_material_props_check
 
std::map< BoundaryID, std::multimap< std::string, std::string > > _map_boundary_material_props_check
 
const Parallel::Communicator & _communicator
 

Detailed Description

Quadrilateral subchannel solver.

Definition at line 18 of file QuadSubChannel1PhaseProblem.h.

Constructor & Destructor Documentation

◆ QuadSubChannel1PhaseProblem()

QuadSubChannel1PhaseProblem::QuadSubChannel1PhaseProblem ( const InputParameters params)

Definition at line 36 of file QuadSubChannel1PhaseProblem.C.

37  : SubChannel1PhaseProblem(params),
38  _subchannel_mesh(SCM::getMesh<QuadSubChannelMesh>(_mesh)),
39  _beta(getParam<Real>("beta")),
40  _default_friction_model(getParam<bool>("default_friction_model")),
41  _constant_beta(getParam<bool>("constant_beta"))
42 {
43 }
const bool _constant_beta
Flag that activates the use of constant beta.
const bool _default_friction_model
Flag that activates one of the two friction models (default: f=a*Re^b, non-default: Todreas-Kazimi) ...
MooseMesh & _mesh
const Real & _beta
Thermal diffusion coefficient used in turbulent crossflow.
SubChannel1PhaseProblem(const InputParameters &params)

Member Function Documentation

◆ cleanUp()

PetscErrorCode SubChannel1PhaseProblem::cleanUp ( )
protectedinherited

Definition at line 279 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::~SubChannel1PhaseProblem().

280 {
282  // We need to clean up the petsc matrices/vectors
283  // Mass conservation components
284  LibmeshPetscCall(MatDestroy(&_mc_sumWij_mat));
285  LibmeshPetscCall(VecDestroy(&_Wij_vec));
286  LibmeshPetscCall(VecDestroy(&_prod));
287  LibmeshPetscCall(VecDestroy(&_prodp));
288  LibmeshPetscCall(MatDestroy(&_mc_axial_convection_mat));
289  LibmeshPetscCall(VecDestroy(&_mc_axial_convection_rhs));
290 
291  // Axial momentum conservation components
292  LibmeshPetscCall(MatDestroy(&_amc_turbulent_cross_flows_mat));
293  LibmeshPetscCall(VecDestroy(&_amc_turbulent_cross_flows_rhs));
294  LibmeshPetscCall(MatDestroy(&_amc_time_derivative_mat));
295  LibmeshPetscCall(VecDestroy(&_amc_time_derivative_rhs));
296  LibmeshPetscCall(MatDestroy(&_amc_advective_derivative_mat));
297  LibmeshPetscCall(VecDestroy(&_amc_advective_derivative_rhs));
298  LibmeshPetscCall(MatDestroy(&_amc_cross_derivative_mat));
299  LibmeshPetscCall(VecDestroy(&_amc_cross_derivative_rhs));
300  LibmeshPetscCall(MatDestroy(&_amc_friction_force_mat));
301  LibmeshPetscCall(VecDestroy(&_amc_friction_force_rhs));
302  LibmeshPetscCall(VecDestroy(&_amc_gravity_rhs));
303  LibmeshPetscCall(MatDestroy(&_amc_pressure_force_mat));
304  LibmeshPetscCall(VecDestroy(&_amc_pressure_force_rhs));
305  LibmeshPetscCall(MatDestroy(&_amc_sys_mdot_mat));
306  LibmeshPetscCall(VecDestroy(&_amc_sys_mdot_rhs));
307 
308  // Lateral momentum conservation components
309  LibmeshPetscCall(MatDestroy(&_cmc_time_derivative_mat));
310  LibmeshPetscCall(VecDestroy(&_cmc_time_derivative_rhs));
311  LibmeshPetscCall(MatDestroy(&_cmc_advective_derivative_mat));
312  LibmeshPetscCall(VecDestroy(&_cmc_advective_derivative_rhs));
313  LibmeshPetscCall(MatDestroy(&_cmc_friction_force_mat));
314  LibmeshPetscCall(VecDestroy(&_cmc_friction_force_rhs));
315  LibmeshPetscCall(MatDestroy(&_cmc_pressure_force_mat));
316  LibmeshPetscCall(VecDestroy(&_cmc_pressure_force_rhs));
317  LibmeshPetscCall(MatDestroy(&_cmc_sys_Wij_mat));
318  LibmeshPetscCall(VecDestroy(&_cmc_sys_Wij_rhs));
319 
320  // Energy conservation components
321  LibmeshPetscCall(MatDestroy(&_hc_time_derivative_mat));
322  LibmeshPetscCall(VecDestroy(&_hc_time_derivative_rhs));
323  LibmeshPetscCall(MatDestroy(&_hc_advective_derivative_mat));
324  LibmeshPetscCall(VecDestroy(&_hc_advective_derivative_rhs));
325  LibmeshPetscCall(MatDestroy(&_hc_cross_derivative_mat));
326  LibmeshPetscCall(VecDestroy(&_hc_cross_derivative_rhs));
327  LibmeshPetscCall(VecDestroy(&_hc_added_heat_rhs));
328  LibmeshPetscCall(MatDestroy(&_hc_sys_h_mat));
329  LibmeshPetscCall(VecDestroy(&_hc_sys_h_rhs));
330 
331  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
332 }
Mat _amc_sys_mdot_mat
Axial momentum system matrix.
Vec _amc_gravity_rhs
Axial momentum conservation - buoyancy force No implicit matrix.
Mat _cmc_friction_force_mat
Cross momentum conservation - friction force.
Mat _amc_friction_force_mat
Axial momentum conservation - friction force.
PetscFunctionBegin
Mat _cmc_sys_Wij_mat
Lateral momentum system matrix.
Mat _mc_sumWij_mat
Matrices and vectors to be used in implicit assembly Mass conservation Mass conservation - sum of cro...
Mat _amc_turbulent_cross_flows_mat
Mass conservation - density time derivative No implicit matrix.
Mat _amc_advective_derivative_mat
Axial momentum conservation - advective (Eulerian) derivative.
Vec _hc_added_heat_rhs
Enthalpy conservation - source and sink.
Mat _amc_pressure_force_mat
Axial momentum conservation - pressure force.
Mat _hc_cross_derivative_mat
Enthalpy conservation - cross flux derivative.
Mat _mc_axial_convection_mat
Mass conservation - axial convection.
Mat _amc_cross_derivative_mat
Axial momentum conservation - cross flux derivative.
Mat _hc_advective_derivative_mat
Enthalpy conservation - advective (Eulerian) derivative;.
Mat _amc_time_derivative_mat
Axial momentum conservation - time derivative.
Mat _hc_time_derivative_mat
Enthalpy Enthalpy conservation - time derivative.
Mat _cmc_time_derivative_mat
Cross momentum Cross momentum conservation - time derivative.
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)
Mat _cmc_pressure_force_mat
Cross momentum conservation - pressure force.
Mat _cmc_advective_derivative_mat
Cross momentum conservation - advective (Eulerian) derivative.
Mat _hc_sys_h_mat
System matrices.

◆ computeAddedHeatDuct()

Real SubChannel1PhaseProblem::computeAddedHeatDuct ( unsigned int  i_ch,
unsigned int  iz 
)
protectedinherited

Function that computes the heat flux added by the duct.

Definition at line 1312 of file SubChannel1PhaseProblem.C.

Referenced by TriSubChannel1PhaseProblem::computeh().

1313 {
1314  if (_duct_mesh_exist)
1315  {
1316  auto subch_type = _subchannel_mesh.getSubchannelType(i_ch);
1317  if (subch_type == EChannelType::EDGE || subch_type == EChannelType::CORNER)
1318  {
1319  auto dz = _z_grid[iz] - _z_grid[iz - 1];
1320  auto * node_in_chan = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1321  auto * node_out_chan = _subchannel_mesh.getChannelNode(i_ch, iz);
1322  auto * node_in_duct = _subchannel_mesh.getDuctNodeFromChannel(node_in_chan);
1323  auto * node_out_duct = _subchannel_mesh.getDuctNodeFromChannel(node_out_chan);
1324  auto heat_rate_in = (*_q_prime_duct_soln)(node_in_duct);
1325  auto heat_rate_out = (*_q_prime_duct_soln)(node_out_duct);
1326  return 0.5 * (heat_rate_in + heat_rate_out) * dz / _outer_channels;
1327  }
1328  else
1329  {
1330  return 0.0;
1331  }
1332  }
1333  else
1334  {
1335  return 0;
1336  }
1337 }
virtual EChannelType getSubchannelType(unsigned int index) const =0
Return the type of the subchannel for given subchannel index.
const bool _duct_mesh_exist
Flag that informs if there is a pin mesh or not.
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
std::vector< Real > _z_grid
axial location of nodes
virtual Node * getDuctNodeFromChannel(Node *channel_node)=0
Function that gets the duct node from the channel node.

◆ computeAddedHeatPin()

Real QuadSubChannel1PhaseProblem::computeAddedHeatPin ( unsigned int  i_ch,
unsigned int  iz 
)
overrideprotectedvirtual

Computes added heat for channel i_ch and cell iz.

Implements SubChannel1PhaseProblem.

Definition at line 427 of file QuadSubChannel1PhaseProblem.C.

Referenced by computeh().

428 {
429  // Compute axial location of nodes.
430  auto z2 = _z_grid[iz];
431  auto z1 = _z_grid[iz - 1];
432  auto heated_length = _subchannel_mesh.getHeatedLength();
433  auto unheated_length_entry = _subchannel_mesh.getHeatedLengthEntry();
434  if (MooseUtils::absoluteFuzzyGreaterThan(z2, unheated_length_entry) &&
435  MooseUtils::absoluteFuzzyLessThan(z1, unheated_length_entry + heated_length))
436  {
437  // Compute the height of this element.
438  auto dz = z2 - z1;
439  if (_pin_mesh_exist)
440  {
441  auto heat_rate_in = 0.0;
442  auto heat_rate_out = 0.0;
443  for (auto i_pin : _subchannel_mesh.getChannelPins(i_ch))
444  {
445  auto * node_in = _subchannel_mesh.getPinNode(i_pin, iz - 1);
446  auto * node_out = _subchannel_mesh.getPinNode(i_pin, iz);
447  heat_rate_out += 0.25 * (*_q_prime_soln)(node_out);
448  heat_rate_in += 0.25 * (*_q_prime_soln)(node_in);
449  }
450  return (heat_rate_in + heat_rate_out) * dz / 2.0;
451  }
452  else
453  {
454  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
455  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
456  return ((*_q_prime_soln)(node_out) + (*_q_prime_soln)(node_in)) * dz / 2.0;
457  }
458  }
459  else
460  return 0.0;
461 }
const bool _pin_mesh_exist
Flag that informs if there is a pin mesh or not.
virtual Node * getPinNode(unsigned int i_pin, unsigned iz) const override
Get the pin mesh node for a given pin index and elevation index.
std::vector< Real > _z_grid
axial location of nodes
virtual const Real & getHeatedLength() const
Return heated length.
std::unique_ptr< SolutionHandle > _q_prime_soln
bool absoluteFuzzyLessThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const override
Get the subchannel mesh node for a given channel index and elevation index.
virtual const std::vector< unsigned int > & getChannelPins(unsigned int i_chan) const override
Return a vector of pin indices for a given channel index.
bool absoluteFuzzyGreaterThan(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
virtual const Real & getHeatedLengthEntry() const
Return unheated length at entry.

◆ computeBeta()

Real QuadSubChannel1PhaseProblem::computeBeta ( unsigned int  i_gap,
unsigned int  iz 
)
overrideprotectedvirtual

Computes turbulent mixing coefficient.

Implements SubChannel1PhaseProblem.

Definition at line 360 of file QuadSubChannel1PhaseProblem.C.

361 {
362  auto beta = _beta;
363  if (!_constant_beta)
364  {
365  const Real & pitch = _subchannel_mesh.getPitch();
366  const Real & pin_diameter = _subchannel_mesh.getPinDiameter();
367  auto chans = _subchannel_mesh.getGapChannels(i_gap);
368  unsigned int i_ch = chans.first;
369  unsigned int j_ch = chans.second;
370  auto * node_in_i = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
371  auto * node_out_i = _subchannel_mesh.getChannelNode(i_ch, iz);
372  auto * node_in_j = _subchannel_mesh.getChannelNode(j_ch, iz - 1);
373  auto * node_out_j = _subchannel_mesh.getChannelNode(j_ch, iz);
374  auto Si_in = (*_S_flow_soln)(node_in_i);
375  auto Sj_in = (*_S_flow_soln)(node_in_j);
376  auto Si_out = (*_S_flow_soln)(node_out_i);
377  auto Sj_out = (*_S_flow_soln)(node_out_j);
378  // crossflow area between channels i,j (dz*gap_width)
379  auto gap = _subchannel_mesh.getGapWidth(iz, i_gap);
380  auto avg_massflux =
381  0.5 * (((*_mdot_soln)(node_in_i) + (*_mdot_soln)(node_in_j)) / (Si_in + Sj_in) +
382  ((*_mdot_soln)(node_out_i) + (*_mdot_soln)(node_out_j)) / (Si_out + Sj_out));
383  auto S_total = Si_in + Sj_in + Si_out + Sj_out;
384  auto Si = 0.5 * (Si_in + Si_out);
385  auto Sj = 0.5 * (Sj_in + Sj_out);
386  auto w_perim_i = 0.5 * ((*_w_perim_soln)(node_in_i) + (*_w_perim_soln)(node_out_i));
387  auto w_perim_j = 0.5 * ((*_w_perim_soln)(node_in_j) + (*_w_perim_soln)(node_out_j));
388  auto avg_mu = (1 / S_total) * ((*_mu_soln)(node_out_i)*Si_out + (*_mu_soln)(node_in_i)*Si_in +
389  (*_mu_soln)(node_out_j)*Sj_out + (*_mu_soln)(node_in_j)*Sj_in);
390  auto avg_hD = 4.0 * (Si + Sj) / (w_perim_i + w_perim_j);
391  auto Re = avg_massflux * avg_hD / avg_mu;
392  Real gamma = 20.0; // empirical constant
393  Real sf = 1.0; // shape factor
394  Real a = 0.18;
395  Real b = 0.2;
396  auto f = a * std::pow(Re, -b); // Rehme 1992 circular tube friction factor
397  auto k = (1 / S_total) *
398  (_fp->k_from_p_T((*_P_soln)(node_out_i) + _P_out, (*_T_soln)(node_out_i)) * Si_out +
399  _fp->k_from_p_T((*_P_soln)(node_in_i) + _P_out, (*_T_soln)(node_in_i)) * Si_in +
400  _fp->k_from_p_T((*_P_soln)(node_out_j) + _P_out, (*_T_soln)(node_out_j)) * Sj_out +
401  _fp->k_from_p_T((*_P_soln)(node_in_j) + _P_out, (*_T_soln)(node_in_j)) * Sj_in);
402  auto cp = (1 / S_total) *
403  (_fp->cp_from_p_T((*_P_soln)(node_out_i) + _P_out, (*_T_soln)(node_out_i)) * Si_out +
404  _fp->cp_from_p_T((*_P_soln)(node_in_i) + _P_out, (*_T_soln)(node_in_i)) * Si_in +
405  _fp->cp_from_p_T((*_P_soln)(node_out_j) + _P_out, (*_T_soln)(node_out_j)) * Sj_out +
406  _fp->cp_from_p_T((*_P_soln)(node_in_j) + _P_out, (*_T_soln)(node_in_j)) * Sj_in);
407  auto Pr = avg_mu * cp / k; // Prandtl number
408  auto Pr_t = Pr * (Re / gamma) * std::sqrt(f / 8.0); // Turbulent Prandtl number
409  auto delta = pitch; // centroid to centroid distance
410  auto L_x = sf * delta; // axial length scale (gap is the lateral length scale)
411  auto lamda = gap / L_x; // aspect ratio
412  auto a_x = 1.0 - 2.0 * lamda * lamda / libMesh::pi; // velocity coefficient
413  auto z_FP_over_D = (2.0 * L_x / pin_diameter) *
414  (1 + (-0.5 * std::log(lamda) + 0.5 * std::log(4.0) - 0.25) * lamda * lamda);
415  auto Str = 1.0 / (0.822 * (gap / pin_diameter) + 0.144); // Strouhal number (Wu & Trupp 1994)
416  auto freq_factor = 2.0 / std::pow(gamma, 2) * std::sqrt(a / 8.0) * (avg_hD / gap);
417  auto rod_mixing = (1 / Pr_t) * lamda;
418  auto axial_mixing = a_x * z_FP_over_D * Str;
419  // Mixing Stanton number: Stg (eq 25,Kim and Chung (2001), eq 19 (Jeong et. al 2005)
420  beta = freq_factor * (rod_mixing + axial_mixing) * std::pow(Re, -b / 2.0);
421  }
422  mooseAssert(beta > 0, "beta should be positive");
423  return beta;
424 }
virtual const Real & getPinDiameter() const
Return Pin diameter.
std::unique_ptr< SolutionHandle > _T_soln
const PostprocessorValue & _P_out
Outlet Pressure.
const bool _constant_beta
Flag that activates the use of constant beta.
int delta(unsigned int i, unsigned int j)
Delta function, which returns zero if $i j$ and unity if $i=j$.
virtual Real getGapWidth(unsigned int axial_index, unsigned int gap_index) const override
Return gap width for a given gap index.
virtual const std::pair< unsigned int, unsigned int > & getGapChannels(unsigned int i_gap) const override
Return a pair of subchannel indices for a given gap index.
static const std::string cp
Definition: NS.h:121
Real f(Real x)
Test function for Brents method.
static const std::string pitch
const Real & _beta
Thermal diffusion coefficient used in turbulent crossflow.
std::unique_ptr< SolutionHandle > _mdot_soln
virtual const Real & getPitch() const override
Return the pitch between 2 subchannels.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const override
Get the subchannel mesh node for a given channel index and elevation index.
MooseUnits pow(const MooseUnits &, int)
std::unique_ptr< SolutionHandle > _P_soln
static const std::string k
Definition: NS.h:130
std::unique_ptr< SolutionHandle > _w_perim_soln
const SinglePhaseFluidProperties * _fp
Solutions handles and link to TH tables properties.
const Real pi
std::unique_ptr< SolutionHandle > _mu_soln

◆ computeDP()

void SubChannel1PhaseProblem::computeDP ( int  iblock)
protectedinherited

Computes Pressure Drop per channel for block iblock.

Upwind local form loss

Upwind local form loss

Time derivative term

Advective derivative term

Cross derivative term

Friction term

Upwind local form loss

Gravity force

Assembling system

Definition at line 578 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::implicitPetscSolve(), and SubChannel1PhaseProblem::residualFunction().

579 {
580  unsigned int last_node = (iblock + 1) * _block_size;
581  unsigned int first_node = iblock * _block_size + 1;
582  if (!_implicit_bool)
583  {
584  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
585  {
586  auto k_grid = _subchannel_mesh.getKGrid();
587  auto dz = _z_grid[iz] - _z_grid[iz - 1];
588  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
589  {
590  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
591  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
592  auto rho_in = (*_rho_soln)(node_in);
593  auto rho_out = (*_rho_soln)(node_out);
594  auto mu_in = (*_mu_soln)(node_in);
595  auto S = (*_S_flow_soln)(node_in);
596  auto w_perim = (*_w_perim_soln)(node_in);
597  // hydraulic diameter in the i direction
598  auto Dh_i = 4.0 * S / w_perim;
599  auto time_term = _TR * ((*_mdot_soln)(node_out)-_mdot_soln->old(node_out)) * dz / _dt -
600  dz * 2.0 * (*_mdot_soln)(node_out) * (rho_out - _rho_soln->old(node_out)) /
601  rho_in / _dt;
602  auto mass_term1 =
603  std::pow((*_mdot_soln)(node_out), 2.0) * (1.0 / S / rho_out - 1.0 / S / rho_in);
604  auto mass_term2 = -2.0 * (*_mdot_soln)(node_out) * (*_SumWij_soln)(node_out) / S / rho_in;
605  auto crossflow_term = 0.0;
606  auto turbulent_term = 0.0;
607  unsigned int counter = 0;
608  for (auto i_gap : _subchannel_mesh.getChannelGaps(i_ch))
609  {
610  auto chans = _subchannel_mesh.getGapChannels(i_gap);
611  unsigned int ii_ch = chans.first;
612  unsigned int jj_ch = chans.second;
613  auto * node_in_i = _subchannel_mesh.getChannelNode(ii_ch, iz - 1);
614  auto * node_in_j = _subchannel_mesh.getChannelNode(jj_ch, iz - 1);
615  auto * node_out_i = _subchannel_mesh.getChannelNode(ii_ch, iz);
616  auto * node_out_j = _subchannel_mesh.getChannelNode(jj_ch, iz);
617  auto rho_i = (*_rho_soln)(node_in_i);
618  auto rho_j = (*_rho_soln)(node_in_j);
619  auto Si = (*_S_flow_soln)(node_in_i);
620  auto Sj = (*_S_flow_soln)(node_in_j);
621  Real u_star = 0.0;
622  // figure out donor axial velocity
623  if (_Wij(i_gap, iz) > 0.0)
624  u_star = (*_mdot_soln)(node_out_i) / Si / rho_i;
625  else
626  u_star = (*_mdot_soln)(node_out_j) / Sj / rho_j;
627 
628  crossflow_term +=
629  _subchannel_mesh.getCrossflowSign(i_ch, counter) * _Wij(i_gap, iz) * u_star;
630 
631  turbulent_term += _WijPrime(i_gap, iz) * (2 * (*_mdot_soln)(node_out) / rho_in / S -
632  (*_mdot_soln)(node_out_j) / Sj / rho_j -
633  (*_mdot_soln)(node_out_i) / Si / rho_i);
634  counter++;
635  }
636  turbulent_term *= _CT;
637  auto Re = (((*_mdot_soln)(node_in) / S) * Dh_i / mu_in);
638  _friction_args.Re = Re;
639  _friction_args.i_ch = i_ch;
640  _friction_args.S = S;
641  _friction_args.w_perim = w_perim;
644  auto ki = 0.0;
645  if ((*_mdot_soln)(node_out) >= 0)
646  ki = k_grid[i_ch][iz - 1];
647  else
648  ki = k_grid[i_ch][iz];
649  auto friction_term = (fi * dz / Dh_i + ki) * 0.5 *
650  (*_mdot_soln)(node_out)*std::abs((*_mdot_soln)(node_out)) /
651  (S * (*_rho_soln)(node_out));
652  auto gravity_term = _g_grav * (*_rho_soln)(node_out)*dz * S;
653  auto DP = std::pow(S, -1.0) * (time_term + mass_term1 + mass_term2 + crossflow_term +
654  turbulent_term + friction_term + gravity_term); // Pa
655  _DP_soln->set(node_out, DP);
656  }
657  }
658  }
659  else
660  {
661  LibmeshPetscCall(MatZeroEntries(_amc_time_derivative_mat));
662  LibmeshPetscCall(MatZeroEntries(_amc_advective_derivative_mat));
663  LibmeshPetscCall(MatZeroEntries(_amc_cross_derivative_mat));
664  LibmeshPetscCall(MatZeroEntries(_amc_friction_force_mat));
665  LibmeshPetscCall(VecZeroEntries(_amc_time_derivative_rhs));
666  LibmeshPetscCall(VecZeroEntries(_amc_advective_derivative_rhs));
667  LibmeshPetscCall(VecZeroEntries(_amc_cross_derivative_rhs));
668  LibmeshPetscCall(VecZeroEntries(_amc_friction_force_rhs));
669  LibmeshPetscCall(VecZeroEntries(_amc_gravity_rhs));
670  LibmeshPetscCall(MatZeroEntries(_amc_sys_mdot_mat));
671  LibmeshPetscCall(VecZeroEntries(_amc_sys_mdot_rhs));
672  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
673  {
674  auto k_grid = _subchannel_mesh.getKGrid();
675  auto dz = _z_grid[iz] - _z_grid[iz - 1];
676  auto iz_ind = iz - first_node;
677  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
678  {
679  // inlet and outlet nodes
680  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
681  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
682 
683  // interpolation weight coefficient
684  PetscScalar Pe = 0.5;
685  if (_interpolation_scheme == 3)
686  {
687  // Compute the Peclet number
688  auto S_in = (*_S_flow_soln)(node_in);
689  auto S_out = (*_S_flow_soln)(node_out);
690  auto S_interp = computeInterpolatedValue(S_out, S_in, 0.5);
691  auto w_perim_in = (*_w_perim_soln)(node_in);
692  auto w_perim_out = (*_w_perim_soln)(node_out);
693  auto w_perim_interp = this->computeInterpolatedValue(w_perim_out, w_perim_in, 0.5);
694  auto mdot_loc =
695  this->computeInterpolatedValue((*_mdot_soln)(node_out), (*_mdot_soln)(node_in), 0.5);
696  auto mu_in = (*_mu_soln)(node_in);
697  auto mu_out = (*_mu_soln)(node_out);
698  auto mu_interp = this->computeInterpolatedValue(mu_out, mu_in, 0.5);
699  auto Dh_i = 4.0 * S_interp / w_perim_interp;
700  // Compute friction
701  auto Re = ((mdot_loc / S_interp) * Dh_i / mu_interp);
702  _friction_args.Re = Re;
703  _friction_args.i_ch = i_ch;
704  _friction_args.S = S_interp;
705  _friction_args.w_perim = w_perim_interp;
708  auto ki = 0.0;
709  if ((*_mdot_soln)(node_out) >= 0)
710  ki = k_grid[i_ch][iz - 1];
711  else
712  ki = k_grid[i_ch][iz];
713  Pe = 1.0 / ((fi * dz / Dh_i + ki) * 0.5) * mdot_loc / std::abs(mdot_loc);
714  }
716 
717  // inlet, outlet, and interpolated density
718  auto rho_in = (*_rho_soln)(node_in);
719  auto rho_out = (*_rho_soln)(node_out);
720  auto rho_interp = computeInterpolatedValue(rho_out, rho_in, Pe);
721 
722  // inlet, outlet, and interpolated viscosity
723  auto mu_in = (*_mu_soln)(node_in);
724  auto mu_out = (*_mu_soln)(node_out);
725  auto mu_interp = computeInterpolatedValue(mu_out, mu_in, Pe);
726 
727  // inlet, outlet, and interpolated axial surface area
728  auto S_in = (*_S_flow_soln)(node_in);
729  auto S_out = (*_S_flow_soln)(node_out);
730  auto S_interp = computeInterpolatedValue(S_out, S_in, Pe);
731 
732  // inlet, outlet, and interpolated wetted perimeter
733  auto w_perim_in = (*_w_perim_soln)(node_in);
734  auto w_perim_out = (*_w_perim_soln)(node_out);
735  auto w_perim_interp = computeInterpolatedValue(w_perim_out, w_perim_in, Pe);
736 
737  // hydraulic diameter in the i direction
738  auto Dh_i = 4.0 * S_interp / w_perim_interp;
739 
741  if (iz == first_node)
742  {
743  PetscScalar value_vec_tt = -1.0 * _TR * alpha * (*_mdot_soln)(node_in)*dz / _dt;
744  PetscInt row_vec_tt = i_ch + _n_channels * iz_ind;
745  LibmeshPetscCall(
746  VecSetValues(_amc_time_derivative_rhs, 1, &row_vec_tt, &value_vec_tt, ADD_VALUES));
747  }
748  else
749  {
750  PetscInt row_tt = i_ch + _n_channels * iz_ind;
751  PetscInt col_tt = i_ch + _n_channels * (iz_ind - 1);
752  PetscScalar value_tt = _TR * alpha * dz / _dt;
753  LibmeshPetscCall(MatSetValues(
754  _amc_time_derivative_mat, 1, &row_tt, 1, &col_tt, &value_tt, INSERT_VALUES));
755  }
756 
757  // Adding diagonal elements
758  PetscInt row_tt = i_ch + _n_channels * iz_ind;
759  PetscInt col_tt = i_ch + _n_channels * iz_ind;
760  PetscScalar value_tt = _TR * (1.0 - alpha) * dz / _dt;
761  LibmeshPetscCall(MatSetValues(
762  _amc_time_derivative_mat, 1, &row_tt, 1, &col_tt, &value_tt, INSERT_VALUES));
763 
764  // Adding RHS elements
765  PetscScalar mdot_old_interp =
766  computeInterpolatedValue(_mdot_soln->old(node_out), _mdot_soln->old(node_in), Pe);
767  PetscScalar value_vec_tt = _TR * mdot_old_interp * dz / _dt;
768  PetscInt row_vec_tt = i_ch + _n_channels * iz_ind;
769  LibmeshPetscCall(
770  VecSetValues(_amc_time_derivative_rhs, 1, &row_vec_tt, &value_vec_tt, ADD_VALUES));
771 
773  if (iz == first_node)
774  {
775  PetscScalar value_vec_at = std::pow((*_mdot_soln)(node_in), 2.0) / (S_in * rho_in);
776  PetscInt row_vec_at = i_ch + _n_channels * iz_ind;
777  LibmeshPetscCall(VecSetValues(
778  _amc_advective_derivative_rhs, 1, &row_vec_at, &value_vec_at, ADD_VALUES));
779  }
780  else
781  {
782  PetscInt row_at = i_ch + _n_channels * iz_ind;
783  PetscInt col_at = i_ch + _n_channels * (iz_ind - 1);
784  PetscScalar value_at = -1.0 * std::abs((*_mdot_soln)(node_in)) / (S_in * rho_in);
785  LibmeshPetscCall(MatSetValues(
786  _amc_advective_derivative_mat, 1, &row_at, 1, &col_at, &value_at, INSERT_VALUES));
787  }
788 
789  // Adding diagonal elements
790  PetscInt row_at = i_ch + _n_channels * iz_ind;
791  PetscInt col_at = i_ch + _n_channels * iz_ind;
792  PetscScalar value_at = std::abs((*_mdot_soln)(node_out)) / (S_out * rho_out);
793  LibmeshPetscCall(MatSetValues(
794  _amc_advective_derivative_mat, 1, &row_at, 1, &col_at, &value_at, INSERT_VALUES));
795 
797  unsigned int counter = 0;
798  unsigned int cross_index = iz; // iz-1;
799  for (auto i_gap : _subchannel_mesh.getChannelGaps(i_ch))
800  {
801  auto chans = _subchannel_mesh.getGapChannels(i_gap);
802  unsigned int ii_ch = chans.first;
803  unsigned int jj_ch = chans.second;
804  auto * node_in_i = _subchannel_mesh.getChannelNode(ii_ch, iz - 1);
805  auto * node_in_j = _subchannel_mesh.getChannelNode(jj_ch, iz - 1);
806  auto * node_out_i = _subchannel_mesh.getChannelNode(ii_ch, iz);
807  auto * node_out_j = _subchannel_mesh.getChannelNode(jj_ch, iz);
808  auto rho_i =
809  computeInterpolatedValue((*_rho_soln)(node_out_i), (*_rho_soln)(node_in_i), Pe);
810  auto rho_j =
811  computeInterpolatedValue((*_rho_soln)(node_out_j), (*_rho_soln)(node_in_j), Pe);
812  auto S_i =
813  computeInterpolatedValue((*_S_flow_soln)(node_out_i), (*_S_flow_soln)(node_in_i), Pe);
814  auto S_j =
815  computeInterpolatedValue((*_S_flow_soln)(node_out_j), (*_S_flow_soln)(node_in_j), Pe);
816  auto u_star = 0.0;
817  // figure out donor axial velocity
818  if (_Wij(i_gap, cross_index) > 0.0)
819  {
820  if (iz == first_node)
821  {
822  u_star = (*_mdot_soln)(node_in_i) / S_i / rho_i;
823  PetscScalar value_vec_ct = -1.0 * alpha *
824  _subchannel_mesh.getCrossflowSign(i_ch, counter) *
825  _Wij(i_gap, cross_index) * u_star;
826  PetscInt row_vec_ct = i_ch + _n_channels * iz_ind;
827  LibmeshPetscCall(VecSetValues(
828  _amc_cross_derivative_rhs, 1, &row_vec_ct, &value_vec_ct, ADD_VALUES));
829  }
830  else
831  {
832  PetscScalar value_ct = alpha * _subchannel_mesh.getCrossflowSign(i_ch, counter) *
833  _Wij(i_gap, cross_index) / S_i / rho_i;
834  PetscInt row_ct = i_ch + _n_channels * iz_ind;
835  PetscInt col_ct = ii_ch + _n_channels * (iz_ind - 1);
836  LibmeshPetscCall(MatSetValues(
837  _amc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_ct, ADD_VALUES));
838  }
839  PetscScalar value_ct = (1.0 - alpha) *
840  _subchannel_mesh.getCrossflowSign(i_ch, counter) *
841  _Wij(i_gap, cross_index) / S_i / rho_i;
842  PetscInt row_ct = i_ch + _n_channels * iz_ind;
843  PetscInt col_ct = ii_ch + _n_channels * iz_ind;
844  LibmeshPetscCall(MatSetValues(
845  _amc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_ct, ADD_VALUES));
846  }
847  else if (_Wij(i_gap, cross_index) < 0.0) // _Wij=0 operations not necessary
848  {
849  if (iz == first_node)
850  {
851  u_star = (*_mdot_soln)(node_in_j) / S_j / rho_j;
852  PetscScalar value_vec_ct = -1.0 * alpha *
853  _subchannel_mesh.getCrossflowSign(i_ch, counter) *
854  _Wij(i_gap, cross_index) * u_star;
855  PetscInt row_vec_ct = i_ch + _n_channels * iz_ind;
856  LibmeshPetscCall(VecSetValues(
857  _amc_cross_derivative_rhs, 1, &row_vec_ct, &value_vec_ct, ADD_VALUES));
858  }
859  else
860  {
861  PetscScalar value_ct = alpha * _subchannel_mesh.getCrossflowSign(i_ch, counter) *
862  _Wij(i_gap, cross_index) / S_j / rho_j;
863  PetscInt row_ct = i_ch + _n_channels * iz_ind;
864  PetscInt col_ct = jj_ch + _n_channels * (iz_ind - 1);
865  LibmeshPetscCall(MatSetValues(
866  _amc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_ct, ADD_VALUES));
867  }
868  PetscScalar value_ct = (1.0 - alpha) *
869  _subchannel_mesh.getCrossflowSign(i_ch, counter) *
870  _Wij(i_gap, cross_index) / S_j / rho_j;
871  PetscInt row_ct = i_ch + _n_channels * iz_ind;
872  PetscInt col_ct = jj_ch + _n_channels * iz_ind;
873  LibmeshPetscCall(MatSetValues(
874  _amc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_ct, ADD_VALUES));
875  }
876 
877  if (iz == first_node)
878  {
879  PetscScalar value_vec_ct = -2.0 * alpha * (*_mdot_soln)(node_in)*_CT *
880  _WijPrime(i_gap, cross_index) / (rho_interp * S_interp);
881  value_vec_ct += alpha * (*_mdot_soln)(node_in_j)*_CT * _WijPrime(i_gap, cross_index) /
882  (rho_j * S_j);
883  value_vec_ct += alpha * (*_mdot_soln)(node_in_i)*_CT * _WijPrime(i_gap, cross_index) /
884  (rho_i * S_i);
885  PetscInt row_vec_ct = i_ch + _n_channels * iz_ind;
886  LibmeshPetscCall(
887  VecSetValues(_amc_cross_derivative_rhs, 1, &row_vec_ct, &value_vec_ct, ADD_VALUES));
888  }
889  else
890  {
891  PetscScalar value_center_ct =
892  2.0 * alpha * _CT * _WijPrime(i_gap, cross_index) / (rho_interp * S_interp);
893  PetscInt row_ct = i_ch + _n_channels * iz_ind;
894  PetscInt col_ct = i_ch + _n_channels * (iz_ind - 1);
895  LibmeshPetscCall(MatSetValues(
896  _amc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_center_ct, ADD_VALUES));
897 
898  PetscScalar value_left_ct =
899  -1.0 * alpha * _CT * _WijPrime(i_gap, cross_index) / (rho_j * S_j);
900  row_ct = i_ch + _n_channels * iz_ind;
901  col_ct = jj_ch + _n_channels * (iz_ind - 1);
902  LibmeshPetscCall(MatSetValues(
903  _amc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_left_ct, ADD_VALUES));
904 
905  PetscScalar value_right_ct =
906  -1.0 * alpha * _CT * _WijPrime(i_gap, cross_index) / (rho_i * S_i);
907  row_ct = i_ch + _n_channels * iz_ind;
908  col_ct = ii_ch + _n_channels * (iz_ind - 1);
909  LibmeshPetscCall(MatSetValues(
910  _amc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_right_ct, ADD_VALUES));
911  }
912 
913  PetscScalar value_center_ct =
914  2.0 * (1.0 - alpha) * _CT * _WijPrime(i_gap, cross_index) / (rho_interp * S_interp);
915  PetscInt row_ct = i_ch + _n_channels * iz_ind;
916  PetscInt col_ct = i_ch + _n_channels * iz_ind;
917  LibmeshPetscCall(MatSetValues(
918  _amc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_center_ct, ADD_VALUES));
919 
920  PetscScalar value_left_ct =
921  -1.0 * (1.0 - alpha) * _CT * _WijPrime(i_gap, cross_index) / (rho_j * S_j);
922  row_ct = i_ch + _n_channels * iz_ind;
923  col_ct = jj_ch + _n_channels * iz_ind;
924  LibmeshPetscCall(MatSetValues(
925  _amc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_left_ct, ADD_VALUES));
926 
927  PetscScalar value_right_ct =
928  -1.0 * (1.0 - alpha) * _CT * _WijPrime(i_gap, cross_index) / (rho_i * S_i);
929  row_ct = i_ch + _n_channels * iz_ind;
930  col_ct = ii_ch + _n_channels * iz_ind;
931  LibmeshPetscCall(MatSetValues(
932  _amc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_right_ct, ADD_VALUES));
933  counter++;
934  }
935 
937  PetscScalar mdot_interp =
938  computeInterpolatedValue((*_mdot_soln)(node_out), (*_mdot_soln)(node_in), Pe);
939  auto Re = ((mdot_interp / S_interp) * Dh_i / mu_interp);
940  _friction_args.Re = Re;
941  _friction_args.i_ch = i_ch;
942  _friction_args.S = S_interp;
943  _friction_args.w_perim = w_perim_interp;
946  auto ki = 0.0;
947  if ((*_mdot_soln)(node_out) >= 0)
948  ki = k_grid[i_ch][iz - 1];
949  else
950  ki = k_grid[i_ch][iz];
951  auto coef = (fi * dz / Dh_i + ki) * 0.5 * std::abs((*_mdot_soln)(node_out)) /
952  (S_interp * rho_interp);
953  if (iz == first_node)
954  {
955  PetscScalar value_vec = -1.0 * alpha * coef * (*_mdot_soln)(node_in);
956  PetscInt row_vec = i_ch + _n_channels * iz_ind;
957  LibmeshPetscCall(
958  VecSetValues(_amc_friction_force_rhs, 1, &row_vec, &value_vec, ADD_VALUES));
959  }
960  else
961  {
962  PetscInt row = i_ch + _n_channels * iz_ind;
963  PetscInt col = i_ch + _n_channels * (iz_ind - 1);
964  PetscScalar value = alpha * coef;
965  LibmeshPetscCall(
966  MatSetValues(_amc_friction_force_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
967  }
968 
969  // Adding diagonal elements
970  PetscInt row = i_ch + _n_channels * iz_ind;
971  PetscInt col = i_ch + _n_channels * iz_ind;
972  PetscScalar value = (1.0 - alpha) * coef;
973  LibmeshPetscCall(
974  MatSetValues(_amc_friction_force_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
975 
977  PetscScalar value_vec = -1.0 * _g_grav * rho_interp * dz * S_interp;
978  PetscInt row_vec = i_ch + _n_channels * iz_ind;
979  LibmeshPetscCall(VecSetValues(_amc_gravity_rhs, 1, &row_vec, &value_vec, ADD_VALUES));
980  }
981  }
983  LibmeshPetscCall(MatZeroEntries(_amc_sys_mdot_mat));
984  LibmeshPetscCall(VecZeroEntries(_amc_sys_mdot_rhs));
985  LibmeshPetscCall(MatAssemblyBegin(_amc_time_derivative_mat, MAT_FINAL_ASSEMBLY));
986  LibmeshPetscCall(MatAssemblyEnd(_amc_time_derivative_mat, MAT_FINAL_ASSEMBLY));
987  LibmeshPetscCall(MatAssemblyBegin(_amc_advective_derivative_mat, MAT_FINAL_ASSEMBLY));
988  LibmeshPetscCall(MatAssemblyEnd(_amc_advective_derivative_mat, MAT_FINAL_ASSEMBLY));
989  LibmeshPetscCall(MatAssemblyBegin(_amc_cross_derivative_mat, MAT_FINAL_ASSEMBLY));
990  LibmeshPetscCall(MatAssemblyEnd(_amc_cross_derivative_mat, MAT_FINAL_ASSEMBLY));
991  LibmeshPetscCall(MatAssemblyBegin(_amc_friction_force_mat, MAT_FINAL_ASSEMBLY));
992  LibmeshPetscCall(MatAssemblyEnd(_amc_friction_force_mat, MAT_FINAL_ASSEMBLY));
993  LibmeshPetscCall(MatAssemblyBegin(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
994  LibmeshPetscCall(MatAssemblyEnd(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
995  // Matrix
996 #if !PETSC_VERSION_LESS_THAN(3, 15, 0)
997  LibmeshPetscCall(
998  MatAXPY(_amc_sys_mdot_mat, 1.0, _amc_time_derivative_mat, UNKNOWN_NONZERO_PATTERN));
999  LibmeshPetscCall(MatAssemblyBegin(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
1000  LibmeshPetscCall(MatAssemblyEnd(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
1001  LibmeshPetscCall(
1002  MatAXPY(_amc_sys_mdot_mat, 1.0, _amc_advective_derivative_mat, UNKNOWN_NONZERO_PATTERN));
1003  LibmeshPetscCall(MatAssemblyBegin(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
1004  LibmeshPetscCall(MatAssemblyEnd(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
1005  LibmeshPetscCall(
1006  MatAXPY(_amc_sys_mdot_mat, 1.0, _amc_cross_derivative_mat, UNKNOWN_NONZERO_PATTERN));
1007  LibmeshPetscCall(MatAssemblyBegin(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
1008  LibmeshPetscCall(MatAssemblyEnd(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
1009  LibmeshPetscCall(
1010  MatAXPY(_amc_sys_mdot_mat, 1.0, _amc_friction_force_mat, UNKNOWN_NONZERO_PATTERN));
1011 #else
1012  LibmeshPetscCall(
1013  MatAXPY(_amc_sys_mdot_mat, 1.0, _amc_time_derivative_mat, DIFFERENT_NONZERO_PATTERN));
1014  LibmeshPetscCall(MatAssemblyBegin(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
1015  LibmeshPetscCall(MatAssemblyEnd(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
1016  LibmeshPetscCall(
1017  MatAXPY(_amc_sys_mdot_mat, 1.0, _amc_advective_derivative_mat, DIFFERENT_NONZERO_PATTERN));
1018  LibmeshPetscCall(MatAssemblyBegin(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
1019  LibmeshPetscCall(MatAssemblyEnd(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
1020  LibmeshPetscCall(
1021  MatAXPY(_amc_sys_mdot_mat, 1.0, _amc_cross_derivative_mat, DIFFERENT_NONZERO_PATTERN));
1022  LibmeshPetscCall(MatAssemblyBegin(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
1023  LibmeshPetscCall(MatAssemblyEnd(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
1024  LibmeshPetscCall(
1025  MatAXPY(_amc_sys_mdot_mat, 1.0, _amc_friction_force_mat, DIFFERENT_NONZERO_PATTERN));
1026 #endif
1027  LibmeshPetscCall(MatAssemblyBegin(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
1028  LibmeshPetscCall(MatAssemblyEnd(_amc_sys_mdot_mat, MAT_FINAL_ASSEMBLY));
1029  // RHS
1030  LibmeshPetscCall(VecAXPY(_amc_sys_mdot_rhs, 1.0, _amc_time_derivative_rhs));
1031  LibmeshPetscCall(VecAXPY(_amc_sys_mdot_rhs, 1.0, _amc_advective_derivative_rhs));
1032  LibmeshPetscCall(VecAXPY(_amc_sys_mdot_rhs, 1.0, _amc_cross_derivative_rhs));
1033  LibmeshPetscCall(VecAXPY(_amc_sys_mdot_rhs, 1.0, _amc_friction_force_rhs));
1034  LibmeshPetscCall(VecAXPY(_amc_sys_mdot_rhs, 1.0, _amc_gravity_rhs));
1035  if (_segregated_bool)
1036  {
1037  // Assembly the matrix system
1038  LibmeshPetscCall(populateVectorFromHandle<SolutionHandle>(
1039  _prod, *_mdot_soln, first_node, last_node, _n_channels));
1040  Vec ls;
1041  LibmeshPetscCall(VecDuplicate(_amc_sys_mdot_rhs, &ls));
1042  LibmeshPetscCall(MatMult(_amc_sys_mdot_mat, _prod, ls));
1043  LibmeshPetscCall(VecAXPY(ls, -1.0, _amc_sys_mdot_rhs));
1044  PetscScalar * xx;
1045  LibmeshPetscCall(VecGetArray(ls, &xx));
1046  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
1047  {
1048  auto iz_ind = iz - first_node;
1049  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1050  {
1051  // Setting nodes
1052  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1053  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
1054 
1055  // inlet, outlet, and interpolated axial surface area
1056  auto S_in = (*_S_flow_soln)(node_in);
1057  auto S_out = (*_S_flow_soln)(node_out);
1058  auto S_interp = computeInterpolatedValue(S_out, S_in, 0.5);
1059 
1060  // Setting solutions
1061  if (S_interp != 0)
1062  {
1063  auto DP = std::pow(S_interp, -1.0) * xx[iz_ind * _n_channels + i_ch];
1064  _DP_soln->set(node_out, DP);
1065  }
1066  else
1067  {
1068  auto DP = 0.0;
1069  _DP_soln->set(node_out, DP);
1070  }
1071  }
1072  }
1073  LibmeshPetscCall(VecDestroy(&ls));
1074  }
1075  }
1076 }
Mat _amc_sys_mdot_mat
Axial momentum system matrix.
Vec _amc_gravity_rhs
Axial momentum conservation - buoyancy force No implicit matrix.
Real _TR
Flag that activates or deactivates the transient parts of the equations we solve by multiplication...
std::unique_ptr< SolutionHandle > _S_flow_soln
Mat _amc_friction_force_mat
Axial momentum conservation - friction force.
PetscScalar computeInterpolatedValue(PetscScalar topValue, PetscScalar botValue, PetscScalar Peclet=0.0)
const bool _segregated_bool
Segregated solve.
virtual const std::vector< unsigned int > & getChannelGaps(unsigned int i_chan) const =0
Return a vector of gap indices for a given channel index.
const Real & _CT
Turbulent modeling parameter used in axial momentum equation.
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
std::unique_ptr< SolutionHandle > _rho_soln
Mat _amc_advective_derivative_mat
Axial momentum conservation - advective (Eulerian) derivative.
std::vector< Real > _z_grid
axial location of nodes
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
static const std::string S
Definition: NS.h:163
PetscScalar computeInterpolationCoefficients(PetscScalar Peclet=0.0)
Functions that computes the interpolation scheme given the Peclet number.
virtual Real computeFrictionFactor(FrictionStruct friction_args)=0
Returns friction factor.
virtual const std::vector< std::vector< Real > > & getKGrid() const
Get axial cell location and value of loss coefficient.
const MooseEnum _interpolation_scheme
The interpolation method used in constructing the systems.
std::unique_ptr< SolutionHandle > _mdot_soln
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::unique_ptr< SolutionHandle > _DP_soln
libMesh::DenseMatrix< Real > & _Wij
static const std::string alpha
Definition: NS.h:134
virtual const Real & getCrossflowSign(unsigned int i_chan, unsigned int i_local) const =0
Return a sign for the crossflow given a subchannel index and local neighbor index.
std::unique_ptr< SolutionHandle > _SumWij_soln
Mat _amc_cross_derivative_mat
Axial momentum conservation - cross flux derivative.
struct SubChannel1PhaseProblem::FrictionStruct _friction_args
const bool _implicit_bool
Flag to define the usage of a implicit or explicit solution.
Mat _amc_time_derivative_mat
Axial momentum conservation - time derivative.
libMesh::DenseMatrix< Real > _WijPrime
MooseUnits pow(const MooseUnits &, int)
virtual const std::pair< unsigned int, unsigned int > & getGapChannels(unsigned int i_gap) const =0
Return a pair of subchannel indices for a given gap index.

◆ computeFrictionFactor()

Real QuadSubChannel1PhaseProblem::computeFrictionFactor ( FrictionStruct  friction_args)
overrideprotectedvirtual

Returns friction factor.

Pang, B. et al. KIT, 2013

Todreas-Kazimi NUCLEAR SYSTEMS, second edition, Volume 1, 2011

Implements SubChannel1PhaseProblem.

Definition at line 208 of file QuadSubChannel1PhaseProblem.C.

209 {
210  auto Re = friction_args.Re;
211  auto i_ch = friction_args.i_ch;
214  {
215  Real a, b;
216  if (Re < 1)
217  {
218  return 64.0;
219  }
220  else if (Re >= 1 and Re < 5000)
221  {
222  a = 64.0;
223  b = -1.0;
224  }
225  else if (Re >= 5000 and Re < 30000)
226  {
227  a = 0.316;
228  b = -0.25;
229  }
230  else
231  {
232  a = 0.184;
233  b = -0.20;
234  }
235  return a * std::pow(Re, b);
236  }
238  else
239  {
240  Real aL, b1L, b2L, cL;
241  Real aT, b1T, b2T, cT;
243  auto pin_diameter = _subchannel_mesh.getPinDiameter();
244  // This gap is a constant value for the whole assembly. Might want to make it
245  // subchannel specific in the future if we have duct deformation.
246  auto gap = _subchannel_mesh.getGap();
247  auto w = (pin_diameter / 2.0) + (pitch / 2.0) + gap;
248  auto p_over_d = pitch / pin_diameter;
249  auto w_over_d = w / pin_diameter;
250  auto ReL = std::pow(10, (p_over_d - 1)) * 320.0;
251  auto ReT = std::pow(10, 0.7 * (p_over_d - 1)) * 1.0E+4;
252  auto psi = std::log(Re / ReL) / std::log(ReT / ReL);
253  auto subch_type = _subchannel_mesh.getSubchannelType(i_ch);
254  const Real lambda = 7.0;
255 
256  // Find the coefficients of bare Pin bundle friction factor
257  // correlations for turbulent and laminar flow regimes. Todreas & Kazimi, Nuclear Systems Volume
258  // 1
259  if (subch_type == EChannelType::CENTER)
260  {
261  if (p_over_d < 1.1)
262  {
263  aL = 26.37;
264  b1L = 374.2;
265  b2L = -493.9;
266  aT = 0.09423;
267  b1T = 0.5806;
268  b2T = -1.239;
269  }
270  else
271  {
272  aL = 35.55;
273  b1L = 263.7;
274  b2L = -190.2;
275  aT = 0.1339;
276  b1T = 0.09059;
277  b2T = -0.09926;
278  }
279  // laminar flow friction factor for bare Pin bundle - Center subchannel
280  cL = aL + b1L * (p_over_d - 1) + b2L * std::pow((p_over_d - 1), 2);
281  // turbulent flow friction factor for bare Pin bundle - Center subchannel
282  cT = aT + b1T * (p_over_d - 1) + b2T * std::pow((p_over_d - 1), 2);
283  }
284  else if (subch_type == EChannelType::EDGE)
285  {
286  if (p_over_d < 1.1)
287  {
288  aL = 26.18;
289  b1L = 554.5;
290  b2L = -1480;
291  aT = 0.09377;
292  b1T = 0.8732;
293  b2T = -3.341;
294  }
295  else
296  {
297  aL = 44.40;
298  b1L = 256.7;
299  b2L = -267.6;
300  aT = 0.1430;
301  b1T = 0.04199;
302  b2T = -0.04428;
303  }
304  // laminar flow friction factor for bare Pin bundle - Edge subchannel
305  cL = aL + b1L * (w_over_d - 1) + b2L * std::pow((w_over_d - 1), 2);
306  // turbulent flow friction factor for bare Pin bundle - Edge subchannel
307  cT = aT + b1T * (w_over_d - 1) + b2T * std::pow((w_over_d - 1), 2);
308  }
309  else
310  {
311  if (p_over_d < 1.1)
312  {
313  aL = 28.62;
314  b1L = 715.9;
315  b2L = -2807;
316  aT = 0.09755;
317  b1T = 1.127;
318  b2T = -6.304;
319  }
320  else
321  {
322  aL = 58.83;
323  b1L = 160.7;
324  b2L = -203.5;
325  aT = 0.1452;
326  b1T = 0.02681;
327  b2T = -0.03411;
328  }
329  // laminar flow friction factor for bare Pin bundle - Corner subchannel
330  cL = aL + b1L * (w_over_d - 1) + b2L * std::pow((w_over_d - 1), 2);
331  // turbulent flow friction factor for bare Pin bundle - Corner subchannel
332  cT = aT + b1T * (w_over_d - 1) + b2T * std::pow((w_over_d - 1), 2);
333  }
334 
335  // laminar friction factor
336  auto fL = cL / Re;
337  // turbulent friction factor
338  auto fT = cT / std::pow(Re, 0.18);
339 
340  if (Re < ReL)
341  {
342  // laminar flow
343  return fL;
344  }
345  else if (Re > ReT)
346  {
347  // turbulent flow
348  return fT;
349  }
350  else
351  {
352  // transient flow: psi definition uses a Bulk ReT/ReL number, same for all channels
353  return fL * std::pow((1 - psi), 1.0 / 3.0) * (1 - std::pow(psi, lambda)) +
354  fT * std::pow(psi, 1.0 / 3.0);
355  }
356  }
357 }
virtual const Real & getPinDiameter() const
Return Pin diameter.
const Real & getGap() const
Returns the gap, not to be confused with the gap between pins, this refers to the gap next to the duc...
const bool _default_friction_model
Flag that activates one of the two friction models (default: f=a*Re^b, non-default: Todreas-Kazimi) ...
static const std::string pitch
virtual const Real & getPitch() const override
Return the pitch between 2 subchannels.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual EChannelType getSubchannelType(unsigned int index) const override
Return the type of the subchannel for given subchannel index.
MooseUnits pow(const MooseUnits &, int)
static const std::string cL
Definition: NS.h:111

◆ computeh()

void QuadSubChannel1PhaseProblem::computeh ( int  iblock)
overrideprotectedvirtual

Computes Enthalpy per channel for block iblock.

Time derivative term

Advective derivative term

Cross derivative term

Added heat enthalpy

Assembling system

Implements SubChannel1PhaseProblem.

Definition at line 464 of file QuadSubChannel1PhaseProblem.C.

465 {
466  unsigned int last_node = (iblock + 1) * _block_size;
467  unsigned int first_node = iblock * _block_size + 1;
468  if (iblock == 0)
469  {
470  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
471  {
472  auto * node = _subchannel_mesh.getChannelNode(i_ch, 0);
473  auto h_out = _fp->h_from_p_T((*_P_soln)(node) + _P_out, (*_T_soln)(node));
474  if (h_out < 0)
475  {
476  mooseError(
477  name(), " : Calculation of negative Enthalpy h_out = : ", h_out, " Axial Level= : ", 0);
478  }
479  _h_soln->set(node, h_out);
480  }
481  }
482 
483  if (!_implicit_bool)
484  {
485  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
486  {
487  auto dz = _z_grid[iz] - _z_grid[iz - 1];
488  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
489  {
490  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
491  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
492  auto mdot_in = (*_mdot_soln)(node_in);
493  auto h_in = (*_h_soln)(node_in); // J/kg
494  auto volume = dz * (*_S_flow_soln)(node_in);
495  auto mdot_out = (*_mdot_soln)(node_out);
496  auto h_out = 0.0;
497  Real sumWijh = 0.0;
498  Real sumWijPrimeDhij = 0.0;
499  Real added_enthalpy = computeAddedHeatPin(i_ch, iz);
500  // Calculate sum of crossflow into channel i from channels j around i
501  unsigned int counter = 0;
502  for (auto i_gap : _subchannel_mesh.getChannelGaps(i_ch))
503  {
504  auto chans = _subchannel_mesh.getGapChannels(i_gap);
505  unsigned int ii_ch = chans.first;
506  // i is always the smallest and first index in the mapping
507  unsigned int jj_ch = chans.second;
508  auto * node_in_i = _subchannel_mesh.getChannelNode(ii_ch, iz - 1);
509  auto * node_in_j = _subchannel_mesh.getChannelNode(jj_ch, iz - 1);
510  // Define donor enthalpy
511  Real h_star = 0.0;
512  if (_Wij(i_gap, iz) > 0.0)
513  h_star = (*_h_soln)(node_in_i);
514  else if (_Wij(i_gap, iz) < 0.0)
515  h_star = (*_h_soln)(node_in_j);
516  // take care of the sign by applying the map, use donor cell
517  sumWijh += _subchannel_mesh.getCrossflowSign(i_ch, counter) * _Wij(i_gap, iz) * h_star;
518  sumWijPrimeDhij += _WijPrime(i_gap, iz) * (2 * (*_h_soln)(node_in) -
519  (*_h_soln)(node_in_j) - (*_h_soln)(node_in_i));
520  counter++;
521  }
522  h_out = (mdot_in * h_in - sumWijh - sumWijPrimeDhij + added_enthalpy +
523  _TR * _rho_soln->old(node_out) * _h_soln->old(node_out) * volume / _dt) /
524  (mdot_out + _TR * (*_rho_soln)(node_out)*volume / _dt);
525  if (h_out < 0)
526  {
527  mooseError(name(),
528  " : Calculation of negative Enthalpy h_out = : ",
529  h_out,
530  " Axial Level= : ",
531  iz);
532  }
533  _h_soln->set(node_out, h_out); // J/kg
534  }
535  }
536  }
537  else
538  {
539  LibmeshPetscCall(MatZeroEntries(_hc_time_derivative_mat));
540  LibmeshPetscCall(MatZeroEntries(_hc_advective_derivative_mat));
541  LibmeshPetscCall(MatZeroEntries(_hc_cross_derivative_mat));
542  LibmeshPetscCall(VecZeroEntries(_hc_time_derivative_rhs));
543  LibmeshPetscCall(VecZeroEntries(_hc_advective_derivative_rhs));
544  LibmeshPetscCall(VecZeroEntries(_hc_cross_derivative_rhs));
545  LibmeshPetscCall(VecZeroEntries(_hc_added_heat_rhs));
546  LibmeshPetscCall(MatZeroEntries(_hc_sys_h_mat));
547  LibmeshPetscCall(VecZeroEntries(_hc_sys_h_rhs));
548  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
549  {
550  auto dz = _z_grid[iz] - _z_grid[iz - 1];
551  auto iz_ind = iz - first_node;
552  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
553  {
554  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
555  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
556  auto S_in = (*_S_flow_soln)(node_in);
557  auto S_out = (*_S_flow_soln)(node_out);
558  auto S_interp = computeInterpolatedValue(S_out, S_in, 0.5);
559  auto volume = dz * S_interp;
560 
561  // interpolation weight coefficient
563 
565  if (iz == first_node)
566  {
567  PetscScalar value_vec_tt =
568  -1.0 * _TR * alpha * (*_rho_soln)(node_in) * (*_h_soln)(node_in)*volume / _dt;
569  PetscInt row_vec_tt = i_ch + _n_channels * iz_ind;
570  LibmeshPetscCall(
571  VecSetValues(_hc_time_derivative_rhs, 1, &row_vec_tt, &value_vec_tt, ADD_VALUES));
572  }
573  else
574  {
575  PetscInt row_tt = i_ch + _n_channels * iz_ind;
576  PetscInt col_tt = i_ch + _n_channels * (iz_ind - 1);
577  PetscScalar value_tt = _TR * alpha * (*_rho_soln)(node_in)*volume / _dt;
578  LibmeshPetscCall(MatSetValues(
579  _hc_time_derivative_mat, 1, &row_tt, 1, &col_tt, &value_tt, INSERT_VALUES));
580  }
581 
582  // Adding diagonal elements
583  PetscInt row_tt = i_ch + _n_channels * iz_ind;
584  PetscInt col_tt = i_ch + _n_channels * iz_ind;
585  PetscScalar value_tt = _TR * (1.0 - alpha) * (*_rho_soln)(node_out)*volume / _dt;
586  LibmeshPetscCall(MatSetValues(
587  _hc_time_derivative_mat, 1, &row_tt, 1, &col_tt, &value_tt, INSERT_VALUES));
588 
589  // Adding RHS elements
590  PetscScalar rho_old_interp =
591  computeInterpolatedValue(_rho_soln->old(node_out), _rho_soln->old(node_in), 0.5);
592  PetscScalar h_old_interp =
593  computeInterpolatedValue(_h_soln->old(node_out), _h_soln->old(node_in), 0.5);
594  PetscScalar value_vec_tt = _TR * rho_old_interp * h_old_interp * volume / _dt;
595  PetscInt row_vec_tt = i_ch + _n_channels * iz_ind;
596  LibmeshPetscCall(
597  VecSetValues(_hc_time_derivative_rhs, 1, &row_vec_tt, &value_vec_tt, ADD_VALUES));
598 
600  if (iz == first_node)
601  {
602  PetscScalar value_vec_at = (*_mdot_soln)(node_in) * (*_h_soln)(node_in);
603  PetscInt row_vec_at = i_ch + _n_channels * iz_ind;
604  LibmeshPetscCall(VecSetValues(
605  _hc_advective_derivative_rhs, 1, &row_vec_at, &value_vec_at, ADD_VALUES));
606  }
607  else
608  {
609  PetscInt row_at = i_ch + _n_channels * iz_ind;
610  PetscInt col_at = i_ch + _n_channels * (iz_ind - 1);
611  PetscScalar value_at = -1.0 * (*_mdot_soln)(node_in);
612  LibmeshPetscCall(MatSetValues(
613  _hc_advective_derivative_mat, 1, &row_at, 1, &col_at, &value_at, INSERT_VALUES));
614  }
615 
616  // Adding diagonal elements
617  PetscInt row_at = i_ch + _n_channels * iz_ind;
618  PetscInt col_at = i_ch + _n_channels * iz_ind;
619  PetscScalar value_at = (*_mdot_soln)(node_out);
620  LibmeshPetscCall(MatSetValues(
621  _hc_advective_derivative_mat, 1, &row_at, 1, &col_at, &value_at, INSERT_VALUES));
622 
624  unsigned int counter = 0;
625  unsigned int cross_index = iz; // iz-1;
626  for (auto i_gap : _subchannel_mesh.getChannelGaps(i_ch))
627  {
628  auto chans = _subchannel_mesh.getGapChannels(i_gap);
629  unsigned int ii_ch = chans.first;
630  unsigned int jj_ch = chans.second;
631  auto * node_in_i = _subchannel_mesh.getChannelNode(ii_ch, iz - 1);
632  auto * node_in_j = _subchannel_mesh.getChannelNode(jj_ch, iz - 1);
633  PetscScalar h_star;
634  // figure out donor axial velocity
635  if (_Wij(i_gap, cross_index) > 0.0)
636  {
637  if (iz == first_node)
638  {
639  h_star = (*_h_soln)(node_in_i);
640  PetscScalar value_vec_ct = -1.0 * alpha *
641  _subchannel_mesh.getCrossflowSign(i_ch, counter) *
642  _Wij(i_gap, cross_index) * h_star;
643  PetscInt row_vec_ct = i_ch + _n_channels * iz_ind;
644  LibmeshPetscCall(VecSetValues(
645  _hc_cross_derivative_rhs, 1, &row_vec_ct, &value_vec_ct, ADD_VALUES));
646  }
647  else
648  {
649  PetscScalar value_ct = alpha * _subchannel_mesh.getCrossflowSign(i_ch, counter) *
650  _Wij(i_gap, cross_index);
651  PetscInt row_ct = i_ch + _n_channels * iz_ind;
652  PetscInt col_ct = ii_ch + _n_channels * (iz_ind - 1);
653  LibmeshPetscCall(MatSetValues(
654  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_ct, ADD_VALUES));
655  }
656  PetscScalar value_ct = (1.0 - alpha) *
657  _subchannel_mesh.getCrossflowSign(i_ch, counter) *
658  _Wij(i_gap, cross_index);
659  PetscInt row_ct = i_ch + _n_channels * iz_ind;
660  PetscInt col_ct = ii_ch + _n_channels * iz_ind;
661  LibmeshPetscCall(MatSetValues(
662  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_ct, ADD_VALUES));
663  }
664  else if (_Wij(i_gap, cross_index) < 0.0) // _Wij=0 operations not necessary
665  {
666  if (iz == first_node)
667  {
668  h_star = (*_h_soln)(node_in_j);
669  PetscScalar value_vec_ct = -1.0 * alpha *
670  _subchannel_mesh.getCrossflowSign(i_ch, counter) *
671  _Wij(i_gap, cross_index) * h_star;
672  PetscInt row_vec_ct = i_ch + _n_channels * iz_ind;
673  LibmeshPetscCall(VecSetValues(
674  _hc_cross_derivative_rhs, 1, &row_vec_ct, &value_vec_ct, ADD_VALUES));
675  }
676  else
677  {
678  PetscScalar value_ct = alpha * _subchannel_mesh.getCrossflowSign(i_ch, counter) *
679  _Wij(i_gap, cross_index);
680  PetscInt row_ct = i_ch + _n_channels * iz_ind;
681  PetscInt col_ct = jj_ch + _n_channels * (iz_ind - 1);
682  LibmeshPetscCall(MatSetValues(
683  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_ct, ADD_VALUES));
684  }
685  PetscScalar value_ct = (1.0 - alpha) *
686  _subchannel_mesh.getCrossflowSign(i_ch, counter) *
687  _Wij(i_gap, cross_index);
688  PetscInt row_ct = i_ch + _n_channels * iz_ind;
689  PetscInt col_ct = jj_ch + _n_channels * iz_ind;
690  LibmeshPetscCall(MatSetValues(
691  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_ct, ADD_VALUES));
692  }
693 
694  // Turbulent cross flows
695  if (iz == first_node)
696  {
697  PetscScalar value_vec_ct =
698  -2.0 * alpha * (*_h_soln)(node_in)*_WijPrime(i_gap, cross_index);
699  value_vec_ct += alpha * (*_h_soln)(node_in_j)*_WijPrime(i_gap, cross_index);
700  value_vec_ct += alpha * (*_h_soln)(node_in_i)*_WijPrime(i_gap, cross_index);
701  PetscInt row_vec_ct = i_ch + _n_channels * iz_ind;
702  LibmeshPetscCall(
703  VecSetValues(_hc_cross_derivative_rhs, 1, &row_vec_ct, &value_vec_ct, ADD_VALUES));
704  }
705  else
706  {
707  PetscScalar value_center_ct = 2.0 * alpha * _WijPrime(i_gap, cross_index);
708  PetscInt row_ct = i_ch + _n_channels * iz_ind;
709  PetscInt col_ct = i_ch + _n_channels * (iz_ind - 1);
710  LibmeshPetscCall(MatSetValues(
711  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_center_ct, ADD_VALUES));
712 
713  PetscScalar value_left_ct = -1.0 * alpha * _WijPrime(i_gap, cross_index);
714  row_ct = i_ch + _n_channels * iz_ind;
715  col_ct = jj_ch + _n_channels * (iz_ind - 1);
716  LibmeshPetscCall(MatSetValues(
717  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_left_ct, ADD_VALUES));
718 
719  PetscScalar value_right_ct = -1.0 * alpha * _WijPrime(i_gap, cross_index);
720  row_ct = i_ch + _n_channels * iz_ind;
721  col_ct = ii_ch + _n_channels * (iz_ind - 1);
722  LibmeshPetscCall(MatSetValues(
723  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_right_ct, ADD_VALUES));
724  }
725  PetscScalar value_center_ct = 2.0 * (1.0 - alpha) * _WijPrime(i_gap, cross_index);
726  PetscInt row_ct = i_ch + _n_channels * iz_ind;
727  PetscInt col_ct = i_ch + _n_channels * iz_ind;
728  LibmeshPetscCall(MatSetValues(
729  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_center_ct, ADD_VALUES));
730 
731  PetscScalar value_left_ct = -1.0 * (1.0 - alpha) * _WijPrime(i_gap, cross_index);
732  row_ct = i_ch + _n_channels * iz_ind;
733  col_ct = jj_ch + _n_channels * iz_ind;
734  LibmeshPetscCall(MatSetValues(
735  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_left_ct, ADD_VALUES));
736 
737  PetscScalar value_right_ct = -1.0 * (1.0 - alpha) * _WijPrime(i_gap, cross_index);
738  row_ct = i_ch + _n_channels * iz_ind;
739  col_ct = ii_ch + _n_channels * iz_ind;
740  LibmeshPetscCall(MatSetValues(
741  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_right_ct, ADD_VALUES));
742  counter++;
743  }
744 
746  PetscScalar added_enthalpy = computeAddedHeatPin(i_ch, iz);
747  PetscInt row_vec_ht = i_ch + _n_channels * iz_ind;
748  LibmeshPetscCall(
749  VecSetValues(_hc_added_heat_rhs, 1, &row_vec_ht, &added_enthalpy, ADD_VALUES));
750  }
751  }
753  LibmeshPetscCall(MatAssemblyBegin(_hc_time_derivative_mat, MAT_FINAL_ASSEMBLY));
754  LibmeshPetscCall(MatAssemblyEnd(_hc_time_derivative_mat, MAT_FINAL_ASSEMBLY));
755  LibmeshPetscCall(MatAssemblyBegin(_hc_advective_derivative_mat, MAT_FINAL_ASSEMBLY));
756  LibmeshPetscCall(MatAssemblyEnd(_hc_advective_derivative_mat, MAT_FINAL_ASSEMBLY));
757  LibmeshPetscCall(MatAssemblyBegin(_hc_cross_derivative_mat, MAT_FINAL_ASSEMBLY));
758  LibmeshPetscCall(MatAssemblyEnd(_hc_cross_derivative_mat, MAT_FINAL_ASSEMBLY));
759  LibmeshPetscCall(MatAssemblyBegin(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
760  LibmeshPetscCall(MatAssemblyEnd(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
761  // Matrix
762 #if !PETSC_VERSION_LESS_THAN(3, 15, 0)
763  LibmeshPetscCall(MatAXPY(_hc_sys_h_mat, 1.0, _hc_time_derivative_mat, UNKNOWN_NONZERO_PATTERN));
764  LibmeshPetscCall(MatAssemblyBegin(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
765  LibmeshPetscCall(MatAssemblyEnd(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
766  LibmeshPetscCall(
767  MatAXPY(_hc_sys_h_mat, 1.0, _hc_advective_derivative_mat, UNKNOWN_NONZERO_PATTERN));
768  LibmeshPetscCall(MatAssemblyBegin(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
769  LibmeshPetscCall(MatAssemblyEnd(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
770  LibmeshPetscCall(
771  MatAXPY(_hc_sys_h_mat, 1.0, _hc_cross_derivative_mat, UNKNOWN_NONZERO_PATTERN));
772 #else
773  LibmeshPetscCall(
774  MatAXPY(_hc_sys_h_mat, 1.0, _hc_time_derivative_mat, DIFFERENT_NONZERO_PATTERN));
775  LibmeshPetscCall(MatAssemblyBegin(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
776  LibmeshPetscCall(MatAssemblyEnd(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
777  LibmeshPetscCall(
778  MatAXPY(_hc_sys_h_mat, 1.0, _hc_advective_derivative_mat, DIFFERENT_NONZERO_PATTERN));
779  LibmeshPetscCall(MatAssemblyBegin(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
780  LibmeshPetscCall(MatAssemblyEnd(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
781  LibmeshPetscCall(
782  MatAXPY(_hc_sys_h_mat, 1.0, _hc_cross_derivative_mat, DIFFERENT_NONZERO_PATTERN));
783 #endif
784  LibmeshPetscCall(MatAssemblyBegin(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
785  LibmeshPetscCall(MatAssemblyEnd(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
787  _console << "Block: " << iblock << " - Enthalpy conservation matrix assembled" << std::endl;
788  // RHS
789  LibmeshPetscCall(VecAXPY(_hc_sys_h_rhs, 1.0, _hc_time_derivative_rhs));
790  LibmeshPetscCall(VecAXPY(_hc_sys_h_rhs, 1.0, _hc_advective_derivative_rhs));
791  LibmeshPetscCall(VecAXPY(_hc_sys_h_rhs, 1.0, _hc_cross_derivative_rhs));
792  LibmeshPetscCall(VecAXPY(_hc_sys_h_rhs, 1.0, _hc_added_heat_rhs));
793 
795  {
796  // Assembly the matrix system
797  KSP ksploc;
798  PC pc;
799  Vec sol;
800  LibmeshPetscCall(VecDuplicate(_hc_sys_h_rhs, &sol));
801  LibmeshPetscCall(KSPCreate(PETSC_COMM_WORLD, &ksploc));
802  LibmeshPetscCall(KSPSetOperators(ksploc, _hc_sys_h_mat, _hc_sys_h_mat));
803  LibmeshPetscCall(KSPGetPC(ksploc, &pc));
804  LibmeshPetscCall(PCSetType(pc, PCJACOBI));
805  LibmeshPetscCall(KSPSetTolerances(ksploc, _rtol, _atol, _dtol, _maxit));
806  LibmeshPetscCall(KSPSetOptionsPrefix(ksploc, "h_sys_"));
807  LibmeshPetscCall(KSPSetFromOptions(ksploc));
808  LibmeshPetscCall(KSPSolve(ksploc, _hc_sys_h_rhs, sol));
809  PetscScalar * xx;
810  LibmeshPetscCall(VecGetArray(sol, &xx));
811  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
812  {
813  auto iz_ind = iz - first_node;
814  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
815  {
816  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
817  auto h_out = xx[iz_ind * _n_channels + i_ch];
818  if (h_out < 0)
819  {
820  mooseError(name(),
821  " : Calculation of negative Enthalpy h_out = : ",
822  h_out,
823  " Axial Level= : ",
824  iz);
825  }
826  _h_soln->set(node_out, h_out);
827  }
828  }
829  LibmeshPetscCall(KSPDestroy(&ksploc));
830  LibmeshPetscCall(VecDestroy(&sol));
831  }
832  }
833 }
virtual const Real & getCrossflowSign(unsigned int i_chan, unsigned int i_local) const override
Return a sign for the crossflow given a subchannel index and local neighbor index.
std::unique_ptr< SolutionHandle > _T_soln
std::unique_ptr< SolutionHandle > _h_soln
const PetscReal & _dtol
The divergence tolerance for the ksp linear solver.
const bool _monolithic_thermal_bool
Thermal monolithic bool.
Real _TR
Flag that activates or deactivates the transient parts of the equations we solve by multiplication...
const PostprocessorValue & _P_out
Outlet Pressure.
virtual Real computeAddedHeatPin(unsigned int i_ch, unsigned int iz) override
Computes added heat for channel i_ch and cell iz.
virtual const std::vector< unsigned int > & getChannelGaps(unsigned int i_chan) const override
Return a vector of gap indices for a given channel index.
PetscScalar computeInterpolatedValue(PetscScalar topValue, PetscScalar botValue, PetscScalar Peclet=0.0)
const bool _segregated_bool
Segregated solve.
virtual const std::string & name() const
virtual const std::pair< unsigned int, unsigned int > & getGapChannels(unsigned int i_gap) const override
Return a pair of subchannel indices for a given gap index.
std::unique_ptr< SolutionHandle > _rho_soln
Vec _hc_added_heat_rhs
Enthalpy conservation - source and sink.
std::vector< Real > _z_grid
axial location of nodes
const PetscReal & _atol
The absolute convergence tolerance for the ksp linear solver.
PetscScalar computeInterpolationCoefficients(PetscScalar Peclet=0.0)
Functions that computes the interpolation scheme given the Peclet number.
Mat _hc_cross_derivative_mat
Enthalpy conservation - cross flux derivative.
const PetscInt & _maxit
The maximum number of iterations to use for the ksp linear solver.
Real volume(const MeshBase &mesh, unsigned int dim=libMesh::invalid_uint)
const PetscReal & _rtol
The relative convergence tolerance, (relative decrease) for the ksp linear solver.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
libMesh::DenseMatrix< Real > & _Wij
static const std::string alpha
Definition: NS.h:134
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const override
Get the subchannel mesh node for a given channel index and elevation index.
const bool _verbose_subchannel
Boolean to printout information related to subchannel solve.
void mooseError(Args &&... args) const
Mat _hc_advective_derivative_mat
Enthalpy conservation - advective (Eulerian) derivative;.
const bool _implicit_bool
Flag to define the usage of a implicit or explicit solution.
const ConsoleStream _console
Mat _hc_time_derivative_mat
Enthalpy Enthalpy conservation - time derivative.
libMesh::DenseMatrix< Real > _WijPrime
std::unique_ptr< SolutionHandle > _P_soln
const SinglePhaseFluidProperties * _fp
Solutions handles and link to TH tables properties.
Mat _hc_sys_h_mat
System matrices.

◆ computeInterpolatedValue()

PetscScalar SubChannel1PhaseProblem::computeInterpolatedValue ( PetscScalar  topValue,
PetscScalar  botValue,
PetscScalar  Peclet = 0.0 
)
protectedinherited

Definition at line 361 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::computeDP(), computeh(), TriSubChannel1PhaseProblem::computeh(), SubChannel1PhaseProblem::computeP(), and SubChannel1PhaseProblem::computeWijResidual().

364 {
366  return alpha * botValue + (1.0 - alpha) * topValue;
367 }
PetscScalar computeInterpolationCoefficients(PetscScalar Peclet=0.0)
Functions that computes the interpolation scheme given the Peclet number.
auto Peclet(const T1 &volume_fraction, const T2 &cp, const T3 &rho, const T4 &vel, const T5 &D_h, const T6 &k)
Compute Peclet number.
Definition: Numerics.h:153
static const std::string alpha
Definition: NS.h:134

◆ computeInterpolationCoefficients()

PetscScalar SubChannel1PhaseProblem::computeInterpolationCoefficients ( PetscScalar  Peclet = 0.0)
protectedinherited

Functions that computes the interpolation scheme given the Peclet number.

Definition at line 341 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::computeDP(), computeh(), TriSubChannel1PhaseProblem::computeh(), SubChannel1PhaseProblem::computeInterpolatedValue(), SubChannel1PhaseProblem::computeP(), and SubChannel1PhaseProblem::computeWijResidual().

342 {
343  switch (_interpolation_scheme)
344  {
345  case 0: // upwind interpolation
346  return 1.0;
347  case 1: // downwind interpolation
348  return 0.0;
349  case 2: // central_difference interpolation
350  return 0.5;
351  case 3: // exponential interpolation (Peclet limited)
352  return ((Peclet - 1.0) * std::exp(Peclet) + 1) / (Peclet * (std::exp(Peclet) - 1.) + 1e-10);
353  default:
354  mooseError(name(),
355  ": Interpolation scheme should be a string: upwind, downwind, central_difference, "
356  "exponential");
357  }
358 }
virtual const std::string & name() const
auto Peclet(const T1 &volume_fraction, const T2 &cp, const T3 &rho, const T4 &vel, const T5 &D_h, const T6 &k)
Compute Peclet number.
Definition: Numerics.h:153
const MooseEnum _interpolation_scheme
The interpolation method used in constructing the systems.
void mooseError(Args &&... args) const

◆ computeMdot()

void SubChannel1PhaseProblem::computeMdot ( int  iblock)
protectedinherited

Computes mass flow per channel for block iblock.

Definition at line 468 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::implicitPetscSolve(), and SubChannel1PhaseProblem::residualFunction().

469 {
470  unsigned int last_node = (iblock + 1) * _block_size;
471  unsigned int first_node = iblock * _block_size + 1;
472  if (!_implicit_bool)
473  {
474  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
475  {
476  auto dz = _z_grid[iz] - _z_grid[iz - 1];
477  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
478  {
479  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
480  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
481  auto volume = dz * (*_S_flow_soln)(node_in);
482  auto time_term = _TR * ((*_rho_soln)(node_out)-_rho_soln->old(node_out)) * volume / _dt;
483  // Wij positive out of i into j;
484  auto mdot_out = (*_mdot_soln)(node_in) - (*_SumWij_soln)(node_out)-time_term;
485  if (mdot_out < 0)
486  {
487  _console << "Wij = : " << _Wij << "\n";
488  mooseError(name(),
489  " : Calculation of negative mass flow mdot_out = : ",
490  mdot_out,
491  " Axial Level= : ",
492  iz,
493  " - Implicit solves are required for recirculating flow.");
494  }
495  _mdot_soln->set(node_out, mdot_out); // kg/sec
496  }
497  }
498  }
499  else
500  {
501  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
502  {
503  auto dz = _z_grid[iz] - _z_grid[iz - 1];
504  auto iz_ind = iz - first_node;
505  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
506  {
507  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
508  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
509  auto volume = dz * (*_S_flow_soln)(node_in);
510 
511  // Adding time derivative to the RHS
512  auto time_term = _TR * ((*_rho_soln)(node_out)-_rho_soln->old(node_out)) * volume / _dt;
513  PetscInt row_vec = i_ch + _n_channels * iz_ind;
514  PetscScalar value_vec = -1.0 * time_term;
515  LibmeshPetscCall(
516  VecSetValues(_mc_axial_convection_rhs, 1, &row_vec, &value_vec, INSERT_VALUES));
517 
518  // Imposing bottom boundary condition or adding of diagonal elements
519  if (iz == first_node)
520  {
521  PetscScalar value_vec = (*_mdot_soln)(node_in);
522  PetscInt row_vec = i_ch + _n_channels * iz_ind;
523  LibmeshPetscCall(
524  VecSetValues(_mc_axial_convection_rhs, 1, &row_vec, &value_vec, ADD_VALUES));
525  }
526  else
527  {
528  PetscInt row = i_ch + _n_channels * iz_ind;
529  PetscInt col = i_ch + _n_channels * (iz_ind - 1);
530  PetscScalar value = -1.0;
531  LibmeshPetscCall(
532  MatSetValues(_mc_axial_convection_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
533  }
534 
535  // Adding diagonal elements
536  PetscInt row = i_ch + _n_channels * iz_ind;
537  PetscInt col = i_ch + _n_channels * iz_ind;
538  PetscScalar value = 1.0;
539  LibmeshPetscCall(
540  MatSetValues(_mc_axial_convection_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
541 
542  // Adding cross flows RHS
543  if (_segregated_bool)
544  {
545  PetscScalar value_vec_2 = -1.0 * (*_SumWij_soln)(node_out);
546  PetscInt row_vec_2 = i_ch + _n_channels * iz_ind;
547  LibmeshPetscCall(
548  VecSetValues(_mc_axial_convection_rhs, 1, &row_vec_2, &value_vec_2, ADD_VALUES));
549  }
550  }
551  }
552  LibmeshPetscCall(MatAssemblyBegin(_mc_axial_convection_mat, MAT_FINAL_ASSEMBLY));
553  LibmeshPetscCall(MatAssemblyEnd(_mc_axial_convection_mat, MAT_FINAL_ASSEMBLY));
554 
555  if (_segregated_bool)
556  {
557  KSP ksploc;
558  PC pc;
559  Vec sol;
560  LibmeshPetscCall(VecDuplicate(_mc_axial_convection_rhs, &sol));
561  LibmeshPetscCall(KSPCreate(PETSC_COMM_WORLD, &ksploc));
562  LibmeshPetscCall(KSPSetOperators(ksploc, _mc_axial_convection_mat, _mc_axial_convection_mat));
563  LibmeshPetscCall(KSPGetPC(ksploc, &pc));
564  LibmeshPetscCall(PCSetType(pc, PCJACOBI));
565  LibmeshPetscCall(KSPSetTolerances(ksploc, _rtol, _atol, _dtol, _maxit));
566  LibmeshPetscCall(KSPSetFromOptions(ksploc));
567  LibmeshPetscCall(KSPSolve(ksploc, _mc_axial_convection_rhs, sol));
568  LibmeshPetscCall(populateSolutionChan<SolutionHandle>(
569  sol, *_mdot_soln, first_node, last_node, _n_channels));
570  LibmeshPetscCall(VecZeroEntries(_mc_axial_convection_rhs));
571  LibmeshPetscCall(KSPDestroy(&ksploc));
572  LibmeshPetscCall(VecDestroy(&sol));
573  }
574  }
575 }
const PetscReal & _dtol
The divergence tolerance for the ksp linear solver.
Real _TR
Flag that activates or deactivates the transient parts of the equations we solve by multiplication...
const bool _segregated_bool
Segregated solve.
virtual const std::string & name() const
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
std::unique_ptr< SolutionHandle > _rho_soln
std::vector< Real > _z_grid
axial location of nodes
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
const PetscReal & _atol
The absolute convergence tolerance for the ksp linear solver.
Mat _mc_axial_convection_mat
Mass conservation - axial convection.
const PetscInt & _maxit
The maximum number of iterations to use for the ksp linear solver.
Real volume(const MeshBase &mesh, unsigned int dim=libMesh::invalid_uint)
std::unique_ptr< SolutionHandle > _mdot_soln
const PetscReal & _rtol
The relative convergence tolerance, (relative decrease) for the ksp linear solver.
libMesh::DenseMatrix< Real > & _Wij
std::unique_ptr< SolutionHandle > _SumWij_soln
void mooseError(Args &&... args) const
const bool _implicit_bool
Flag to define the usage of a implicit or explicit solution.
const ConsoleStream _console

◆ computeMu()

void SubChannel1PhaseProblem::computeMu ( int  iblock)
protectedinherited

Computes Viscosity per channel for block iblock.

Definition at line 1378 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::externalSolve().

1379 {
1380  unsigned int last_node = (iblock + 1) * _block_size;
1381  unsigned int first_node = iblock * _block_size + 1;
1382  if (iblock == 0)
1383  {
1384  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1385  {
1386  auto * node = _subchannel_mesh.getChannelNode(i_ch, 0);
1387  _mu_soln->set(node, _fp->mu_from_p_T((*_P_soln)(node) + _P_out, (*_T_soln)(node)));
1388  }
1389  }
1390  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
1391  {
1392  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1393  {
1394  auto * node = _subchannel_mesh.getChannelNode(i_ch, iz);
1395  _mu_soln->set(node, _fp->mu_from_p_T((*_P_soln)(node) + _P_out, (*_T_soln)(node)));
1396  }
1397  }
1398 }
std::unique_ptr< SolutionHandle > _T_soln
const PostprocessorValue & _P_out
Outlet Pressure.
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
std::unique_ptr< SolutionHandle > _P_soln
const SinglePhaseFluidProperties * _fp
Solutions handles and link to TH tables properties.
std::unique_ptr< SolutionHandle > _mu_soln

◆ computeP()

void SubChannel1PhaseProblem::computeP ( int  iblock)
protectedinherited

Computes Pressure per channel for block iblock.

Definition at line 1079 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::implicitPetscSolve(), and SubChannel1PhaseProblem::residualFunction().

1080 {
1081  unsigned int last_node = (iblock + 1) * _block_size;
1082  unsigned int first_node = iblock * _block_size + 1;
1083  if (!_implicit_bool)
1084  {
1086  {
1087  for (unsigned int iz = last_node; iz > first_node - 1; iz--)
1088  {
1089  // Calculate pressure in the inlet of the cell assuming known outlet
1090  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1091  {
1092  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
1093  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1094  // update Pressure solution
1095  _P_soln->set(node_in, (*_P_soln)(node_out) + (*_DP_soln)(node_out));
1096  }
1097  }
1098  }
1099  else
1100  {
1101  for (unsigned int iz = last_node; iz > first_node - 1; iz--)
1102  {
1103  // Calculate pressure in the inlet of the cell assuming known outlet
1104  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1105  {
1106  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
1107  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1108  // update Pressure solution
1109  // Note: assuming uniform axial discretization in the curren code
1110  // We will need to update this later if we allow non-uniform refinements in the axial
1111  // direction
1112  PetscScalar Pe = 0.5;
1114  if (iz == last_node)
1115  {
1116  _P_soln->set(node_in, (*_P_soln)(node_out) + (*_DP_soln)(node_out) / 2.0);
1117  }
1118  else
1119  {
1120  _P_soln->set(node_in,
1121  (*_P_soln)(node_out) + (1.0 - alpha) * (*_DP_soln)(node_out) +
1122  alpha * (*_DP_soln)(node_in));
1123  }
1124  }
1125  }
1126  }
1127  }
1128  else
1129  {
1131  {
1132  LibmeshPetscCall(VecZeroEntries(_amc_pressure_force_rhs));
1133  for (unsigned int iz = last_node; iz > first_node - 1; iz--)
1134  {
1135  auto iz_ind = iz - first_node;
1136  // Calculate pressure in the inlet of the cell assuming known outlet
1137  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1138  {
1139  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
1140  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1141 
1142  // inlet, outlet, and interpolated axial surface area
1143  auto S_in = (*_S_flow_soln)(node_in);
1144  auto S_out = (*_S_flow_soln)(node_out);
1145  auto S_interp = computeInterpolatedValue(S_out, S_in, 0.5);
1146 
1147  // Creating matrix of coefficients
1148  PetscInt row = i_ch + _n_channels * iz_ind;
1149  PetscInt col = i_ch + _n_channels * iz_ind;
1150  PetscScalar value = -1.0 * S_interp;
1151  LibmeshPetscCall(
1152  MatSetValues(_amc_pressure_force_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
1153 
1154  if (iz == last_node)
1155  {
1156  PetscScalar value = -1.0 * (*_P_soln)(node_out)*S_interp;
1157  PetscInt row = i_ch + _n_channels * iz_ind;
1158  LibmeshPetscCall(VecSetValues(_amc_pressure_force_rhs, 1, &row, &value, ADD_VALUES));
1159  }
1160  else
1161  {
1162  PetscInt row = i_ch + _n_channels * iz_ind;
1163  PetscInt col = i_ch + _n_channels * (iz_ind + 1);
1164  PetscScalar value = 1.0 * S_interp;
1165  LibmeshPetscCall(
1166  MatSetValues(_amc_pressure_force_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
1167  }
1168 
1169  if (_segregated_bool)
1170  {
1171  auto dp_out = (*_DP_soln)(node_out);
1172  PetscScalar value_v = -1.0 * dp_out * S_interp;
1173  PetscInt row_v = i_ch + _n_channels * iz_ind;
1174  LibmeshPetscCall(
1175  VecSetValues(_amc_pressure_force_rhs, 1, &row_v, &value_v, ADD_VALUES));
1176  }
1177  }
1178  }
1179  // Solving pressure problem
1180  LibmeshPetscCall(MatAssemblyBegin(_amc_pressure_force_mat, MAT_FINAL_ASSEMBLY));
1181  LibmeshPetscCall(MatAssemblyEnd(_amc_pressure_force_mat, MAT_FINAL_ASSEMBLY));
1182  if (_segregated_bool)
1183  {
1184  KSP ksploc;
1185  PC pc;
1186  Vec sol;
1187  LibmeshPetscCall(VecDuplicate(_amc_pressure_force_rhs, &sol));
1188  LibmeshPetscCall(KSPCreate(PETSC_COMM_WORLD, &ksploc));
1189  LibmeshPetscCall(KSPSetOperators(ksploc, _amc_pressure_force_mat, _amc_pressure_force_mat));
1190  LibmeshPetscCall(KSPGetPC(ksploc, &pc));
1191  LibmeshPetscCall(PCSetType(pc, PCJACOBI));
1192  LibmeshPetscCall(KSPSetTolerances(ksploc, _rtol, _atol, _dtol, _maxit));
1193  LibmeshPetscCall(KSPSetFromOptions(ksploc));
1194  LibmeshPetscCall(KSPSolve(ksploc, _amc_pressure_force_rhs, sol));
1195  PetscScalar * xx;
1196  LibmeshPetscCall(VecGetArray(sol, &xx));
1197  // update Pressure solution
1198  for (unsigned int iz = last_node; iz > first_node - 1; iz--)
1199  {
1200  auto iz_ind = iz - first_node;
1201  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1202  {
1203  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1204  PetscScalar value = xx[iz_ind * _n_channels + i_ch];
1205  _P_soln->set(node_in, value);
1206  }
1207  }
1208  LibmeshPetscCall(VecZeroEntries(_amc_pressure_force_rhs));
1209  LibmeshPetscCall(KSPDestroy(&ksploc));
1210  LibmeshPetscCall(VecDestroy(&sol));
1211  }
1212  }
1213  else
1214  {
1215  LibmeshPetscCall(VecZeroEntries(_amc_pressure_force_rhs));
1216  for (unsigned int iz = last_node; iz > first_node - 1; iz--)
1217  {
1218  auto iz_ind = iz - first_node;
1219  // Calculate pressure in the inlet of the cell assuming known outlet
1220  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1221  {
1222  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
1223  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1224 
1225  // inlet, outlet, and interpolated axial surface area
1226  auto S_in = (*_S_flow_soln)(node_in);
1227  auto S_out = (*_S_flow_soln)(node_out);
1228  auto S_interp = computeInterpolatedValue(S_out, S_in, 0.5);
1229 
1230  // Creating matrix of coefficients
1231  PetscInt row = i_ch + _n_channels * iz_ind;
1232  PetscInt col = i_ch + _n_channels * iz_ind;
1233  PetscScalar value = -1.0 * S_interp;
1234  LibmeshPetscCall(
1235  MatSetValues(_amc_pressure_force_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
1236 
1237  if (iz == last_node)
1238  {
1239  PetscScalar value = -1.0 * (*_P_soln)(node_out)*S_interp;
1240  PetscInt row = i_ch + _n_channels * iz_ind;
1241  LibmeshPetscCall(VecSetValues(_amc_pressure_force_rhs, 1, &row, &value, ADD_VALUES));
1242 
1243  auto dp_out = (*_DP_soln)(node_out);
1244  PetscScalar value_v = -1.0 * dp_out / 2.0 * S_interp;
1245  PetscInt row_v = i_ch + _n_channels * iz_ind;
1246  LibmeshPetscCall(
1247  VecSetValues(_amc_pressure_force_rhs, 1, &row_v, &value_v, ADD_VALUES));
1248  }
1249  else
1250  {
1251  PetscInt row = i_ch + _n_channels * iz_ind;
1252  PetscInt col = i_ch + _n_channels * (iz_ind + 1);
1253  PetscScalar value = 1.0 * S_interp;
1254  LibmeshPetscCall(
1255  MatSetValues(_amc_pressure_force_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
1256 
1257  if (_segregated_bool)
1258  {
1259  auto dp_in = (*_DP_soln)(node_in);
1260  auto dp_out = (*_DP_soln)(node_out);
1261  auto dp_interp = computeInterpolatedValue(dp_out, dp_in, 0.5);
1262  PetscScalar value_v = -1.0 * dp_interp * S_interp;
1263  PetscInt row_v = i_ch + _n_channels * iz_ind;
1264  LibmeshPetscCall(
1265  VecSetValues(_amc_pressure_force_rhs, 1, &row_v, &value_v, ADD_VALUES));
1266  }
1267  }
1268  }
1269  }
1270  // Solving pressure problem
1271  LibmeshPetscCall(MatAssemblyBegin(_amc_pressure_force_mat, MAT_FINAL_ASSEMBLY));
1272  LibmeshPetscCall(MatAssemblyEnd(_amc_pressure_force_mat, MAT_FINAL_ASSEMBLY));
1273  if (_verbose_subchannel)
1274  _console << "Block: " << iblock << " - Axial momentum pressure force matrix assembled"
1275  << std::endl;
1276 
1277  if (_segregated_bool)
1278  {
1279  KSP ksploc;
1280  PC pc;
1281  Vec sol;
1282  LibmeshPetscCall(VecDuplicate(_amc_pressure_force_rhs, &sol));
1283  LibmeshPetscCall(KSPCreate(PETSC_COMM_WORLD, &ksploc));
1284  LibmeshPetscCall(KSPSetOperators(ksploc, _amc_pressure_force_mat, _amc_pressure_force_mat));
1285  LibmeshPetscCall(KSPGetPC(ksploc, &pc));
1286  LibmeshPetscCall(PCSetType(pc, PCJACOBI));
1287  LibmeshPetscCall(KSPSetTolerances(ksploc, _rtol, _atol, _dtol, _maxit));
1288  LibmeshPetscCall(KSPSetFromOptions(ksploc));
1289  LibmeshPetscCall(KSPSolve(ksploc, _amc_pressure_force_rhs, sol));
1290  PetscScalar * xx;
1291  LibmeshPetscCall(VecGetArray(sol, &xx));
1292  // update Pressure solution
1293  for (unsigned int iz = last_node; iz > first_node - 1; iz--)
1294  {
1295  auto iz_ind = iz - first_node;
1296  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1297  {
1298  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1299  PetscScalar value = xx[iz_ind * _n_channels + i_ch];
1300  _P_soln->set(node_in, value);
1301  }
1302  }
1303  LibmeshPetscCall(VecZeroEntries(_amc_pressure_force_rhs));
1304  LibmeshPetscCall(KSPDestroy(&ksploc));
1305  LibmeshPetscCall(VecDestroy(&sol));
1306  }
1307  }
1308  }
1309 }
const PetscReal & _dtol
The divergence tolerance for the ksp linear solver.
PetscScalar computeInterpolatedValue(PetscScalar topValue, PetscScalar botValue, PetscScalar Peclet=0.0)
const bool _segregated_bool
Segregated solve.
const bool _staggered_pressure_bool
Flag to define the usage of staggered or collocated pressure.
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
Mat _amc_pressure_force_mat
Axial momentum conservation - pressure force.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
const PetscReal & _atol
The absolute convergence tolerance for the ksp linear solver.
PetscScalar computeInterpolationCoefficients(PetscScalar Peclet=0.0)
Functions that computes the interpolation scheme given the Peclet number.
const PetscInt & _maxit
The maximum number of iterations to use for the ksp linear solver.
const PetscReal & _rtol
The relative convergence tolerance, (relative decrease) for the ksp linear solver.
std::unique_ptr< SolutionHandle > _DP_soln
static const std::string alpha
Definition: NS.h:134
const bool _verbose_subchannel
Boolean to printout information related to subchannel solve.
const bool _implicit_bool
Flag to define the usage of a implicit or explicit solution.
const ConsoleStream _console
std::unique_ptr< SolutionHandle > _P_soln

◆ computeRho()

void SubChannel1PhaseProblem::computeRho ( int  iblock)
protectedinherited

Computes Density per channel for block iblock.

Definition at line 1355 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::externalSolve().

1356 {
1357  unsigned int last_node = (iblock + 1) * _block_size;
1358  unsigned int first_node = iblock * _block_size + 1;
1359  if (iblock == 0)
1360  {
1361  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1362  {
1363  auto * node = _subchannel_mesh.getChannelNode(i_ch, 0);
1364  _rho_soln->set(node, _fp->rho_from_p_T((*_P_soln)(node) + _P_out, (*_T_soln)(node)));
1365  }
1366  }
1367  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
1368  {
1369  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1370  {
1371  auto * node = _subchannel_mesh.getChannelNode(i_ch, iz);
1372  _rho_soln->set(node, _fp->rho_from_p_T((*_P_soln)(node) + _P_out, (*_T_soln)(node)));
1373  }
1374  }
1375 }
std::unique_ptr< SolutionHandle > _T_soln
const PostprocessorValue & _P_out
Outlet Pressure.
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
std::unique_ptr< SolutionHandle > _rho_soln
std::unique_ptr< SolutionHandle > _P_soln
const SinglePhaseFluidProperties * _fp
Solutions handles and link to TH tables properties.

◆ computeSumWij()

void SubChannel1PhaseProblem::computeSumWij ( int  iblock)
protectedinherited

Computes net diversion crossflow per channel for block iblock.

Definition at line 403 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::implicitPetscSolve(), and SubChannel1PhaseProblem::residualFunction().

404 {
405  unsigned int last_node = (iblock + 1) * _block_size;
406  unsigned int first_node = iblock * _block_size + 1;
407  // Add to solution vector if explicit
408  if (!_implicit_bool)
409  {
410  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
411  {
412  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
413  {
414  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
415  Real sumWij = 0.0;
416  // Calculate sum of crossflow into channel i from channels j around i
417  unsigned int counter = 0;
418  for (auto i_gap : _subchannel_mesh.getChannelGaps(i_ch))
419  {
420  sumWij += _subchannel_mesh.getCrossflowSign(i_ch, counter) * _Wij(i_gap, iz);
421  counter++;
422  }
423  // The net crossflow coming out of cell i [kg/sec]
424  _SumWij_soln->set(node_out, sumWij);
425  }
426  }
427  }
428  // Add to matrix if explicit
429  else
430  {
431  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
432  {
433  unsigned int iz_ind = iz - first_node;
434  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
435  {
436  // Calculate sum of crossflow into channel i from channels j around i
437  unsigned int counter = 0;
438  for (auto i_gap : _subchannel_mesh.getChannelGaps(i_ch))
439  {
440  PetscInt row = i_ch + _n_channels * iz_ind;
441  PetscInt col = i_gap + _n_gaps * iz_ind;
442  PetscScalar value = _subchannel_mesh.getCrossflowSign(i_ch, counter);
443  LibmeshPetscCall(MatSetValues(_mc_sumWij_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
444  counter++;
445  }
446  }
447  }
448  LibmeshPetscCall(MatAssemblyBegin(_mc_sumWij_mat, MAT_FINAL_ASSEMBLY));
449  LibmeshPetscCall(MatAssemblyEnd(_mc_sumWij_mat, MAT_FINAL_ASSEMBLY));
450  if (_segregated_bool)
451  {
452  Vec loc_prod;
453  Vec loc_Wij;
454  LibmeshPetscCall(VecDuplicate(_amc_sys_mdot_rhs, &loc_prod));
455  LibmeshPetscCall(VecDuplicate(_Wij_vec, &loc_Wij));
457  loc_Wij, _Wij, first_node, last_node + 1, _n_gaps));
458  LibmeshPetscCall(MatMult(_mc_sumWij_mat, loc_Wij, loc_prod));
459  LibmeshPetscCall(populateSolutionChan<SolutionHandle>(
460  loc_prod, *_SumWij_soln, first_node, last_node, _n_channels));
461  LibmeshPetscCall(VecDestroy(&loc_prod));
462  LibmeshPetscCall(VecDestroy(&loc_Wij));
463  }
464  }
465 }
const bool _segregated_bool
Segregated solve.
virtual const std::vector< unsigned int > & getChannelGaps(unsigned int i_chan) const =0
Return a vector of gap indices for a given channel index.
Mat _mc_sumWij_mat
Matrices and vectors to be used in implicit assembly Mass conservation Mass conservation - sum of cro...
PetscErrorCode populateVectorFromDense(Vec &x, const T &solution, const unsigned int first_axial_level, const unsigned int last_axial_level, const unsigned int cross_dimension)
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
libMesh::DenseMatrix< Real > & _Wij
virtual const Real & getCrossflowSign(unsigned int i_chan, unsigned int i_local) const =0
Return a sign for the crossflow given a subchannel index and local neighbor index.
std::unique_ptr< SolutionHandle > _SumWij_soln
const bool _implicit_bool
Flag to define the usage of a implicit or explicit solution.

◆ computeT()

void SubChannel1PhaseProblem::computeT ( int  iblock)
protectedinherited

Computes Temperature per channel for block iblock.

Definition at line 1340 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::externalSolve().

1341 {
1342  unsigned int last_node = (iblock + 1) * _block_size;
1343  unsigned int first_node = iblock * _block_size + 1;
1344  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
1345  {
1346  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1347  {
1348  auto * node = _subchannel_mesh.getChannelNode(i_ch, iz);
1349  _T_soln->set(node, _fp->T_from_p_h((*_P_soln)(node) + _P_out, (*_h_soln)(node)));
1350  }
1351  }
1352 }
std::unique_ptr< SolutionHandle > _T_soln
std::unique_ptr< SolutionHandle > _h_soln
const PostprocessorValue & _P_out
Outlet Pressure.
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
std::unique_ptr< SolutionHandle > _P_soln
const SinglePhaseFluidProperties * _fp
Solutions handles and link to TH tables properties.

◆ computeWijFromSolve()

void SubChannel1PhaseProblem::computeWijFromSolve ( int  iblock)
protectedinherited

Computes diversion crossflow per gap for block iblock.

Definition at line 370 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::externalSolve().

371 {
372  unsigned int last_node = (iblock + 1) * _block_size;
373  unsigned int first_node = iblock * _block_size + 1;
374  // Initial guess, port crossflow of block (iblock) into a vector that will act as my initial guess
375  libMesh::DenseVector<Real> solution_seed(_n_gaps * _block_size, 0.0);
376  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
377  {
378  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
379  {
380  int i = _n_gaps * (iz - first_node) + i_gap; // column wise transfer
381  solution_seed(i) = _Wij(i_gap, iz);
382  }
383  }
384 
385  // Solving the combined lateral momentum equation for Wij using a PETSc solver and update vector
386  // root
388  LibmeshPetscCall(petscSnesSolver(iblock, solution_seed, root));
389 
390  // Assign the solution to the cross-flow matrix
391  int i = 0;
392  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
393  {
394  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
395  {
396  _Wij(i_gap, iz) = root(i);
397  i++;
398  }
399  }
400 }
Real root(std::function< Real(Real)> const &f, Real x1, Real x2, Real tol=1.0e-12)
Finds the root of a function using Brent&#39;s method.
Definition: BrentsMethod.C:66
libMesh::DenseMatrix< Real > & _Wij
PetscErrorCode petscSnesSolver(int iblock, const libMesh::DenseVector< Real > &solution, libMesh::DenseVector< Real > &root)
Computes solution of nonlinear equation using snes and provided a residual in a formFunction.

◆ computeWijPrime()

void SubChannel1PhaseProblem::computeWijPrime ( int  iblock)
protectedinherited

Computes turbulent crossflow per gap for block iblock.

Update turbulent crossflow

Definition at line 1719 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::externalSolve(), SubChannel1PhaseProblem::implicitPetscSolve(), and SubChannel1PhaseProblem::residualFunction().

1720 {
1721  unsigned int last_node = (iblock + 1) * _block_size;
1722  unsigned int first_node = iblock * _block_size + 1;
1723  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
1724  {
1725  auto dz = _z_grid[iz] - _z_grid[iz - 1];
1726  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
1727  {
1728  auto chans = _subchannel_mesh.getGapChannels(i_gap);
1729  unsigned int i_ch = chans.first;
1730  unsigned int j_ch = chans.second;
1731  auto * node_in_i = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1732  auto * node_out_i = _subchannel_mesh.getChannelNode(i_ch, iz);
1733  auto * node_in_j = _subchannel_mesh.getChannelNode(j_ch, iz - 1);
1734  auto * node_out_j = _subchannel_mesh.getChannelNode(j_ch, iz);
1735  auto Si_in = (*_S_flow_soln)(node_in_i);
1736  auto Sj_in = (*_S_flow_soln)(node_in_j);
1737  auto Si_out = (*_S_flow_soln)(node_out_i);
1738  auto Sj_out = (*_S_flow_soln)(node_out_j);
1739  auto gap = _subchannel_mesh.getGapWidth(iz, i_gap);
1740  auto Sij = dz * gap;
1741  auto avg_massflux =
1742  0.5 * (((*_mdot_soln)(node_in_i) + (*_mdot_soln)(node_in_j)) / (Si_in + Sj_in) +
1743  ((*_mdot_soln)(node_out_i) + (*_mdot_soln)(node_out_j)) / (Si_out + Sj_out));
1744  auto beta = computeBeta(i_gap, iz);
1745 
1746  if (!_implicit_bool)
1747  {
1748  _WijPrime(i_gap, iz) = beta * avg_massflux * Sij;
1749  }
1750  else
1751  {
1752  auto iz_ind = iz - first_node;
1753  PetscScalar base_value = beta * 0.5 * Sij;
1754 
1755  // Bottom values
1756  if (iz == first_node)
1757  {
1758  PetscScalar value_tl = -1.0 * base_value / (Si_in + Sj_in) *
1759  ((*_mdot_soln)(node_in_i) + (*_mdot_soln)(node_in_j));
1760  PetscInt row = i_gap + _n_gaps * iz_ind;
1761  LibmeshPetscCall(
1762  VecSetValues(_amc_turbulent_cross_flows_rhs, 1, &row, &value_tl, INSERT_VALUES));
1763  }
1764  else
1765  {
1766  PetscScalar value_tl = base_value / (Si_in + Sj_in);
1767  PetscInt row = i_gap + _n_gaps * iz_ind;
1768 
1769  PetscInt col_ich = i_ch + _n_channels * (iz_ind - 1);
1770  LibmeshPetscCall(MatSetValues(
1771  _amc_turbulent_cross_flows_mat, 1, &row, 1, &col_ich, &value_tl, INSERT_VALUES));
1772 
1773  PetscInt col_jch = j_ch + _n_channels * (iz_ind - 1);
1774  LibmeshPetscCall(MatSetValues(
1775  _amc_turbulent_cross_flows_mat, 1, &row, 1, &col_jch, &value_tl, INSERT_VALUES));
1776  }
1777 
1778  // Top values
1779  PetscScalar value_bl = base_value / (Si_out + Sj_out);
1780  PetscInt row = i_gap + _n_gaps * iz_ind;
1781 
1782  PetscInt col_ich = i_ch + _n_channels * iz_ind;
1783  LibmeshPetscCall(MatSetValues(
1784  _amc_turbulent_cross_flows_mat, 1, &row, 1, &col_ich, &value_bl, INSERT_VALUES));
1785 
1786  PetscInt col_jch = j_ch + _n_channels * iz_ind;
1787  LibmeshPetscCall(MatSetValues(
1788  _amc_turbulent_cross_flows_mat, 1, &row, 1, &col_jch, &value_bl, INSERT_VALUES));
1789  }
1790  }
1791  }
1792 
1793  if (_implicit_bool)
1794  {
1795  LibmeshPetscCall(MatAssemblyBegin(_amc_turbulent_cross_flows_mat, MAT_FINAL_ASSEMBLY));
1796  LibmeshPetscCall(MatAssemblyEnd(_amc_turbulent_cross_flows_mat, MAT_FINAL_ASSEMBLY));
1797 
1799  Vec loc_prod;
1800  Vec loc_Wij;
1801  LibmeshPetscCall(VecDuplicate(_amc_sys_mdot_rhs, &loc_prod));
1802  LibmeshPetscCall(VecDuplicate(_Wij_vec, &loc_Wij));
1803  LibmeshPetscCall(populateVectorFromHandle<SolutionHandle>(
1804  loc_prod, *_mdot_soln, first_node, last_node, _n_channels));
1805  LibmeshPetscCall(MatMult(_amc_turbulent_cross_flows_mat, loc_prod, loc_Wij));
1806  LibmeshPetscCall(VecAXPY(loc_Wij, -1.0, _amc_turbulent_cross_flows_rhs));
1808  loc_Wij, _WijPrime, first_node, last_node, _n_gaps));
1809  LibmeshPetscCall(VecDestroy(&loc_prod));
1810  LibmeshPetscCall(VecDestroy(&loc_Wij));
1811  }
1812 }
virtual Real computeBeta(unsigned int i_gap, unsigned int iz)=0
Computes turbulent mixing coefficient.
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
Mat _amc_turbulent_cross_flows_mat
Mass conservation - density time derivative No implicit matrix.
std::vector< Real > _z_grid
axial location of nodes
std::unique_ptr< SolutionHandle > _mdot_soln
PetscErrorCode populateDenseFromVector(const Vec &x, T &solution, const unsigned int first_axial_level, const unsigned int last_axial_level, const unsigned int cross_dimension)
virtual Real getGapWidth(unsigned int axial_index, unsigned int gap_index) const =0
Return gap width for a given gap index.
const bool _implicit_bool
Flag to define the usage of a implicit or explicit solution.
libMesh::DenseMatrix< Real > _WijPrime
virtual const std::pair< unsigned int, unsigned int > & getGapChannels(unsigned int i_gap) const =0
Return a pair of subchannel indices for a given gap index.

◆ computeWijResidual()

void SubChannel1PhaseProblem::computeWijResidual ( int  iblock)
protectedinherited

Computes Residual Matrix based on the lateral momentum conservation equation for block iblock.

Assembling system

Definition at line 1401 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::implicitPetscSolve(), and SubChannel1PhaseProblem::residualFunction().

1402 {
1403  // Cross flow residual
1404  if (!_implicit_bool)
1405  {
1406  unsigned int last_node = (iblock + 1) * _block_size;
1407  unsigned int first_node = iblock * _block_size;
1408  const Real & pitch = _subchannel_mesh.getPitch();
1409  for (unsigned int iz = first_node + 1; iz < last_node + 1; iz++)
1410  {
1411  auto dz = _z_grid[iz] - _z_grid[iz - 1];
1412  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
1413  {
1414  auto chans = _subchannel_mesh.getGapChannels(i_gap);
1415  unsigned int i_ch = chans.first;
1416  unsigned int j_ch = chans.second;
1417  auto * node_in_i = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1418  auto * node_out_i = _subchannel_mesh.getChannelNode(i_ch, iz);
1419  auto * node_in_j = _subchannel_mesh.getChannelNode(j_ch, iz - 1);
1420  auto * node_out_j = _subchannel_mesh.getChannelNode(j_ch, iz);
1421  auto rho_i = (*_rho_soln)(node_in_i);
1422  auto rho_j = (*_rho_soln)(node_in_j);
1423  auto Si = (*_S_flow_soln)(node_in_i);
1424  auto Sj = (*_S_flow_soln)(node_in_j);
1425  auto Sij = dz * _subchannel_mesh.getGapWidth(iz, i_gap);
1426  auto Lij = pitch;
1427  // total local form loss in the ij direction
1428  auto friction_term = _kij * _Wij(i_gap, iz) * std::abs(_Wij(i_gap, iz));
1429  auto DPij = (*_P_soln)(node_in_i) - (*_P_soln)(node_in_j);
1430  // Figure out donor cell density
1431  auto rho_star = 0.0;
1432  if (_Wij(i_gap, iz) > 0.0)
1433  rho_star = rho_i;
1434  else if (_Wij(i_gap, iz) < 0.0)
1435  rho_star = rho_j;
1436  else
1437  rho_star = (rho_i + rho_j) / 2.0;
1438  auto mass_term_out =
1439  (*_mdot_soln)(node_out_i) / Si / rho_i + (*_mdot_soln)(node_out_j) / Sj / rho_j;
1440  auto mass_term_in =
1441  (*_mdot_soln)(node_in_i) / Si / rho_i + (*_mdot_soln)(node_in_j) / Sj / rho_j;
1442  auto term_out = Sij * rho_star * (Lij / dz) * mass_term_out * _Wij(i_gap, iz);
1443  auto term_in = Sij * rho_star * (Lij / dz) * mass_term_in * _Wij(i_gap, iz - 1);
1444  auto inertia_term = term_out - term_in;
1445  auto pressure_term = 2 * std::pow(Sij, 2.0) * DPij * rho_star;
1446  auto time_term =
1447  _TR * 2.0 * (_Wij(i_gap, iz) - _Wij_old(i_gap, iz)) * Lij * Sij * rho_star / _dt;
1448 
1449  _Wij_residual_matrix(i_gap, iz - 1 - iblock * _block_size) =
1450  time_term + friction_term + inertia_term - pressure_term;
1451  }
1452  }
1453  }
1454  else
1455  {
1456  // Initializing to zero the elements of the lateral momentum assembly
1457  LibmeshPetscCall(MatZeroEntries(_cmc_time_derivative_mat));
1458  LibmeshPetscCall(MatZeroEntries(_cmc_advective_derivative_mat));
1459  LibmeshPetscCall(MatZeroEntries(_cmc_friction_force_mat));
1460  LibmeshPetscCall(MatZeroEntries(_cmc_pressure_force_mat));
1461  LibmeshPetscCall(VecZeroEntries(_cmc_time_derivative_rhs));
1462  LibmeshPetscCall(VecZeroEntries(_cmc_advective_derivative_rhs));
1463  LibmeshPetscCall(VecZeroEntries(_cmc_friction_force_rhs));
1464  LibmeshPetscCall(VecZeroEntries(_cmc_pressure_force_rhs));
1465  LibmeshPetscCall(MatZeroEntries(_cmc_sys_Wij_mat));
1466  LibmeshPetscCall(VecZeroEntries(_cmc_sys_Wij_rhs));
1467  unsigned int last_node = (iblock + 1) * _block_size;
1468  unsigned int first_node = iblock * _block_size;
1469  const Real & pitch = _subchannel_mesh.getPitch();
1470  for (unsigned int iz = first_node + 1; iz < last_node + 1; iz++)
1471  {
1472  auto dz = _z_grid[iz] - _z_grid[iz - 1];
1473  auto iz_ind = iz - first_node - 1;
1474  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
1475  {
1476  auto chans = _subchannel_mesh.getGapChannels(i_gap);
1477  unsigned int i_ch = chans.first;
1478  unsigned int j_ch = chans.second;
1479  auto * node_in_i = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1480  auto * node_out_i = _subchannel_mesh.getChannelNode(i_ch, iz);
1481  auto * node_in_j = _subchannel_mesh.getChannelNode(j_ch, iz - 1);
1482  auto * node_out_j = _subchannel_mesh.getChannelNode(j_ch, iz);
1483 
1484  // inlet, outlet, and interpolated densities
1485  auto rho_i_in = (*_rho_soln)(node_in_i);
1486  auto rho_i_out = (*_rho_soln)(node_out_i);
1487  auto rho_i_interp = computeInterpolatedValue(rho_i_out, rho_i_in, 0.5);
1488  auto rho_j_in = (*_rho_soln)(node_in_j);
1489  auto rho_j_out = (*_rho_soln)(node_out_j);
1490  auto rho_j_interp = computeInterpolatedValue(rho_j_out, rho_j_in, 0.5);
1491 
1492  // inlet, outlet, and interpolated areas
1493  auto S_i_in = (*_S_flow_soln)(node_in_i);
1494  auto S_i_out = (*_S_flow_soln)(node_out_i);
1495  auto S_j_in = (*_S_flow_soln)(node_in_j);
1496  auto S_j_out = (*_S_flow_soln)(node_out_j);
1497 
1498  // Cross-sectional gap area
1499  auto Sij = dz * _subchannel_mesh.getGapWidth(iz, i_gap);
1500  auto Lij = pitch;
1501 
1502  // Figure out donor cell density
1503  auto rho_star = 0.0;
1504  if (_Wij(i_gap, iz) > 0.0)
1505  rho_star = rho_i_interp;
1506  else if (_Wij(i_gap, iz) < 0.0)
1507  rho_star = rho_j_interp;
1508  else
1509  rho_star = (rho_i_interp + rho_j_interp) / 2.0;
1510 
1511  // Assembling time derivative
1512  PetscScalar time_factor = _TR * Lij * Sij * rho_star / _dt;
1513  PetscInt row_td = i_gap + _n_gaps * iz_ind;
1514  PetscInt col_td = i_gap + _n_gaps * iz_ind;
1515  PetscScalar value_td = time_factor;
1516  LibmeshPetscCall(MatSetValues(
1517  _cmc_time_derivative_mat, 1, &row_td, 1, &col_td, &value_td, INSERT_VALUES));
1518  PetscScalar value_td_rhs = time_factor * _Wij_old(i_gap, iz);
1519  LibmeshPetscCall(
1520  VecSetValues(_cmc_time_derivative_rhs, 1, &row_td, &value_td_rhs, INSERT_VALUES));
1521 
1522  // Assembling inertial term
1523  PetscScalar Pe = 0.5;
1525  auto mass_term_out = (*_mdot_soln)(node_out_i) / S_i_out / rho_i_out +
1526  (*_mdot_soln)(node_out_j) / S_j_out / rho_j_out;
1527  auto mass_term_in = (*_mdot_soln)(node_in_i) / S_i_in / rho_i_in +
1528  (*_mdot_soln)(node_in_j) / S_j_in / rho_j_in;
1529  auto term_out = Sij * rho_star * (Lij / dz) * mass_term_out / 2.0;
1530  auto term_in = Sij * rho_star * (Lij / dz) * mass_term_in / 2.0;
1531  if (iz == first_node + 1)
1532  {
1533  PetscInt row_ad = i_gap + _n_gaps * iz_ind;
1534  PetscScalar value_ad = term_in * alpha * _Wij(i_gap, iz - 1);
1535  LibmeshPetscCall(
1536  VecSetValues(_cmc_advective_derivative_rhs, 1, &row_ad, &value_ad, ADD_VALUES));
1537 
1538  PetscInt col_ad = i_gap + _n_gaps * iz_ind;
1539  value_ad = -1.0 * term_in * (1.0 - alpha) + term_out * alpha;
1540  LibmeshPetscCall(MatSetValues(
1541  _cmc_advective_derivative_mat, 1, &row_ad, 1, &col_ad, &value_ad, INSERT_VALUES));
1542 
1543  col_ad = i_gap + _n_gaps * (iz_ind + 1);
1544  value_ad = term_out * (1.0 - alpha);
1545  LibmeshPetscCall(MatSetValues(
1546  _cmc_advective_derivative_mat, 1, &row_ad, 1, &col_ad, &value_ad, INSERT_VALUES));
1547  }
1548  else if (iz == last_node)
1549  {
1550  PetscInt row_ad = i_gap + _n_gaps * iz_ind;
1551  PetscInt col_ad = i_gap + _n_gaps * (iz_ind - 1);
1552  PetscScalar value_ad = -1.0 * term_in * alpha;
1553  LibmeshPetscCall(MatSetValues(
1554  _cmc_advective_derivative_mat, 1, &row_ad, 1, &col_ad, &value_ad, INSERT_VALUES));
1555 
1556  col_ad = i_gap + _n_gaps * iz_ind;
1557  value_ad = -1.0 * term_in * (1.0 - alpha) + term_out * alpha;
1558  LibmeshPetscCall(MatSetValues(
1559  _cmc_advective_derivative_mat, 1, &row_ad, 1, &col_ad, &value_ad, INSERT_VALUES));
1560 
1561  value_ad = -1.0 * term_out * (1.0 - alpha) * _Wij(i_gap, iz);
1562  LibmeshPetscCall(
1563  VecSetValues(_cmc_advective_derivative_rhs, 1, &row_ad, &value_ad, ADD_VALUES));
1564  }
1565  else
1566  {
1567  PetscInt row_ad = i_gap + _n_gaps * iz_ind;
1568  PetscInt col_ad = i_gap + _n_gaps * (iz_ind - 1);
1569  PetscScalar value_ad = -1.0 * term_in * alpha;
1570  LibmeshPetscCall(MatSetValues(
1571  _cmc_advective_derivative_mat, 1, &row_ad, 1, &col_ad, &value_ad, INSERT_VALUES));
1572 
1573  col_ad = i_gap + _n_gaps * iz_ind;
1574  value_ad = -1.0 * term_in * (1.0 - alpha) + term_out * alpha;
1575  LibmeshPetscCall(MatSetValues(
1576  _cmc_advective_derivative_mat, 1, &row_ad, 1, &col_ad, &value_ad, INSERT_VALUES));
1577 
1578  col_ad = i_gap + _n_gaps * (iz_ind + 1);
1579  value_ad = term_out * (1.0 - alpha);
1580  LibmeshPetscCall(MatSetValues(
1581  _cmc_advective_derivative_mat, 1, &row_ad, 1, &col_ad, &value_ad, INSERT_VALUES));
1582  }
1583  // Assembling friction force
1584  PetscInt row_ff = i_gap + _n_gaps * iz_ind;
1585  PetscInt col_ff = i_gap + _n_gaps * iz_ind;
1586  PetscScalar value_ff = _kij * std::abs(_Wij(i_gap, iz)) / 2.0;
1587  LibmeshPetscCall(MatSetValues(
1588  _cmc_friction_force_mat, 1, &row_ff, 1, &col_ff, &value_ff, INSERT_VALUES));
1589 
1590  // Assembling pressure force
1592 
1594  {
1595  PetscScalar pressure_factor = std::pow(Sij, 2.0) * rho_star;
1596  PetscInt row_pf = i_gap + _n_gaps * iz_ind;
1597  PetscInt col_pf = i_ch + _n_channels * iz_ind;
1598  PetscScalar value_pf = -1.0 * alpha * pressure_factor;
1599  LibmeshPetscCall(
1600  MatSetValues(_cmc_pressure_force_mat, 1, &row_pf, 1, &col_pf, &value_pf, ADD_VALUES));
1601  col_pf = j_ch + _n_channels * iz_ind;
1602  value_pf = alpha * pressure_factor;
1603  LibmeshPetscCall(
1604  MatSetValues(_cmc_pressure_force_mat, 1, &row_pf, 1, &col_pf, &value_pf, ADD_VALUES));
1605 
1606  if (iz == last_node)
1607  {
1608  PetscInt row_pf = i_gap + _n_gaps * iz_ind;
1609  PetscScalar value_pf = (1.0 - alpha) * pressure_factor * (*_P_soln)(node_out_i);
1610  LibmeshPetscCall(
1611  VecSetValues(_cmc_pressure_force_rhs, 1, &row_pf, &value_pf, ADD_VALUES));
1612  value_pf = -1.0 * (1.0 - alpha) * pressure_factor * (*_P_soln)(node_out_j);
1613  LibmeshPetscCall(
1614  VecSetValues(_cmc_pressure_force_rhs, 1, &row_pf, &value_pf, ADD_VALUES));
1615  }
1616  else
1617  {
1618  row_pf = i_gap + _n_gaps * iz_ind;
1619  col_pf = i_ch + _n_channels * (iz_ind + 1);
1620  value_pf = -1.0 * (1.0 - alpha) * pressure_factor;
1621  LibmeshPetscCall(MatSetValues(
1622  _cmc_pressure_force_mat, 1, &row_pf, 1, &col_pf, &value_pf, ADD_VALUES));
1623  col_pf = j_ch + _n_channels * (iz_ind + 1);
1624  value_pf = (1.0 - alpha) * pressure_factor;
1625  LibmeshPetscCall(MatSetValues(
1626  _cmc_pressure_force_mat, 1, &row_pf, 1, &col_pf, &value_pf, ADD_VALUES));
1627  }
1628  }
1629  else
1630  {
1631  PetscScalar pressure_factor = std::pow(Sij, 2.0) * rho_star;
1632  PetscInt row_pf = i_gap + _n_gaps * iz_ind;
1633  PetscInt col_pf = i_ch + _n_channels * iz_ind;
1634  PetscScalar value_pf = -1.0 * pressure_factor;
1635  LibmeshPetscCall(
1636  MatSetValues(_cmc_pressure_force_mat, 1, &row_pf, 1, &col_pf, &value_pf, ADD_VALUES));
1637  col_pf = j_ch + _n_channels * iz_ind;
1638  value_pf = pressure_factor;
1639  LibmeshPetscCall(
1640  MatSetValues(_cmc_pressure_force_mat, 1, &row_pf, 1, &col_pf, &value_pf, ADD_VALUES));
1641  }
1642  }
1643  }
1645  LibmeshPetscCall(MatZeroEntries(_cmc_sys_Wij_mat));
1646  LibmeshPetscCall(VecZeroEntries(_cmc_sys_Wij_rhs));
1647  LibmeshPetscCall(MatAssemblyBegin(_cmc_time_derivative_mat, MAT_FINAL_ASSEMBLY));
1648  LibmeshPetscCall(MatAssemblyEnd(_cmc_time_derivative_mat, MAT_FINAL_ASSEMBLY));
1649  LibmeshPetscCall(MatAssemblyBegin(_cmc_advective_derivative_mat, MAT_FINAL_ASSEMBLY));
1650  LibmeshPetscCall(MatAssemblyEnd(_cmc_advective_derivative_mat, MAT_FINAL_ASSEMBLY));
1651  LibmeshPetscCall(MatAssemblyBegin(_cmc_friction_force_mat, MAT_FINAL_ASSEMBLY));
1652  LibmeshPetscCall(MatAssemblyEnd(_cmc_friction_force_mat, MAT_FINAL_ASSEMBLY));
1653  LibmeshPetscCall(MatAssemblyBegin(_cmc_pressure_force_mat, MAT_FINAL_ASSEMBLY));
1654  LibmeshPetscCall(MatAssemblyEnd(_cmc_pressure_force_mat, MAT_FINAL_ASSEMBLY));
1655  LibmeshPetscCall(MatAssemblyBegin(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1656  LibmeshPetscCall(MatAssemblyEnd(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1657  // Matrix
1658 #if !PETSC_VERSION_LESS_THAN(3, 15, 0)
1659  LibmeshPetscCall(
1660  MatAXPY(_cmc_sys_Wij_mat, 1.0, _cmc_time_derivative_mat, UNKNOWN_NONZERO_PATTERN));
1661  LibmeshPetscCall(MatAssemblyBegin(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1662  LibmeshPetscCall(MatAssemblyEnd(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1663  LibmeshPetscCall(
1664  MatAXPY(_cmc_sys_Wij_mat, 1.0, _cmc_advective_derivative_mat, UNKNOWN_NONZERO_PATTERN));
1665  LibmeshPetscCall(MatAssemblyBegin(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1666  LibmeshPetscCall(MatAssemblyEnd(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1667  LibmeshPetscCall(
1668  MatAXPY(_cmc_sys_Wij_mat, 1.0, _cmc_friction_force_mat, UNKNOWN_NONZERO_PATTERN));
1669 #else
1670  LibmeshPetscCall(
1671  MatAXPY(_cmc_sys_Wij_mat, 1.0, _cmc_time_derivative_mat, DIFFERENT_NONZERO_PATTERN));
1672  LibmeshPetscCall(MatAssemblyBegin(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1673  LibmeshPetscCall(MatAssemblyEnd(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1674  LibmeshPetscCall(
1675  MatAXPY(_cmc_sys_Wij_mat, 1.0, _cmc_advective_derivative_mat, DIFFERENT_NONZERO_PATTERN));
1676  LibmeshPetscCall(MatAssemblyBegin(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1677  LibmeshPetscCall(MatAssemblyEnd(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1678  LibmeshPetscCall(
1679  MatAXPY(_cmc_sys_Wij_mat, 1.0, _cmc_friction_force_mat, DIFFERENT_NONZERO_PATTERN));
1680 #endif
1681  LibmeshPetscCall(MatAssemblyBegin(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1682  LibmeshPetscCall(MatAssemblyEnd(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1683  // RHS
1684  LibmeshPetscCall(VecAXPY(_cmc_sys_Wij_rhs, 1.0, _cmc_time_derivative_rhs));
1685  LibmeshPetscCall(VecAXPY(_cmc_sys_Wij_rhs, 1.0, _cmc_advective_derivative_rhs));
1686  LibmeshPetscCall(VecAXPY(_cmc_sys_Wij_rhs, 1.0, _cmc_friction_force_rhs));
1687 
1688  if (_segregated_bool)
1689  {
1690  // Assembly the matrix system
1691  Vec sol_holder_P;
1692  LibmeshPetscCall(createPetscVector(sol_holder_P, _block_size * _n_gaps));
1693  Vec sol_holder_W;
1694  LibmeshPetscCall(createPetscVector(sol_holder_W, _block_size * _n_gaps));
1695  LibmeshPetscCall(populateVectorFromHandle<SolutionHandle>(
1696  _prodp, *_P_soln, iblock * _block_size, (iblock + 1) * _block_size - 1, _n_channels));
1697  LibmeshPetscCall(MatMult(_cmc_sys_Wij_mat, _Wij_vec, sol_holder_W));
1698  LibmeshPetscCall(VecAXPY(sol_holder_W, -1.0, _cmc_sys_Wij_rhs));
1699  LibmeshPetscCall(MatMult(_cmc_pressure_force_mat, _prodp, sol_holder_P));
1700  LibmeshPetscCall(VecAXPY(sol_holder_P, -1.0, _cmc_pressure_force_rhs));
1701  LibmeshPetscCall(VecAXPY(sol_holder_W, 1.0, sol_holder_P));
1702  PetscScalar * xx;
1703  LibmeshPetscCall(VecGetArray(sol_holder_W, &xx));
1704  for (unsigned int iz = first_node + 1; iz < last_node + 1; iz++)
1705  {
1706  auto iz_ind = iz - first_node - 1;
1707  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
1708  {
1709  _Wij_residual_matrix(i_gap, iz - 1 - iblock * _block_size) = xx[iz_ind * _n_gaps + i_gap];
1710  }
1711  }
1712  LibmeshPetscCall(VecDestroy(&sol_holder_P));
1713  LibmeshPetscCall(VecDestroy(&sol_holder_W));
1714  }
1715  }
1716 }
Mat _cmc_friction_force_mat
Cross momentum conservation - friction force.
Real _TR
Flag that activates or deactivates the transient parts of the equations we solve by multiplication...
libMesh::DenseMatrix< Real > _Wij_old
virtual const Real & getPitch() const
Return the pitch between 2 subchannels.
PetscErrorCode createPetscVector(Vec &v, PetscInt n)
Petsc Functions.
PetscScalar computeInterpolatedValue(PetscScalar topValue, PetscScalar botValue, PetscScalar Peclet=0.0)
const bool _segregated_bool
Segregated solve.
Mat _cmc_sys_Wij_mat
Lateral momentum system matrix.
const bool _staggered_pressure_bool
Flag to define the usage of staggered or collocated pressure.
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
std::vector< Real > _z_grid
axial location of nodes
static const std::string pitch
PetscScalar computeInterpolationCoefficients(PetscScalar Peclet=0.0)
Functions that computes the interpolation scheme given the Peclet number.
libMesh::DenseMatrix< Real > _Wij_residual_matrix
std::unique_ptr< SolutionHandle > _mdot_soln
virtual Real getGapWidth(unsigned int axial_index, unsigned int gap_index) const =0
Return gap width for a given gap index.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
libMesh::DenseMatrix< Real > & _Wij
static const std::string alpha
Definition: NS.h:134
const bool _implicit_bool
Flag to define the usage of a implicit or explicit solution.
Mat _cmc_time_derivative_mat
Cross momentum Cross momentum conservation - time derivative.
Mat _cmc_pressure_force_mat
Cross momentum conservation - pressure force.
MooseUnits pow(const MooseUnits &, int)
std::unique_ptr< SolutionHandle > _P_soln
Mat _cmc_advective_derivative_mat
Cross momentum conservation - advective (Eulerian) derivative.
virtual const std::pair< unsigned int, unsigned int > & getGapChannels(unsigned int i_gap) const =0
Return a pair of subchannel indices for a given gap index.

◆ createPetscMatrix()

PetscErrorCode SubChannel1PhaseProblem::createPetscMatrix ( Mat &  M,
PetscInt  n,
PetscInt  m 
)
inlineprotectedinherited

Definition at line 195 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::SubChannel1PhaseProblem(), and TriSubChannel1PhaseProblem::TriSubChannel1PhaseProblem().

196  {
198  LibmeshPetscCall(MatCreate(PETSC_COMM_WORLD, &M));
199  LibmeshPetscCall(MatSetSizes(M, PETSC_DECIDE, PETSC_DECIDE, n, m));
200  LibmeshPetscCall(MatSetFromOptions(M));
201  LibmeshPetscCall(MatSetUp(M));
202  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
203  }
PetscFunctionBegin
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)

◆ createPetscVector()

PetscErrorCode SubChannel1PhaseProblem::createPetscVector ( Vec &  v,
PetscInt  n 
)
inlineprotectedinherited

Petsc Functions.

Definition at line 184 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::computeWijResidual(), SubChannel1PhaseProblem::implicitPetscSolve(), SubChannel1PhaseProblem::SubChannel1PhaseProblem(), and TriSubChannel1PhaseProblem::TriSubChannel1PhaseProblem().

185  {
187  LibmeshPetscCall(VecCreate(PETSC_COMM_WORLD, &v));
188  LibmeshPetscCall(PetscObjectSetName((PetscObject)v, "Solution"));
189  LibmeshPetscCall(VecSetSizes(v, PETSC_DECIDE, n));
190  LibmeshPetscCall(VecSetFromOptions(v));
191  LibmeshPetscCall(VecZeroEntries(v));
192  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
193  }
PetscFunctionBegin
static const std::string v
Definition: NS.h:84
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)

◆ externalSolve()

void SubChannel1PhaseProblem::externalSolve ( )
overridevirtualinherited

Assigning temperature to the fuel pins

Assigning temperatures to duct

Implements ExternalProblem.

Definition at line 2512 of file SubChannel1PhaseProblem.C.

2513 {
2514  _console << "Executing subchannel solver\n";
2515  _dt = (isTransient() ? dt() : _one);
2516  _TR = isTransient();
2518  if (_verbose_subchannel)
2519  _console << "Solution initialized" << std::endl;
2520  Real P_error = 1.0;
2521  unsigned int P_it = 0;
2522  unsigned int P_it_max;
2523 
2524  if (_segregated_bool)
2525  P_it_max = 20 * _n_blocks;
2526  else
2527  P_it_max = 100;
2528 
2529  if ((_n_blocks == 1) && (_segregated_bool))
2530  P_it_max = 5;
2531 
2532  while ((P_error > _P_tol && P_it < P_it_max))
2533  {
2534  P_it += 1;
2535  if (P_it == P_it_max && _n_blocks != 1)
2536  {
2537  _console << "Reached maximum number of axial pressure iterations" << std::endl;
2538  _converged = false;
2539  }
2540  _console << "Solving Outer Iteration : " << P_it << std::endl;
2541  auto P_L2norm_old_axial = _P_soln->L2norm();
2542  for (unsigned int iblock = 0; iblock < _n_blocks; iblock++)
2543  {
2544  int last_level = (iblock + 1) * _block_size;
2545  int first_level = iblock * _block_size + 1;
2546  Real T_block_error = 1.0;
2547  auto T_it = 0;
2548  _console << "Solving Block: " << iblock << " From first level: " << first_level
2549  << " to last level: " << last_level << std::endl;
2550  while (T_block_error > _T_tol && T_it < _T_maxit)
2551  {
2552  T_it += 1;
2553  if (T_it == _T_maxit)
2554  {
2555  _console << "Reached maximum number of temperature iterations for block: " << iblock
2556  << std::endl;
2557  _converged = false;
2558  }
2559  auto T_L2norm_old_block = _T_soln->L2norm();
2560 
2561  if (_segregated_bool)
2562  {
2563  computeWijFromSolve(iblock);
2564 
2565  if (_compute_power)
2566  {
2567  computeh(iblock);
2568  computeT(iblock);
2569  }
2570  }
2571  else
2572  {
2573  LibmeshPetscCall(implicitPetscSolve(iblock));
2574  computeWijPrime(iblock);
2575  if (_verbose_subchannel)
2576  _console << "Done with main solve." << std::endl;
2578  {
2579  // Enthalpy is already solved from the monolithic solve
2580  computeT(iblock);
2581  }
2582  else
2583  {
2584  if (_verbose_subchannel)
2585  _console << "Starting thermal solve." << std::endl;
2586  if (_compute_power)
2587  {
2588  computeh(iblock);
2589  computeT(iblock);
2590  }
2591  if (_verbose_subchannel)
2592  _console << "Done with thermal solve." << std::endl;
2593  }
2594  }
2595 
2596  if (_verbose_subchannel)
2597  _console << "Start updating thermophysical properties." << std::endl;
2598 
2599  if (_compute_density)
2600  computeRho(iblock);
2601 
2602  if (_compute_viscosity)
2603  computeMu(iblock);
2604 
2605  if (_verbose_subchannel)
2606  _console << "Done updating thermophysical properties." << std::endl;
2607 
2608  // We must do a global assembly to make sure data is parallel consistent before we do things
2609  // like compute L2 norms
2610  _aux->solution().close();
2611 
2612  auto T_L2norm_new = _T_soln->L2norm();
2613  T_block_error =
2614  std::abs((T_L2norm_new - T_L2norm_old_block) / (T_L2norm_old_block + 1E-14));
2615  _console << "T_block_error: " << T_block_error << std::endl;
2616  }
2617  }
2618  auto P_L2norm_new_axial = _P_soln->L2norm();
2619  P_error =
2620  std::abs((P_L2norm_new_axial - P_L2norm_old_axial) / (P_L2norm_old_axial + _P_out + 1E-14));
2621  _console << "P_error :" << P_error << std::endl;
2622  if (_verbose_subchannel)
2623  {
2624  _console << "Iteration: " << P_it << std::endl;
2625  _console << "Maximum iterations: " << P_it_max << std::endl;
2626  }
2627  }
2628  // update old crossflow matrix
2629  _Wij_old = _Wij;
2630  _console << "Finished executing subchannel solver\n";
2631 
2633  if (_pin_mesh_exist)
2634  {
2635  _console << "Commencing calculation of Pin surface temperature \n";
2636  for (unsigned int i_pin = 0; i_pin < _n_pins; i_pin++)
2637  {
2638  for (unsigned int iz = 0; iz < _n_cells + 1; ++iz)
2639  {
2640  const auto * pin_node = _subchannel_mesh.getPinNode(i_pin, iz);
2641  Real sumTemp = 0.0;
2642  Real rod_counter = 0.0;
2643  // Calculate sum of pin surface temperatures that the channels around the pin see
2644  for (auto i_ch : _subchannel_mesh.getPinChannels(i_pin))
2645  {
2646  const auto * node = _subchannel_mesh.getChannelNode(i_ch, iz);
2647  auto mu = (*_mu_soln)(node);
2648  auto S = (*_S_flow_soln)(node);
2649  auto w_perim = (*_w_perim_soln)(node);
2650  auto Dh_i = 4.0 * S / w_perim;
2651  auto Re = (((*_mdot_soln)(node) / S) * Dh_i / mu);
2652  auto k = _fp->k_from_p_T((*_P_soln)(node) + _P_out, (*_T_soln)(node));
2653  auto cp = _fp->cp_from_p_T((*_P_soln)(node) + _P_out, (*_T_soln)(node));
2654  auto Pr = (*_mu_soln)(node)*cp / k;
2655  auto Nu = 0.023 * std::pow(Re, 0.8) * std::pow(Pr, 0.4);
2656  auto hw = Nu * k / Dh_i;
2657  if ((*_Dpin_soln)(pin_node) <= 0)
2658  mooseError("Dpin should not be null or negative when computing pin powers: ",
2659  (*_Dpin_soln)(pin_node));
2660  sumTemp +=
2661  (*_q_prime_soln)(pin_node) / ((*_Dpin_soln)(pin_node)*M_PI * hw) + (*_T_soln)(node);
2662  rod_counter += 1.0;
2663  }
2664  if (rod_counter > 0)
2665  _Tpin_soln->set(pin_node, sumTemp / rod_counter);
2666  else
2667  mooseError("Pin was not found for pin index: " + std::to_string(i_pin));
2668  }
2669  }
2670  }
2671 
2673  if (_duct_mesh_exist)
2674  {
2675  _console << "Commencing calculation of duct surface temperature " << std::endl;
2676  auto duct_nodes = _subchannel_mesh.getDuctNodes();
2677  for (Node * dn : duct_nodes)
2678  {
2679  auto * node_chan = _subchannel_mesh.getChannelNodeFromDuct(dn);
2680  auto mu = (*_mu_soln)(node_chan);
2681  auto S = (*_S_flow_soln)(node_chan);
2682  auto w_perim = (*_w_perim_soln)(node_chan);
2683  auto Dh_i = 4.0 * S / w_perim;
2684  auto Re = (((*_mdot_soln)(node_chan) / S) * Dh_i / mu);
2685  auto k = _fp->k_from_p_T((*_P_soln)(node_chan) + _P_out, (*_T_soln)(node_chan));
2686  auto cp = _fp->cp_from_p_T((*_P_soln)(node_chan) + _P_out, (*_T_soln)(node_chan));
2687  auto Pr = (*_mu_soln)(node_chan)*cp / k;
2688  auto Nu = 0.023 * std::pow(Re, 0.8) * std::pow(Pr, 0.4);
2689  auto hw = Nu * k / Dh_i;
2690  auto T_chan = (*_q_prime_duct_soln)(dn) / (_subchannel_mesh.getPinDiameter() * M_PI * hw) +
2691  (*_T_soln)(node_chan);
2692  _Tduct_soln->set(dn, T_chan);
2693  }
2694  }
2695  _aux->solution().close();
2696  _aux->update();
2697 
2698  Real power_in = 0.0;
2699  Real power_out = 0.0;
2700  Real Total_surface_area = 0.0;
2701  Real Total_wetted_perimeter = 0.0;
2702  Real mass_flow_in = 0.0;
2703  Real mass_flow_out = 0.0;
2704  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
2705  {
2706  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, 0);
2707  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, _n_cells);
2708  Total_surface_area += (*_S_flow_soln)(node_in);
2709  Total_wetted_perimeter += (*_w_perim_soln)(node_in);
2710  power_in += (*_mdot_soln)(node_in) * (*_h_soln)(node_in);
2711  power_out += (*_mdot_soln)(node_out) * (*_h_soln)(node_out);
2712  mass_flow_in += (*_mdot_soln)(node_in);
2713  mass_flow_out += (*_mdot_soln)(node_out);
2714  }
2715  auto h_bulk_out = power_out / mass_flow_out;
2716  auto T_bulk_out = _fp->T_from_p_h(_P_out, h_bulk_out);
2717 
2718  Real bulk_Dh = 4.0 * Total_surface_area / Total_wetted_perimeter;
2719  Real inlet_mu = (*_mu_soln)(_subchannel_mesh.getChannelNode(0, 0));
2720  Real bulk_Re = mass_flow_in * bulk_Dh / (inlet_mu * Total_surface_area);
2721  if (_verbose_subchannel)
2722  {
2723  _console << " ======================================= " << std::endl;
2724  _console << " ======== Subchannel Print Outs ======== " << std::endl;
2725  _console << " ======================================= " << std::endl;
2726  _console << "Total flow area :" << Total_surface_area << " m^2" << std::endl;
2727  _console << "Assembly hydraulic diameter :" << bulk_Dh << " m" << std::endl;
2728  _console << "Assembly Re number :" << bulk_Re << " [-]" << std::endl;
2729  _console << "Bulk coolant temperature at outlet :" << T_bulk_out << " K" << std::endl;
2730  _console << "Power added to coolant is : " << power_out - power_in << " Watt" << std::endl;
2731  _console << "Mass flow rate in is : " << mass_flow_in << " kg/sec" << std::endl;
2732  _console << "Mass balance is : " << mass_flow_out - mass_flow_in << " kg/sec" << std::endl;
2733  _console << "User defined outlet pressure is : " << _P_out << " Pa" << std::endl;
2734  _console << " ======================================= " << std::endl;
2735  }
2736 
2737  if (MooseUtils::absoluteFuzzyLessEqual((power_out - power_in), -1.0))
2738  mooseWarning(
2739  "Energy conservation equation might not be solved correctly, Power added to coolant: " +
2740  std::to_string(power_out - power_in) + " Watt ");
2741 }
const bool _pin_mesh_exist
Flag that informs if there is a pin mesh or not.
void computeRho(int iblock)
Computes Density per channel for block iblock.
std::unique_ptr< SolutionHandle > _Tduct_soln
unsigned int _n_blocks
number of axial blocks
const bool _compute_power
Flag that informs if we need to solve the Enthalpy/Temperature equations or not.
virtual const Real & getPinDiameter() const
Return Pin diameter.
std::unique_ptr< SolutionHandle > _T_soln
std::unique_ptr< SolutionHandle > _h_soln
const bool _monolithic_thermal_bool
Thermal monolithic bool.
virtual const std::vector< unsigned int > & getPinChannels(unsigned int i_pin) const =0
Return a vector of channel indices for a given Pin index.
virtual Node * getChannelNodeFromDuct(Node *channel_node)=0
Function that gets the channel node from the duct node.
Real _TR
Flag that activates or deactivates the transient parts of the equations we solve by multiplication...
libMesh::DenseMatrix< Real > _Wij_old
const PostprocessorValue & _P_out
Outlet Pressure.
void computeT(int iblock)
Computes Temperature per channel for block iblock.
const bool _compute_density
Flag that activates or deactivates the calculation of density.
const bool _duct_mesh_exist
Flag that informs if there is a pin mesh or not.
const Real & _T_tol
Convergence tolerance for the temperature loop in external solve.
void computeMu(int iblock)
Computes Viscosity per channel for block iblock.
virtual Node * getPinNode(unsigned int i_pin, unsigned iz) const =0
Get the pin mesh node for a given pin index and elevation index.
const bool _segregated_bool
Segregated solve.
bool _converged
Variable that informs whether we exited external solve with a converged solution or not...
virtual void initializeSolution()=0
Function to initialize the solution & geometry fields.
void mooseWarning(Args &&... args) const
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
virtual void computeh(int iblock)=0
Computes Enthalpy per channel for block iblock.
static const std::string cp
Definition: NS.h:121
const int & _T_maxit
Maximum iterations for the inner temperature loop.
static const std::string S
Definition: NS.h:163
static const std::string mu
Definition: NS.h:123
std::shared_ptr< AuxiliarySystem > _aux
std::unique_ptr< SolutionHandle > _Dpin_soln
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual const std::vector< Node * > getDuctNodes() const =0
Function that return the vector with the maps to the nodes if they exist.
const bool _compute_viscosity
Flag that activates or deactivates the calculation of viscosity.
libMesh::DenseMatrix< Real > & _Wij
void computeWijPrime(int iblock)
Computes turbulent crossflow per gap for block iblock.
bool absoluteFuzzyLessEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
const bool _verbose_subchannel
Boolean to printout information related to subchannel solve.
const Real & _P_tol
Convergence tolerance for the pressure loop in external solve.
void mooseError(Args &&... args) const
void computeWijFromSolve(int iblock)
Computes diversion crossflow per gap for block iblock.
const ConsoleStream _console
virtual bool isTransient() const override
PetscErrorCode implicitPetscSolve(int iblock)
Computes implicit solve using PetSc.
virtual Real & dt() const
MooseUnits pow(const MooseUnits &, int)
std::unique_ptr< SolutionHandle > _P_soln
static const std::string k
Definition: NS.h:130
const SinglePhaseFluidProperties * _fp
Solutions handles and link to TH tables properties.
std::unique_ptr< SolutionHandle > _Tpin_soln

◆ implicitPetscSolve()

PetscErrorCode SubChannel1PhaseProblem::implicitPetscSolve ( int  iblock)
protectedinherited

Computes implicit solve using PetSc.

Initializing flags

Assembling matrices

Setting up linear solver

Solving

Destroying solver elements

Recovering the solutions

Assigning the solutions to arrays

Populating Mass flow

Populating Pressure

Populating Crossflow

Populating Enthalpy

Populating sum_Wij

Destroying arrays

Definition at line 1912 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::externalSolve().

1913 {
1914  bool lag_block_thermal_solve = true;
1915  Vec b_nest, x_nest; /* approx solution, RHS, exact solution */
1916  Mat A_nest; /* linear system matrix */
1917  KSP ksp; /* linear solver context */
1918  PC pc; /* preconditioner context */
1919 
1921  PetscInt Q = _monolithic_thermal_bool ? 4 : 3;
1922  std::vector<Mat> mat_array(Q * Q);
1923  std::vector<Vec> vec_array(Q);
1924 
1926  bool _axial_mass_flow_tight_coupling = true;
1927  bool _pressure_axial_momentum_tight_coupling = true;
1928  bool _pressure_cross_momentum_tight_coupling = true;
1929  unsigned int first_node = iblock * _block_size + 1;
1930  unsigned int last_node = (iblock + 1) * _block_size;
1931 
1933  // Computing sum of crossflows with previous iteration
1934  computeSumWij(iblock);
1935  // Assembling axial flux matrix
1936  computeMdot(iblock);
1937  // Computing turbulent crossflow with previous step axial mass flows
1938  computeWijPrime(iblock);
1939  // Assembling for Pressure Drop matrix
1940  computeDP(iblock);
1941  // Assembling pressure matrix
1942  computeP(iblock);
1943  // Assembling cross fluxes matrix
1944  computeWijResidual(iblock);
1945  // If monolithic solve - Assembling enthalpy matrix
1947  computeh(iblock);
1948 
1949  if (_verbose_subchannel)
1950  {
1951  _console << "Starting nested system." << std::endl;
1952  _console << "Number of simultaneous variables: " << Q << std::endl;
1953  }
1954  // Mass conservation
1955  PetscInt field_num = 0;
1956  LibmeshPetscCall(
1957  MatDuplicate(_mc_axial_convection_mat, MAT_COPY_VALUES, &mat_array[Q * field_num + 0]));
1958  LibmeshPetscCall(MatAssemblyBegin(mat_array[Q * field_num + 0], MAT_FINAL_ASSEMBLY));
1959  LibmeshPetscCall(MatAssemblyEnd(mat_array[Q * field_num + 0], MAT_FINAL_ASSEMBLY));
1960  mat_array[Q * field_num + 1] = NULL;
1961  if (_axial_mass_flow_tight_coupling)
1962  {
1963  LibmeshPetscCall(MatDuplicate(_mc_sumWij_mat, MAT_COPY_VALUES, &mat_array[Q * field_num + 2]));
1964  LibmeshPetscCall(MatAssemblyBegin(mat_array[Q * field_num + 2], MAT_FINAL_ASSEMBLY));
1965  LibmeshPetscCall(MatAssemblyEnd(mat_array[Q * field_num + 2], MAT_FINAL_ASSEMBLY));
1966  }
1967  else
1968  {
1969  mat_array[Q * field_num + 2] = NULL;
1970  }
1972  {
1973  mat_array[Q * field_num + 3] = NULL;
1974  }
1975  LibmeshPetscCall(VecDuplicate(_mc_axial_convection_rhs, &vec_array[field_num]));
1976  LibmeshPetscCall(VecCopy(_mc_axial_convection_rhs, vec_array[field_num]));
1977  if (!_axial_mass_flow_tight_coupling)
1978  {
1979  Vec sumWij_loc;
1980  LibmeshPetscCall(VecDuplicate(_mc_axial_convection_rhs, &sumWij_loc));
1981  LibmeshPetscCall(VecSet(sumWij_loc, 0.0));
1982  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
1983  {
1984  auto iz_ind = iz - first_node;
1985  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1986  {
1987  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
1988 
1989  PetscScalar value_vec_2 = -1.0 * (*_SumWij_soln)(node_out);
1990  PetscInt row_vec_2 = i_ch + _n_channels * iz_ind;
1991  LibmeshPetscCall(VecSetValues(sumWij_loc, 1, &row_vec_2, &value_vec_2, ADD_VALUES));
1992  }
1993  }
1994  LibmeshPetscCall(VecAXPY(vec_array[field_num], 1.0, sumWij_loc));
1995  LibmeshPetscCall(VecDestroy(&sumWij_loc));
1996  }
1997 
1998  if (_verbose_subchannel)
1999  _console << "Mass ok." << std::endl;
2000  // Axial momentum conservation
2001  field_num = 1;
2002  if (_pressure_axial_momentum_tight_coupling)
2003  {
2004  LibmeshPetscCall(
2005  MatDuplicate(_amc_sys_mdot_mat, MAT_COPY_VALUES, &mat_array[Q * field_num + 0]));
2006  LibmeshPetscCall(MatAssemblyBegin(mat_array[Q * field_num + 0], MAT_FINAL_ASSEMBLY));
2007  LibmeshPetscCall(MatAssemblyEnd(mat_array[Q * field_num + 0], MAT_FINAL_ASSEMBLY));
2008  }
2009  else
2010  {
2011  mat_array[Q * field_num + 0] = NULL;
2012  }
2013  LibmeshPetscCall(
2014  MatDuplicate(_amc_pressure_force_mat, MAT_COPY_VALUES, &mat_array[Q * field_num + 1]));
2015  LibmeshPetscCall(MatAssemblyBegin(mat_array[Q * field_num + 1], MAT_FINAL_ASSEMBLY));
2016  LibmeshPetscCall(MatAssemblyEnd(mat_array[Q * field_num + 1], MAT_FINAL_ASSEMBLY));
2017  mat_array[Q * field_num + 2] = NULL;
2019  {
2020  mat_array[Q * field_num + 3] = NULL;
2021  }
2022  LibmeshPetscCall(VecDuplicate(_amc_pressure_force_rhs, &vec_array[field_num]));
2023  LibmeshPetscCall(VecCopy(_amc_pressure_force_rhs, vec_array[field_num]));
2024  if (_pressure_axial_momentum_tight_coupling)
2025  {
2026  LibmeshPetscCall(VecAXPY(vec_array[field_num], 1.0, _amc_sys_mdot_rhs));
2027  }
2028  else
2029  {
2030  unsigned int last_node = (iblock + 1) * _block_size;
2031  unsigned int first_node = iblock * _block_size + 1;
2032  LibmeshPetscCall(populateVectorFromHandle<SolutionHandle>(
2033  _prod, *_mdot_soln, first_node, last_node, _n_channels));
2034  Vec ls;
2035  LibmeshPetscCall(VecDuplicate(_amc_sys_mdot_rhs, &ls));
2036  LibmeshPetscCall(MatMult(_amc_sys_mdot_mat, _prod, ls));
2037  LibmeshPetscCall(VecAXPY(ls, -1.0, _amc_sys_mdot_rhs));
2038  LibmeshPetscCall(VecAXPY(vec_array[field_num], -1.0, ls));
2039  LibmeshPetscCall(VecDestroy(&ls));
2040  }
2041 
2042  if (_verbose_subchannel)
2043  _console << "Lin mom OK." << std::endl;
2044 
2045  // Cross momentum conservation
2046  field_num = 2;
2047  mat_array[Q * field_num + 0] = NULL;
2048  if (_pressure_cross_momentum_tight_coupling)
2049  {
2050  LibmeshPetscCall(
2051  MatDuplicate(_cmc_pressure_force_mat, MAT_COPY_VALUES, &mat_array[Q * field_num + 1]));
2052  LibmeshPetscCall(MatAssemblyBegin(mat_array[Q * field_num + 1], MAT_FINAL_ASSEMBLY));
2053  LibmeshPetscCall(MatAssemblyEnd(mat_array[Q * field_num + 1], MAT_FINAL_ASSEMBLY));
2054  }
2055  else
2056  {
2057  mat_array[Q * field_num + 1] = NULL;
2058  }
2059 
2060  LibmeshPetscCall(MatDuplicate(_cmc_sys_Wij_mat, MAT_COPY_VALUES, &mat_array[Q * field_num + 2]));
2061  LibmeshPetscCall(MatAssemblyBegin(mat_array[Q * field_num + 2], MAT_FINAL_ASSEMBLY));
2062  LibmeshPetscCall(MatAssemblyEnd(mat_array[Q * field_num + 2], MAT_FINAL_ASSEMBLY));
2064  {
2065  mat_array[Q * field_num + 3] = NULL;
2066  }
2067 
2068  LibmeshPetscCall(VecDuplicate(_cmc_sys_Wij_rhs, &vec_array[field_num]));
2069  LibmeshPetscCall(VecCopy(_cmc_sys_Wij_rhs, vec_array[field_num]));
2070  if (_pressure_cross_momentum_tight_coupling)
2071  {
2072  LibmeshPetscCall(VecAXPY(vec_array[field_num], 1.0, _cmc_pressure_force_rhs));
2073  }
2074  else
2075  {
2076  Vec sol_holder_P;
2077  LibmeshPetscCall(createPetscVector(sol_holder_P, _block_size * _n_gaps));
2078  LibmeshPetscCall(populateVectorFromHandle<SolutionHandle>(
2079  _prodp, *_P_soln, iblock * _block_size, (iblock + 1) * _block_size - 1, _n_channels));
2080 
2081  LibmeshPetscCall(MatMult(_cmc_pressure_force_mat, _prodp, sol_holder_P));
2082  LibmeshPetscCall(VecAXPY(sol_holder_P, -1.0, _cmc_pressure_force_rhs));
2083  LibmeshPetscCall(VecScale(sol_holder_P, 1.0));
2084  LibmeshPetscCall(VecAXPY(vec_array[field_num], 1.0, sol_holder_P));
2085  LibmeshPetscCall(VecDestroy(&sol_holder_P));
2086  }
2087 
2088  if (_verbose_subchannel)
2089  _console << "Cross mom ok." << std::endl;
2090 
2091  // Energy conservation
2093  {
2094  field_num = 3;
2095  mat_array[Q * field_num + 0] = NULL;
2096  mat_array[Q * field_num + 1] = NULL;
2097  mat_array[Q * field_num + 2] = NULL;
2098  LibmeshPetscCall(MatDuplicate(_hc_sys_h_mat, MAT_COPY_VALUES, &mat_array[Q * field_num + 3]));
2099  if (lag_block_thermal_solve)
2100  {
2101  LibmeshPetscCall(MatZeroEntries(mat_array[Q * field_num + 3]));
2102  LibmeshPetscCall(MatShift(mat_array[Q * field_num + 3], 1.0));
2103  }
2104  LibmeshPetscCall(MatAssemblyBegin(mat_array[Q * field_num + 3], MAT_FINAL_ASSEMBLY));
2105  LibmeshPetscCall(MatAssemblyEnd(mat_array[Q * field_num + 3], MAT_FINAL_ASSEMBLY));
2106  LibmeshPetscCall(VecDuplicate(_hc_sys_h_rhs, &vec_array[field_num]));
2107  LibmeshPetscCall(VecCopy(_hc_sys_h_rhs, vec_array[field_num]));
2108  if (lag_block_thermal_solve)
2109  {
2110  LibmeshPetscCall(VecZeroEntries(vec_array[field_num]));
2111  LibmeshPetscCall(VecShift(vec_array[field_num], 1.0));
2112  }
2113 
2114  if (_verbose_subchannel)
2115  _console << "Energy ok." << std::endl;
2116  }
2117 
2118  // Relaxing linear system
2119  // Weaker relaxation
2120  if (true)
2121  {
2122  // Estimating cross-flow resistances to achieve realizable solves
2123  LibmeshPetscCall(populateVectorFromHandle<SolutionHandle>(
2124  _prod, *_mdot_soln, first_node, last_node, _n_channels));
2125  Vec mdot_estimate;
2126  LibmeshPetscCall(createPetscVector(mdot_estimate, _block_size * _n_channels));
2127  Vec pmat_diag;
2128  LibmeshPetscCall(createPetscVector(pmat_diag, _block_size * _n_channels));
2129  Vec p_estimate;
2130  LibmeshPetscCall(createPetscVector(p_estimate, _block_size * _n_channels));
2131  Vec unity_vec;
2132  LibmeshPetscCall(createPetscVector(unity_vec, _block_size * _n_channels));
2133  LibmeshPetscCall(VecSet(unity_vec, 1.0));
2134  Vec sol_holder_P;
2135  LibmeshPetscCall(createPetscVector(sol_holder_P, _block_size * _n_gaps));
2136  Vec diag_Wij_loc;
2137  LibmeshPetscCall(createPetscVector(diag_Wij_loc, _block_size * _n_gaps));
2138  Vec Wij_estimate;
2139  LibmeshPetscCall(createPetscVector(Wij_estimate, _block_size * _n_gaps));
2140  Vec unity_vec_Wij;
2141  LibmeshPetscCall(createPetscVector(unity_vec_Wij, _block_size * _n_gaps));
2142  LibmeshPetscCall(VecSet(unity_vec_Wij, 1.0));
2143  Vec _Wij_loc_vec;
2144  LibmeshPetscCall(createPetscVector(_Wij_loc_vec, _block_size * _n_gaps));
2145  Vec _Wij_old_loc_vec;
2146  LibmeshPetscCall(createPetscVector(_Wij_old_loc_vec, _block_size * _n_gaps));
2147  LibmeshPetscCall(MatMult(mat_array[Q], _prod, mdot_estimate));
2148  LibmeshPetscCall(MatGetDiagonal(mat_array[Q + 1], pmat_diag));
2149  LibmeshPetscCall(VecAXPY(pmat_diag, 1e-10, unity_vec));
2150  LibmeshPetscCall(VecPointwiseDivide(p_estimate, mdot_estimate, pmat_diag));
2151  LibmeshPetscCall(MatMult(mat_array[2 * Q + 1], p_estimate, sol_holder_P));
2152  LibmeshPetscCall(VecAXPY(sol_holder_P, -1.0, _cmc_pressure_force_rhs));
2153  LibmeshPetscCall(MatGetDiagonal(mat_array[2 * Q + 2], diag_Wij_loc));
2154  LibmeshPetscCall(VecAXPY(diag_Wij_loc, 1e-10, unity_vec_Wij));
2155  LibmeshPetscCall(VecPointwiseDivide(Wij_estimate, sol_holder_P, diag_Wij_loc));
2156  Vec sumWij_loc;
2157  LibmeshPetscCall(createPetscVector(sumWij_loc, _block_size * _n_channels));
2158  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
2159  {
2160  auto iz_ind = iz - first_node;
2161  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
2162  {
2163  PetscScalar sumWij = 0.0;
2164  unsigned int counter = 0;
2165  for (auto i_gap : _subchannel_mesh.getChannelGaps(i_ch))
2166  {
2167  auto chans = _subchannel_mesh.getGapChannels(i_gap);
2168  unsigned int i_ch_loc = chans.first;
2169  PetscInt row_vec = i_ch_loc + _n_channels * iz_ind;
2170  PetscScalar loc_Wij_value;
2171  LibmeshPetscCall(VecGetValues(sol_holder_P, 1, &row_vec, &loc_Wij_value));
2172  sumWij += _subchannel_mesh.getCrossflowSign(i_ch, counter) * loc_Wij_value;
2173  counter++;
2174  }
2175  PetscInt row_vec = i_ch + _n_channels * iz_ind;
2176  LibmeshPetscCall(VecSetValues(sumWij_loc, 1, &row_vec, &sumWij, INSERT_VALUES));
2177  }
2178  }
2179 
2180  PetscScalar min_mdot;
2181  LibmeshPetscCall(VecAbs(_prod));
2182  LibmeshPetscCall(VecMin(_prod, NULL, &min_mdot));
2183  if (_verbose_subchannel)
2184  _console << "Minimum estimated mdot: " << min_mdot << std::endl;
2185 
2186  LibmeshPetscCall(VecAbs(sumWij_loc));
2187  LibmeshPetscCall(VecMax(sumWij_loc, NULL, &_max_sumWij));
2188  _max_sumWij = std::max(1e-10, _max_sumWij);
2189  if (_verbose_subchannel)
2190  _console << "Maximum estimated Wij: " << _max_sumWij << std::endl;
2191 
2193  _Wij_loc_vec, _Wij, first_node, last_node, _n_gaps));
2194  LibmeshPetscCall(VecAbs(_Wij_loc_vec));
2196  _Wij_old_loc_vec, _Wij_old, first_node, last_node, _n_gaps));
2197  LibmeshPetscCall(VecAbs(_Wij_old_loc_vec));
2198  LibmeshPetscCall(VecAXPY(_Wij_loc_vec, -1.0, _Wij_old_loc_vec));
2199  PetscScalar relax_factor;
2200  LibmeshPetscCall(VecAbs(_Wij_loc_vec));
2201 #if !PETSC_VERSION_LESS_THAN(3, 16, 0)
2202  LibmeshPetscCall(VecMean(_Wij_loc_vec, &relax_factor));
2203 #else
2204  VecSum(_Wij_loc_vec, &relax_factor);
2205  relax_factor /= _block_size * _n_gaps;
2206 #endif
2207  relax_factor = relax_factor / _max_sumWij + 0.5;
2208  if (_verbose_subchannel)
2209  _console << "Relax base value: " << relax_factor << std::endl;
2210 
2211  PetscScalar resistance_relaxation = 0.9;
2212  _added_K = _max_sumWij / min_mdot;
2213  if (_verbose_subchannel)
2214  _console << "New cross resistance: " << _added_K << std::endl;
2215  _added_K = (_added_K * resistance_relaxation + (1.0 - resistance_relaxation) * _added_K_old) *
2216  relax_factor;
2217  if (_verbose_subchannel)
2218  _console << "Relaxed cross resistance: " << _added_K << std::endl;
2219  if (_added_K < 10 && _added_K >= 1.0)
2220  _added_K = 1.0; //(1.0 - resistance_relaxation);
2221  if (_added_K < 1.0 && _added_K >= 0.1)
2222  _added_K = 0.5;
2223  if (_added_K < 0.1 && _added_K >= 0.01)
2224  _added_K = 1. / 3.;
2225  if (_added_K < 1e-2 && _added_K >= 1e-3)
2226  _added_K = 0.1;
2227  if (_added_K < 1e-3)
2228  _added_K = 1.0 * _added_K;
2229  if (_verbose_subchannel)
2230  _console << "Actual added cross resistance: " << _added_K << std::endl;
2231  LibmeshPetscCall(VecScale(unity_vec_Wij, _added_K));
2233 
2234  // Adding cross resistances
2235  LibmeshPetscCall(MatDiagonalSet(mat_array[2 * Q + 2], unity_vec_Wij, ADD_VALUES));
2236  LibmeshPetscCall(VecDestroy(&mdot_estimate));
2237  LibmeshPetscCall(VecDestroy(&pmat_diag));
2238  LibmeshPetscCall(VecDestroy(&unity_vec));
2239  LibmeshPetscCall(VecDestroy(&p_estimate));
2240  LibmeshPetscCall(VecDestroy(&sol_holder_P));
2241  LibmeshPetscCall(VecDestroy(&diag_Wij_loc));
2242  LibmeshPetscCall(VecDestroy(&unity_vec_Wij));
2243  LibmeshPetscCall(VecDestroy(&Wij_estimate));
2244  LibmeshPetscCall(VecDestroy(&sumWij_loc));
2245  LibmeshPetscCall(VecDestroy(&_Wij_loc_vec));
2246  LibmeshPetscCall(VecDestroy(&_Wij_old_loc_vec));
2247 
2248  // Auto-computing relaxation factors
2249  PetscScalar relaxation_factor_mdot, relaxation_factor_P, relaxation_factor_Wij;
2250  relaxation_factor_mdot = 1.0;
2251  relaxation_factor_P = 1.0; // std::exp(-5.0);
2252  relaxation_factor_Wij = 0.1;
2253 
2254  if (_verbose_subchannel)
2255  {
2256  _console << "Relax mdot: " << relaxation_factor_mdot << std::endl;
2257  _console << "Relax P: " << relaxation_factor_P << std::endl;
2258  _console << "Relax Wij: " << relaxation_factor_Wij << std::endl;
2259  }
2260 
2261  PetscInt field_num = 0;
2262  Vec diag_mdot;
2263  LibmeshPetscCall(VecDuplicate(vec_array[field_num], &diag_mdot));
2264  LibmeshPetscCall(MatGetDiagonal(mat_array[Q * field_num + field_num], diag_mdot));
2265  LibmeshPetscCall(VecScale(diag_mdot, 1.0 / relaxation_factor_mdot));
2266  LibmeshPetscCall(
2267  MatDiagonalSet(mat_array[Q * field_num + field_num], diag_mdot, INSERT_VALUES));
2268  LibmeshPetscCall(populateVectorFromHandle<SolutionHandle>(
2269  _prod, *_mdot_soln, first_node, last_node, _n_channels));
2270  LibmeshPetscCall(VecScale(diag_mdot, (1.0 - relaxation_factor_mdot)));
2271  LibmeshPetscCall(VecPointwiseMult(_prod, _prod, diag_mdot));
2272  LibmeshPetscCall(VecAXPY(vec_array[field_num], 1.0, _prod));
2273  LibmeshPetscCall(VecDestroy(&diag_mdot));
2274 
2275  if (_verbose_subchannel)
2276  _console << "mdot relaxed" << std::endl;
2277 
2278  field_num = 1;
2279  Vec diag_P;
2280  LibmeshPetscCall(VecDuplicate(vec_array[field_num], &diag_P));
2281  LibmeshPetscCall(MatGetDiagonal(mat_array[Q * field_num + field_num], diag_P));
2282  LibmeshPetscCall(VecScale(diag_P, 1.0 / relaxation_factor_P));
2283  LibmeshPetscCall(MatDiagonalSet(mat_array[Q * field_num + field_num], diag_P, INSERT_VALUES));
2284  if (_verbose_subchannel)
2285  _console << "Mat assembled" << std::endl;
2286  LibmeshPetscCall(populateVectorFromHandle<SolutionHandle>(
2287  _prod, *_P_soln, first_node, last_node, _n_channels));
2288  LibmeshPetscCall(VecScale(diag_P, (1.0 - relaxation_factor_P)));
2289  LibmeshPetscCall(VecPointwiseMult(_prod, _prod, diag_P));
2290  LibmeshPetscCall(VecAXPY(vec_array[field_num], 1.0, _prod));
2291  LibmeshPetscCall(VecDestroy(&diag_P));
2292 
2293  if (_verbose_subchannel)
2294  _console << "P relaxed" << std::endl;
2295 
2296  field_num = 2;
2297  Vec diag_Wij;
2298  LibmeshPetscCall(VecDuplicate(vec_array[field_num], &diag_Wij));
2299  LibmeshPetscCall(MatGetDiagonal(mat_array[Q * field_num + field_num], diag_Wij));
2300  LibmeshPetscCall(VecScale(diag_Wij, 1.0 / relaxation_factor_Wij));
2301  LibmeshPetscCall(MatDiagonalSet(mat_array[Q * field_num + field_num], diag_Wij, INSERT_VALUES));
2303  _Wij_vec, _Wij, first_node, last_node, _n_gaps));
2304  LibmeshPetscCall(VecScale(diag_Wij, (1.0 - relaxation_factor_Wij)));
2305  LibmeshPetscCall(VecPointwiseMult(_Wij_vec, _Wij_vec, diag_Wij));
2306  LibmeshPetscCall(VecAXPY(vec_array[field_num], 1.0, _Wij_vec));
2307  LibmeshPetscCall(VecDestroy(&diag_Wij));
2308 
2309  if (_verbose_subchannel)
2310  _console << "Wij relaxed" << std::endl;
2311  }
2312  if (_verbose_subchannel)
2313  _console << "Linear solver relaxed." << std::endl;
2314 
2315  // Creating nested matrices
2316  LibmeshPetscCall(MatCreateNest(PETSC_COMM_WORLD, Q, NULL, Q, NULL, mat_array.data(), &A_nest));
2317  LibmeshPetscCall(VecCreateNest(PETSC_COMM_WORLD, Q, NULL, vec_array.data(), &b_nest));
2318  if (_verbose_subchannel)
2319  _console << "Nested system created." << std::endl;
2320 
2322  // Creating linear solver
2323  LibmeshPetscCall(KSPCreate(PETSC_COMM_WORLD, &ksp));
2324  LibmeshPetscCall(KSPSetType(ksp, KSPFGMRES));
2325  // Setting KSP operators
2326  LibmeshPetscCall(KSPSetOperators(ksp, A_nest, A_nest));
2327  // Set KSP and PC options
2328  LibmeshPetscCall(KSPGetPC(ksp, &pc));
2329  LibmeshPetscCall(PCSetType(pc, PCFIELDSPLIT));
2330  LibmeshPetscCall(KSPSetTolerances(ksp, _rtol, _atol, _dtol, _maxit));
2331  // Splitting fields
2332  std::vector<IS> rows(Q);
2333  // IS rows[Q];
2334  PetscInt M = 0;
2335  LibmeshPetscCall(MatNestGetISs(A_nest, rows.data(), NULL));
2336  for (PetscInt j = 0; j < Q; ++j)
2337  {
2338  IS expand1;
2339  LibmeshPetscCall(ISDuplicate(rows[M], &expand1));
2340  M += 1;
2341  LibmeshPetscCall(PCFieldSplitSetIS(pc, NULL, expand1));
2342  LibmeshPetscCall(ISDestroy(&expand1));
2343  }
2344  if (_verbose_subchannel)
2345  _console << "Linear solver assembled." << std::endl;
2346 
2348  LibmeshPetscCall(VecDuplicate(b_nest, &x_nest));
2349  LibmeshPetscCall(VecSet(x_nest, 0.0));
2350  LibmeshPetscCall(KSPSolve(ksp, b_nest, x_nest));
2351 
2353  LibmeshPetscCall(VecDestroy(&b_nest));
2354  LibmeshPetscCall(MatDestroy(&A_nest));
2355  LibmeshPetscCall(KSPDestroy(&ksp));
2356  for (PetscInt i = 0; i < Q * Q; i++)
2357  {
2358  LibmeshPetscCall(MatDestroy(&mat_array[i]));
2359  }
2360  for (PetscInt i = 0; i < Q; i++)
2361  {
2362  LibmeshPetscCall(VecDestroy(&vec_array[i]));
2363  }
2364  if (_verbose_subchannel)
2365  _console << "Solver elements destroyed." << std::endl;
2366 
2368  Vec sol_mdot, sol_p, sol_Wij;
2369  if (_verbose_subchannel)
2370  _console << "Vectors created." << std::endl;
2371  PetscInt num_vecs;
2372  Vec * loc_vecs;
2373  LibmeshPetscCall(VecNestGetSubVecs(x_nest, &num_vecs, &loc_vecs));
2374  if (_verbose_subchannel)
2375  _console << "Starting extraction." << std::endl;
2376  LibmeshPetscCall(VecDuplicate(_mc_axial_convection_rhs, &sol_mdot));
2377  LibmeshPetscCall(VecCopy(loc_vecs[0], sol_mdot));
2378  LibmeshPetscCall(VecDuplicate(_amc_sys_mdot_rhs, &sol_p));
2379  LibmeshPetscCall(VecCopy(loc_vecs[1], sol_p));
2380  LibmeshPetscCall(VecDuplicate(_cmc_sys_Wij_rhs, &sol_Wij));
2381  LibmeshPetscCall(VecCopy(loc_vecs[2], sol_Wij));
2382  if (_verbose_subchannel)
2383  _console << "Getting individual field solutions from coupled solver." << std::endl;
2384 
2386  PetscScalar * sol_p_array;
2387  LibmeshPetscCall(VecGetArray(sol_p, &sol_p_array));
2388  PetscScalar * sol_Wij_array;
2389  LibmeshPetscCall(VecGetArray(sol_Wij, &sol_Wij_array));
2390 
2392  LibmeshPetscCall(populateSolutionChan<SolutionHandle>(
2393  sol_mdot, *_mdot_soln, first_node, last_node, _n_channels));
2394 
2396  for (unsigned int iz = last_node; iz > first_node - 1; iz--)
2397  {
2398  auto iz_ind = iz - first_node;
2399  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
2400  {
2401  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
2402  PetscScalar value = sol_p_array[iz_ind * _n_channels + i_ch];
2403  _P_soln->set(node_in, value);
2404  }
2405  }
2406 
2409  sol_Wij, _Wij, first_node, last_node - 1, _n_gaps));
2410 
2413  {
2414  if (lag_block_thermal_solve)
2415  {
2416  KSP ksploc;
2417  PC pc;
2418  Vec sol;
2419  LibmeshPetscCall(VecDuplicate(_hc_sys_h_rhs, &sol));
2420  LibmeshPetscCall(KSPCreate(PETSC_COMM_WORLD, &ksploc));
2421  LibmeshPetscCall(KSPSetOperators(ksploc, _hc_sys_h_mat, _hc_sys_h_mat));
2422  LibmeshPetscCall(KSPGetPC(ksploc, &pc));
2423  LibmeshPetscCall(PCSetType(pc, PCJACOBI));
2424  LibmeshPetscCall(KSPSetTolerances(ksploc, _rtol, _atol, _dtol, _maxit));
2425  LibmeshPetscCall(KSPSetFromOptions(ksploc));
2426  LibmeshPetscCall(KSPSolve(ksploc, _hc_sys_h_rhs, sol));
2427  PetscScalar * xx;
2428  LibmeshPetscCall(VecGetArray(sol, &xx));
2429  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
2430  {
2431  auto iz_ind = iz - first_node;
2432  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
2433  {
2434  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
2435  auto h_out = xx[iz_ind * _n_channels + i_ch];
2436  if (h_out < 0)
2437  {
2438  mooseError(name(),
2439  " : Calculation of negative Enthalpy h_out = : ",
2440  h_out,
2441  " Axial Level= : ",
2442  iz);
2443  }
2444  _h_soln->set(node_out, h_out);
2445  }
2446  }
2447  LibmeshPetscCall(KSPDestroy(&ksploc));
2448  LibmeshPetscCall(VecDestroy(&sol));
2449  }
2450  else
2451  {
2452  Vec sol_h;
2453  LibmeshPetscCall(VecDuplicate(_hc_sys_h_rhs, &sol_h));
2454  LibmeshPetscCall(VecCopy(loc_vecs[3], sol_h));
2455  PetscScalar * sol_h_array;
2456  LibmeshPetscCall(VecGetArray(sol_h, &sol_h_array));
2457  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
2458  {
2459  auto iz_ind = iz - first_node;
2460  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
2461  {
2462  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
2463  auto h_out = sol_h_array[iz_ind * _n_channels + i_ch];
2464  if (h_out < 0)
2465  {
2466  mooseError(name(),
2467  " : Calculation of negative Enthalpy h_out = : ",
2468  h_out,
2469  " Axial Level= : ",
2470  iz);
2471  }
2472  _h_soln->set(node_out, h_out);
2473  }
2474  }
2475  LibmeshPetscCall(VecDestroy(&sol_h));
2476  }
2477  }
2478 
2480  LibmeshPetscCall(MatMult(_mc_sumWij_mat, sol_Wij, _prod));
2481  LibmeshPetscCall(populateSolutionChan<SolutionHandle>(
2482  _prod, *_SumWij_soln, first_node, last_node, _n_channels));
2483 
2484  Vec sumWij_loc;
2485  LibmeshPetscCall(createPetscVector(sumWij_loc, _block_size * _n_channels));
2486  LibmeshPetscCall(populateVectorFromHandle<SolutionHandle>(
2487  _prod, *_SumWij_soln, first_node, last_node, _n_channels));
2488 
2489  LibmeshPetscCall(VecAbs(_prod));
2490  LibmeshPetscCall(VecMax(_prod, NULL, &_max_sumWij_new));
2491  if (_verbose_subchannel)
2492  _console << "Maximum estimated Wij new: " << _max_sumWij_new << std::endl;
2494  if (_verbose_subchannel)
2495  _console << "Correction factor: " << _correction_factor << std::endl;
2496  if (_verbose_subchannel)
2497  _console << "Solutions assigned to MOOSE variables." << std::endl;
2498 
2500  LibmeshPetscCall(VecDestroy(&x_nest));
2501  LibmeshPetscCall(VecDestroy(&sol_mdot));
2502  LibmeshPetscCall(VecDestroy(&sol_p));
2503  LibmeshPetscCall(VecDestroy(&sol_Wij));
2504  LibmeshPetscCall(VecDestroy(&sumWij_loc));
2505  if (_verbose_subchannel)
2506  _console << "Solutions destroyed." << std::endl;
2507 
2508  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
2509 }
Mat _amc_sys_mdot_mat
Axial momentum system matrix.
void computeSumWij(int iblock)
Computes net diversion crossflow per channel for block iblock.
std::unique_ptr< SolutionHandle > _h_soln
const PetscReal & _dtol
The divergence tolerance for the ksp linear solver.
const bool _monolithic_thermal_bool
Thermal monolithic bool.
void computeP(int iblock)
Computes Pressure per channel for block iblock.
libMesh::DenseMatrix< Real > _Wij_old
void computeMdot(int iblock)
Computes mass flow per channel for block iblock.
PetscScalar _added_K
Added resistances for monolithic convergence.
PetscErrorCode createPetscVector(Vec &v, PetscInt n)
Petsc Functions.
PetscFunctionBegin
Mat _cmc_sys_Wij_mat
Lateral momentum system matrix.
virtual const std::string & name() const
virtual const std::vector< unsigned int > & getChannelGaps(unsigned int i_chan) const =0
Return a vector of gap indices for a given channel index.
Mat _mc_sumWij_mat
Matrices and vectors to be used in implicit assembly Mass conservation Mass conservation - sum of cro...
PetscErrorCode populateVectorFromDense(Vec &x, const T &solution, const unsigned int first_axial_level, const unsigned int last_axial_level, const unsigned int cross_dimension)
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
virtual void computeh(int iblock)=0
Computes Enthalpy per channel for block iblock.
Mat _amc_pressure_force_mat
Axial momentum conservation - pressure force.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
void computeWijResidual(int iblock)
Computes Residual Matrix based on the lateral momentum conservation equation for block iblock...
const PetscReal & _atol
The absolute convergence tolerance for the ksp linear solver.
Mat _mc_axial_convection_mat
Mass conservation - axial convection.
const PetscInt & _maxit
The maximum number of iterations to use for the ksp linear solver.
std::unique_ptr< SolutionHandle > _mdot_soln
PetscErrorCode populateDenseFromVector(const Vec &x, T &solution, const unsigned int first_axial_level, const unsigned int last_axial_level, const unsigned int cross_dimension)
const PetscReal & _rtol
The relative convergence tolerance, (relative decrease) for the ksp linear solver.
libMesh::DenseMatrix< Real > & _Wij
void computeWijPrime(int iblock)
Computes turbulent crossflow per gap for block iblock.
virtual const Real & getCrossflowSign(unsigned int i_chan, unsigned int i_local) const =0
Return a sign for the crossflow given a subchannel index and local neighbor index.
std::unique_ptr< SolutionHandle > _SumWij_soln
const bool _verbose_subchannel
Boolean to printout information related to subchannel solve.
void mooseError(Args &&... args) const
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const ConsoleStream _console
void computeDP(int iblock)
Computes Pressure Drop per channel for block iblock.
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)
Mat _cmc_pressure_force_mat
Cross momentum conservation - pressure force.
std::unique_ptr< SolutionHandle > _P_soln
Mat _hc_sys_h_mat
System matrices.
virtual const std::pair< unsigned int, unsigned int > & getGapChannels(unsigned int i_gap) const =0
Return a pair of subchannel indices for a given gap index.

◆ initializeSolution()

void QuadSubChannel1PhaseProblem::initializeSolution ( )
overrideprotectedvirtual

Function to initialize the solution & geometry fields.

update surface area, wetted perimeter based on: Dpin, displacement

Calculate subchannel area

Correct subchannel area and wetted perimeter in case of overlapping pins

Apply area reduction on subchannels affected by blockage

update map of gap between pins (gij) based on: Dpin, displacement

Implements SubChannel1PhaseProblem.

Definition at line 46 of file QuadSubChannel1PhaseProblem.C.

47 {
49  if (_deformation)
50  {
51  Real standard_area, additional_area, wetted_perimeter, displaced_area;
53  auto gap = _subchannel_mesh.getGap();
54  auto z_blockage = _subchannel_mesh.getZBlockage();
55  auto index_blockage = _subchannel_mesh.getIndexBlockage();
56  auto reduction_blockage = _subchannel_mesh.getReductionBlockage();
57  for (unsigned int iz = 0; iz < _n_cells + 1; iz++)
58  {
59  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
60  {
61  auto * node = _subchannel_mesh.getChannelNode(i_ch, iz);
62  auto subch_type = _subchannel_mesh.getSubchannelType(i_ch);
63  auto Z = _z_grid[iz];
64  Real rod_area = 0.0;
65  Real rod_perimeter = 0.0;
66  for (auto i_pin : _subchannel_mesh.getChannelPins(i_ch))
67  {
68  auto * pin_node = _subchannel_mesh.getPinNode(i_pin, iz);
69  rod_area += 0.25 * 0.25 * M_PI * (*_Dpin_soln)(pin_node) * (*_Dpin_soln)(pin_node);
70  rod_perimeter += 0.25 * M_PI * (*_Dpin_soln)(pin_node);
71  }
72 
73  if (subch_type == EChannelType::CORNER)
74  {
75  standard_area = 0.25 * pitch * pitch;
76  displaced_area = (2 * gap + pitch) * (*_displacement_soln)(node) / sqrt(2) +
77  (*_displacement_soln)(node) * (*_displacement_soln)(node) / 2;
78  additional_area = pitch * gap + gap * gap;
79  wetted_perimeter =
80  rod_perimeter + pitch + 2 * gap + 2 * (*_displacement_soln)(node) / sqrt(2);
81  }
82  else if (subch_type == EChannelType::EDGE)
83  {
84  standard_area = 0.5 * pitch * pitch;
85  additional_area = pitch * gap;
86  displaced_area = pitch * (*_displacement_soln)(node);
87  wetted_perimeter = rod_perimeter + pitch;
88  }
89  else
90  {
91  standard_area = pitch * pitch;
92  displaced_area = 0.0;
93  additional_area = 0.0;
94  wetted_perimeter = rod_perimeter;
95  }
96 
98  auto subchannel_area = displaced_area + standard_area + additional_area - rod_area;
99 
101  auto overlapping_pin_area = 0.0;
102  auto overlapping_wetted_perimeter = 0.0;
103  for (auto i_gap : _subchannel_mesh.getChannelGaps(i_ch))
104  {
105  auto gap_pins = _subchannel_mesh.getGapPins(i_gap);
106  auto pin_1 = gap_pins.first;
107  auto pin_2 = gap_pins.second;
108  auto * pin_node_1 = _subchannel_mesh.getPinNode(pin_1, iz);
109  auto * pin_node_2 = _subchannel_mesh.getPinNode(pin_2, iz);
110  auto Diameter1 = (*_Dpin_soln)(pin_node_1);
111  auto Radius1 = Diameter1 / 2.0;
112  auto Diameter2 = (*_Dpin_soln)(pin_node_2);
113  auto Radius2 = Diameter2 / 2.0;
115 
116  if (pitch < (Radius1 + Radius2)) // overlapping pins
117  {
118  mooseWarning(" The gap of index : '", i_gap, " at axial cell ", iz, " ' is blocked.");
119  auto cos1 =
120  (pitch * pitch + Radius1 * Radius1 - Radius2 * Radius2) / (2 * pitch * Radius1);
121  auto cos2 =
122  (pitch * pitch + Radius2 * Radius2 - Radius1 * Radius1) / (2 * pitch * Radius2);
123  auto angle1 = 2.0 * acos(cos1);
124  auto angle2 = 2.0 * acos(cos2);
125  // half of the intersecting arc-length
126  overlapping_wetted_perimeter += 0.5 * angle1 * Radius1 + 0.5 * angle2 * Radius2;
127  // Half of the overlapping area
128  overlapping_pin_area +=
129  0.5 * Radius1 * Radius1 * acos(cos1) + 0.5 * Radius2 * Radius2 * acos(cos2) -
130  0.25 * sqrt((-pitch + Radius1 + Radius2) * (pitch + Radius1 - Radius2) *
131  (pitch - Radius1 + Radius2) * (pitch + Radius1 + Radius2));
132  }
133  }
134  subchannel_area += overlapping_pin_area; // correct surface area
135  wetted_perimeter += -overlapping_wetted_perimeter; // correct wetted perimeter
136 
138  auto index = 0;
139  for (const auto & i_blockage : index_blockage)
140  {
141  if (i_ch == i_blockage && (Z >= z_blockage.front() && Z <= z_blockage.back()))
142  {
143  subchannel_area *= reduction_blockage[index];
144  }
145  index++;
146  }
147 
148  _S_flow_soln->set(node, subchannel_area);
149  _w_perim_soln->set(node, wetted_perimeter);
150  }
151  }
153  for (unsigned int iz = 0; iz < _n_cells + 1; iz++)
154  {
155  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
156  {
157  auto gap_pins = _subchannel_mesh.getGapPins(i_gap);
158  auto pin_1 = gap_pins.first;
159  auto pin_2 = gap_pins.second;
160  auto * pin_node_1 = _subchannel_mesh.getPinNode(pin_1, iz);
161  auto * pin_node_2 = _subchannel_mesh.getPinNode(pin_2, iz);
162  if (pin_1 == pin_2) // Corner or edge gap
163  {
164  auto displacement = 0.0;
165  auto counter = 0.0;
166  for (auto i_ch : _subchannel_mesh.getPinChannels(pin_1))
167  {
168  auto subch_type = _subchannel_mesh.getSubchannelType(i_ch);
169  auto * node = _subchannel_mesh.getChannelNode(i_ch, iz);
170  if (subch_type == EChannelType::EDGE || subch_type == EChannelType::CORNER)
171  {
172  displacement += (*_displacement_soln)(node);
173  counter += 1.0;
174  }
175  }
176  displacement = displacement / counter;
177  _subchannel_mesh._gij_map[iz][i_gap] =
178  (pitch - (*_Dpin_soln)(pin_node_1)) / 2.0 + gap + displacement;
179  }
180  else // center gap
181  {
182  _subchannel_mesh._gij_map[iz][i_gap] =
183  pitch - (*_Dpin_soln)(pin_node_1) / 2.0 - (*_Dpin_soln)(pin_node_2) / 2.0;
184  }
185  // if pins come in contact, the gap is zero
186  if (_subchannel_mesh._gij_map[iz][i_gap] <= 0.0)
187  _subchannel_mesh._gij_map[iz][i_gap] = 0.0;
188  }
189  }
190  }
191 
192  for (unsigned int iz = 1; iz < _n_cells + 1; iz++)
193  {
194  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
195  {
196  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
197  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
198  _mdot_soln->set(node_out, (*_mdot_soln)(node_in));
199  }
200  }
201 
202  // We must do a global assembly to make sure data is parallel consistent before we do things
203  // like compute L2 norms
204  _aux->solution().close();
205 }
virtual Node * getPinNode(unsigned int i_pin, unsigned iz) const override
Get the pin mesh node for a given pin index and elevation index.
virtual const std::vector< unsigned int > & getChannelGaps(unsigned int i_chan) const override
Return a vector of gap indices for a given channel index.
std::unique_ptr< SolutionHandle > _S_flow_soln
virtual const std::pair< unsigned int, unsigned int > & getGapPins(unsigned int i_gap) const override
Return a pair of pin indices for a given gap index.
void mooseWarning(Args &&... args) const
const Real & getGap() const
Returns the gap, not to be confused with the gap between pins, this refers to the gap next to the duc...
std::vector< Real > _z_grid
axial location of nodes
static const std::string pitch
std::shared_ptr< AuxiliarySystem > _aux
std::unique_ptr< SolutionHandle > _Dpin_soln
virtual const std::vector< Real > & getReductionBlockage() const
Get area reduction of blocked subchannels.
std::unique_ptr< SolutionHandle > _mdot_soln
virtual const Real & getPitch() const override
Return the pitch between 2 subchannels.
static const std::string Z
Definition: NS.h:169
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::unique_ptr< SolutionHandle > _displacement_soln
virtual const std::vector< Real > & getZBlockage() const
Get axial location of blockage (in,out) [m].
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const override
Get the subchannel mesh node for a given channel index and elevation index.
std::vector< std::vector< Real > > _gij_map
Vector to store gap size.
virtual const std::vector< unsigned int > & getPinChannels(unsigned int i_pin) const override
Return a vector of channel indices for a given Pin index.
virtual const std::vector< unsigned int > & getIndexBlockage() const
Get index of blocked subchannels.
virtual EChannelType getSubchannelType(unsigned int index) const override
Return the type of the subchannel for given subchannel index.
const bool _deformation
Flag that activates the effect of deformation (pin/duct) based on the auxvalues for displacement...
virtual const std::vector< unsigned int > & getChannelPins(unsigned int i_chan) const override
Return a vector of pin indices for a given channel index.
std::unique_ptr< SolutionHandle > _w_perim_soln

◆ initialSetup()

void SubChannel1PhaseProblem::initialSetup ( )
overridevirtualinherited

Reimplemented from ExternalProblem.

Definition at line 241 of file SubChannel1PhaseProblem.C.

242 {
244  _fp = &getUserObject<SinglePhaseFluidProperties>(getParam<UserObjectName>("fp"));
245  _mdot_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::MASS_FLOW_RATE));
246  _SumWij_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::SUM_CROSSFLOW));
247  _P_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::PRESSURE));
248  _DP_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::PRESSURE_DROP));
249  _h_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::ENTHALPY));
250  _T_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::TEMPERATURE));
251  if (_pin_mesh_exist)
252  {
253  _Tpin_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::PIN_TEMPERATURE));
254  _Dpin_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::PIN_DIAMETER));
255  }
256  _rho_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::DENSITY));
257  _mu_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::VISCOSITY));
258  _S_flow_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::SURFACE_AREA));
259  _w_perim_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::WETTED_PERIMETER));
260  _q_prime_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::LINEAR_HEAT_RATE));
262  std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::DISPLACEMENT));
263  if (_duct_mesh_exist)
264  {
266  std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::DUCT_LINEAR_HEAT_RATE));
267  _Tduct_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::DUCT_TEMPERATURE));
268  }
269 }
static const std::string PRESSURE_DROP
pressure drop
Definition: SubChannelApp.h:37
static const std::string MASS_FLOW_RATE
mass flow rate
Definition: SubChannelApp.h:29
const bool _pin_mesh_exist
Flag that informs if there is a pin mesh or not.
std::unique_ptr< SolutionHandle > _Tduct_soln
static const std::string DENSITY
density
Definition: SubChannelApp.h:47
std::unique_ptr< SolutionHandle > _T_soln
std::unique_ptr< SolutionHandle > _h_soln
std::unique_ptr< SolutionHandle > _q_prime_duct_soln
std::unique_ptr< SolutionHandle > _S_flow_soln
static const std::string PIN_DIAMETER
pin diameter
Definition: SubChannelApp.h:45
static const std::string DUCT_LINEAR_HEAT_RATE
duct linear heat rate
Definition: SubChannelApp.h:55
const bool _duct_mesh_exist
Flag that informs if there is a pin mesh or not.
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 override
static const std::string DUCT_TEMPERATURE
duct temperature
Definition: SubChannelApp.h:57
static const std::string WETTED_PERIMETER
wetted perimeter
Definition: SubChannelApp.h:51
std::unique_ptr< SolutionHandle > _rho_soln
static const std::string VISCOSITY
viscosity
Definition: SubChannelApp.h:49
static const std::string PIN_TEMPERATURE
pin temperature
Definition: SubChannelApp.h:43
static const std::string LINEAR_HEAT_RATE
linear heat rate
Definition: SubChannelApp.h:53
std::unique_ptr< SolutionHandle > _q_prime_soln
static const std::string ENTHALPY
enthalpy
Definition: SubChannelApp.h:39
void initialSetup() override
std::unique_ptr< SolutionHandle > _Dpin_soln
std::unique_ptr< SolutionHandle > _mdot_soln
static const std::string SUM_CROSSFLOW
sum of diversion crossflow
Definition: SubChannelApp.h:33
std::unique_ptr< SolutionHandle > _displacement_soln
std::unique_ptr< SolutionHandle > _DP_soln
static const std::string PRESSURE
pressure
Definition: SubChannelApp.h:35
std::unique_ptr< SolutionHandle > _SumWij_soln
static const std::string SURFACE_AREA
surface area
Definition: SubChannelApp.h:31
static const std::string DISPLACEMENT
subchannel displacement
Definition: SubChannelApp.h:59
static const std::string TEMPERATURE
temperature
Definition: SubChannelApp.h:41
std::unique_ptr< SolutionHandle > _P_soln
std::unique_ptr< SolutionHandle > _w_perim_soln
const SinglePhaseFluidProperties * _fp
Solutions handles and link to TH tables properties.
std::unique_ptr< SolutionHandle > _mu_soln
std::unique_ptr< SolutionHandle > _Tpin_soln

◆ petscSnesSolver()

PetscErrorCode SubChannel1PhaseProblem::petscSnesSolver ( int  iblock,
const libMesh::DenseVector< Real > &  solution,
libMesh::DenseVector< Real > &  root 
)
protectedinherited

Computes solution of nonlinear equation using snes and provided a residual in a formFunction.

Definition at line 1857 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::computeWijFromSolve().

1860 {
1861  SNES snes;
1862  KSP ksp;
1863  PC pc;
1864  Vec x, r;
1865  PetscMPIInt size;
1866  PetscScalar * xx;
1867 
1869  PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size));
1870  if (size > 1)
1871  SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_SUP, "Example is only for sequential runs");
1872  LibmeshPetscCall(SNESCreate(PETSC_COMM_WORLD, &snes));
1873  LibmeshPetscCall(VecCreate(PETSC_COMM_WORLD, &x));
1874  LibmeshPetscCall(VecSetSizes(x, PETSC_DECIDE, _block_size * _n_gaps));
1875  LibmeshPetscCall(VecSetFromOptions(x));
1876  LibmeshPetscCall(VecDuplicate(x, &r));
1877 
1878 #if PETSC_VERSION_LESS_THAN(3, 13, 0)
1879  LibmeshPetscCall(PetscOptionsSetValue(PETSC_NULL, "-snes_mf", PETSC_NULL));
1880 #else
1881  LibmeshPetscCall(SNESSetUseMatrixFree(snes, PETSC_FALSE, PETSC_TRUE));
1882 #endif
1883  Ctx ctx;
1884  ctx.iblock = iblock;
1885  ctx.schp = this;
1886  LibmeshPetscCall(SNESSetFunction(snes, r, formFunction, &ctx));
1887  LibmeshPetscCall(SNESGetKSP(snes, &ksp));
1888  LibmeshPetscCall(KSPGetPC(ksp, &pc));
1889  LibmeshPetscCall(PCSetType(pc, PCNONE));
1890  LibmeshPetscCall(KSPSetTolerances(ksp, _rtol, _atol, _dtol, _maxit));
1891  LibmeshPetscCall(SNESSetFromOptions(snes));
1892  LibmeshPetscCall(VecGetArray(x, &xx));
1893  for (unsigned int i = 0; i < _block_size * _n_gaps; i++)
1894  {
1895  xx[i] = solution(i);
1896  }
1897  LibmeshPetscCall(VecRestoreArray(x, &xx));
1898 
1899  LibmeshPetscCall(SNESSolve(snes, NULL, x));
1900  LibmeshPetscCall(VecGetArray(x, &xx));
1901  for (unsigned int i = 0; i < _block_size * _n_gaps; i++)
1902  root(i) = xx[i];
1903 
1904  LibmeshPetscCall(VecRestoreArray(x, &xx));
1905  LibmeshPetscCall(VecDestroy(&x));
1906  LibmeshPetscCall(VecDestroy(&r));
1907  LibmeshPetscCall(SNESDestroy(&snes));
1908  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
1909 }
const PetscReal & _dtol
The divergence tolerance for the ksp linear solver.
PetscFunctionBegin
const std::vector< double > x
const PetscReal & _atol
The absolute convergence tolerance for the ksp linear solver.
Real root(std::function< Real(Real)> const &f, Real x1, Real x2, Real tol=1.0e-12)
Finds the root of a function using Brent&#39;s method.
Definition: BrentsMethod.C:66
const PetscInt & _maxit
The maximum number of iterations to use for the ksp linear solver.
friend PetscErrorCode formFunction(SNES snes, Vec x, Vec f, void *ctx)
This is the residual Vector function in a form compatible with the SNES PETC solvers.
const PetscReal & _rtol
The relative convergence tolerance, (relative decrease) for the ksp linear solver.
void * ctx
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)

◆ populateDenseFromVector()

template<class T >
PetscErrorCode SubChannel1PhaseProblem::populateDenseFromVector ( const Vec &  x,
T &  solution,
const unsigned int  first_axial_level,
const unsigned int  last_axial_level,
const unsigned int  cross_dimension 
)
protectedinherited

Definition at line 322 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::computeWijPrime(), and SubChannel1PhaseProblem::implicitPetscSolve().

327 {
328  PetscScalar * xx;
329 
331  LibmeshPetscCall(VecGetArray(x, &xx));
332  for (unsigned int iz = first_axial_level; iz < last_axial_level + 1; iz++)
333  {
334  unsigned int iz_ind = iz - first_axial_level;
335  for (unsigned int i_l = 0; i_l < cross_dimension; i_l++)
336  {
337  loc_solution(i_l, iz) = xx[iz_ind * cross_dimension + i_l];
338  }
339  }
340  LibmeshPetscCall(VecRestoreArray(x, &xx));
341 
342  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
343 }
PetscFunctionBegin
const std::vector< double > x
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)

◆ populateSolutionChan()

template<class T >
PetscErrorCode SubChannel1PhaseProblem::populateSolutionChan ( const Vec &  x,
T &  solution,
const unsigned int  first_axial_level,
const unsigned int  last_axial_level,
const unsigned int  cross_dimension 
)
protectedinherited

Definition at line 396 of file SubChannel1PhaseProblem.h.

401 {
402  PetscScalar * xx;
404  LibmeshPetscCall(VecGetArray(x, &xx));
405  Node * loc_node;
406  for (unsigned int iz = first_axial_level; iz < last_axial_level + 1; iz++)
407  {
408  unsigned int iz_ind = iz - first_axial_level;
409  for (unsigned int i_l = 0; i_l < cross_dimension; i_l++)
410  {
411  loc_node = _subchannel_mesh.getChannelNode(i_l, iz);
412  loc_solution.set(loc_node, xx[iz_ind * cross_dimension + i_l]);
413  }
414  }
415  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
416 }
PetscFunctionBegin
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
const std::vector< double > x
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)

◆ populateSolutionGap()

template<class T >
PetscErrorCode SubChannel1PhaseProblem::populateSolutionGap ( const Vec &  x,
T &  solution,
const unsigned int  first_axial_level,
const unsigned int  last_axial_level,
const unsigned int  cross_dimension 
)
protectedinherited

Definition at line 420 of file SubChannel1PhaseProblem.h.

425 {
426  PetscScalar * xx;
428  LibmeshPetscCall(VecGetArray(x, &xx));
429  for (unsigned int iz = first_axial_level; iz < last_axial_level + 1; iz++)
430  {
431  unsigned int iz_ind = iz - first_axial_level;
432  for (unsigned int i_l = 0; i_l < cross_dimension; i_l++)
433  {
434  loc_solution(iz * cross_dimension + i_l) = xx[iz_ind * cross_dimension + i_l];
435  }
436  }
437  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
438 }
PetscFunctionBegin
const std::vector< double > x
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)

◆ populateVectorFromDense()

template<class T >
PetscErrorCode SubChannel1PhaseProblem::populateVectorFromDense ( Vec &  x,
const T &  solution,
const unsigned int  first_axial_level,
const unsigned int  last_axial_level,
const unsigned int  cross_dimension 
)
protectedinherited

Definition at line 373 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::computeSumWij(), and SubChannel1PhaseProblem::implicitPetscSolve().

378 {
379  PetscScalar * xx;
381  LibmeshPetscCall(VecGetArray(x, &xx));
382  for (unsigned int iz = first_axial_level; iz < last_axial_level; iz++)
383  {
384  unsigned int iz_ind = iz - first_axial_level;
385  for (unsigned int i_l = 0; i_l < cross_dimension; i_l++)
386  {
387  xx[iz_ind * cross_dimension + i_l] = loc_solution(i_l, iz);
388  }
389  }
390  LibmeshPetscCall(VecRestoreArray(x, &xx));
391  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
392 }
PetscFunctionBegin
const std::vector< double > x
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)

◆ populateVectorFromHandle()

template<class T >
PetscErrorCode SubChannel1PhaseProblem::populateVectorFromHandle ( Vec &  x,
const T &  solution,
const unsigned int  first_axial_level,
const unsigned int  last_axial_level,
const unsigned int  cross_dimension 
)
protectedinherited

Definition at line 347 of file SubChannel1PhaseProblem.h.

352 {
353  PetscScalar * xx;
354 
356  LibmeshPetscCall(VecGetArray(x, &xx));
357  for (unsigned int iz = first_axial_level; iz < last_axial_level + 1; iz++)
358  {
359  unsigned int iz_ind = iz - first_axial_level;
360  for (unsigned int i_l = 0; i_l < cross_dimension; i_l++)
361  {
362  auto * loc_node = _subchannel_mesh.getChannelNode(i_l, iz);
363  xx[iz_ind * cross_dimension + i_l] = loc_solution(loc_node);
364  }
365  }
366  LibmeshPetscCall(VecRestoreArray(x, &xx));
367 
368  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
369 }
PetscFunctionBegin
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
const std::vector< double > x
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)

◆ residualFunction()

libMesh::DenseVector< Real > SubChannel1PhaseProblem::residualFunction ( int  iblock,
libMesh::DenseVector< Real solution 
)
protectedinherited

Computes Residual Vector based on the lateral momentum conservation equation for block iblock & updates flow variables based on current crossflow solution.

Definition at line 1815 of file SubChannel1PhaseProblem.C.

Referenced by formFunction().

1816 {
1817  unsigned int last_node = (iblock + 1) * _block_size;
1818  unsigned int first_node = iblock * _block_size;
1819  libMesh::DenseVector<Real> Wij_residual_vector(_n_gaps * _block_size, 0.0);
1820  // Assign the solution to the cross-flow matrix
1821  int i = 0;
1822  for (unsigned int iz = first_node + 1; iz < last_node + 1; iz++)
1823  {
1824  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
1825  {
1826  _Wij(i_gap, iz) = solution(i);
1827  i++;
1828  }
1829  }
1830 
1831  // Calculating sum of crossflows
1832  computeSumWij(iblock);
1833  // Solving axial flux
1834  computeMdot(iblock);
1835  // Calculation of turbulent Crossflow
1836  computeWijPrime(iblock);
1837  // Solving for Pressure Drop
1838  computeDP(iblock);
1839  // Solving for pressure
1840  computeP(iblock);
1841  // Populating lateral crossflow residual matrix
1842  computeWijResidual(iblock);
1843 
1844  // Turn the residual matrix into a residual vector
1845  for (unsigned int iz = 0; iz < _block_size; iz++)
1846  {
1847  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
1848  {
1849  int i = _n_gaps * iz + i_gap; // column wise transfer
1850  Wij_residual_vector(i) = _Wij_residual_matrix(i_gap, iz);
1851  }
1852  }
1853  return Wij_residual_vector;
1854 }
void computeSumWij(int iblock)
Computes net diversion crossflow per channel for block iblock.
void computeP(int iblock)
Computes Pressure per channel for block iblock.
void computeMdot(int iblock)
Computes mass flow per channel for block iblock.
void computeWijResidual(int iblock)
Computes Residual Matrix based on the lateral momentum conservation equation for block iblock...
libMesh::DenseMatrix< Real > _Wij_residual_matrix
libMesh::DenseMatrix< Real > & _Wij
void computeWijPrime(int iblock)
Computes turbulent crossflow per gap for block iblock.
void computeDP(int iblock)
Computes Pressure Drop per channel for block iblock.

◆ solverSystemConverged()

bool SubChannel1PhaseProblem::solverSystemConverged ( const unsigned int  )
overridevirtualinherited

Reimplemented from ExternalProblem.

Definition at line 335 of file SubChannel1PhaseProblem.C.

336 {
337  return _converged;
338 }
bool _converged
Variable that informs whether we exited external solve with a converged solution or not...

◆ syncSolutions()

void SubChannel1PhaseProblem::syncSolutions ( Direction  direction)
overridevirtualinherited

Implements ExternalProblem.

Definition at line 2744 of file SubChannel1PhaseProblem.C.

2745 {
2746 }

◆ validParams()

InputParameters QuadSubChannel1PhaseProblem::validParams ( )
static

Definition at line 17 of file QuadSubChannel1PhaseProblem.C.

18 {
20  params.addClassDescription(
21  "Solver class for subchannels in a square lattice assembly and bare fuel pins");
22  params.addRequiredParam<Real>("beta",
23  "Thermal diffusion coefficient used in turbulent crossflow.");
24  params.addParam<bool>(
25  "default_friction_model",
26  true,
27  "Boolean to define which friction model to use (default: Pang, B. et al. "
28  "KIT, 2013. / non-default: Todreas-Kazimi NUCLEAR SYSTEMS, second edition, Volume 1, 2011)");
29  params.addParam<bool>(
30  "constant_beta",
31  true,
32  "Boolean to define the use of a constant beta or beta correlation (Kim and Chung, 2001)");
33  return params;
34 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)

Member Data Documentation

◆ _added_K

PetscScalar SubChannel1PhaseProblem::_added_K = 0.0
protectedinherited

Added resistances for monolithic convergence.

Definition at line 310 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::implicitPetscSolve().

◆ _added_K_old

PetscScalar SubChannel1PhaseProblem::_added_K_old = 1000.0
protectedinherited

◆ _amc_advective_derivative_mat

Mat SubChannel1PhaseProblem::_amc_advective_derivative_mat
protectedinherited

Axial momentum conservation - advective (Eulerian) derivative.

Definition at line 258 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::cleanUp(), SubChannel1PhaseProblem::computeDP(), and SubChannel1PhaseProblem::SubChannel1PhaseProblem().

◆ _amc_advective_derivative_rhs

Vec SubChannel1PhaseProblem::_amc_advective_derivative_rhs
protectedinherited

◆ _amc_cross_derivative_mat

Mat SubChannel1PhaseProblem::_amc_cross_derivative_mat
protectedinherited

Axial momentum conservation - cross flux derivative.

Definition at line 261 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::cleanUp(), SubChannel1PhaseProblem::computeDP(), and SubChannel1PhaseProblem::SubChannel1PhaseProblem().

◆ _amc_cross_derivative_rhs

Vec SubChannel1PhaseProblem::_amc_cross_derivative_rhs
protectedinherited

◆ _amc_friction_force_mat

Mat SubChannel1PhaseProblem::_amc_friction_force_mat
protectedinherited

Axial momentum conservation - friction force.

Definition at line 264 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::cleanUp(), SubChannel1PhaseProblem::computeDP(), and SubChannel1PhaseProblem::SubChannel1PhaseProblem().

◆ _amc_friction_force_rhs

Vec SubChannel1PhaseProblem::_amc_friction_force_rhs
protectedinherited

◆ _amc_gravity_rhs

Vec SubChannel1PhaseProblem::_amc_gravity_rhs
protectedinherited

Axial momentum conservation - buoyancy force No implicit matrix.

Definition at line 268 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::cleanUp(), SubChannel1PhaseProblem::computeDP(), and SubChannel1PhaseProblem::SubChannel1PhaseProblem().

◆ _amc_pressure_force_mat

Mat SubChannel1PhaseProblem::_amc_pressure_force_mat
protectedinherited

◆ _amc_pressure_force_rhs

Vec SubChannel1PhaseProblem::_amc_pressure_force_rhs
protectedinherited

◆ _amc_sys_mdot_mat

Mat SubChannel1PhaseProblem::_amc_sys_mdot_mat
protectedinherited

◆ _amc_sys_mdot_rhs

Vec SubChannel1PhaseProblem::_amc_sys_mdot_rhs
protectedinherited

◆ _amc_time_derivative_mat

Mat SubChannel1PhaseProblem::_amc_time_derivative_mat
protectedinherited

Axial momentum conservation - time derivative.

Definition at line 255 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::cleanUp(), SubChannel1PhaseProblem::computeDP(), and SubChannel1PhaseProblem::SubChannel1PhaseProblem().

◆ _amc_time_derivative_rhs

Vec SubChannel1PhaseProblem::_amc_time_derivative_rhs
protectedinherited

◆ _amc_turbulent_cross_flows_mat

Mat SubChannel1PhaseProblem::_amc_turbulent_cross_flows_mat
protectedinherited

Mass conservation - density time derivative No implicit matrix.

Axial momentum Axial momentum conservation - compute turbulent cross fluxes

Definition at line 252 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::cleanUp(), SubChannel1PhaseProblem::computeWijPrime(), and SubChannel1PhaseProblem::SubChannel1PhaseProblem().

◆ _amc_turbulent_cross_flows_rhs

Vec SubChannel1PhaseProblem::_amc_turbulent_cross_flows_rhs
protectedinherited

◆ _atol

const PetscReal& SubChannel1PhaseProblem::_atol
protectedinherited

◆ _beta

const Real& QuadSubChannel1PhaseProblem::_beta
protected

Thermal diffusion coefficient used in turbulent crossflow.

Definition at line 32 of file QuadSubChannel1PhaseProblem.h.

Referenced by computeBeta().

◆ _block_size

unsigned int SubChannel1PhaseProblem::_block_size
protectedinherited

◆ _cmc_advective_derivative_mat

Mat SubChannel1PhaseProblem::_cmc_advective_derivative_mat
protectedinherited

Cross momentum conservation - advective (Eulerian) derivative.

Definition at line 281 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::cleanUp(), SubChannel1PhaseProblem::computeWijResidual(), and SubChannel1PhaseProblem::SubChannel1PhaseProblem().

◆ _cmc_advective_derivative_rhs

Vec SubChannel1PhaseProblem::_cmc_advective_derivative_rhs
protectedinherited

◆ _cmc_friction_force_mat

Mat SubChannel1PhaseProblem::_cmc_friction_force_mat
protectedinherited

◆ _cmc_friction_force_rhs

Vec SubChannel1PhaseProblem::_cmc_friction_force_rhs
protectedinherited

◆ _cmc_pressure_force_mat

Mat SubChannel1PhaseProblem::_cmc_pressure_force_mat
protectedinherited

◆ _cmc_pressure_force_rhs

Vec SubChannel1PhaseProblem::_cmc_pressure_force_rhs
protectedinherited

◆ _cmc_sys_Wij_mat

Mat SubChannel1PhaseProblem::_cmc_sys_Wij_mat
protectedinherited

◆ _cmc_sys_Wij_rhs

Vec SubChannel1PhaseProblem::_cmc_sys_Wij_rhs
protectedinherited

◆ _cmc_time_derivative_mat

Mat SubChannel1PhaseProblem::_cmc_time_derivative_mat
protectedinherited

Cross momentum Cross momentum conservation - time derivative.

Definition at line 278 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::cleanUp(), SubChannel1PhaseProblem::computeWijResidual(), and SubChannel1PhaseProblem::SubChannel1PhaseProblem().

◆ _cmc_time_derivative_rhs

Vec SubChannel1PhaseProblem::_cmc_time_derivative_rhs
protectedinherited

◆ _compute_density

const bool SubChannel1PhaseProblem::_compute_density
protectedinherited

Flag that activates or deactivates the calculation of density.

Definition at line 118 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::externalSolve().

◆ _compute_power

const bool SubChannel1PhaseProblem::_compute_power
protectedinherited

Flag that informs if we need to solve the Enthalpy/Temperature equations or not.

Definition at line 122 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::externalSolve().

◆ _compute_viscosity

const bool SubChannel1PhaseProblem::_compute_viscosity
protectedinherited

Flag that activates or deactivates the calculation of viscosity.

Definition at line 120 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::externalSolve().

◆ _constant_beta

const bool QuadSubChannel1PhaseProblem::_constant_beta
protected

Flag that activates the use of constant beta.

Definition at line 36 of file QuadSubChannel1PhaseProblem.h.

Referenced by computeBeta().

◆ _converged

bool SubChannel1PhaseProblem::_converged
protectedinherited

Variable that informs whether we exited external solve with a converged solution or not.

Definition at line 128 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::externalSolve(), SubChannel1PhaseProblem::solverSystemConverged(), and SubChannel1PhaseProblem::SubChannel1PhaseProblem().

◆ _correction_factor

PetscScalar SubChannel1PhaseProblem::_correction_factor = 1.0
protectedinherited

◆ _CT

const Real& SubChannel1PhaseProblem::_CT
protectedinherited

Turbulent modeling parameter used in axial momentum equation.

Definition at line 134 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::computeDP().

◆ _default_friction_model

const bool QuadSubChannel1PhaseProblem::_default_friction_model
protected

Flag that activates one of the two friction models (default: f=a*Re^b, non-default: Todreas-Kazimi)

Definition at line 34 of file QuadSubChannel1PhaseProblem.h.

Referenced by computeFrictionFactor().

◆ _deformation

const bool SubChannel1PhaseProblem::_deformation
protectedinherited

Flag that activates the effect of deformation (pin/duct) based on the auxvalues for displacement, Dpin.

Definition at line 162 of file SubChannel1PhaseProblem.h.

Referenced by initializeSolution(), and TriSubChannel1PhaseProblem::initializeSolution().

◆ _displacement_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_displacement_soln
protectedinherited

◆ _DP_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_DP_soln
protectedinherited

◆ _Dpin_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_Dpin_soln
protectedinherited

◆ _dt

Real SubChannel1PhaseProblem::_dt
protectedinherited

◆ _dtol

const PetscReal& SubChannel1PhaseProblem::_dtol
protectedinherited

◆ _duct_mesh_exist

const bool SubChannel1PhaseProblem::_duct_mesh_exist
protectedinherited

Flag that informs if there is a pin mesh or not.

Definition at line 126 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::computeAddedHeatDuct(), SubChannel1PhaseProblem::externalSolve(), and SubChannel1PhaseProblem::initialSetup().

◆ _fp

const SinglePhaseFluidProperties* SubChannel1PhaseProblem::_fp
protectedinherited

◆ _friction_args

struct SubChannel1PhaseProblem::FrictionStruct SubChannel1PhaseProblem::_friction_args
protectedinherited

◆ _g_grav

const Real SubChannel1PhaseProblem::_g_grav
protectedinherited

Definition at line 104 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::computeDP().

◆ _h_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_h_soln
protectedinherited

◆ _hc_added_heat_rhs

Vec SubChannel1PhaseProblem::_hc_added_heat_rhs
protectedinherited

◆ _hc_advective_derivative_mat

Mat SubChannel1PhaseProblem::_hc_advective_derivative_mat
protectedinherited

Enthalpy conservation - advective (Eulerian) derivative;.

Definition at line 298 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::cleanUp(), computeh(), TriSubChannel1PhaseProblem::computeh(), and SubChannel1PhaseProblem::SubChannel1PhaseProblem().

◆ _hc_advective_derivative_rhs

Vec SubChannel1PhaseProblem::_hc_advective_derivative_rhs
protectedinherited

◆ _hc_cross_derivative_mat

Mat SubChannel1PhaseProblem::_hc_cross_derivative_mat
protectedinherited

◆ _hc_cross_derivative_rhs

Vec SubChannel1PhaseProblem::_hc_cross_derivative_rhs
protectedinherited

◆ _hc_sys_h_mat

Mat SubChannel1PhaseProblem::_hc_sys_h_mat
protectedinherited

◆ _hc_sys_h_rhs

Vec SubChannel1PhaseProblem::_hc_sys_h_rhs
protectedinherited

◆ _hc_time_derivative_mat

Mat SubChannel1PhaseProblem::_hc_time_derivative_mat
protectedinherited

Enthalpy Enthalpy conservation - time derivative.

Definition at line 295 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::cleanUp(), computeh(), TriSubChannel1PhaseProblem::computeh(), and SubChannel1PhaseProblem::SubChannel1PhaseProblem().

◆ _hc_time_derivative_rhs

Vec SubChannel1PhaseProblem::_hc_time_derivative_rhs
protectedinherited

◆ _implicit_bool

const bool SubChannel1PhaseProblem::_implicit_bool
protectedinherited

◆ _interpolation_scheme

const MooseEnum SubChannel1PhaseProblem::_interpolation_scheme
protectedinherited

The interpolation method used in constructing the systems.

Definition at line 150 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::computeDP(), TriSubChannel1PhaseProblem::computeh(), and SubChannel1PhaseProblem::computeInterpolationCoefficients().

◆ _kij

const Real& SubChannel1PhaseProblem::_kij
protectedinherited

◆ _max_sumWij

PetscScalar SubChannel1PhaseProblem::_max_sumWij
protectedinherited

◆ _max_sumWij_new

PetscScalar SubChannel1PhaseProblem::_max_sumWij_new
protectedinherited

◆ _maxit

const PetscInt& SubChannel1PhaseProblem::_maxit
protectedinherited

◆ _mc_axial_convection_mat

Mat SubChannel1PhaseProblem::_mc_axial_convection_mat
protectedinherited

◆ _mc_axial_convection_rhs

Vec SubChannel1PhaseProblem::_mc_axial_convection_rhs
protectedinherited

◆ _mc_sumWij_mat

Mat SubChannel1PhaseProblem::_mc_sumWij_mat
protectedinherited

Matrices and vectors to be used in implicit assembly Mass conservation Mass conservation - sum of cross fluxes.

Definition at line 240 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::cleanUp(), SubChannel1PhaseProblem::computeSumWij(), SubChannel1PhaseProblem::implicitPetscSolve(), and SubChannel1PhaseProblem::SubChannel1PhaseProblem().

◆ _mdot_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_mdot_soln
protectedinherited

◆ _monolithic_thermal_bool

const bool SubChannel1PhaseProblem::_monolithic_thermal_bool
protectedinherited

◆ _mu_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_mu_soln
protectedinherited

◆ _n_blocks

unsigned int SubChannel1PhaseProblem::_n_blocks
protectedinherited

◆ _n_cells

unsigned int SubChannel1PhaseProblem::_n_cells
protectedinherited

◆ _n_channels

unsigned int SubChannel1PhaseProblem::_n_channels
protectedinherited

◆ _n_gaps

unsigned int SubChannel1PhaseProblem::_n_gaps
protectedinherited

◆ _n_pins

unsigned int SubChannel1PhaseProblem::_n_pins
protectedinherited

◆ _one

Real SubChannel1PhaseProblem::_one
protectedinherited

Definition at line 114 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::externalSolve().

◆ _outer_channels

Real SubChannel1PhaseProblem::_outer_channels
protectedinherited

◆ _P_out

const PostprocessorValue& SubChannel1PhaseProblem::_P_out
protectedinherited

◆ _P_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_P_soln
protectedinherited

◆ _P_tol

const Real& SubChannel1PhaseProblem::_P_tol
protectedinherited

Convergence tolerance for the pressure loop in external solve.

Definition at line 136 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::externalSolve().

◆ _pin_mesh_exist

const bool SubChannel1PhaseProblem::_pin_mesh_exist
protectedinherited

◆ _prod

Vec SubChannel1PhaseProblem::_prod
protectedinherited

◆ _prodp

Vec SubChannel1PhaseProblem::_prodp
protectedinherited

◆ _q_prime_duct_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_q_prime_duct_soln
protectedinherited

Definition at line 179 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::initialSetup().

◆ _q_prime_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_q_prime_soln
protectedinherited

◆ _rho_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_rho_soln
protectedinherited

◆ _rtol

const PetscReal& SubChannel1PhaseProblem::_rtol
protectedinherited

◆ _S_flow_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_S_flow_soln
protectedinherited

◆ _segregated_bool

const bool SubChannel1PhaseProblem::_segregated_bool
protectedinherited

◆ _staggered_pressure_bool

const bool SubChannel1PhaseProblem::_staggered_pressure_bool
protectedinherited

Flag to define the usage of staggered or collocated pressure.

Definition at line 154 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::computeP(), and SubChannel1PhaseProblem::computeWijResidual().

◆ _subchannel_mesh

QuadSubChannelMesh& QuadSubChannel1PhaseProblem::_subchannel_mesh
protected

◆ _SumWij_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_SumWij_soln
protectedinherited

◆ _T_maxit

const int& SubChannel1PhaseProblem::_T_maxit
protectedinherited

Maximum iterations for the inner temperature loop.

Definition at line 140 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::externalSolve().

◆ _T_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_T_soln
protectedinherited

◆ _T_tol

const Real& SubChannel1PhaseProblem::_T_tol
protectedinherited

Convergence tolerance for the temperature loop in external solve.

Definition at line 138 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::externalSolve().

◆ _Tduct_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_Tduct_soln
protectedinherited

◆ _Tpin_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_Tpin_soln
protectedinherited

◆ _TR

Real SubChannel1PhaseProblem::_TR
protectedinherited

Flag that activates or deactivates the transient parts of the equations we solve by multiplication.

Definition at line 116 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::computeDP(), computeh(), TriSubChannel1PhaseProblem::computeh(), SubChannel1PhaseProblem::computeMdot(), SubChannel1PhaseProblem::computeWijResidual(), and SubChannel1PhaseProblem::externalSolve().

◆ _verbose_subchannel

const bool SubChannel1PhaseProblem::_verbose_subchannel
protectedinherited

◆ _w_perim_soln

std::unique_ptr<SolutionHandle> SubChannel1PhaseProblem::_w_perim_soln
protectedinherited

◆ _Wij

libMesh::DenseMatrix<Real>& SubChannel1PhaseProblem::_Wij
protectedinherited

◆ _Wij_old

libMesh::DenseMatrix<Real> SubChannel1PhaseProblem::_Wij_old
protectedinherited

◆ _Wij_residual_matrix

libMesh::DenseMatrix<Real> SubChannel1PhaseProblem::_Wij_residual_matrix
protectedinherited

◆ _Wij_vec

Vec SubChannel1PhaseProblem::_Wij_vec
protectedinherited

◆ _WijPrime

libMesh::DenseMatrix<Real> SubChannel1PhaseProblem::_WijPrime
protectedinherited

◆ _z_grid

std::vector<Real> SubChannel1PhaseProblem::_z_grid
protectedinherited

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