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

Triangular subchannel solver. More...

#include <TriSubChannel1PhaseProblem.h>

Inheritance diagram for TriSubChannel1PhaseProblem:
[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

 TriSubChannel1PhaseProblem (const InputParameters &params)
 
virtual ~TriSubChannel1PhaseProblem ()
 
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
 Computes the axial friction factor for the sodium coolant and for each subchannel. 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...
 
PetscErrorCode cleanUp ()
 
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 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

TriSubChannelMesh_tri_sch_mesh
 
Mat _hc_axial_heat_conduction_mat
 
Vec _hc_axial_heat_conduction_rhs
 
Mat _hc_radial_heat_conduction_mat
 
Vec _hc_radial_heat_conduction_rhs
 
Mat _hc_sweep_enthalpy_mat
 
Vec _hc_sweep_enthalpy_rhs
 
struct SubChannel1PhaseProblem::FrictionStruct _friction_args
 
SubChannelMesh_subchannel_mesh
 
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
 
Real _dpz_error
 average relative error in pressure drop of channels More...
 
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
 
Vec _cmc_Wij_channel_dummy
 
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
 
PetscInt _global_counter = 0
 No implicit matrix. More...
 
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

Triangular subchannel solver.

Definition at line 19 of file TriSubChannel1PhaseProblem.h.

Constructor & Destructor Documentation

◆ TriSubChannel1PhaseProblem()

TriSubChannel1PhaseProblem::TriSubChannel1PhaseProblem ( const InputParameters params)

Definition at line 26 of file TriSubChannel1PhaseProblem.C.

27  : SubChannel1PhaseProblem(params),
28  _tri_sch_mesh(SCM::getMesh<TriSubChannelMesh>(_subchannel_mesh))
29 {
30  // Initializing heat conduction system
31  LibmeshPetscCall(createPetscMatrix(
34  LibmeshPetscCall(createPetscMatrix(
37  LibmeshPetscCall(createPetscMatrix(
40 }
PetscErrorCode createPetscVector(Vec &v, PetscInt n)
Petsc Functions.
PetscErrorCode createPetscMatrix(Mat &M, PetscInt n, PetscInt m)
SubChannel1PhaseProblem(const InputParameters &params)

◆ ~TriSubChannel1PhaseProblem()

TriSubChannel1PhaseProblem::~TriSubChannel1PhaseProblem ( )
virtual

Definition at line 42 of file TriSubChannel1PhaseProblem.C.

43 {
44  PetscErrorCode ierr = cleanUp();
45  if (ierr)
46  mooseError(name(), ": Error in memory cleanup");
47 }
virtual const std::string & name() const
void mooseError(Args &&... args) const

Member Function Documentation

◆ cleanUp()

PetscErrorCode TriSubChannel1PhaseProblem::cleanUp ( )
protected

Definition at line 50 of file TriSubChannel1PhaseProblem.C.

Referenced by ~TriSubChannel1PhaseProblem().

51 {
53  // Clean up heat conduction system
54  LibmeshPetscCall(MatDestroy(&_hc_axial_heat_conduction_mat));
55  LibmeshPetscCall(VecDestroy(&_hc_axial_heat_conduction_rhs));
56  LibmeshPetscCall(MatDestroy(&_hc_radial_heat_conduction_mat));
57  LibmeshPetscCall(VecDestroy(&_hc_radial_heat_conduction_rhs));
58  LibmeshPetscCall(MatDestroy(&_hc_sweep_enthalpy_mat));
59  LibmeshPetscCall(VecDestroy(&_hc_sweep_enthalpy_rhs));
60  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
61 }
PetscFunctionBegin
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)

◆ 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 1320 of file SubChannel1PhaseProblem.C.

Referenced by computeh().

1321 {
1322  if (_duct_mesh_exist)
1323  {
1324  auto subch_type = _subchannel_mesh.getSubchannelType(i_ch);
1325  if (subch_type == EChannelType::EDGE || subch_type == EChannelType::CORNER)
1326  {
1327  auto dz = _z_grid[iz] - _z_grid[iz - 1];
1328  auto * node_in_chan = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1329  auto * node_out_chan = _subchannel_mesh.getChannelNode(i_ch, iz);
1330  auto * node_in_duct = _subchannel_mesh.getDuctNodeFromChannel(node_in_chan);
1331  auto * node_out_duct = _subchannel_mesh.getDuctNodeFromChannel(node_out_chan);
1332  auto heat_rate_in = (*_q_prime_duct_soln)(node_in_duct);
1333  auto heat_rate_out = (*_q_prime_duct_soln)(node_out_duct);
1334  return 0.5 * (heat_rate_in + heat_rate_out) * dz / _outer_channels;
1335  }
1336  else
1337  {
1338  return 0.0;
1339  }
1340  }
1341  else
1342  {
1343  return 0;
1344  }
1345 }
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 TriSubChannel1PhaseProblem::computeAddedHeatPin ( unsigned int  i_ch,
unsigned int  iz 
)
overrideprotectedvirtual

Computes added heat for channel i_ch and cell iz.

Implements SubChannel1PhaseProblem.

Definition at line 550 of file TriSubChannel1PhaseProblem.C.

Referenced by computeh().

551 {
552  auto dz = _z_grid[iz] - _z_grid[iz - 1];
553  auto subch_type = _subchannel_mesh.getSubchannelType(i_ch);
554 
555  if (_pin_mesh_exist)
556  {
557  double factor;
558  switch (subch_type)
559  {
561  factor = 1.0 / 6.0;
562  break;
563  case EChannelType::EDGE:
564  factor = 1.0 / 4.0;
565  break;
567  factor = 1.0 / 6.0;
568  break;
569  default:
570  return 0.0; // handle invalid subch_type if needed
571  }
572  double heat_rate_in = 0.0;
573  double heat_rate_out = 0.0;
574  for (auto i_pin : _subchannel_mesh.getChannelPins(i_ch))
575  {
576  auto * node_in = _subchannel_mesh.getPinNode(i_pin, iz - 1);
577  auto * node_out = _subchannel_mesh.getPinNode(i_pin, iz);
578  heat_rate_out += factor * (*_q_prime_soln)(node_out);
579  heat_rate_in += factor * (*_q_prime_soln)(node_in);
580  }
581  return (heat_rate_in + heat_rate_out) * dz / 2.0;
582  }
583  else
584  {
585  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
586  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
587  return ((*_q_prime_soln)(node_out) + (*_q_prime_soln)(node_in)) * dz / 2.0;
588  }
589 }
const bool _pin_mesh_exist
Flag that informs if there is a pin mesh or not.
virtual const std::vector< unsigned int > & getChannelPins(unsigned int i_chan) const =0
Return a vector of pin indices for a given channel index.
virtual EChannelType getSubchannelType(unsigned int index) const =0
Return the type of the subchannel for given subchannel index.
virtual Node * getPinNode(unsigned int i_pin, unsigned iz) const =0
Get the pin mesh node for a given pin index and elevation index.
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
std::unique_ptr< SolutionHandle > _q_prime_soln

◆ computeBeta()

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

Computes turbulent mixing coefficient.

Implements SubChannel1PhaseProblem.

Definition at line 438 of file TriSubChannel1PhaseProblem.C.

439 {
440  auto beta = 0.0;
441  const Real & pitch = _subchannel_mesh.getPitch();
442  const Real & pin_diameter = _subchannel_mesh.getPinDiameter();
443  const Real & wire_lead_length = _tri_sch_mesh.getWireLeadLength();
444  const Real & wire_diameter = _tri_sch_mesh.getWireDiameter();
445  auto chans = _subchannel_mesh.getGapChannels(i_gap);
446  unsigned int i_ch = chans.first;
447  unsigned int j_ch = chans.second;
448  auto subch_type1 = _subchannel_mesh.getSubchannelType(i_ch);
449  auto subch_type2 = _subchannel_mesh.getSubchannelType(j_ch);
450  auto * node_in_i = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
451  auto * node_out_i = _subchannel_mesh.getChannelNode(i_ch, iz);
452  auto * node_in_j = _subchannel_mesh.getChannelNode(j_ch, iz - 1);
453  auto * node_out_j = _subchannel_mesh.getChannelNode(j_ch, iz);
454  auto Si_in = (*_S_flow_soln)(node_in_i);
455  auto Sj_in = (*_S_flow_soln)(node_in_j);
456  auto Si_out = (*_S_flow_soln)(node_out_i);
457  auto Sj_out = (*_S_flow_soln)(node_out_j);
458  auto S_total = Si_in + Sj_in + Si_out + Sj_out;
459  auto Si = 0.5 * (Si_in + Si_out);
460  auto Sj = 0.5 * (Sj_in + Sj_out);
461  auto w_perim_i = 0.5 * ((*_w_perim_soln)(node_in_i) + (*_w_perim_soln)(node_out_i));
462  auto w_perim_j = 0.5 * ((*_w_perim_soln)(node_in_j) + (*_w_perim_soln)(node_out_j));
463  auto avg_mu = (1 / S_total) * ((*_mu_soln)(node_out_i)*Si_out + (*_mu_soln)(node_in_i)*Si_in +
464  (*_mu_soln)(node_out_j)*Sj_out + (*_mu_soln)(node_in_j)*Sj_in);
465  auto avg_hD = 4.0 * (Si + Sj) / (w_perim_i + w_perim_j);
466  auto avg_massflux =
467  0.5 * (((*_mdot_soln)(node_in_i) + (*_mdot_soln)(node_in_j)) / (Si_in + Sj_in) +
468  ((*_mdot_soln)(node_out_i) + (*_mdot_soln)(node_out_j)) / (Si_out + Sj_out));
469  auto Re = avg_massflux * avg_hD / avg_mu;
470  // crossflow area between channels i,j (dz*gap_width)
471  auto gap = _subchannel_mesh.getGapWidth(iz, i_gap);
472  // Calculation of flow regime
473  auto ReL = 320.0 * std::pow(10.0, pitch / pin_diameter - 1);
474  auto ReT = 10000.0 * std::pow(10.0, 0.7 * (pitch / pin_diameter - 1));
475  // Calculation of Turbulent Crossflow for wire-wrapped triangular assemblies. Cheng &
476  // Todreas (1986)
477  if ((subch_type1 == EChannelType::CENTER || subch_type2 == EChannelType::CENTER) &&
478  (wire_lead_length != 0) && (wire_diameter != 0))
479  {
480  // Calculation of geometric parameters
481  auto theta = std::acos(wire_lead_length /
482  std::sqrt(std::pow(wire_lead_length, 2) +
483  std::pow(libMesh::pi * (pin_diameter + wire_diameter), 2)));
484  auto Ar1 = libMesh::pi * (pin_diameter + wire_diameter) * wire_diameter / 6.0;
485  auto A1prime =
486  (std::sqrt(3.0) / 4.0) * std::pow(pitch, 2) - libMesh::pi * std::pow(pin_diameter, 2) / 8.0;
487  auto A1 = A1prime - libMesh::pi * std::pow(wire_diameter, 2) / 8.0 / std::cos(theta);
488  auto Cm = 0.0;
489  if (Re < ReL)
490  {
491  Cm = 0.077 * std::pow((pitch - pin_diameter) / pin_diameter, -0.5);
492  }
493  else if (Re > ReT)
494  {
495  Cm = 0.14 * std::pow((pitch - pin_diameter) / pin_diameter, -0.5);
496  }
497  else
498  {
499  auto psi = (std::log(Re) - std::log(ReL)) / (std::log(ReT) - std::log(ReL));
500  auto gamma = 2.0 / 3.0;
501  Cm = 0.14 * std::pow((pitch - pin_diameter) / pin_diameter, -0.5) +
502  (0.14 * std::pow((pitch - pin_diameter) / pin_diameter, -0.5) -
503  0.077 * std::pow((pitch - pin_diameter) / pin_diameter, -0.5)) *
504  std::pow(psi, gamma);
505  }
506  // Calculation of turbulent mixing parameter
507  beta = Cm * std::pow(Ar1 / A1, 0.5) * std::tan(theta);
508  }
509  // Calculation of Turbulent Crossflow for bare assemblies, from Kim and Chung (2001).
510  else if ((wire_lead_length == 0) && (wire_diameter == 0))
511  {
512  Real gamma = 20.0; // empirical constant
513  Real sf = 2.0 / 3.0; // shape factor
514  Real a = 0.18;
515  Real b = 0.2;
516  auto f = a * std::pow(Re, -b); // Rehme 1992 circular tube friction factor
517  auto k = (1 / S_total) *
518  (_fp->k_from_p_T((*_P_soln)(node_out_i) + _P_out, (*_T_soln)(node_out_i)) * Si_out +
519  _fp->k_from_p_T((*_P_soln)(node_in_i) + _P_out, (*_T_soln)(node_in_i)) * Si_in +
520  _fp->k_from_p_T((*_P_soln)(node_out_j) + _P_out, (*_T_soln)(node_out_j)) * Sj_out +
521  _fp->k_from_p_T((*_P_soln)(node_in_j) + _P_out, (*_T_soln)(node_in_j)) * Sj_in);
522  auto cp = (1 / S_total) *
523  (_fp->cp_from_p_T((*_P_soln)(node_out_i) + _P_out, (*_T_soln)(node_out_i)) * Si_out +
524  _fp->cp_from_p_T((*_P_soln)(node_in_i) + _P_out, (*_T_soln)(node_in_i)) * Si_in +
525  _fp->cp_from_p_T((*_P_soln)(node_out_j) + _P_out, (*_T_soln)(node_out_j)) * Sj_out +
526  _fp->cp_from_p_T((*_P_soln)(node_in_j) + _P_out, (*_T_soln)(node_in_j)) * Sj_in);
527  auto Pr = avg_mu * cp / k; // Prandtl number
528  auto Pr_t = Pr * (Re / gamma) * std::sqrt(f / 8.0); // Turbulent Prandtl number
529  auto delta = pitch / std::sqrt(3.0); // centroid to centroid distance
530  auto L_x = sf * delta; // axial length scale (gap is the lateral length scale)
531  auto lamda = gap / L_x; // aspect ratio
532  auto a_x = 1.0 - 2.0 * lamda * lamda / libMesh::pi; // velocity coefficient
533  auto z_FP_over_D = (2.0 * L_x / pin_diameter) *
534  (1 + (-0.5 * std::log(lamda) + 0.5 * std::log(4.0) - 0.25) * lamda * lamda);
535  auto Str = 1.0 / (0.822 * (gap / pin_diameter) + 0.144); // Strouhal number (Wu & Trupp 1994)
536  auto freq_factor = 2.0 / std::pow(gamma, 2) * std::sqrt(a / 8.0) * (avg_hD / gap);
537  auto rod_mixing = (1 / Pr_t) * lamda;
538  auto axial_mixing = a_x * z_FP_over_D * Str;
539  // Mixing Stanton number: Stg (eq 25,Kim and Chung (2001), eq 19 (Jeong et. al 2005)
540  beta = freq_factor * (rod_mixing + axial_mixing) * std::pow(Re, -b / 2.0);
541  }
542  mooseAssert(beta >= 0,
543  "beta should be positive for the inner gaps, or zero for the edge gaps, because this "
544  "case is covered "
545  "explicitly in the computeh method.");
546  return beta;
547 }
virtual const Real & getPinDiameter() const
Return Pin diameter.
std::unique_ptr< SolutionHandle > _T_soln
const PostprocessorValue & _P_out
Outlet Pressure.
virtual const Real & getPitch() const
Return the pitch between 2 subchannels.
virtual EChannelType getSubchannelType(unsigned int index) const =0
Return the type of the subchannel for given subchannel index.
int delta(unsigned int i, unsigned int j)
Delta function, which returns zero if $i j$ and unity if $i=j$.
virtual Node * getChannelNode(unsigned int i_chan, unsigned iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
static const std::string cp
Definition: NS.h:121
Real f(Real x)
Test function for Brents method.
static const std::string pitch
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
virtual const Real & getWireLeadLength() const
Return the wire lead length.
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
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.
virtual const Real & getWireDiameter() const
Return wire diameter.

◆ 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 583 of file SubChannel1PhaseProblem.C.

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

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

Computes the axial friction factor for the sodium coolant and for each subchannel.

Upgraded Cheng-Todreas Correlation (2018).

The upgraded Cheng and Todreas correlation for pressure drop in hexagonal wire-wrapped rod bundles

Implements SubChannel1PhaseProblem.

Definition at line 253 of file TriSubChannel1PhaseProblem.C.

254 {
256  auto Re = friction_args.Re;
257  auto i_ch = friction_args.i_ch;
258  auto S = friction_args.S;
259  auto w_perim = friction_args.w_perim;
260  auto Dh_i = 4.0 * S / w_perim;
261  Real aL, b1L, b2L, cL;
262  Real aT, b1T, b2T, cT;
263  const Real & pitch = _subchannel_mesh.getPitch();
264  const Real & pin_diameter = _subchannel_mesh.getPinDiameter();
265  const Real & wire_lead_length = _tri_sch_mesh.getWireLeadLength();
266  const Real & wire_diameter = _tri_sch_mesh.getWireDiameter();
267  auto p_over_d = pitch / pin_diameter;
268  auto subch_type = _subchannel_mesh.getSubchannelType(i_ch);
269  // This gap is a constant value for the whole assembly. Might want to make it
270  // subchannel specific in the future if we have duct deformation.
271  auto gap = _tri_sch_mesh.getDuctToPinGap();
272  auto w_over_d = (pin_diameter + gap) / pin_diameter;
273  auto ReL = std::pow(10, (p_over_d - 1)) * 320.0;
274  auto ReT = std::pow(10, 0.7 * (p_over_d - 1)) * 1.0E+4;
275  auto psi = std::log(Re / ReL) / std::log(ReT / ReL);
276  const Real lambda = 7.0;
277  auto theta = std::acos(wire_lead_length /
278  std::sqrt(std::pow(wire_lead_length, 2) +
279  std::pow(libMesh::pi * (pin_diameter + wire_diameter), 2)));
280  auto wd_t = (19.56 - 98.71 * (wire_diameter / pin_diameter) +
281  303.47 * std::pow((wire_diameter / pin_diameter), 2.0)) *
282  std::pow((wire_lead_length / pin_diameter), -0.541);
283  auto wd_l = 1.4 * wd_t;
284  auto ws_t = -11.0 * std::log(wire_lead_length / pin_diameter) + 19.0;
285  auto ws_l = ws_t;
286  Real pw_p = 0.0;
287  Real ar = 0.0;
288  Real a_p = 0.0;
289 
290  // Find the coefficients of bare Pin bundle friction factor
291  // correlations for turbulent and laminar flow regimes. Todreas & Kazimi, Nuclear Systems
292  // second edition, Volume 1, Chapter 9.6
293  if (subch_type == EChannelType::CENTER)
294  {
295  if (p_over_d < 1.1)
296  {
297  aL = 26.0;
298  b1L = 888.2;
299  b2L = -3334.0;
300  aT = 0.09378;
301  b1T = 1.398;
302  b2T = -8.664;
303  }
304  else
305  {
306  aL = 62.97;
307  b1L = 216.9;
308  b2L = -190.2;
309  aT = 0.1458;
310  b1T = 0.03632;
311  b2T = -0.03333;
312  }
313  // laminar flow friction factor for bare Pin bundle - Center subchannel
314  cL = aL + b1L * (p_over_d - 1) + b2L * std::pow((p_over_d - 1), 2.0);
315  // turbulent flow friction factor for bare Pin bundle - Center subchannel
316  cT = aT + b1T * (p_over_d - 1) + b2T * std::pow((p_over_d - 1), 2.0);
317  }
318  else if (subch_type == EChannelType::EDGE)
319  {
320  if (w_over_d < 1.1)
321  {
322  aL = 26.18;
323  b1L = 554.5;
324  b2L = -1480.0;
325  aT = 0.09377;
326  b1T = 0.8732;
327  b2T = -3.341;
328  }
329  else
330  {
331  aL = 44.4;
332  b1L = 256.7;
333  b2L = -267.6;
334  aT = 0.1430;
335  b1T = 0.04199;
336  b2T = -0.04428;
337  }
338  // laminar flow friction factor for bare Pin bundle - Edge subchannel
339  cL = aL + b1L * (w_over_d - 1) + b2L * std::pow((w_over_d - 1), 2.0);
340  // turbulent flow friction factor for bare Pin bundle - Edge subchannel
341  cT = aT + b1T * (w_over_d - 1) + b2T * std::pow((w_over_d - 1), 2.0);
342  }
343  else
344  {
345  if (w_over_d < 1.1)
346  {
347  aL = 26.98;
348  b1L = 1636.0;
349  b2L = -10050.0;
350  aT = 0.1004;
351  b1T = 1.625;
352  b2T = -11.85;
353  }
354  else
355  {
356  aL = 87.26;
357  b1L = 38.59;
358  b2L = -55.12;
359  aT = 0.1499;
360  b1T = 0.006706;
361  b2T = -0.009567;
362  }
363  // laminar flow friction factor for bare Pin bundle - Corner subchannel
364  cL = aL + b1L * (w_over_d - 1) + b2L * std::pow((w_over_d - 1), 2.0);
365  // turbulent flow friction factor for bare Pin bundle - Corner subchannel
366  cT = aT + b1T * (w_over_d - 1) + b2T * std::pow((w_over_d - 1), 2.0);
367  }
368 
369  // Find the coefficients of wire-wrapped Pin bundle friction factor
370  // correlations for turbulent and laminar flow regimes. Todreas & Kazimi, Nuclear Systems
371  // Volume 1 Chapter 9-6 also Chen and Todreas (2018).
372  if ((wire_diameter != 0.0) && (wire_lead_length != 0.0))
373  {
374  if (subch_type == EChannelType::CENTER)
375  {
376  // wetted perimeter for center subchannel and bare Pin bundle
377  pw_p = libMesh::pi * pin_diameter / 2.0;
378  // wire projected area - center subchannel wire-wrapped bundle
379  ar = libMesh::pi * (pin_diameter + wire_diameter) * wire_diameter / 6.0;
380  // bare Pin bundle center subchannel flow area (normal area + wire area)
381  a_p = S + libMesh::pi * std::pow(wire_diameter, 2.0) / 8.0 / std::cos(theta);
382  // turbulent friction factor equation constant - Center subchannel
383  cT *= (pw_p / w_perim);
384  cT += wd_t * (3.0 * ar / a_p) * (Dh_i / wire_lead_length) *
385  std::pow((Dh_i / wire_diameter), 0.18);
386  // laminar friction factor equation constant - Center subchannel
387  cL *= (pw_p / w_perim);
388  cL += wd_l * (3.0 * ar / a_p) * (Dh_i / wire_lead_length) * (Dh_i / wire_diameter);
389  }
390  else if (subch_type == EChannelType::EDGE)
391  {
392  // wire projected area - edge subchannel wire-wrapped bundle
393  ar = libMesh::pi * (pin_diameter + wire_diameter) * wire_diameter / 4.0;
394  // bare Pin bundle edge subchannel flow area (normal area + wire area)
395  a_p = S + libMesh::pi * std::pow(wire_diameter, 2.0) / 8.0 / std::cos(theta);
396  // turbulent friction factor equation constant - Edge subchannel
397  cT *= std::pow((1 + ws_t * (ar / a_p) * std::pow(std::tan(theta), 2.0)), 1.41);
398  // laminar friction factor equation constant - Edge subchannel
399  cL *= (1 + ws_l * (ar / a_p) * std::pow(std::tan(theta), 2.0));
400  }
401  else
402  {
403  // wire projected area - corner subchannel wire-wrapped bundle
404  ar = libMesh::pi * (pin_diameter + wire_diameter) * wire_diameter / 6.0;
405  // bare Pin bundle corner subchannel flow area (normal area + wire area)
406  a_p = S + libMesh::pi * std::pow(wire_diameter, 2.0) / 24.0 / std::cos(theta);
407  // turbulent friction factor equation constant - Corner subchannel
408  cT *= std::pow((1 + ws_t * (ar / a_p) * std::pow(std::tan(theta), 2.0)), 1.41);
409  // laminar friction factor equation constant - Corner subchannel
410  cL *= (1 + ws_l * (ar / a_p) * std::pow(std::tan(theta), 2.0));
411  }
412  }
413 
414  // laminar friction factor
415  auto fL = cL / Re;
416  // turbulent friction factor
417  auto fT = cT / std::pow(Re, 0.18);
418 
419  if (Re < ReL)
420  {
421  // laminar flow
422  return fL;
423  }
424  else if (Re > ReT)
425  {
426  // turbulent flow
427  return fT;
428  }
429  else
430  {
431  // transient flow: psi definition uses a Bulk ReT/ReL number, same for all channels
432  return fL * std::pow((1 - psi), 1.0 / 3.0) * (1 - std::pow(psi, lambda)) +
433  fT * std::pow(psi, 1.0 / 3.0);
434  }
435 }
virtual const Real & getPinDiameter() const
Return Pin diameter.
virtual const Real & getDuctToPinGap() const
Return the the gap thickness between the duct and peripheral fuel pins.
virtual const Real & getPitch() const
Return the pitch between 2 subchannels.
virtual EChannelType getSubchannelType(unsigned int index) const =0
Return the type of the subchannel for given subchannel index.
static const std::string S
Definition: NS.h:163
static const std::string pitch
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual const Real & getWireLeadLength() const
Return the wire lead length.
MooseUnits pow(const MooseUnits &, int)
static const std::string cL
Definition: NS.h:111
const Real pi
virtual const Real & getWireDiameter() const
Return wire diameter.

◆ computeh()

void TriSubChannel1PhaseProblem::computeh ( int  iblock)
overrideprotectedvirtual

Computes Enthalpy per channel for block iblock.

Time derivative term

Advective derivative term

Axial heat conduction

TODO: Current axial derivative is zero - check if outflow conditions may make a difference

Radial Terms

Radial heat conduction

Add heat enthalpy from pin

Assembling system

Add all matrices together

Implements SubChannel1PhaseProblem.

Definition at line 592 of file TriSubChannel1PhaseProblem.C.

593 {
594  unsigned int last_node = (iblock + 1) * _block_size;
595  unsigned int first_node = iblock * _block_size + 1;
596  auto heated_length = _subchannel_mesh.getHeatedLength();
597  auto unheated_length_entry = _subchannel_mesh.getHeatedLengthEntry();
598  const Real & wire_lead_length = _tri_sch_mesh.getWireLeadLength();
599  const Real & wire_diameter = _tri_sch_mesh.getWireDiameter();
600  const Real & pitch = _subchannel_mesh.getPitch();
601  const Real & pin_diameter = _subchannel_mesh.getPinDiameter();
602 
603  if (iblock == 0)
604  {
605  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
606  {
607  auto * node = _subchannel_mesh.getChannelNode(i_ch, 0);
608  auto h_out = _fp->h_from_p_T((*_P_soln)(node) + _P_out, (*_T_soln)(node));
609  if (h_out < 0)
610  {
611  mooseError(
612  name(), " : Calculation of negative Enthalpy h_out = : ", h_out, " Axial Level= : ", 0);
613  }
614  _h_soln->set(node, h_out);
615  }
616  }
617 
618  if (!_implicit_bool)
619  {
620  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
621  {
622  auto z_grid = _subchannel_mesh.getZGrid();
623  auto dz = z_grid[iz] - z_grid[iz - 1];
624  Real gedge_ave = 0.0;
625  Real mdot_sum = 0.0;
626  Real si_sum = 0.0;
627  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
628  {
629  auto subch_type = _subchannel_mesh.getSubchannelType(i_ch);
630  if (subch_type == EChannelType::EDGE || subch_type == EChannelType::CORNER)
631  {
632  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
633  auto Si = (*_S_flow_soln)(node_in);
634  auto mdot_in = (*_mdot_soln)(node_in);
635  mdot_sum = mdot_sum + mdot_in;
636  si_sum = si_sum + Si;
637  }
638  }
639  gedge_ave = mdot_sum / si_sum;
640 
641  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
642  {
643  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
644  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
645  auto mdot_in = (*_mdot_soln)(node_in);
646  auto h_in = (*_h_soln)(node_in); // J/kg
647  auto volume = dz * (*_S_flow_soln)(node_in);
648  auto mdot_out = (*_mdot_soln)(node_out);
649  auto h_out = 0.0;
650  Real sumWijh = 0.0;
651  Real sumWijPrimeDhij = 0.0;
652  Real e_cond = 0.0;
653 
654  Real added_enthalpy;
655  if (z_grid[iz] > unheated_length_entry &&
656  z_grid[iz] <= unheated_length_entry + heated_length)
657  {
658  added_enthalpy = computeAddedHeatPin(i_ch, iz);
659  }
660  else
661  added_enthalpy = 0.0;
662 
663  added_enthalpy += computeAddedHeatDuct(i_ch, iz);
664 
665  // compute the sweep flow enthalpy change
666  auto subch_type = _subchannel_mesh.getSubchannelType(i_ch);
667  Real sweep_enthalpy = 0.0;
668 
669  if ((subch_type == EChannelType::EDGE || subch_type == EChannelType::CORNER) &&
670  (wire_diameter != 0.0) && (wire_lead_length != 0.0))
671  {
672  const Real & pitch = _subchannel_mesh.getPitch();
673  const Real & pin_diameter = _subchannel_mesh.getPinDiameter();
674  const Real & wire_lead_length = _tri_sch_mesh.getWireLeadLength();
675  const Real & wire_diameter = _tri_sch_mesh.getWireDiameter();
676  auto gap = _tri_sch_mesh.getDuctToPinGap();
677  auto w = pin_diameter + gap;
678  auto theta =
679  std::acos(wire_lead_length /
680  std::sqrt(std::pow(wire_lead_length, 2) +
681  std::pow(libMesh::pi * (pin_diameter + wire_diameter), 2)));
682  auto Sij = dz * gap;
683  auto Si = (*_S_flow_soln)(node_in);
684  // in/out channels for i_ch
685  auto sweep_in = _tri_sch_mesh.getSweepFlowChans(i_ch).first;
686  auto * node_sin = _subchannel_mesh.getChannelNode(sweep_in, iz - 1);
687 
688  // Calculation of flow regime
689  auto ReL = 320.0 * std::pow(10.0, pitch / pin_diameter - 1);
690  auto ReT = 10000.0 * std::pow(10.0, 0.7 * (pitch / pin_diameter - 1));
691  auto massflux = (*_mdot_soln)(node_in) / Si;
692  auto w_perim = (*_w_perim_soln)(node_in);
693  auto mu = (*_mu_soln)(node_in);
694  // hydraulic diameter
695  auto hD = 4.0 * Si / w_perim;
696  auto Re = massflux * hD / mu;
697  // Calculation of geometric parameters
698  auto Ar2 = libMesh::pi * (pin_diameter + wire_diameter) * wire_diameter / 4.0;
699  auto A2prime =
700  pitch * (w - pin_diameter / 2.0) - libMesh::pi * std::pow(pin_diameter, 2) / 8.0;
701  auto A2 = A2prime - libMesh::pi * std::pow(wire_diameter, 2) / 8.0 / std::cos(theta);
702  auto Cs = 0.0;
703  if (Re < ReL)
704  {
705  Cs = 0.033 * std::pow(wire_lead_length / pin_diameter, 0.3);
706  }
707  else if (Re > ReT)
708  {
709  Cs = 0.75 * std::pow(wire_lead_length / pin_diameter, 0.3);
710  }
711  else
712  {
713  auto psi = (std::log(Re) - std::log(ReL)) / (std::log(ReT) - std::log(ReL));
714  auto gamma = 2.0 / 3.0;
715  Cs = 0.75 * std::pow(wire_lead_length / pin_diameter, 0.3) +
716  (0.75 * std::pow(wire_lead_length / pin_diameter, 0.3) -
717  0.033 * std::pow(wire_lead_length / pin_diameter, 0.3)) *
718  std::pow(psi, gamma);
719  }
720  // Calculation of turbulent mixing parameter
721  auto beta = Cs * std::pow(Ar2 / A2, 0.5) * std::tan(theta);
722 
723  auto wsweep_in = gedge_ave * beta * Sij;
724  auto wsweep_out = gedge_ave * beta * Sij;
725  auto sweep_hin = (*_h_soln)(node_sin);
726  auto sweep_hout = (*_h_soln)(node_in);
727  sweep_enthalpy = (wsweep_in * sweep_hin - wsweep_out * sweep_hout);
728  }
729 
730  // Calculate sum of crossflow into channel i from channels j around i
731  unsigned int counter = 0;
732  for (auto i_gap : _subchannel_mesh.getChannelGaps(i_ch))
733  {
734  auto chans = _subchannel_mesh.getGapChannels(i_gap);
735  unsigned int ii_ch = chans.first;
736  // i is always the smallest and first index in the mapping
737  unsigned int jj_ch = chans.second;
738  auto * node_in_i = _subchannel_mesh.getChannelNode(ii_ch, iz - 1);
739  auto * node_in_j = _subchannel_mesh.getChannelNode(jj_ch, iz - 1);
740  // Define donor enthalpy
741  auto h_star = 0.0;
742  if (_Wij(i_gap, iz) > 0.0)
743  h_star = (*_h_soln)(node_in_i);
744  else if (_Wij(i_gap, iz) < 0.0)
745  h_star = (*_h_soln)(node_in_j);
746  // take care of the sign by applying the map, use donor cell
747  sumWijh += _subchannel_mesh.getCrossflowSign(i_ch, counter) * _Wij(i_gap, iz) * h_star;
748  sumWijPrimeDhij += _WijPrime(i_gap, iz) * (2 * (*_h_soln)(node_in) -
749  (*_h_soln)(node_in_j) - (*_h_soln)(node_in_i));
750  counter++;
751 
752  // compute the radial heat conduction through the gaps
753  auto subch_type_i = _subchannel_mesh.getSubchannelType(ii_ch);
754  auto subch_type_j = _subchannel_mesh.getSubchannelType(jj_ch);
755  Real dist_ij = pitch;
756 
757  if (subch_type_i == EChannelType::EDGE && subch_type_j == EChannelType::EDGE)
758  {
759  dist_ij = pitch;
760  }
761  else if ((subch_type_i == EChannelType::CORNER && subch_type_j == EChannelType::EDGE) ||
762  (subch_type_i == EChannelType::EDGE && subch_type_j == EChannelType::CORNER))
763  {
764  dist_ij = pitch;
765  }
766  else
767  {
768  dist_ij = pitch / std::sqrt(3);
769  }
770 
771  auto Sij = dz * _subchannel_mesh.getGapWidth(iz, i_gap);
772  auto thcon_i = _fp->k_from_p_T((*_P_soln)(node_in_i) + _P_out, (*_T_soln)(node_in_i));
773  auto thcon_j = _fp->k_from_p_T((*_P_soln)(node_in_j) + _P_out, (*_T_soln)(node_in_j));
774  auto shape_factor =
775  0.66 * (pitch / pin_diameter) *
776  std::pow((_subchannel_mesh.getGapWidth(iz, i_gap) / pin_diameter), -0.3);
777  if (ii_ch == i_ch)
778  {
779  e_cond += 0.5 * (thcon_i + thcon_j) * Sij * shape_factor *
780  ((*_T_soln)(node_in_j) - (*_T_soln)(node_in_i)) / dist_ij;
781  }
782  else
783  {
784  e_cond += -0.5 * (thcon_i + thcon_j) * Sij * shape_factor *
785  ((*_T_soln)(node_in_j) - (*_T_soln)(node_in_i)) / dist_ij;
786  }
787  }
788 
789  // compute the axial heat conduction between current and lower axial node
790  auto * node_in_i = _subchannel_mesh.getChannelNode(i_ch, iz);
791  auto * node_in_j = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
792  auto thcon_i = _fp->k_from_p_T((*_P_soln)(node_in_i) + _P_out, (*_T_soln)(node_in_i));
793  auto thcon_j = _fp->k_from_p_T((*_P_soln)(node_in_j) + _P_out, (*_T_soln)(node_in_j));
794  auto Si = (*_S_flow_soln)(node_in_i);
795  auto dist_ij = z_grid[iz] - z_grid[iz - 1];
796 
797  e_cond += 0.5 * (thcon_i + thcon_j) * Si * ((*_T_soln)(node_in_j) - (*_T_soln)(node_in_i)) /
798  dist_ij;
799 
800  unsigned int nz = _subchannel_mesh.getNumOfAxialCells();
801  // compute the axial heat conduction between current and upper axial node
802  if (iz < nz)
803  {
804  auto * node_in_i = _subchannel_mesh.getChannelNode(i_ch, iz);
805  auto * node_in_j = _subchannel_mesh.getChannelNode(i_ch, iz + 1);
806  auto thcon_i = _fp->k_from_p_T((*_P_soln)(node_in_i) + _P_out, (*_T_soln)(node_in_i));
807  auto thcon_j = _fp->k_from_p_T((*_P_soln)(node_in_j) + _P_out, (*_T_soln)(node_in_j));
808  auto Si = (*_S_flow_soln)(node_in_i);
809  auto dist_ij = z_grid[iz + 1] - z_grid[iz];
810  e_cond += 0.5 * (thcon_i + thcon_j) * Si *
811  ((*_T_soln)(node_in_j) - (*_T_soln)(node_in_i)) / dist_ij;
812  }
813 
814  // end of radial heat conduction calc.
815  h_out =
816  (mdot_in * h_in - sumWijh - sumWijPrimeDhij + added_enthalpy + e_cond + sweep_enthalpy +
817  _TR * _rho_soln->old(node_out) * _h_soln->old(node_out) * volume / _dt) /
818  (mdot_out + _TR * (*_rho_soln)(node_out)*volume / _dt);
819  if (h_out < 0)
820  {
821  mooseError(name(),
822  " : Calculation of negative Enthalpy h_out = : ",
823  h_out,
824  " Axial Level= : ",
825  iz);
826  }
827  _h_soln->set(node_out, h_out); // J/kg
828  }
829  }
830  }
831  else
832  {
833  LibmeshPetscCall(MatZeroEntries(_hc_time_derivative_mat));
834  LibmeshPetscCall(MatZeroEntries(_hc_advective_derivative_mat));
835  LibmeshPetscCall(MatZeroEntries(_hc_cross_derivative_mat));
836  LibmeshPetscCall(MatZeroEntries(_hc_axial_heat_conduction_mat));
837  LibmeshPetscCall(MatZeroEntries(_hc_radial_heat_conduction_mat));
838  LibmeshPetscCall(MatZeroEntries(_hc_sweep_enthalpy_mat));
839 
840  LibmeshPetscCall(VecZeroEntries(_hc_time_derivative_rhs));
841  LibmeshPetscCall(VecZeroEntries(_hc_advective_derivative_rhs));
842  LibmeshPetscCall(VecZeroEntries(_hc_cross_derivative_rhs));
843  LibmeshPetscCall(VecZeroEntries(_hc_added_heat_rhs));
844  LibmeshPetscCall(VecZeroEntries(_hc_axial_heat_conduction_rhs));
845  LibmeshPetscCall(VecZeroEntries(_hc_radial_heat_conduction_rhs));
846  LibmeshPetscCall(VecZeroEntries(_hc_sweep_enthalpy_rhs));
847 
848  LibmeshPetscCall(MatZeroEntries(_hc_sys_h_mat));
849  LibmeshPetscCall(VecZeroEntries(_hc_sys_h_rhs));
850 
851  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
852  {
853  auto dz = _z_grid[iz] - _z_grid[iz - 1];
854  auto heated_length = _subchannel_mesh.getHeatedLength();
855  auto unheated_length_entry = _subchannel_mesh.getHeatedLengthEntry();
857  auto pin_diameter = _subchannel_mesh.getPinDiameter();
858  auto iz_ind = iz - first_node;
859 
860  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
861  {
862  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
863  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
864  auto S_in = (*_S_flow_soln)(node_in);
865  auto S_out = (*_S_flow_soln)(node_out);
866  auto S_interp = computeInterpolatedValue(S_out, S_in, 0.5);
867  auto volume = dz * S_interp;
868 
869  PetscScalar Pe = 0.5;
870  if (_interpolation_scheme == 3)
871  {
872  // Compute the Peclet number
873  auto w_perim_in = (*_w_perim_soln)(node_in);
874  auto w_perim_out = (*_w_perim_soln)(node_out);
875  auto w_perim_interp = this->computeInterpolatedValue(w_perim_out, w_perim_in, 0.5);
876  auto K_in = _fp->k_from_p_T((*_P_soln)(node_in) + _P_out, (*_T_soln)(node_in));
877  auto K_out = _fp->k_from_p_T((*_P_soln)(node_out) + _P_out, (*_T_soln)(node_out));
878  auto K = this->computeInterpolatedValue(K_out, K_in, 0.5);
879  auto cp_in = _fp->cp_from_p_T((*_P_soln)(node_in) + _P_out, (*_T_soln)(node_in));
880  auto cp_out = _fp->cp_from_p_T((*_P_soln)(node_out) + _P_out, (*_T_soln)(node_out));
881  auto cp = this->computeInterpolatedValue(cp_out, cp_in, 0.5);
882  auto mdot_loc =
883  this->computeInterpolatedValue((*_mdot_soln)(node_out), (*_mdot_soln)(node_in), 0.5);
884  // hydraulic diameter in the i direction
885  auto Dh_i = 4.0 * S_interp / w_perim_interp;
886  Pe = mdot_loc * Dh_i * cp / (K * S_interp) * (mdot_loc / std::abs(mdot_loc));
887  }
889 
891  if (iz == first_node)
892  {
893  PetscScalar value_vec_tt =
894  -1.0 * _TR * alpha * (*_rho_soln)(node_in) * (*_h_soln)(node_in)*volume / _dt;
895  PetscInt row_vec_tt = i_ch + _n_channels * iz_ind;
896  LibmeshPetscCall(
897  VecSetValues(_hc_time_derivative_rhs, 1, &row_vec_tt, &value_vec_tt, ADD_VALUES));
898  }
899  else
900  {
901  PetscInt row_tt = i_ch + _n_channels * iz_ind;
902  PetscInt col_tt = i_ch + _n_channels * (iz_ind - 1);
903  PetscScalar value_tt = _TR * alpha * (*_rho_soln)(node_in)*volume / _dt;
904  LibmeshPetscCall(MatSetValues(
905  _hc_time_derivative_mat, 1, &row_tt, 1, &col_tt, &value_tt, INSERT_VALUES));
906  }
907 
908  // Adding diagonal elements
909  PetscInt row_tt = i_ch + _n_channels * iz_ind;
910  PetscInt col_tt = i_ch + _n_channels * iz_ind;
911  PetscScalar value_tt = _TR * (1.0 - alpha) * (*_rho_soln)(node_out)*volume / _dt;
912  LibmeshPetscCall(MatSetValues(
913  _hc_time_derivative_mat, 1, &row_tt, 1, &col_tt, &value_tt, INSERT_VALUES));
914 
915  // Adding RHS elements
916  PetscScalar rho_old_interp =
917  computeInterpolatedValue(_rho_soln->old(node_out), _rho_soln->old(node_in), Pe);
918  PetscScalar h_old_interp =
919  computeInterpolatedValue(_h_soln->old(node_out), _h_soln->old(node_in), Pe);
920  PetscScalar value_vec_tt = _TR * rho_old_interp * h_old_interp * volume / _dt;
921  PetscInt row_vec_tt = i_ch + _n_channels * iz_ind;
922  LibmeshPetscCall(
923  VecSetValues(_hc_time_derivative_rhs, 1, &row_vec_tt, &value_vec_tt, ADD_VALUES));
924 
926  if (iz == first_node)
927  {
928  PetscInt row_at = i_ch + _n_channels * iz_ind;
929  PetscScalar value_at = alpha * (*_mdot_soln)(node_in) * (*_h_soln)(node_in);
930  LibmeshPetscCall(
931  VecSetValues(_hc_advective_derivative_rhs, 1, &row_at, &value_at, ADD_VALUES));
932 
933  value_at = alpha * (*_mdot_soln)(node_out) - (1 - alpha) * (*_mdot_soln)(node_in);
934  PetscInt col_at = i_ch + _n_channels * iz_ind;
935  LibmeshPetscCall(MatSetValues(
936  _hc_advective_derivative_mat, 1, &row_at, 1, &col_at, &value_at, ADD_VALUES));
937 
938  value_at = (1 - alpha) * (*_mdot_soln)(node_out);
939  col_at = i_ch + _n_channels * (iz_ind + 1);
940  LibmeshPetscCall(MatSetValues(
941  _hc_advective_derivative_mat, 1, &row_at, 1, &col_at, &value_at, ADD_VALUES));
942  }
943  else if (iz == last_node)
944  {
945  PetscInt row_at = i_ch + _n_channels * iz_ind;
946  PetscScalar value_at = 1.0 * (*_mdot_soln)(node_out);
947  PetscInt col_at = i_ch + _n_channels * iz_ind;
948  LibmeshPetscCall(MatSetValues(
949  _hc_advective_derivative_mat, 1, &row_at, 1, &col_at, &value_at, ADD_VALUES));
950 
951  value_at = -1.0 * (*_mdot_soln)(node_in);
952  col_at = i_ch + _n_channels * (iz_ind - 1);
953  LibmeshPetscCall(MatSetValues(
954  _hc_advective_derivative_mat, 1, &row_at, 1, &col_at, &value_at, ADD_VALUES));
955  }
956  else
957  {
958  PetscInt row_at = i_ch + _n_channels * iz_ind;
959  PetscInt col_at;
960 
961  PetscScalar value_at = -alpha * (*_mdot_soln)(node_in);
962  col_at = i_ch + _n_channels * (iz_ind - 1);
963  LibmeshPetscCall(MatSetValues(
964  _hc_advective_derivative_mat, 1, &row_at, 1, &col_at, &value_at, ADD_VALUES));
965 
966  value_at = alpha * (*_mdot_soln)(node_out) - (1 - alpha) * (*_mdot_soln)(node_in);
967  col_at = i_ch + _n_channels * iz_ind;
968  LibmeshPetscCall(MatSetValues(
969  _hc_advective_derivative_mat, 1, &row_at, 1, &col_at, &value_at, ADD_VALUES));
970 
971  value_at = (1 - alpha) * (*_mdot_soln)(node_out);
972  col_at = i_ch + _n_channels * (iz_ind + 1);
973  LibmeshPetscCall(MatSetValues(
974  _hc_advective_derivative_mat, 1, &row_at, 1, &col_at, &value_at, ADD_VALUES));
975  }
976 
978  auto * node_center = _subchannel_mesh.getChannelNode(i_ch, iz);
979  auto K_center = _fp->k_from_p_T((*_P_soln)(node_center) + _P_out, (*_T_soln)(node_center));
980  auto cp_center =
981  _fp->cp_from_p_T((*_P_soln)(node_center) + _P_out, (*_T_soln)(node_center));
982  auto diff_center = K_center / (cp_center + 1e-15);
983 
984  if (iz == first_node)
985  {
986  auto * node_top = _subchannel_mesh.getChannelNode(i_ch, iz + 1);
987  auto * node_bottom = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
988  auto K_bottom =
989  _fp->k_from_p_T((*_P_soln)(node_bottom) + _P_out, (*_T_soln)(node_bottom));
990  auto K_top = _fp->k_from_p_T((*_P_soln)(node_top) + _P_out, (*_T_soln)(node_top));
991  auto cp_bottom =
992  _fp->cp_from_p_T((*_P_soln)(node_bottom) + _P_out, (*_T_soln)(node_bottom));
993  auto cp_top = _fp->cp_from_p_T((*_P_soln)(node_top) + _P_out, (*_T_soln)(node_top));
994  auto diff_bottom = K_bottom / (cp_bottom + 1e-15);
995  auto diff_top = K_top / (cp_top + 1e-15);
996 
997  auto dz_up = _z_grid[iz + 1] - _z_grid[iz];
998  auto dz_down = _z_grid[iz] - _z_grid[iz - 1];
999  auto S_up =
1000  computeInterpolatedValue((*_S_flow_soln)(node_top), (*_S_flow_soln)(node_center));
1001  auto S_down =
1002  computeInterpolatedValue((*_S_flow_soln)(node_center), (*_S_flow_soln)(node_bottom));
1003  auto diff_up = computeInterpolatedValue(diff_top, diff_center);
1004  auto diff_down = computeInterpolatedValue(diff_center, diff_bottom);
1005 
1006  // Diagonal value
1007  PetscInt row_at = i_ch + _n_channels * iz_ind;
1008  PetscInt col_at = i_ch + _n_channels * iz_ind;
1009  PetscScalar value_at = diff_up * S_up / dz_up + diff_down * S_down / dz_down;
1010  LibmeshPetscCall(MatSetValues(
1011  _hc_axial_heat_conduction_mat, 1, &row_at, 1, &col_at, &value_at, INSERT_VALUES));
1012 
1013  // Bottom value
1014  value_at = 1.0 * diff_down * S_down / dz_down * (*_h_soln)(node_bottom);
1015  LibmeshPetscCall(
1016  VecSetValues(_hc_axial_heat_conduction_rhs, 1, &row_at, &value_at, ADD_VALUES));
1017 
1018  // Top value
1019  col_at = i_ch + _n_channels * (iz_ind + 1);
1020  value_at = -diff_up * S_up / dz_up;
1021  LibmeshPetscCall(MatSetValues(
1022  _hc_axial_heat_conduction_mat, 1, &row_at, 1, &col_at, &value_at, INSERT_VALUES));
1023  }
1024  else if (iz == last_node)
1025  {
1026  auto * node_bottom = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1027  auto K_bottom =
1028  _fp->k_from_p_T((*_P_soln)(node_bottom) + _P_out, (*_T_soln)(node_bottom));
1029  auto cp_bottom =
1030  _fp->cp_from_p_T((*_P_soln)(node_bottom) + _P_out, (*_T_soln)(node_bottom));
1031  auto diff_bottom = K_bottom / (cp_bottom + 1e-15);
1032 
1033  auto dz_down = _z_grid[iz] - _z_grid[iz - 1];
1034  auto S_down = 0.5 * ((*_S_flow_soln)(node_center) + (*_S_flow_soln)(node_bottom));
1035  auto diff_down = 0.5 * (diff_center + diff_bottom);
1036 
1037  // Diagonal value
1038  PetscInt row_at = i_ch + _n_channels * iz_ind;
1039  PetscInt col_at = i_ch + _n_channels * iz_ind;
1040  PetscScalar value_at = diff_down * S_down / dz_down;
1041  LibmeshPetscCall(MatSetValues(
1042  _hc_axial_heat_conduction_mat, 1, &row_at, 1, &col_at, &value_at, INSERT_VALUES));
1043 
1044  // Bottom value
1045  col_at = i_ch + _n_channels * (iz_ind - 1);
1046  value_at = -diff_down * S_down / dz_down;
1047  LibmeshPetscCall(MatSetValues(
1048  _hc_axial_heat_conduction_mat, 1, &row_at, 1, &col_at, &value_at, INSERT_VALUES));
1049 
1050  // Outflow derivative
1052  // value_at = -1.0 * (*_mdot_soln)(node_center) * (*_h_soln)(node_center);
1053  // VecSetValues(_hc_axial_heat_conduction_rhs, 1, &row_at, &value_at, ADD_VALUES);
1054  }
1055  else
1056  {
1057  auto * node_top = _subchannel_mesh.getChannelNode(i_ch, iz + 1);
1058  auto * node_bottom = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1059  auto K_bottom =
1060  _fp->k_from_p_T((*_P_soln)(node_bottom) + _P_out, (*_T_soln)(node_bottom));
1061  auto K_top = _fp->k_from_p_T((*_P_soln)(node_top) + _P_out, (*_T_soln)(node_top));
1062  auto cp_bottom =
1063  _fp->cp_from_p_T((*_P_soln)(node_bottom) + _P_out, (*_T_soln)(node_bottom));
1064  auto cp_top = _fp->cp_from_p_T((*_P_soln)(node_top) + _P_out, (*_T_soln)(node_top));
1065  auto diff_bottom = K_bottom / (cp_bottom + 1e-15);
1066  auto diff_top = K_top / (cp_top + 1e-15);
1067 
1068  auto dz_up = _z_grid[iz + 1] - _z_grid[iz];
1069  auto dz_down = _z_grid[iz] - _z_grid[iz - 1];
1070  auto S_up =
1071  computeInterpolatedValue((*_S_flow_soln)(node_top), (*_S_flow_soln)(node_center));
1072  auto S_down =
1073  computeInterpolatedValue((*_S_flow_soln)(node_center), (*_S_flow_soln)(node_bottom));
1074  auto diff_up = computeInterpolatedValue(diff_top, diff_center);
1075  auto diff_down = computeInterpolatedValue(diff_center, diff_bottom);
1076 
1077  // Diagonal value
1078  PetscInt row_at = i_ch + _n_channels * iz_ind;
1079  PetscInt col_at = i_ch + _n_channels * iz_ind;
1080  PetscScalar value_at = diff_up * S_up / dz_up + diff_down * S_down / dz_down;
1081  LibmeshPetscCall(MatSetValues(
1082  _hc_axial_heat_conduction_mat, 1, &row_at, 1, &col_at, &value_at, INSERT_VALUES));
1083 
1084  // Bottom value
1085  col_at = i_ch + _n_channels * (iz_ind - 1);
1086  value_at = -diff_down * S_down / dz_down;
1087  LibmeshPetscCall(MatSetValues(
1088  _hc_axial_heat_conduction_mat, 1, &row_at, 1, &col_at, &value_at, INSERT_VALUES));
1089 
1090  // Top value
1091  col_at = i_ch + _n_channels * (iz_ind + 1);
1092  value_at = -diff_up * S_up / dz_up;
1093  LibmeshPetscCall(MatSetValues(
1094  _hc_axial_heat_conduction_mat, 1, &row_at, 1, &col_at, &value_at, INSERT_VALUES));
1095  }
1096 
1098  unsigned int counter = 0;
1099  unsigned int cross_index = iz;
1100  // Real radial_heat_conduction(0.0);
1101  for (auto i_gap : _subchannel_mesh.getChannelGaps(i_ch))
1102  {
1103  auto chans = _subchannel_mesh.getGapChannels(i_gap);
1104  unsigned int ii_ch = chans.first;
1105  unsigned int jj_ch = chans.second;
1106  auto * node_in_i = _subchannel_mesh.getChannelNode(ii_ch, iz - 1);
1107  auto * node_in_j = _subchannel_mesh.getChannelNode(jj_ch, iz - 1);
1108  PetscScalar h_star;
1109  // figure out donor axial velocity
1110  if (_Wij(i_gap, cross_index) > 0.0)
1111  {
1112  if (iz == first_node)
1113  {
1114  h_star = (*_h_soln)(node_in_i);
1115  PetscScalar value_vec_ct = -1.0 * alpha *
1116  _subchannel_mesh.getCrossflowSign(i_ch, counter) *
1117  _Wij(i_gap, cross_index) * h_star;
1118  PetscInt row_vec_ct = i_ch + _n_channels * iz_ind;
1119  LibmeshPetscCall(VecSetValues(
1120  _hc_cross_derivative_rhs, 1, &row_vec_ct, &value_vec_ct, ADD_VALUES));
1121  }
1122  else
1123  {
1124  PetscScalar value_ct = alpha * _subchannel_mesh.getCrossflowSign(i_ch, counter) *
1125  _Wij(i_gap, cross_index);
1126  PetscInt row_ct = i_ch + _n_channels * iz_ind;
1127  PetscInt col_ct = ii_ch + _n_channels * (iz_ind - 1);
1128  LibmeshPetscCall(MatSetValues(
1129  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_ct, ADD_VALUES));
1130  }
1131  PetscScalar value_ct = (1.0 - alpha) *
1132  _subchannel_mesh.getCrossflowSign(i_ch, counter) *
1133  _Wij(i_gap, cross_index);
1134  PetscInt row_ct = i_ch + _n_channels * iz_ind;
1135  PetscInt col_ct = ii_ch + _n_channels * iz_ind;
1136  LibmeshPetscCall(MatSetValues(
1137  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_ct, ADD_VALUES));
1138  }
1139  else if (_Wij(i_gap, cross_index) < 0.0) // _Wij=0 operations not necessary
1140  {
1141  if (iz == first_node)
1142  {
1143  h_star = (*_h_soln)(node_in_j);
1144  PetscScalar value_vec_ct = -1.0 * alpha *
1145  _subchannel_mesh.getCrossflowSign(i_ch, counter) *
1146  _Wij(i_gap, cross_index) * h_star;
1147  PetscInt row_vec_ct = i_ch + _n_channels * iz_ind;
1148  LibmeshPetscCall(VecSetValues(
1149  _hc_cross_derivative_rhs, 1, &row_vec_ct, &value_vec_ct, ADD_VALUES));
1150  }
1151  else
1152  {
1153  PetscScalar value_ct = alpha * _subchannel_mesh.getCrossflowSign(i_ch, counter) *
1154  _Wij(i_gap, cross_index);
1155  PetscInt row_ct = i_ch + _n_channels * iz_ind;
1156  PetscInt col_ct = jj_ch + _n_channels * (iz_ind - 1);
1157  LibmeshPetscCall(MatSetValues(
1158  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_ct, ADD_VALUES));
1159  }
1160  PetscScalar value_ct = (1.0 - alpha) *
1161  _subchannel_mesh.getCrossflowSign(i_ch, counter) *
1162  _Wij(i_gap, cross_index);
1163  PetscInt row_ct = i_ch + _n_channels * iz_ind;
1164  PetscInt col_ct = jj_ch + _n_channels * iz_ind;
1165  LibmeshPetscCall(MatSetValues(
1166  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_ct, ADD_VALUES));
1167  }
1168 
1169  // Turbulent cross flows
1170  if (iz == first_node)
1171  {
1172  PetscScalar value_vec_ct =
1173  -2.0 * alpha * (*_h_soln)(node_in)*_WijPrime(i_gap, cross_index);
1174  value_vec_ct += alpha * (*_h_soln)(node_in_j)*_WijPrime(i_gap, cross_index);
1175  value_vec_ct += alpha * (*_h_soln)(node_in_i)*_WijPrime(i_gap, cross_index);
1176  PetscInt row_vec_ct = i_ch + _n_channels * iz_ind;
1177  LibmeshPetscCall(
1178  VecSetValues(_hc_cross_derivative_rhs, 1, &row_vec_ct, &value_vec_ct, ADD_VALUES));
1179  }
1180  else
1181  {
1182  PetscScalar value_center_ct = 2.0 * alpha * _WijPrime(i_gap, cross_index);
1183  PetscInt row_ct = i_ch + _n_channels * iz_ind;
1184  PetscInt col_ct = i_ch + _n_channels * (iz_ind - 1);
1185  LibmeshPetscCall(MatSetValues(
1186  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_center_ct, ADD_VALUES));
1187 
1188  PetscScalar value_left_ct = -1.0 * alpha * _WijPrime(i_gap, cross_index);
1189  row_ct = i_ch + _n_channels * iz_ind;
1190  col_ct = jj_ch + _n_channels * (iz_ind - 1);
1191  LibmeshPetscCall(MatSetValues(
1192  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_left_ct, ADD_VALUES));
1193 
1194  PetscScalar value_right_ct = -1.0 * alpha * _WijPrime(i_gap, cross_index);
1195  row_ct = i_ch + _n_channels * iz_ind;
1196  col_ct = ii_ch + _n_channels * (iz_ind - 1);
1197  LibmeshPetscCall(MatSetValues(
1198  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_right_ct, ADD_VALUES));
1199  }
1200  PetscScalar value_center_ct = 2.0 * (1.0 - alpha) * _WijPrime(i_gap, cross_index);
1201  PetscInt row_ct = i_ch + _n_channels * iz_ind;
1202  PetscInt col_ct = i_ch + _n_channels * iz_ind;
1203  LibmeshPetscCall(MatSetValues(
1204  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_center_ct, ADD_VALUES));
1205 
1206  PetscScalar value_left_ct = -1.0 * (1.0 - alpha) * _WijPrime(i_gap, cross_index);
1207  row_ct = i_ch + _n_channels * iz_ind;
1208  col_ct = jj_ch + _n_channels * iz_ind;
1209  LibmeshPetscCall(MatSetValues(
1210  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_left_ct, ADD_VALUES));
1211 
1212  PetscScalar value_right_ct = -1.0 * (1.0 - alpha) * _WijPrime(i_gap, cross_index);
1213  row_ct = i_ch + _n_channels * iz_ind;
1214  col_ct = ii_ch + _n_channels * iz_ind;
1215  LibmeshPetscCall(MatSetValues(
1216  _hc_cross_derivative_mat, 1, &row_ct, 1, &col_ct, &value_right_ct, ADD_VALUES));
1217 
1219  auto subch_type_i = _subchannel_mesh.getSubchannelType(ii_ch);
1220  auto subch_type_j = _subchannel_mesh.getSubchannelType(jj_ch);
1221  Real dist_ij = pitch;
1222 
1223  if (subch_type_i == EChannelType::EDGE && subch_type_j == EChannelType::EDGE)
1224  {
1225  dist_ij = pitch;
1226  }
1227  else if ((subch_type_i == EChannelType::CORNER && subch_type_j == EChannelType::EDGE) ||
1228  (subch_type_i == EChannelType::EDGE && subch_type_j == EChannelType::CORNER))
1229  {
1230  dist_ij = pitch;
1231  }
1232  else
1233  {
1234  dist_ij = pitch / std::sqrt(3);
1235  }
1236 
1237  auto Sij = dz * _subchannel_mesh.getGapWidth(iz, i_gap);
1238  auto K_i = _fp->k_from_p_T((*_P_soln)(node_in_i) + _P_out, (*_T_soln)(node_in_i));
1239  auto K_j = _fp->k_from_p_T((*_P_soln)(node_in_j) + _P_out, (*_T_soln)(node_in_j));
1240  auto cp_i = _fp->cp_from_p_T((*_P_soln)(node_in_i) + _P_out, (*_T_soln)(node_in_i));
1241  auto cp_j = _fp->cp_from_p_T((*_P_soln)(node_in_j) + _P_out, (*_T_soln)(node_in_j));
1242  auto A_i = K_i / cp_i;
1243  auto A_j = K_j / cp_j;
1244  auto harm_A = 2.0 * A_i * A_j / (A_i + A_j);
1245  auto shape_factor =
1246  0.66 * (pitch / pin_diameter) *
1247  std::pow((_subchannel_mesh.getGapWidth(iz, i_gap) / pin_diameter), -0.3);
1248  // auto base_value = 0.5 * (A_i + A_j) * Sij * shape_factor / dist_ij;
1249  auto base_value = harm_A * shape_factor * Sij / dist_ij;
1250  auto neg_base_value = -1.0 * base_value;
1251 
1252  row_ct = ii_ch + _n_channels * iz_ind;
1253  col_ct = ii_ch + _n_channels * iz_ind;
1254  LibmeshPetscCall(MatSetValues(
1255  _hc_radial_heat_conduction_mat, 1, &row_ct, 1, &col_ct, &base_value, ADD_VALUES));
1256 
1257  row_ct = jj_ch + _n_channels * iz_ind;
1258  col_ct = jj_ch + _n_channels * iz_ind;
1259  LibmeshPetscCall(MatSetValues(
1260  _hc_radial_heat_conduction_mat, 1, &row_ct, 1, &col_ct, &base_value, ADD_VALUES));
1261 
1262  row_ct = ii_ch + _n_channels * iz_ind;
1263  col_ct = jj_ch + _n_channels * iz_ind;
1264  LibmeshPetscCall(MatSetValues(
1265  _hc_radial_heat_conduction_mat, 1, &row_ct, 1, &col_ct, &neg_base_value, ADD_VALUES));
1266 
1267  row_ct = jj_ch + _n_channels * iz_ind;
1268  col_ct = ii_ch + _n_channels * iz_ind;
1269  LibmeshPetscCall(MatSetValues(
1270  _hc_radial_heat_conduction_mat, 1, &row_ct, 1, &col_ct, &neg_base_value, ADD_VALUES));
1271  counter++;
1272  }
1273 
1274  // compute the sweep flow enthalpy change
1275  Real gedge_ave = 0.0;
1276  Real mdot_sum = 0.0;
1277  Real si_sum = 0.0;
1278  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1279  {
1280  auto subch_type = _subchannel_mesh.getSubchannelType(i_ch);
1281  if (subch_type == EChannelType::EDGE || subch_type == EChannelType::CORNER)
1282  {
1283  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1284  auto Si = (*_S_flow_soln)(node_in);
1285  auto mdot_in = (*_mdot_soln)(node_in);
1286  mdot_sum = mdot_sum + mdot_in;
1287  si_sum = si_sum + Si;
1288  }
1289  }
1290  gedge_ave = mdot_sum / si_sum;
1291  auto subch_type = _subchannel_mesh.getSubchannelType(i_ch);
1292  PetscScalar sweep_enthalpy = 0.0;
1293  if ((subch_type == EChannelType::EDGE || subch_type == EChannelType::CORNER) &&
1294  (wire_diameter != 0.0) && (wire_lead_length != 0.0))
1295  {
1296  const Real & pitch = _subchannel_mesh.getPitch();
1297  const Real & pin_diameter = _subchannel_mesh.getPinDiameter();
1298  const Real & wire_lead_length = _tri_sch_mesh.getWireLeadLength();
1299  const Real & wire_diameter = _tri_sch_mesh.getWireDiameter();
1300  auto gap = _tri_sch_mesh.getDuctToPinGap();
1301  auto w = pin_diameter + gap;
1302  auto theta =
1303  std::acos(wire_lead_length /
1304  std::sqrt(std::pow(wire_lead_length, 2) +
1305  std::pow(libMesh::pi * (pin_diameter + wire_diameter), 2)));
1306  auto Sij = dz * gap;
1307  auto Si = (*_S_flow_soln)(node_in);
1308  // in/out channels for i_ch
1309  auto sweep_in = _tri_sch_mesh.getSweepFlowChans(i_ch).first;
1310  auto * node_sin = _subchannel_mesh.getChannelNode(sweep_in, iz - 1);
1311 
1312  // Calculation of flow regime
1313  auto ReL = 320.0 * std::pow(10.0, pitch / pin_diameter - 1);
1314  auto ReT = 10000.0 * std::pow(10.0, 0.7 * (pitch / pin_diameter - 1));
1315  auto massflux = (*_mdot_soln)(node_in) / Si;
1316  auto w_perim = (*_w_perim_soln)(node_in);
1317  auto mu = (*_mu_soln)(node_in);
1318  // hydraulic diameter
1319  auto hD = 4.0 * Si / w_perim;
1320  auto Re = massflux * hD / mu;
1321  // Calculation of geometric parameters
1322  auto Ar2 = libMesh::pi * (pin_diameter + wire_diameter) * wire_diameter / 4.0;
1323  auto A2prime =
1324  pitch * (w - pin_diameter / 2.0) - libMesh::pi * std::pow(pin_diameter, 2) / 8.0;
1325  auto A2 = A2prime - libMesh::pi * std::pow(wire_diameter, 2) / 8.0 / std::cos(theta);
1326  auto Cs = 0.0;
1327  if (Re < ReL)
1328  {
1329  Cs = 0.033 * std::pow(wire_lead_length / pin_diameter, 0.3);
1330  }
1331  else if (Re > ReT)
1332  {
1333  Cs = 0.75 * std::pow(wire_lead_length / pin_diameter, 0.3);
1334  }
1335  else
1336  {
1337  auto psi = (std::log(Re) - std::log(ReL)) / (std::log(ReT) - std::log(ReL));
1338  auto gamma = 2.0 / 3.0;
1339  Cs = 0.75 * std::pow(wire_lead_length / pin_diameter, 0.3) +
1340  (0.75 * std::pow(wire_lead_length / pin_diameter, 0.3) -
1341  0.033 * std::pow(wire_lead_length / pin_diameter, 0.3)) *
1342  std::pow(psi, gamma);
1343  }
1344  // Calculation of turbulent mixing parameter
1345  auto beta = Cs * std::pow(Ar2 / A2, 0.5) * std::tan(theta);
1346 
1347  auto wsweep_in = gedge_ave * beta * Sij;
1348  auto wsweep_out = gedge_ave * beta * Sij;
1349  auto sweep_hin = (*_h_soln)(node_sin);
1350  auto sweep_hout = (*_h_soln)(node_in);
1351  sweep_enthalpy = (wsweep_in * sweep_hin - wsweep_out * sweep_hout);
1352 
1353  if (iz == first_node)
1354  {
1355  PetscInt row_sh = i_ch + _n_channels * iz_ind;
1356  PetscScalar value_hs = -sweep_enthalpy;
1357  LibmeshPetscCall(
1358  VecSetValues(_hc_sweep_enthalpy_rhs, 1, &row_sh, &value_hs, ADD_VALUES));
1359  }
1360  else
1361  {
1362  PetscInt row_sh = i_ch + _n_channels * (iz_ind - 1);
1363  PetscInt col_sh = i_ch + _n_channels * (iz_ind - 1);
1364  LibmeshPetscCall(MatSetValues(
1365  _hc_sweep_enthalpy_mat, 1, &row_sh, 1, &col_sh, &wsweep_out, ADD_VALUES));
1366  PetscInt col_sh_l = sweep_in + _n_channels * (iz_ind - 1);
1367  PetscScalar neg_sweep_in = -1.0 * wsweep_in;
1368  LibmeshPetscCall(MatSetValues(
1369  _hc_sweep_enthalpy_mat, 1, &row_sh, 1, &col_sh_l, &(neg_sweep_in), ADD_VALUES));
1370  }
1371  }
1372 
1374  PetscScalar added_enthalpy;
1375  if (_z_grid[iz] > unheated_length_entry &&
1376  _z_grid[iz] <= unheated_length_entry + heated_length)
1377  added_enthalpy = computeAddedHeatPin(i_ch, iz);
1378  else
1379  added_enthalpy = 0.0;
1380  added_enthalpy += computeAddedHeatDuct(i_ch, iz);
1381  PetscInt row_vec_ht = i_ch + _n_channels * iz_ind;
1382  LibmeshPetscCall(
1383  VecSetValues(_hc_added_heat_rhs, 1, &row_vec_ht, &added_enthalpy, ADD_VALUES));
1384  }
1385  }
1387  LibmeshPetscCall(MatAssemblyBegin(_hc_time_derivative_mat, MAT_FINAL_ASSEMBLY));
1388  LibmeshPetscCall(MatAssemblyEnd(_hc_time_derivative_mat, MAT_FINAL_ASSEMBLY));
1389  LibmeshPetscCall(MatAssemblyBegin(_hc_advective_derivative_mat, MAT_FINAL_ASSEMBLY));
1390  LibmeshPetscCall(MatAssemblyEnd(_hc_advective_derivative_mat, MAT_FINAL_ASSEMBLY));
1391  LibmeshPetscCall(MatAssemblyBegin(_hc_cross_derivative_mat, MAT_FINAL_ASSEMBLY));
1392  LibmeshPetscCall(MatAssemblyEnd(_hc_cross_derivative_mat, MAT_FINAL_ASSEMBLY));
1393  LibmeshPetscCall(MatAssemblyBegin(_hc_axial_heat_conduction_mat, MAT_FINAL_ASSEMBLY));
1394  LibmeshPetscCall(MatAssemblyEnd(_hc_axial_heat_conduction_mat, MAT_FINAL_ASSEMBLY));
1395  LibmeshPetscCall(MatAssemblyBegin(_hc_radial_heat_conduction_mat, MAT_FINAL_ASSEMBLY));
1396  LibmeshPetscCall(MatAssemblyEnd(_hc_radial_heat_conduction_mat, MAT_FINAL_ASSEMBLY));
1397  LibmeshPetscCall(MatAssemblyBegin(_hc_sweep_enthalpy_mat, MAT_FINAL_ASSEMBLY));
1398  LibmeshPetscCall(MatAssemblyEnd(_hc_sweep_enthalpy_mat, MAT_FINAL_ASSEMBLY));
1399  LibmeshPetscCall(MatAssemblyBegin(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1400  LibmeshPetscCall(MatAssemblyEnd(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1402  LibmeshPetscCall(
1403  MatAXPY(_hc_sys_h_mat, 1.0, _hc_time_derivative_mat, DIFFERENT_NONZERO_PATTERN));
1404  LibmeshPetscCall(MatAssemblyBegin(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1405  LibmeshPetscCall(MatAssemblyEnd(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1406  LibmeshPetscCall(
1407  MatAXPY(_hc_sys_h_mat, 1.0, _hc_advective_derivative_mat, DIFFERENT_NONZERO_PATTERN));
1408  LibmeshPetscCall(MatAssemblyBegin(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1409  LibmeshPetscCall(MatAssemblyEnd(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1410  LibmeshPetscCall(
1411  MatAXPY(_hc_sys_h_mat, 1.0, _hc_cross_derivative_mat, DIFFERENT_NONZERO_PATTERN));
1412  LibmeshPetscCall(MatAssemblyBegin(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1413  LibmeshPetscCall(MatAssemblyEnd(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1414  LibmeshPetscCall(
1415  MatAXPY(_hc_sys_h_mat, 1.0, _hc_axial_heat_conduction_mat, DIFFERENT_NONZERO_PATTERN));
1416  LibmeshPetscCall(MatAssemblyBegin(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1417  LibmeshPetscCall(MatAssemblyEnd(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1418  LibmeshPetscCall(
1419  MatAXPY(_hc_sys_h_mat, 1.0, _hc_radial_heat_conduction_mat, DIFFERENT_NONZERO_PATTERN));
1420  LibmeshPetscCall(MatAssemblyBegin(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1421  LibmeshPetscCall(MatAssemblyEnd(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1422  LibmeshPetscCall(
1423  MatAXPY(_hc_sys_h_mat, 1.0, _hc_sweep_enthalpy_mat, DIFFERENT_NONZERO_PATTERN));
1424  LibmeshPetscCall(MatAssemblyBegin(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1425  LibmeshPetscCall(MatAssemblyEnd(_hc_sys_h_mat, MAT_FINAL_ASSEMBLY));
1426  if (_verbose_subchannel)
1427  _console << "Block: " << iblock << " - Enthalpy conservation matrix assembled" << std::endl;
1428  // RHS
1429  LibmeshPetscCall(VecAXPY(_hc_sys_h_rhs, 1.0, _hc_time_derivative_rhs));
1430  LibmeshPetscCall(VecAXPY(_hc_sys_h_rhs, 1.0, _hc_advective_derivative_rhs));
1431  LibmeshPetscCall(VecAXPY(_hc_sys_h_rhs, 1.0, _hc_cross_derivative_rhs));
1432  LibmeshPetscCall(VecAXPY(_hc_sys_h_rhs, 1.0, _hc_added_heat_rhs));
1433  LibmeshPetscCall(VecAXPY(_hc_sys_h_rhs, 1.0, _hc_axial_heat_conduction_rhs));
1434  LibmeshPetscCall(VecAXPY(_hc_sys_h_rhs, 1.0, _hc_radial_heat_conduction_rhs));
1435  LibmeshPetscCall(VecAXPY(_hc_sys_h_rhs, 1.0, _hc_sweep_enthalpy_rhs));
1436 
1438  {
1439  // Assembly the matrix system
1440  KSP ksploc;
1441  PC pc;
1442  Vec sol;
1443  LibmeshPetscCall(VecDuplicate(_hc_sys_h_rhs, &sol));
1444  LibmeshPetscCall(KSPCreate(PETSC_COMM_WORLD, &ksploc));
1445  LibmeshPetscCall(KSPSetOperators(ksploc, _hc_sys_h_mat, _hc_sys_h_mat));
1446  LibmeshPetscCall(KSPGetPC(ksploc, &pc));
1447  LibmeshPetscCall(PCSetType(pc, PCJACOBI));
1448  LibmeshPetscCall(KSPSetTolerances(ksploc, _rtol, _atol, _dtol, _maxit));
1449  LibmeshPetscCall(KSPSetOptionsPrefix(ksploc, "h_sys_"));
1450  LibmeshPetscCall(KSPSetFromOptions(ksploc));
1451  LibmeshPetscCall(KSPSolve(ksploc, _hc_sys_h_rhs, sol));
1452  // VecView(sol, PETSC_VIEWER_STDOUT_WORLD);
1453  PetscScalar * xx;
1454  LibmeshPetscCall(VecGetArray(sol, &xx));
1455  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
1456  {
1457  auto iz_ind = iz - first_node;
1458  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1459  {
1460  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
1461  auto h_out = xx[iz_ind * _n_channels + i_ch];
1462  if (h_out < 0)
1463  {
1464  mooseError(name(),
1465  " : Calculation of negative Enthalpy h_out = : ",
1466  h_out,
1467  " Axial Level= : ",
1468  iz);
1469  }
1470  _h_soln->set(node_out, h_out);
1471  }
1472  }
1473  LibmeshPetscCall(KSPDestroy(&ksploc));
1474  LibmeshPetscCall(VecDestroy(&sol));
1475  }
1476  }
1477 }
virtual Real computeAddedHeatPin(unsigned int i_ch, unsigned int iz) override
Computes added heat for channel i_ch and cell iz.
virtual const Real & getPinDiameter() const
Return Pin diameter.
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...
virtual const Real & getDuctToPinGap() const
Return the the gap thickness between the duct and peripheral fuel pins.
const PostprocessorValue & _P_out
Outlet Pressure.
virtual const std::vector< Real > & getZGrid() const
Get axial location of layers.
static const std::string K
Definition: NS.h:170
virtual const Real & getPitch() const
Return the pitch between 2 subchannels.
virtual EChannelType getSubchannelType(unsigned int index) const =0
Return the type of the subchannel for given subchannel index.
std::unique_ptr< SolutionHandle > _S_flow_soln
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::vector< unsigned int > & getChannelGaps(unsigned int i_chan) const =0
Return a vector of gap indices for a given channel index.
Real computeAddedHeatDuct(unsigned int i_ch, unsigned int iz)
Function that computes the heat flux added by the duct.
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
static const std::string cp
Definition: NS.h:121
Vec _hc_added_heat_rhs
Enthalpy conservation - source and sink.
std::vector< Real > _z_grid
axial location of nodes
virtual const Real & getHeatedLength() const
Return heated length.
static const std::string mu
Definition: NS.h:123
static const std::string pitch
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.
const MooseEnum _interpolation_scheme
The interpolation method used in constructing the systems.
Real volume(const MeshBase &mesh, unsigned int dim=libMesh::invalid_uint)
std::unique_ptr< SolutionHandle > _mdot_soln
virtual const unsigned int & getNumOfAxialCells() const
Return the number of axial cells.
virtual Real getGapWidth(unsigned int axial_index, unsigned int gap_index) const =0
Return gap width for a given gap index.
virtual const std::pair< unsigned int, unsigned int > & getSweepFlowChans(unsigned int i_chan) const
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 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.
const bool _verbose_subchannel
Boolean to printout information related to subchannel solve.
void mooseError(Args &&... args) const
virtual const Real & getWireLeadLength() const
Return the wire lead length.
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
MooseUnits pow(const MooseUnits &, int)
std::unique_ptr< SolutionHandle > _P_soln
virtual const Real & getHeatedLengthEntry() const
Return unheated length at entry.
const SinglePhaseFluidProperties * _fp
Solutions handles and link to TH tables properties.
const Real pi
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.
virtual const Real & getWireDiameter() const
Return wire diameter.

◆ computeInterpolatedValue()

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

Definition at line 364 of file SubChannel1PhaseProblem.C.

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

367 {
369  return alpha * botValue + (1.0 - alpha) * topValue;
370 }
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 344 of file SubChannel1PhaseProblem.C.

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

345 {
346  switch (_interpolation_scheme)
347  {
348  case 0: // upwind interpolation
349  return 1.0;
350  case 1: // downwind interpolation
351  return 0.0;
352  case 2: // central_difference interpolation
353  return 0.5;
354  case 3: // exponential interpolation (Peclet limited)
355  return ((Peclet - 1.0) * std::exp(Peclet) + 1) / (Peclet * (std::exp(Peclet) - 1.) + 1e-10);
356  default:
357  mooseError(name(),
358  ": Interpolation scheme should be a string: upwind, downwind, central_difference, "
359  "exponential");
360  }
361 }
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 471 of file SubChannel1PhaseProblem.C.

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

472 {
473  unsigned int last_node = (iblock + 1) * _block_size;
474  unsigned int first_node = iblock * _block_size + 1;
475  if (!_implicit_bool)
476  {
477  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
478  {
479  auto dz = _z_grid[iz] - _z_grid[iz - 1];
480  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
481  {
482  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
483  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
484  auto volume = dz * (*_S_flow_soln)(node_in);
485  auto time_term = _TR * ((*_rho_soln)(node_out)-_rho_soln->old(node_out)) * volume / _dt;
486  // Wij positive out of i into j;
487  auto mdot_out = (*_mdot_soln)(node_in) - (*_SumWij_soln)(node_out)-time_term;
488  if (mdot_out < 0)
489  {
490  _console << "Wij = : " << _Wij << "\n";
491  mooseError(name(),
492  " : Calculation of negative mass flow mdot_out = : ",
493  mdot_out,
494  " Axial Level= : ",
495  iz,
496  " - Implicit solves are required for recirculating flow.");
497  }
498  _mdot_soln->set(node_out, mdot_out); // kg/sec
499  }
500  }
501  }
502  else
503  {
504  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
505  {
506  auto dz = _z_grid[iz] - _z_grid[iz - 1];
507  auto iz_ind = iz - first_node;
508  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
509  {
510  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
511  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
512  auto volume = dz * (*_S_flow_soln)(node_in);
513 
514  // Adding time derivative to the RHS
515  auto time_term = _TR * ((*_rho_soln)(node_out)-_rho_soln->old(node_out)) * volume / _dt;
516  PetscInt row_vec = i_ch + _n_channels * iz_ind;
517  PetscScalar value_vec = -1.0 * time_term;
518  LibmeshPetscCall(
519  VecSetValues(_mc_axial_convection_rhs, 1, &row_vec, &value_vec, INSERT_VALUES));
520 
521  // Imposing bottom boundary condition or adding of diagonal elements
522  if (iz == first_node)
523  {
524  PetscScalar value_vec = (*_mdot_soln)(node_in);
525  PetscInt row_vec = i_ch + _n_channels * iz_ind;
526  LibmeshPetscCall(
527  VecSetValues(_mc_axial_convection_rhs, 1, &row_vec, &value_vec, ADD_VALUES));
528  }
529  else
530  {
531  PetscInt row = i_ch + _n_channels * iz_ind;
532  PetscInt col = i_ch + _n_channels * (iz_ind - 1);
533  PetscScalar value = -1.0;
534  LibmeshPetscCall(
535  MatSetValues(_mc_axial_convection_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
536  }
537 
538  // Adding diagonal elements
539  PetscInt row = i_ch + _n_channels * iz_ind;
540  PetscInt col = i_ch + _n_channels * iz_ind;
541  PetscScalar value = 1.0;
542  LibmeshPetscCall(
543  MatSetValues(_mc_axial_convection_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
544 
545  // Adding cross flows RHS
546  if (_segregated_bool)
547  {
548  PetscScalar value_vec_2 = -1.0 * (*_SumWij_soln)(node_out);
549  PetscInt row_vec_2 = i_ch + _n_channels * iz_ind;
550  LibmeshPetscCall(
551  VecSetValues(_mc_axial_convection_rhs, 1, &row_vec_2, &value_vec_2, ADD_VALUES));
552  }
553  }
554  }
555  LibmeshPetscCall(MatAssemblyBegin(_mc_axial_convection_mat, MAT_FINAL_ASSEMBLY));
556  LibmeshPetscCall(MatAssemblyEnd(_mc_axial_convection_mat, MAT_FINAL_ASSEMBLY));
558  _console << "Block: " << iblock << " - Mass conservation matrix assembled" << std::endl;
559 
560  if (_segregated_bool)
561  {
562  KSP ksploc;
563  PC pc;
564  Vec sol;
565  LibmeshPetscCall(VecDuplicate(_mc_axial_convection_rhs, &sol));
566  LibmeshPetscCall(KSPCreate(PETSC_COMM_WORLD, &ksploc));
567  LibmeshPetscCall(KSPSetOperators(ksploc, _mc_axial_convection_mat, _mc_axial_convection_mat));
568  LibmeshPetscCall(KSPGetPC(ksploc, &pc));
569  LibmeshPetscCall(PCSetType(pc, PCJACOBI));
570  LibmeshPetscCall(KSPSetTolerances(ksploc, _rtol, _atol, _dtol, _maxit));
571  LibmeshPetscCall(KSPSetFromOptions(ksploc));
572  LibmeshPetscCall(KSPSolve(ksploc, _mc_axial_convection_rhs, sol));
573  LibmeshPetscCall(populateSolutionChan<SolutionHandle>(
574  sol, *_mdot_soln, first_node, last_node, _n_channels));
575  LibmeshPetscCall(VecZeroEntries(_mc_axial_convection_rhs));
576  LibmeshPetscCall(KSPDestroy(&ksploc));
577  LibmeshPetscCall(VecDestroy(&sol));
578  }
579  }
580 }
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
const bool _verbose_subchannel
Boolean to printout information related to subchannel solve.
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 1386 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::externalSolve().

1387 {
1388  unsigned int last_node = (iblock + 1) * _block_size;
1389  unsigned int first_node = iblock * _block_size + 1;
1390  if (iblock == 0)
1391  {
1392  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1393  {
1394  auto * node = _subchannel_mesh.getChannelNode(i_ch, 0);
1395  _mu_soln->set(node, _fp->mu_from_p_T((*_P_soln)(node) + _P_out, (*_T_soln)(node)));
1396  }
1397  }
1398  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
1399  {
1400  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1401  {
1402  auto * node = _subchannel_mesh.getChannelNode(i_ch, iz);
1403  _mu_soln->set(node, _fp->mu_from_p_T((*_P_soln)(node) + _P_out, (*_T_soln)(node)));
1404  }
1405  }
1406 }
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 1087 of file SubChannel1PhaseProblem.C.

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

1088 {
1089  unsigned int last_node = (iblock + 1) * _block_size;
1090  unsigned int first_node = iblock * _block_size + 1;
1091  if (!_implicit_bool)
1092  {
1094  {
1095  for (unsigned int iz = last_node; iz > first_node - 1; iz--)
1096  {
1097  // Calculate pressure in the inlet of the cell assuming known outlet
1098  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1099  {
1100  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
1101  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1102  // update Pressure solution
1103  _P_soln->set(node_in, (*_P_soln)(node_out) + (*_DP_soln)(node_out));
1104  }
1105  }
1106  }
1107  else
1108  {
1109  for (unsigned int iz = last_node; iz > first_node - 1; iz--)
1110  {
1111  // Calculate pressure in the inlet of the cell assuming known outlet
1112  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1113  {
1114  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
1115  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1116  // update Pressure solution
1117  // Note: assuming uniform axial discretization in the curren code
1118  // We will need to update this later if we allow non-uniform refinements in the axial
1119  // direction
1120  PetscScalar Pe = 0.5;
1122  if (iz == last_node)
1123  {
1124  _P_soln->set(node_in, (*_P_soln)(node_out) + (*_DP_soln)(node_out) / 2.0);
1125  }
1126  else
1127  {
1128  _P_soln->set(node_in,
1129  (*_P_soln)(node_out) + (1.0 - alpha) * (*_DP_soln)(node_out) +
1130  alpha * (*_DP_soln)(node_in));
1131  }
1132  }
1133  }
1134  }
1135  }
1136  else
1137  {
1139  {
1140  LibmeshPetscCall(VecZeroEntries(_amc_pressure_force_rhs));
1141  for (unsigned int iz = last_node; iz > first_node - 1; iz--)
1142  {
1143  auto iz_ind = iz - first_node;
1144  // Calculate pressure in the inlet of the cell assuming known outlet
1145  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1146  {
1147  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
1148  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1149 
1150  // inlet, outlet, and interpolated axial surface area
1151  auto S_in = (*_S_flow_soln)(node_in);
1152  auto S_out = (*_S_flow_soln)(node_out);
1153  auto S_interp = computeInterpolatedValue(S_out, S_in, 0.5);
1154 
1155  // Creating matrix of coefficients
1156  PetscInt row = i_ch + _n_channels * iz_ind;
1157  PetscInt col = i_ch + _n_channels * iz_ind;
1158  PetscScalar value = -1.0 * S_interp;
1159  LibmeshPetscCall(
1160  MatSetValues(_amc_pressure_force_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
1161 
1162  if (iz == last_node)
1163  {
1164  PetscScalar value = -1.0 * (*_P_soln)(node_out)*S_interp;
1165  PetscInt row = i_ch + _n_channels * iz_ind;
1166  LibmeshPetscCall(VecSetValues(_amc_pressure_force_rhs, 1, &row, &value, ADD_VALUES));
1167  }
1168  else
1169  {
1170  PetscInt row = i_ch + _n_channels * iz_ind;
1171  PetscInt col = i_ch + _n_channels * (iz_ind + 1);
1172  PetscScalar value = 1.0 * S_interp;
1173  LibmeshPetscCall(
1174  MatSetValues(_amc_pressure_force_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
1175  }
1176 
1177  if (_segregated_bool)
1178  {
1179  auto dp_out = (*_DP_soln)(node_out);
1180  PetscScalar value_v = -1.0 * dp_out * S_interp;
1181  PetscInt row_v = i_ch + _n_channels * iz_ind;
1182  LibmeshPetscCall(
1183  VecSetValues(_amc_pressure_force_rhs, 1, &row_v, &value_v, ADD_VALUES));
1184  }
1185  }
1186  }
1187  // Solving pressure problem
1188  LibmeshPetscCall(MatAssemblyBegin(_amc_pressure_force_mat, MAT_FINAL_ASSEMBLY));
1189  LibmeshPetscCall(MatAssemblyEnd(_amc_pressure_force_mat, MAT_FINAL_ASSEMBLY));
1190  if (_segregated_bool)
1191  {
1192  KSP ksploc;
1193  PC pc;
1194  Vec sol;
1195  LibmeshPetscCall(VecDuplicate(_amc_pressure_force_rhs, &sol));
1196  LibmeshPetscCall(KSPCreate(PETSC_COMM_WORLD, &ksploc));
1197  LibmeshPetscCall(KSPSetOperators(ksploc, _amc_pressure_force_mat, _amc_pressure_force_mat));
1198  LibmeshPetscCall(KSPGetPC(ksploc, &pc));
1199  LibmeshPetscCall(PCSetType(pc, PCJACOBI));
1200  LibmeshPetscCall(KSPSetTolerances(ksploc, _rtol, _atol, _dtol, _maxit));
1201  LibmeshPetscCall(KSPSetFromOptions(ksploc));
1202  LibmeshPetscCall(KSPSolve(ksploc, _amc_pressure_force_rhs, sol));
1203  PetscScalar * xx;
1204  LibmeshPetscCall(VecGetArray(sol, &xx));
1205  // update Pressure solution
1206  for (unsigned int iz = last_node; iz > first_node - 1; iz--)
1207  {
1208  auto iz_ind = iz - first_node;
1209  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1210  {
1211  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1212  PetscScalar value = xx[iz_ind * _n_channels + i_ch];
1213  _P_soln->set(node_in, value);
1214  }
1215  }
1216  LibmeshPetscCall(VecZeroEntries(_amc_pressure_force_rhs));
1217  LibmeshPetscCall(KSPDestroy(&ksploc));
1218  LibmeshPetscCall(VecDestroy(&sol));
1219  }
1220  }
1221  else
1222  {
1223  LibmeshPetscCall(VecZeroEntries(_amc_pressure_force_rhs));
1224  for (unsigned int iz = last_node; iz > first_node - 1; iz--)
1225  {
1226  auto iz_ind = iz - first_node;
1227  // Calculate pressure in the inlet of the cell assuming known outlet
1228  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1229  {
1230  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
1231  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1232 
1233  // inlet, outlet, and interpolated axial surface area
1234  auto S_in = (*_S_flow_soln)(node_in);
1235  auto S_out = (*_S_flow_soln)(node_out);
1236  auto S_interp = computeInterpolatedValue(S_out, S_in, 0.5);
1237 
1238  // Creating matrix of coefficients
1239  PetscInt row = i_ch + _n_channels * iz_ind;
1240  PetscInt col = i_ch + _n_channels * iz_ind;
1241  PetscScalar value = -1.0 * S_interp;
1242  LibmeshPetscCall(
1243  MatSetValues(_amc_pressure_force_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
1244 
1245  if (iz == last_node)
1246  {
1247  PetscScalar value = -1.0 * (*_P_soln)(node_out)*S_interp;
1248  PetscInt row = i_ch + _n_channels * iz_ind;
1249  LibmeshPetscCall(VecSetValues(_amc_pressure_force_rhs, 1, &row, &value, ADD_VALUES));
1250 
1251  auto dp_out = (*_DP_soln)(node_out);
1252  PetscScalar value_v = -1.0 * dp_out / 2.0 * S_interp;
1253  PetscInt row_v = i_ch + _n_channels * iz_ind;
1254  LibmeshPetscCall(
1255  VecSetValues(_amc_pressure_force_rhs, 1, &row_v, &value_v, ADD_VALUES));
1256  }
1257  else
1258  {
1259  PetscInt row = i_ch + _n_channels * iz_ind;
1260  PetscInt col = i_ch + _n_channels * (iz_ind + 1);
1261  PetscScalar value = 1.0 * S_interp;
1262  LibmeshPetscCall(
1263  MatSetValues(_amc_pressure_force_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
1264 
1265  if (_segregated_bool)
1266  {
1267  auto dp_in = (*_DP_soln)(node_in);
1268  auto dp_out = (*_DP_soln)(node_out);
1269  auto dp_interp = computeInterpolatedValue(dp_out, dp_in, 0.5);
1270  PetscScalar value_v = -1.0 * dp_interp * S_interp;
1271  PetscInt row_v = i_ch + _n_channels * iz_ind;
1272  LibmeshPetscCall(
1273  VecSetValues(_amc_pressure_force_rhs, 1, &row_v, &value_v, ADD_VALUES));
1274  }
1275  }
1276  }
1277  }
1278  // Solving pressure problem
1279  LibmeshPetscCall(MatAssemblyBegin(_amc_pressure_force_mat, MAT_FINAL_ASSEMBLY));
1280  LibmeshPetscCall(MatAssemblyEnd(_amc_pressure_force_mat, MAT_FINAL_ASSEMBLY));
1281  if (_verbose_subchannel)
1282  _console << "Block: " << iblock << " - Axial momentum pressure force matrix assembled"
1283  << std::endl;
1284 
1285  if (_segregated_bool)
1286  {
1287  KSP ksploc;
1288  PC pc;
1289  Vec sol;
1290  LibmeshPetscCall(VecDuplicate(_amc_pressure_force_rhs, &sol));
1291  LibmeshPetscCall(KSPCreate(PETSC_COMM_WORLD, &ksploc));
1292  LibmeshPetscCall(KSPSetOperators(ksploc, _amc_pressure_force_mat, _amc_pressure_force_mat));
1293  LibmeshPetscCall(KSPGetPC(ksploc, &pc));
1294  LibmeshPetscCall(PCSetType(pc, PCJACOBI));
1295  LibmeshPetscCall(KSPSetTolerances(ksploc, _rtol, _atol, _dtol, _maxit));
1296  LibmeshPetscCall(KSPSetFromOptions(ksploc));
1297  LibmeshPetscCall(KSPSolve(ksploc, _amc_pressure_force_rhs, sol));
1298  PetscScalar * xx;
1299  LibmeshPetscCall(VecGetArray(sol, &xx));
1300  // update Pressure solution
1301  for (unsigned int iz = last_node; iz > first_node - 1; iz--)
1302  {
1303  auto iz_ind = iz - first_node;
1304  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1305  {
1306  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1307  PetscScalar value = xx[iz_ind * _n_channels + i_ch];
1308  _P_soln->set(node_in, value);
1309  }
1310  }
1311  LibmeshPetscCall(VecZeroEntries(_amc_pressure_force_rhs));
1312  LibmeshPetscCall(KSPDestroy(&ksploc));
1313  LibmeshPetscCall(VecDestroy(&sol));
1314  }
1315  }
1316  }
1317 }
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 1363 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::externalSolve().

1364 {
1365  unsigned int last_node = (iblock + 1) * _block_size;
1366  unsigned int first_node = iblock * _block_size + 1;
1367  if (iblock == 0)
1368  {
1369  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1370  {
1371  auto * node = _subchannel_mesh.getChannelNode(i_ch, 0);
1372  _rho_soln->set(node, _fp->rho_from_p_T((*_P_soln)(node) + _P_out, (*_T_soln)(node)));
1373  }
1374  }
1375  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
1376  {
1377  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1378  {
1379  auto * node = _subchannel_mesh.getChannelNode(i_ch, iz);
1380  _rho_soln->set(node, _fp->rho_from_p_T((*_P_soln)(node) + _P_out, (*_T_soln)(node)));
1381  }
1382  }
1383 }
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 406 of file SubChannel1PhaseProblem.C.

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

407 {
408  unsigned int last_node = (iblock + 1) * _block_size;
409  unsigned int first_node = iblock * _block_size + 1;
410  // Add to solution vector if explicit
411  if (!_implicit_bool)
412  {
413  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
414  {
415  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
416  {
417  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
418  Real sumWij = 0.0;
419  // Calculate sum of crossflow into channel i from channels j around i
420  unsigned int counter = 0;
421  for (auto i_gap : _subchannel_mesh.getChannelGaps(i_ch))
422  {
423  sumWij += _subchannel_mesh.getCrossflowSign(i_ch, counter) * _Wij(i_gap, iz);
424  counter++;
425  }
426  // The net crossflow coming out of cell i [kg/sec]
427  _SumWij_soln->set(node_out, sumWij);
428  }
429  }
430  }
431  // Add to matrix if explicit
432  else
433  {
434  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
435  {
436  unsigned int iz_ind = iz - first_node;
437  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
438  {
439  // Calculate sum of crossflow into channel i from channels j around i
440  unsigned int counter = 0;
441  for (auto i_gap : _subchannel_mesh.getChannelGaps(i_ch))
442  {
443  PetscInt row = i_ch + _n_channels * iz_ind;
444  PetscInt col = i_gap + _n_gaps * iz_ind;
445  PetscScalar value = _subchannel_mesh.getCrossflowSign(i_ch, counter);
446  LibmeshPetscCall(MatSetValues(_mc_sumWij_mat, 1, &row, 1, &col, &value, INSERT_VALUES));
447  counter++;
448  }
449  }
450  }
451  LibmeshPetscCall(MatAssemblyBegin(_mc_sumWij_mat, MAT_FINAL_ASSEMBLY));
452  LibmeshPetscCall(MatAssemblyEnd(_mc_sumWij_mat, MAT_FINAL_ASSEMBLY));
453  if (_segregated_bool)
454  {
455  Vec loc_prod;
456  Vec loc_Wij;
457  LibmeshPetscCall(VecDuplicate(_amc_sys_mdot_rhs, &loc_prod));
458  LibmeshPetscCall(VecDuplicate(_Wij_vec, &loc_Wij));
460  loc_Wij, _Wij, first_node, last_node + 1, _n_gaps));
461  LibmeshPetscCall(MatMult(_mc_sumWij_mat, loc_Wij, loc_prod));
462  LibmeshPetscCall(populateSolutionChan<SolutionHandle>(
463  loc_prod, *_SumWij_soln, first_node, last_node, _n_channels));
464  LibmeshPetscCall(VecDestroy(&loc_prod));
465  LibmeshPetscCall(VecDestroy(&loc_Wij));
466  }
467  }
468 }
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 1348 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::externalSolve().

1349 {
1350  unsigned int last_node = (iblock + 1) * _block_size;
1351  unsigned int first_node = iblock * _block_size + 1;
1352  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
1353  {
1354  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
1355  {
1356  auto * node = _subchannel_mesh.getChannelNode(i_ch, iz);
1357  _T_soln->set(node, _fp->T_from_p_h((*_P_soln)(node) + _P_out, (*_h_soln)(node)));
1358  }
1359  }
1360 }
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 373 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::externalSolve().

374 {
375  unsigned int last_node = (iblock + 1) * _block_size;
376  unsigned int first_node = iblock * _block_size + 1;
377  // Initial guess, port crossflow of block (iblock) into a vector that will act as my initial guess
378  libMesh::DenseVector<Real> solution_seed(_n_gaps * _block_size, 0.0);
379  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
380  {
381  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
382  {
383  int i = _n_gaps * (iz - first_node) + i_gap; // column wise transfer
384  solution_seed(i) = _Wij(i_gap, iz);
385  }
386  }
387 
388  // Solving the combined lateral momentum equation for Wij using a PETSc solver and update vector
389  // root
391  LibmeshPetscCall(petscSnesSolver(iblock, solution_seed, root));
392 
393  // Assign the solution to the cross-flow matrix
394  int i = 0;
395  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
396  {
397  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
398  {
399  _Wij(i_gap, iz) = root(i);
400  i++;
401  }
402  }
403 }
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 1737 of file SubChannel1PhaseProblem.C.

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

1738 {
1739  unsigned int last_node = (iblock + 1) * _block_size;
1740  unsigned int first_node = iblock * _block_size + 1;
1741  for (unsigned int iz = first_node; iz < last_node + 1; iz++)
1742  {
1743  auto dz = _z_grid[iz] - _z_grid[iz - 1];
1744  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
1745  {
1746  auto chans = _subchannel_mesh.getGapChannels(i_gap);
1747  unsigned int i_ch = chans.first;
1748  unsigned int j_ch = chans.second;
1749  auto * node_in_i = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1750  auto * node_out_i = _subchannel_mesh.getChannelNode(i_ch, iz);
1751  auto * node_in_j = _subchannel_mesh.getChannelNode(j_ch, iz - 1);
1752  auto * node_out_j = _subchannel_mesh.getChannelNode(j_ch, iz);
1753  auto Si_in = (*_S_flow_soln)(node_in_i);
1754  auto Sj_in = (*_S_flow_soln)(node_in_j);
1755  auto Si_out = (*_S_flow_soln)(node_out_i);
1756  auto Sj_out = (*_S_flow_soln)(node_out_j);
1757  auto gap = _subchannel_mesh.getGapWidth(iz, i_gap);
1758  auto Sij = dz * gap;
1759  auto avg_massflux =
1760  0.5 * (((*_mdot_soln)(node_in_i) + (*_mdot_soln)(node_in_j)) / (Si_in + Sj_in) +
1761  ((*_mdot_soln)(node_out_i) + (*_mdot_soln)(node_out_j)) / (Si_out + Sj_out));
1762  auto beta = computeBeta(i_gap, iz);
1763 
1764  if (!_implicit_bool)
1765  {
1766  _WijPrime(i_gap, iz) = beta * avg_massflux * Sij;
1767  }
1768  else
1769  {
1770  auto iz_ind = iz - first_node;
1771  PetscScalar base_value = beta * 0.5 * Sij;
1772 
1773  // Bottom values
1774  if (iz == first_node)
1775  {
1776  PetscScalar value_tl = -1.0 * base_value / (Si_in + Sj_in) *
1777  ((*_mdot_soln)(node_in_i) + (*_mdot_soln)(node_in_j));
1778  PetscInt row = i_gap + _n_gaps * iz_ind;
1779  LibmeshPetscCall(
1780  VecSetValues(_amc_turbulent_cross_flows_rhs, 1, &row, &value_tl, INSERT_VALUES));
1781  }
1782  else
1783  {
1784  PetscScalar value_tl = base_value / (Si_in + Sj_in);
1785  PetscInt row = i_gap + _n_gaps * iz_ind;
1786 
1787  PetscInt col_ich = i_ch + _n_channels * (iz_ind - 1);
1788  LibmeshPetscCall(MatSetValues(
1789  _amc_turbulent_cross_flows_mat, 1, &row, 1, &col_ich, &value_tl, INSERT_VALUES));
1790 
1791  PetscInt col_jch = j_ch + _n_channels * (iz_ind - 1);
1792  LibmeshPetscCall(MatSetValues(
1793  _amc_turbulent_cross_flows_mat, 1, &row, 1, &col_jch, &value_tl, INSERT_VALUES));
1794  }
1795 
1796  // Top values
1797  PetscScalar value_bl = base_value / (Si_out + Sj_out);
1798  PetscInt row = i_gap + _n_gaps * iz_ind;
1799 
1800  PetscInt col_ich = i_ch + _n_channels * iz_ind;
1801  LibmeshPetscCall(MatSetValues(
1802  _amc_turbulent_cross_flows_mat, 1, &row, 1, &col_ich, &value_bl, INSERT_VALUES));
1803 
1804  PetscInt col_jch = j_ch + _n_channels * iz_ind;
1805  LibmeshPetscCall(MatSetValues(
1806  _amc_turbulent_cross_flows_mat, 1, &row, 1, &col_jch, &value_bl, INSERT_VALUES));
1807  }
1808  }
1809  }
1810 
1811  if (_implicit_bool)
1812  {
1813  LibmeshPetscCall(MatAssemblyBegin(_amc_turbulent_cross_flows_mat, MAT_FINAL_ASSEMBLY));
1814  LibmeshPetscCall(MatAssemblyEnd(_amc_turbulent_cross_flows_mat, MAT_FINAL_ASSEMBLY));
1815 
1817  Vec loc_prod;
1818  Vec loc_Wij;
1819  LibmeshPetscCall(VecDuplicate(_amc_sys_mdot_rhs, &loc_prod));
1820  LibmeshPetscCall(VecDuplicate(_Wij_vec, &loc_Wij));
1821  LibmeshPetscCall(populateVectorFromHandle<SolutionHandle>(
1822  loc_prod, *_mdot_soln, first_node, last_node, _n_channels));
1823  LibmeshPetscCall(MatMult(_amc_turbulent_cross_flows_mat, loc_prod, loc_Wij));
1824  LibmeshPetscCall(VecAXPY(loc_Wij, -1.0, _amc_turbulent_cross_flows_rhs));
1826  loc_Wij, _WijPrime, first_node, last_node, _n_gaps));
1827  LibmeshPetscCall(VecDestroy(&loc_prod));
1828  LibmeshPetscCall(VecDestroy(&loc_Wij));
1829  }
1830 }
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 1409 of file SubChannel1PhaseProblem.C.

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

1410 {
1411  // Cross flow residual
1412  if (!_implicit_bool)
1413  {
1414  unsigned int last_node = (iblock + 1) * _block_size;
1415  unsigned int first_node = iblock * _block_size;
1416  const Real & pitch = _subchannel_mesh.getPitch();
1417  for (unsigned int iz = first_node + 1; iz < last_node + 1; iz++)
1418  {
1419  auto dz = _z_grid[iz] - _z_grid[iz - 1];
1420  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
1421  {
1422  auto chans = _subchannel_mesh.getGapChannels(i_gap);
1423  unsigned int i_ch = chans.first;
1424  unsigned int j_ch = chans.second;
1425  auto * node_in_i = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1426  auto * node_out_i = _subchannel_mesh.getChannelNode(i_ch, iz);
1427  auto * node_in_j = _subchannel_mesh.getChannelNode(j_ch, iz - 1);
1428  auto * node_out_j = _subchannel_mesh.getChannelNode(j_ch, iz);
1429  auto rho_i = (*_rho_soln)(node_in_i);
1430  auto rho_j = (*_rho_soln)(node_in_j);
1431  auto Si = (*_S_flow_soln)(node_in_i);
1432  auto Sj = (*_S_flow_soln)(node_in_j);
1433  auto Sij = dz * _subchannel_mesh.getGapWidth(iz, i_gap);
1434  auto Lij = pitch;
1435  // total local form loss in the ij direction
1436  auto friction_term = _kij * _Wij(i_gap, iz) * std::abs(_Wij(i_gap, iz));
1437  auto DPij = (*_P_soln)(node_in_i) - (*_P_soln)(node_in_j);
1438  // Figure out donor cell density
1439  auto rho_star = 0.0;
1440  if (_Wij(i_gap, iz) > 0.0)
1441  rho_star = rho_i;
1442  else if (_Wij(i_gap, iz) < 0.0)
1443  rho_star = rho_j;
1444  else
1445  rho_star = (rho_i + rho_j) / 2.0;
1446  auto mass_term_out =
1447  (*_mdot_soln)(node_out_i) / Si / rho_i + (*_mdot_soln)(node_out_j) / Sj / rho_j;
1448  auto mass_term_in =
1449  (*_mdot_soln)(node_in_i) / Si / rho_i + (*_mdot_soln)(node_in_j) / Sj / rho_j;
1450  auto term_out = Sij * rho_star * (Lij / dz) * mass_term_out * _Wij(i_gap, iz);
1451  auto term_in = Sij * rho_star * (Lij / dz) * mass_term_in * _Wij(i_gap, iz - 1);
1452  auto inertia_term = term_out - term_in;
1453  auto pressure_term = 2 * std::pow(Sij, 2.0) * DPij * rho_star;
1454  auto time_term =
1455  _TR * 2.0 * (_Wij(i_gap, iz) - _Wij_old(i_gap, iz)) * Lij * Sij * rho_star / _dt;
1456 
1457  _Wij_residual_matrix(i_gap, iz - 1 - iblock * _block_size) =
1458  time_term + friction_term + inertia_term - pressure_term;
1459  }
1460  }
1461  }
1462  else
1463  {
1464  // Initializing to zero the elements of the lateral momentum assembly
1465  LibmeshPetscCall(MatZeroEntries(_cmc_time_derivative_mat));
1466  LibmeshPetscCall(MatZeroEntries(_cmc_advective_derivative_mat));
1467  LibmeshPetscCall(MatZeroEntries(_cmc_friction_force_mat));
1468  LibmeshPetscCall(MatZeroEntries(_cmc_pressure_force_mat));
1469  LibmeshPetscCall(VecZeroEntries(_cmc_time_derivative_rhs));
1470  LibmeshPetscCall(VecZeroEntries(_cmc_advective_derivative_rhs));
1471  LibmeshPetscCall(VecZeroEntries(_cmc_friction_force_rhs));
1472  LibmeshPetscCall(VecZeroEntries(_cmc_pressure_force_rhs));
1473  LibmeshPetscCall(MatZeroEntries(_cmc_sys_Wij_mat));
1474  LibmeshPetscCall(VecZeroEntries(_cmc_sys_Wij_rhs));
1475  unsigned int last_node = (iblock + 1) * _block_size;
1476  unsigned int first_node = iblock * _block_size;
1477  const Real & pitch = _subchannel_mesh.getPitch();
1478  for (unsigned int iz = first_node + 1; iz < last_node + 1; iz++)
1479  {
1480  auto dz = _z_grid[iz] - _z_grid[iz - 1];
1481  auto iz_ind = iz - first_node - 1;
1482  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
1483  {
1484  auto chans = _subchannel_mesh.getGapChannels(i_gap);
1485  unsigned int i_ch = chans.first;
1486  unsigned int j_ch = chans.second;
1487  auto * node_in_i = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
1488  auto * node_out_i = _subchannel_mesh.getChannelNode(i_ch, iz);
1489  auto * node_in_j = _subchannel_mesh.getChannelNode(j_ch, iz - 1);
1490  auto * node_out_j = _subchannel_mesh.getChannelNode(j_ch, iz);
1491 
1492  // inlet, outlet, and interpolated densities
1493  auto rho_i_in = (*_rho_soln)(node_in_i);
1494  auto rho_i_out = (*_rho_soln)(node_out_i);
1495  auto rho_i_interp = computeInterpolatedValue(rho_i_out, rho_i_in, 0.5);
1496  auto rho_j_in = (*_rho_soln)(node_in_j);
1497  auto rho_j_out = (*_rho_soln)(node_out_j);
1498  auto rho_j_interp = computeInterpolatedValue(rho_j_out, rho_j_in, 0.5);
1499 
1500  // inlet, outlet, and interpolated areas
1501  auto S_i_in = (*_S_flow_soln)(node_in_i);
1502  auto S_i_out = (*_S_flow_soln)(node_out_i);
1503  auto S_j_in = (*_S_flow_soln)(node_in_j);
1504  auto S_j_out = (*_S_flow_soln)(node_out_j);
1505 
1506  // Cross-sectional gap area
1507  auto Sij = dz * _subchannel_mesh.getGapWidth(iz, i_gap);
1508  auto Lij = pitch;
1509 
1510  // Figure out donor cell density
1511  auto rho_star = 0.0;
1512  if (_Wij(i_gap, iz) > 0.0)
1513  rho_star = rho_i_interp;
1514  else if (_Wij(i_gap, iz) < 0.0)
1515  rho_star = rho_j_interp;
1516  else
1517  rho_star = (rho_i_interp + rho_j_interp) / 2.0;
1518 
1519  // Assembling time derivative
1520  PetscScalar time_factor = _TR * Lij * Sij * rho_star / _dt;
1521  PetscInt row_td = i_gap + _n_gaps * iz_ind;
1522  PetscInt col_td = i_gap + _n_gaps * iz_ind;
1523  PetscScalar value_td = time_factor;
1524  LibmeshPetscCall(MatSetValues(
1525  _cmc_time_derivative_mat, 1, &row_td, 1, &col_td, &value_td, INSERT_VALUES));
1526  PetscScalar value_td_rhs = time_factor * _Wij_old(i_gap, iz);
1527  LibmeshPetscCall(
1528  VecSetValues(_cmc_time_derivative_rhs, 1, &row_td, &value_td_rhs, INSERT_VALUES));
1529 
1530  // Assembling inertial term
1531  PetscScalar Pe = 0.5;
1533  auto mass_term_out = (*_mdot_soln)(node_out_i) / S_i_out / rho_i_out +
1534  (*_mdot_soln)(node_out_j) / S_j_out / rho_j_out;
1535  auto mass_term_in = (*_mdot_soln)(node_in_i) / S_i_in / rho_i_in +
1536  (*_mdot_soln)(node_in_j) / S_j_in / rho_j_in;
1537  auto term_out = Sij * rho_star * (Lij / dz) * mass_term_out / 2.0;
1538  auto term_in = Sij * rho_star * (Lij / dz) * mass_term_in / 2.0;
1539  if (iz == first_node + 1)
1540  {
1541  PetscInt row_ad = i_gap + _n_gaps * iz_ind;
1542  PetscScalar value_ad = term_in * alpha * _Wij(i_gap, iz - 1);
1543  LibmeshPetscCall(
1544  VecSetValues(_cmc_advective_derivative_rhs, 1, &row_ad, &value_ad, ADD_VALUES));
1545 
1546  PetscInt col_ad = i_gap + _n_gaps * iz_ind;
1547  value_ad = -1.0 * term_in * (1.0 - alpha) + term_out * alpha;
1548  LibmeshPetscCall(MatSetValues(
1549  _cmc_advective_derivative_mat, 1, &row_ad, 1, &col_ad, &value_ad, INSERT_VALUES));
1550 
1551  col_ad = i_gap + _n_gaps * (iz_ind + 1);
1552  value_ad = term_out * (1.0 - alpha);
1553  LibmeshPetscCall(MatSetValues(
1554  _cmc_advective_derivative_mat, 1, &row_ad, 1, &col_ad, &value_ad, INSERT_VALUES));
1555  }
1556  else if (iz == last_node)
1557  {
1558  PetscInt row_ad = i_gap + _n_gaps * iz_ind;
1559  PetscInt col_ad = i_gap + _n_gaps * (iz_ind - 1);
1560  PetscScalar value_ad = -1.0 * term_in * alpha;
1561  LibmeshPetscCall(MatSetValues(
1562  _cmc_advective_derivative_mat, 1, &row_ad, 1, &col_ad, &value_ad, INSERT_VALUES));
1563 
1564  col_ad = i_gap + _n_gaps * iz_ind;
1565  value_ad = -1.0 * term_in * (1.0 - alpha) + term_out * alpha;
1566  LibmeshPetscCall(MatSetValues(
1567  _cmc_advective_derivative_mat, 1, &row_ad, 1, &col_ad, &value_ad, INSERT_VALUES));
1568 
1569  value_ad = -1.0 * term_out * (1.0 - alpha) * _Wij(i_gap, iz);
1570  LibmeshPetscCall(
1571  VecSetValues(_cmc_advective_derivative_rhs, 1, &row_ad, &value_ad, ADD_VALUES));
1572  }
1573  else
1574  {
1575  PetscInt row_ad = i_gap + _n_gaps * iz_ind;
1576  PetscInt col_ad = i_gap + _n_gaps * (iz_ind - 1);
1577  PetscScalar value_ad = -1.0 * term_in * alpha;
1578  LibmeshPetscCall(MatSetValues(
1579  _cmc_advective_derivative_mat, 1, &row_ad, 1, &col_ad, &value_ad, INSERT_VALUES));
1580 
1581  col_ad = i_gap + _n_gaps * iz_ind;
1582  value_ad = -1.0 * term_in * (1.0 - alpha) + term_out * alpha;
1583  LibmeshPetscCall(MatSetValues(
1584  _cmc_advective_derivative_mat, 1, &row_ad, 1, &col_ad, &value_ad, INSERT_VALUES));
1585 
1586  col_ad = i_gap + _n_gaps * (iz_ind + 1);
1587  value_ad = term_out * (1.0 - alpha);
1588  LibmeshPetscCall(MatSetValues(
1589  _cmc_advective_derivative_mat, 1, &row_ad, 1, &col_ad, &value_ad, INSERT_VALUES));
1590  }
1591  // Assembling friction force
1592  PetscInt row_ff = i_gap + _n_gaps * iz_ind;
1593  PetscInt col_ff = i_gap + _n_gaps * iz_ind;
1594  PetscScalar value_ff = _kij * std::abs(_Wij(i_gap, iz)) / 2.0;
1595  LibmeshPetscCall(MatSetValues(
1596  _cmc_friction_force_mat, 1, &row_ff, 1, &col_ff, &value_ff, INSERT_VALUES));
1597 
1598  // Assembling pressure force
1600 
1602  {
1603  PetscScalar pressure_factor = std::pow(Sij, 2.0) * rho_star;
1604  PetscInt row_pf = i_gap + _n_gaps * iz_ind;
1605  PetscInt col_pf = i_ch + _n_channels * iz_ind;
1606  PetscScalar value_pf = -1.0 * alpha * pressure_factor;
1607  LibmeshPetscCall(
1608  MatSetValues(_cmc_pressure_force_mat, 1, &row_pf, 1, &col_pf, &value_pf, ADD_VALUES));
1609  col_pf = j_ch + _n_channels * iz_ind;
1610  value_pf = alpha * pressure_factor;
1611  LibmeshPetscCall(
1612  MatSetValues(_cmc_pressure_force_mat, 1, &row_pf, 1, &col_pf, &value_pf, ADD_VALUES));
1613 
1614  if (iz == last_node)
1615  {
1616  PetscInt row_pf = i_gap + _n_gaps * iz_ind;
1617  PetscScalar value_pf = (1.0 - alpha) * pressure_factor * (*_P_soln)(node_out_i);
1618  LibmeshPetscCall(
1619  VecSetValues(_cmc_pressure_force_rhs, 1, &row_pf, &value_pf, ADD_VALUES));
1620  value_pf = -1.0 * (1.0 - alpha) * pressure_factor * (*_P_soln)(node_out_j);
1621  LibmeshPetscCall(
1622  VecSetValues(_cmc_pressure_force_rhs, 1, &row_pf, &value_pf, ADD_VALUES));
1623  }
1624  else
1625  {
1626  row_pf = i_gap + _n_gaps * iz_ind;
1627  col_pf = i_ch + _n_channels * (iz_ind + 1);
1628  value_pf = -1.0 * (1.0 - alpha) * pressure_factor;
1629  LibmeshPetscCall(MatSetValues(
1630  _cmc_pressure_force_mat, 1, &row_pf, 1, &col_pf, &value_pf, ADD_VALUES));
1631  col_pf = j_ch + _n_channels * (iz_ind + 1);
1632  value_pf = (1.0 - alpha) * pressure_factor;
1633  LibmeshPetscCall(MatSetValues(
1634  _cmc_pressure_force_mat, 1, &row_pf, 1, &col_pf, &value_pf, ADD_VALUES));
1635  }
1636  }
1637  else
1638  {
1639  PetscScalar pressure_factor = std::pow(Sij, 2.0) * rho_star;
1640  PetscInt row_pf = i_gap + _n_gaps * iz_ind;
1641  PetscInt col_pf = i_ch + _n_channels * iz_ind;
1642  PetscScalar value_pf = -1.0 * pressure_factor;
1643  LibmeshPetscCall(
1644  MatSetValues(_cmc_pressure_force_mat, 1, &row_pf, 1, &col_pf, &value_pf, ADD_VALUES));
1645  col_pf = j_ch + _n_channels * iz_ind;
1646  value_pf = pressure_factor;
1647  LibmeshPetscCall(
1648  MatSetValues(_cmc_pressure_force_mat, 1, &row_pf, 1, &col_pf, &value_pf, ADD_VALUES));
1649  }
1650  }
1651  }
1653  LibmeshPetscCall(MatZeroEntries(_cmc_sys_Wij_mat));
1654  LibmeshPetscCall(VecZeroEntries(_cmc_sys_Wij_rhs));
1655  LibmeshPetscCall(MatAssemblyBegin(_cmc_time_derivative_mat, MAT_FINAL_ASSEMBLY));
1656  LibmeshPetscCall(MatAssemblyEnd(_cmc_time_derivative_mat, MAT_FINAL_ASSEMBLY));
1657  LibmeshPetscCall(MatAssemblyBegin(_cmc_advective_derivative_mat, MAT_FINAL_ASSEMBLY));
1658  LibmeshPetscCall(MatAssemblyEnd(_cmc_advective_derivative_mat, MAT_FINAL_ASSEMBLY));
1659  LibmeshPetscCall(MatAssemblyBegin(_cmc_friction_force_mat, MAT_FINAL_ASSEMBLY));
1660  LibmeshPetscCall(MatAssemblyEnd(_cmc_friction_force_mat, MAT_FINAL_ASSEMBLY));
1661  LibmeshPetscCall(MatAssemblyBegin(_cmc_pressure_force_mat, MAT_FINAL_ASSEMBLY));
1662  LibmeshPetscCall(MatAssemblyEnd(_cmc_pressure_force_mat, MAT_FINAL_ASSEMBLY));
1663  LibmeshPetscCall(MatAssemblyBegin(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1664  LibmeshPetscCall(MatAssemblyEnd(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1665  // Matrix
1666 #if !PETSC_VERSION_LESS_THAN(3, 15, 0)
1667  LibmeshPetscCall(
1668  MatAXPY(_cmc_sys_Wij_mat, 1.0, _cmc_time_derivative_mat, UNKNOWN_NONZERO_PATTERN));
1669  LibmeshPetscCall(MatAssemblyBegin(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1670  LibmeshPetscCall(MatAssemblyEnd(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1671  LibmeshPetscCall(
1672  MatAXPY(_cmc_sys_Wij_mat, 1.0, _cmc_advective_derivative_mat, UNKNOWN_NONZERO_PATTERN));
1673  LibmeshPetscCall(MatAssemblyBegin(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1674  LibmeshPetscCall(MatAssemblyEnd(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1675  LibmeshPetscCall(
1676  MatAXPY(_cmc_sys_Wij_mat, 1.0, _cmc_friction_force_mat, UNKNOWN_NONZERO_PATTERN));
1677 #else
1678  LibmeshPetscCall(
1679  MatAXPY(_cmc_sys_Wij_mat, 1.0, _cmc_time_derivative_mat, DIFFERENT_NONZERO_PATTERN));
1680  LibmeshPetscCall(MatAssemblyBegin(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1681  LibmeshPetscCall(MatAssemblyEnd(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1682  LibmeshPetscCall(
1683  MatAXPY(_cmc_sys_Wij_mat, 1.0, _cmc_advective_derivative_mat, DIFFERENT_NONZERO_PATTERN));
1684  LibmeshPetscCall(MatAssemblyBegin(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1685  LibmeshPetscCall(MatAssemblyEnd(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1686  LibmeshPetscCall(
1687  MatAXPY(_cmc_sys_Wij_mat, 1.0, _cmc_friction_force_mat, DIFFERENT_NONZERO_PATTERN));
1688 #endif
1689  LibmeshPetscCall(MatAssemblyBegin(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1690  LibmeshPetscCall(MatAssemblyEnd(_cmc_sys_Wij_mat, MAT_FINAL_ASSEMBLY));
1691  if (_verbose_subchannel)
1692  _console << "Block: " << iblock << " - Cross flow system matrix assembled" << std::endl;
1693  if (_verbose_subchannel)
1694  _console << "Block: " << iblock << " - Cross flow pressure force matrix assembled"
1695  << std::endl;
1696  // RHS
1697  LibmeshPetscCall(VecAXPY(_cmc_sys_Wij_rhs, 1.0, _cmc_time_derivative_rhs));
1698  LibmeshPetscCall(VecAXPY(_cmc_sys_Wij_rhs, 1.0, _cmc_advective_derivative_rhs));
1699  LibmeshPetscCall(VecAXPY(_cmc_sys_Wij_rhs, 1.0, _cmc_friction_force_rhs));
1700 
1701  if (_segregated_bool)
1702  {
1703  // Assembly the matrix system
1704  Vec sol_holder_P;
1705  LibmeshPetscCall(createPetscVector(sol_holder_P, _block_size * _n_gaps));
1706  Vec sol_holder_W;
1707  LibmeshPetscCall(createPetscVector(sol_holder_W, _block_size * _n_gaps));
1708  Vec loc_holder_Wij;
1709  LibmeshPetscCall(createPetscVector(loc_holder_Wij, _block_size * _n_gaps));
1710  LibmeshPetscCall(populateVectorFromHandle<SolutionHandle>(
1711  _prodp, *_P_soln, iblock * _block_size, (iblock + 1) * _block_size - 1, _n_channels));
1713  loc_holder_Wij, _Wij, first_node, last_node, _n_gaps));
1714  LibmeshPetscCall(MatMult(_cmc_sys_Wij_mat, _Wij_vec, sol_holder_W));
1715  LibmeshPetscCall(VecAXPY(sol_holder_W, -1.0, _cmc_sys_Wij_rhs));
1716  LibmeshPetscCall(MatMult(_cmc_pressure_force_mat, _prodp, sol_holder_P));
1717  LibmeshPetscCall(VecAXPY(sol_holder_P, -1.0, _cmc_pressure_force_rhs));
1718  LibmeshPetscCall(VecAXPY(sol_holder_W, 1.0, sol_holder_P));
1719  PetscScalar * xx;
1720  LibmeshPetscCall(VecGetArray(sol_holder_W, &xx));
1721  for (unsigned int iz = first_node + 1; iz < last_node + 1; iz++)
1722  {
1723  auto iz_ind = iz - first_node - 1;
1724  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
1725  {
1726  _Wij_residual_matrix(i_gap, iz - 1 - iblock * _block_size) = xx[iz_ind * _n_gaps + i_gap];
1727  }
1728  }
1729  LibmeshPetscCall(VecDestroy(&sol_holder_P));
1730  LibmeshPetscCall(VecDestroy(&sol_holder_W));
1731  LibmeshPetscCall(VecDestroy(&loc_holder_Wij));
1732  }
1733  }
1734 }
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.
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.
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 _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
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 203 of file SubChannel1PhaseProblem.h.

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

204  {
206  LibmeshPetscCall(MatCreate(PETSC_COMM_WORLD, &M));
207  LibmeshPetscCall(MatSetSizes(M, PETSC_DECIDE, PETSC_DECIDE, n, m));
208  LibmeshPetscCall(MatSetFromOptions(M));
209  LibmeshPetscCall(MatSetUp(M));
210  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
211  }
PetscFunctionBegin
PetscFunctionReturn(LIBMESH_PETSC_SUCCESS)

◆ createPetscVector()

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

Petsc Functions.

Definition at line 192 of file SubChannel1PhaseProblem.h.

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

193  {
195  LibmeshPetscCall(VecCreate(PETSC_COMM_WORLD, &v));
196  LibmeshPetscCall(PetscObjectSetName((PetscObject)v, "Solution"));
197  LibmeshPetscCall(VecSetSizes(v, PETSC_DECIDE, n));
198  LibmeshPetscCall(VecSetFromOptions(v));
199  LibmeshPetscCall(VecZeroEntries(v));
200  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
201  }
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 2530 of file SubChannel1PhaseProblem.C.

2531 {
2532  _console << "Executing subchannel solver\n";
2533  _dt = (isTransient() ? dt() : _one);
2534  _TR = isTransient();
2536  if (_verbose_subchannel)
2537  _console << "Solution initialized" << std::endl;
2538  Real P_error = 1.0;
2539  unsigned int P_it = 0;
2540  unsigned int P_it_max;
2541 
2542  if (_segregated_bool)
2543  P_it_max = 20 * _n_blocks;
2544  else
2545  P_it_max = 100;
2546 
2547  if ((_n_blocks == 1) && (_segregated_bool))
2548  P_it_max = 5;
2549 
2550  while ((P_error > _P_tol && P_it < P_it_max))
2551  {
2552  P_it += 1;
2553  if (P_it == P_it_max && _n_blocks != 1)
2554  {
2555  _console << "Reached maximum number of axial pressure iterations" << std::endl;
2556  _converged = false;
2557  }
2558  _console << "Solving Outer Iteration : " << P_it << std::endl;
2559  auto P_L2norm_old_axial = _P_soln->L2norm();
2560  for (unsigned int iblock = 0; iblock < _n_blocks; iblock++)
2561  {
2562  int last_level = (iblock + 1) * _block_size;
2563  int first_level = iblock * _block_size + 1;
2564  Real T_block_error = 1.0;
2565  auto T_it = 0;
2566  _console << "Solving Block: " << iblock << " From first level: " << first_level
2567  << " to last level: " << last_level << std::endl;
2568  while (T_block_error > _T_tol && T_it < _T_maxit)
2569  {
2570  T_it += 1;
2571  if (T_it == _T_maxit)
2572  {
2573  _console << "Reached maximum number of temperature iterations for block: " << iblock
2574  << std::endl;
2575  _converged = false;
2576  }
2577  auto T_L2norm_old_block = _T_soln->L2norm();
2578 
2579  if (_segregated_bool)
2580  {
2581  computeWijFromSolve(iblock);
2582 
2583  if (_compute_power)
2584  {
2585  computeh(iblock);
2586  computeT(iblock);
2587  }
2588  }
2589  else
2590  {
2591  LibmeshPetscCall(implicitPetscSolve(iblock));
2592  computeWijPrime(iblock);
2593  if (_verbose_subchannel)
2594  _console << "Done with main solve." << std::endl;
2596  {
2597  // Enthalpy is already solved from the monolithic solve
2598  computeT(iblock);
2599  }
2600  else
2601  {
2602  if (_verbose_subchannel)
2603  _console << "Starting thermal solve." << std::endl;
2604  if (_compute_power)
2605  {
2606  computeh(iblock);
2607  computeT(iblock);
2608  }
2609  if (_verbose_subchannel)
2610  _console << "Done with thermal solve." << std::endl;
2611  }
2612  }
2613 
2614  if (_verbose_subchannel)
2615  _console << "Start updating thermophysical properties." << std::endl;
2616 
2617  if (_compute_density)
2618  computeRho(iblock);
2619 
2620  if (_compute_viscosity)
2621  computeMu(iblock);
2622 
2623  if (_verbose_subchannel)
2624  _console << "Done updating thermophysical properties." << std::endl;
2625 
2626  // We must do a global assembly to make sure data is parallel consistent before we do things
2627  // like compute L2 norms
2628  _aux->solution().close();
2629 
2630  auto T_L2norm_new = _T_soln->L2norm();
2631  T_block_error =
2632  std::abs((T_L2norm_new - T_L2norm_old_block) / (T_L2norm_old_block + 1E-14));
2633  _console << "T_block_error: " << T_block_error << std::endl;
2634  }
2635  }
2636  auto P_L2norm_new_axial = _P_soln->L2norm();
2637  P_error =
2638  std::abs((P_L2norm_new_axial - P_L2norm_old_axial) / (P_L2norm_old_axial + _P_out + 1E-14));
2639  _console << "P_error :" << P_error << std::endl;
2640  if (_verbose_subchannel)
2641  {
2642  _console << "Iteration: " << P_it << std::endl;
2643  _console << "Maximum iterations: " << P_it_max << std::endl;
2644  }
2645  }
2646  // update old crossflow matrix
2647  _Wij_old = _Wij;
2648  _console << "Finished executing subchannel solver\n";
2649 
2651  if (_pin_mesh_exist)
2652  {
2653  _console << "Commencing calculation of Pin surface temperature \n";
2654  for (unsigned int i_pin = 0; i_pin < _n_pins; i_pin++)
2655  {
2656  for (unsigned int iz = 0; iz < _n_cells + 1; ++iz)
2657  {
2658  const auto * pin_node = _subchannel_mesh.getPinNode(i_pin, iz);
2659  Real sumTemp = 0.0;
2660  Real rod_counter = 0.0;
2661  // Calculate sum of pin surface temperatures that the channels around the pin see
2662  for (auto i_ch : _subchannel_mesh.getPinChannels(i_pin))
2663  {
2664  const auto * node = _subchannel_mesh.getChannelNode(i_ch, iz);
2665  auto mu = (*_mu_soln)(node);
2666  auto S = (*_S_flow_soln)(node);
2667  auto w_perim = (*_w_perim_soln)(node);
2668  auto Dh_i = 4.0 * S / w_perim;
2669  auto Re = (((*_mdot_soln)(node) / S) * Dh_i / mu);
2670  auto k = _fp->k_from_p_T((*_P_soln)(node) + _P_out, (*_T_soln)(node));
2671  auto cp = _fp->cp_from_p_T((*_P_soln)(node) + _P_out, (*_T_soln)(node));
2672  auto Pr = (*_mu_soln)(node)*cp / k;
2673  auto Nu = 0.023 * std::pow(Re, 0.8) * std::pow(Pr, 0.4);
2674  auto hw = Nu * k / Dh_i;
2675  if ((*_Dpin_soln)(pin_node) <= 0)
2676  mooseError("Dpin should not be null or negative when computing pin powers: ",
2677  (*_Dpin_soln)(pin_node));
2678  sumTemp +=
2679  (*_q_prime_soln)(pin_node) / ((*_Dpin_soln)(pin_node)*M_PI * hw) + (*_T_soln)(node);
2680  rod_counter += 1.0;
2681  }
2682  if (rod_counter > 0)
2683  _Tpin_soln->set(pin_node, sumTemp / rod_counter);
2684  else
2685  mooseError("Pin was not found for pin index: " + std::to_string(i_pin));
2686  }
2687  }
2688  }
2689 
2691  if (_duct_mesh_exist)
2692  {
2693  _console << "Commencing calculation of duct surface temperature " << std::endl;
2694  auto duct_nodes = _subchannel_mesh.getDuctNodes();
2695  for (Node * dn : duct_nodes)
2696  {
2697  auto * node_chan = _subchannel_mesh.getChannelNodeFromDuct(dn);
2698  auto mu = (*_mu_soln)(node_chan);
2699  auto S = (*_S_flow_soln)(node_chan);
2700  auto w_perim = (*_w_perim_soln)(node_chan);
2701  auto Dh_i = 4.0 * S / w_perim;
2702  auto Re = (((*_mdot_soln)(node_chan) / S) * Dh_i / mu);
2703  auto k = _fp->k_from_p_T((*_P_soln)(node_chan) + _P_out, (*_T_soln)(node_chan));
2704  auto cp = _fp->cp_from_p_T((*_P_soln)(node_chan) + _P_out, (*_T_soln)(node_chan));
2705  auto Pr = (*_mu_soln)(node_chan)*cp / k;
2706  auto Nu = 0.023 * std::pow(Re, 0.8) * std::pow(Pr, 0.4);
2707  auto hw = Nu * k / Dh_i;
2708  auto T_chan = (*_q_prime_duct_soln)(dn) / (_subchannel_mesh.getPinDiameter() * M_PI * hw) +
2709  (*_T_soln)(node_chan);
2710  _Tduct_soln->set(dn, T_chan);
2711  }
2712  }
2713  _aux->solution().close();
2714  _aux->update();
2715 
2716  Real power_in = 0.0;
2717  Real power_out = 0.0;
2718  Real Total_surface_area = 0.0;
2719  Real Total_wetted_perimeter = 0.0;
2720  Real mass_flow_in = 0.0;
2721  Real mass_flow_out = 0.0;
2722  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
2723  {
2724  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, 0);
2725  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, _n_cells);
2726  Total_surface_area += (*_S_flow_soln)(node_in);
2727  Total_wetted_perimeter += (*_w_perim_soln)(node_in);
2728  power_in += (*_mdot_soln)(node_in) * (*_h_soln)(node_in);
2729  power_out += (*_mdot_soln)(node_out) * (*_h_soln)(node_out);
2730  mass_flow_in += (*_mdot_soln)(node_in);
2731  mass_flow_out += (*_mdot_soln)(node_out);
2732  }
2733  auto h_bulk_out = power_out / mass_flow_out;
2734  auto T_bulk_out = _fp->T_from_p_h(_P_out, h_bulk_out);
2735 
2736  Real bulk_Dh = 4.0 * Total_surface_area / Total_wetted_perimeter;
2737  Real inlet_mu = (*_mu_soln)(_subchannel_mesh.getChannelNode(0, 0));
2738  Real bulk_Re = mass_flow_in * bulk_Dh / (inlet_mu * Total_surface_area);
2739  if (_verbose_subchannel)
2740  {
2741  _console << " ======================================= " << std::endl;
2742  _console << " ======== Subchannel Print Outs ======== " << std::endl;
2743  _console << " ======================================= " << std::endl;
2744  _console << "Total flow area :" << Total_surface_area << " m^2" << std::endl;
2745  _console << "Assembly hydraulic diameter :" << bulk_Dh << " m" << std::endl;
2746  _console << "Assembly Re number :" << bulk_Re << " [-]" << std::endl;
2747  _console << "Bulk coolant temperature at outlet :" << T_bulk_out << " K" << std::endl;
2748  _console << "Power added to coolant is : " << power_out - power_in << " Watt" << std::endl;
2749  _console << "Mass flow rate in is : " << mass_flow_in << " kg/sec" << std::endl;
2750  _console << "Mass balance is : " << mass_flow_out - mass_flow_in << " kg/sec" << std::endl;
2751  _console << "User defined outlet pressure is : " << _P_out << " Pa" << std::endl;
2752  _console << " ======================================= " << std::endl;
2753  }
2754 }
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.
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.
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 1930 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::externalSolve().

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

65 {
66  if (_deformation)
67  {
69  Real standard_area, wire_area, additional_area, wetted_perimeter, displaced_area;
70  auto flat_to_flat = _tri_sch_mesh.getFlatToFlat();
71  auto n_rings = _tri_sch_mesh.getNumOfRings();
73  auto pin_diameter = _subchannel_mesh.getPinDiameter();
74  auto wire_diameter = _tri_sch_mesh.getWireDiameter();
75  auto wire_lead_length = _tri_sch_mesh.getWireLeadLength();
76  auto gap = _tri_sch_mesh.getDuctToPinGap();
77  auto z_blockage = _subchannel_mesh.getZBlockage();
78  auto index_blockage = _subchannel_mesh.getIndexBlockage();
79  auto reduction_blockage = _subchannel_mesh.getReductionBlockage();
80  auto theta = std::acos(wire_lead_length /
81  std::sqrt(std::pow(wire_lead_length, 2) +
82  std::pow(libMesh::pi * (pin_diameter + wire_diameter), 2)));
83  for (unsigned int iz = 0; iz < _n_cells + 1; iz++)
84  {
85  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
86  {
87  auto subch_type = _subchannel_mesh.getSubchannelType(i_ch);
88  auto * node = _subchannel_mesh.getChannelNode(i_ch, iz);
89  auto Z = _z_grid[iz];
90  Real rod_area = 0.0;
91  Real rod_perimeter = 0.0;
92  for (auto i_pin : _subchannel_mesh.getChannelPins(i_ch))
93  {
94  auto * pin_node = _subchannel_mesh.getPinNode(i_pin, iz);
95  if (subch_type == EChannelType::CENTER || subch_type == EChannelType::CORNER)
96  {
97  rod_area +=
98  (1.0 / 6.0) * 0.25 * M_PI * (*_Dpin_soln)(pin_node) * (*_Dpin_soln)(pin_node);
99  rod_perimeter += (1.0 / 6.0) * M_PI * (*_Dpin_soln)(pin_node);
100  }
101  else
102  {
103  rod_area +=
104  (1.0 / 4.0) * 0.25 * M_PI * (*_Dpin_soln)(pin_node) * (*_Dpin_soln)(pin_node);
105  rod_perimeter += (1.0 / 4.0) * M_PI * (*_Dpin_soln)(pin_node);
106  }
107  }
108 
109  if (subch_type == EChannelType::CENTER)
110  {
111  standard_area = std::pow(pitch, 2.0) * std::sqrt(3.0) / 4.0;
112  additional_area = 0.0;
113  displaced_area = 0.0;
114  wire_area = libMesh::pi * std::pow(wire_diameter, 2.0) / 8.0 / std::cos(theta);
115  wetted_perimeter = rod_perimeter + 0.5 * libMesh::pi * wire_diameter / std::cos(theta);
116  }
117  else if (subch_type == EChannelType::EDGE)
118  {
119  standard_area = pitch * (pin_diameter / 2.0 + gap);
120  additional_area = 0.0;
121  displaced_area = (*_displacement_soln)(node)*pitch;
122  wire_area = libMesh::pi * std::pow(wire_diameter, 2.0) / 8.0 / std::cos(theta);
123  wetted_perimeter =
124  rod_perimeter + 0.5 * libMesh::pi * wire_diameter / std::cos(theta) + pitch;
125  }
126  else
127  {
128  standard_area = 1.0 / std::sqrt(3.0) * std::pow((pin_diameter / 2.0 + gap), 2.0);
129  additional_area = 0.0;
130  displaced_area = 1.0 / std::sqrt(3.0) *
131  (pin_diameter + 2.0 * gap + (*_displacement_soln)(node)) *
132  (*_displacement_soln)(node);
133  wire_area = libMesh::pi / 24.0 * std::pow(wire_diameter, 2.0) / std::cos(theta);
134  wetted_perimeter =
135  rod_perimeter + libMesh::pi * wire_diameter / std::cos(theta) / 6.0 +
136  2.0 / std::sqrt(3.0) * (pin_diameter / 2.0 + gap + (*_displacement_soln)(node));
137  }
138 
140  auto subchannel_area =
141  standard_area + additional_area + displaced_area - rod_area - wire_area;
142 
144  auto overlapping_pin_area = 0.0;
145  auto overlapping_wetted_perimeter = 0.0;
146  for (auto i_gap : _subchannel_mesh.getChannelGaps(i_ch))
147  {
148  auto gap_pins = _subchannel_mesh.getGapPins(i_gap);
149  auto pin_1 = gap_pins.first;
150  auto pin_2 = gap_pins.second;
151  auto * pin_node_1 = _subchannel_mesh.getPinNode(pin_1, iz);
152  auto * pin_node_2 = _subchannel_mesh.getPinNode(pin_2, iz);
153  auto Diameter1 = (*_Dpin_soln)(pin_node_1);
154  auto Radius1 = Diameter1 / 2.0;
155  auto Diameter2 = (*_Dpin_soln)(pin_node_2);
156  auto Radius2 = Diameter2 / 2.0;
158 
159  if (pitch < (Radius1 + Radius2)) // overlapping pins
160  {
161  mooseWarning(" The gap of index : '", i_gap, " at axial cell ", iz, " ' is blocked.");
162  auto cos1 =
163  (pitch * pitch + Radius1 * Radius1 - Radius2 * Radius2) / (2 * pitch * Radius1);
164  auto cos2 =
165  (pitch * pitch + Radius2 * Radius2 - Radius1 * Radius1) / (2 * pitch * Radius2);
166  auto angle1 = 2.0 * acos(cos1);
167  auto angle2 = 2.0 * acos(cos2);
168  // half of the intersecting arc-length
169  overlapping_wetted_perimeter += 0.5 * angle1 * Radius1 + 0.5 * angle2 * Radius2;
170  // Half of the overlapping area
171  overlapping_pin_area +=
172  0.5 * Radius1 * Radius1 * acos(cos1) + 0.5 * Radius2 * Radius2 * acos(cos2) -
173  0.25 * sqrt((-pitch + Radius1 + Radius2) * (pitch + Radius1 - Radius2) *
174  (pitch - Radius1 + Radius2) * (pitch + Radius1 + Radius2));
175  }
176  }
177  subchannel_area += overlapping_pin_area; // correct surface area
178  wetted_perimeter += -overlapping_wetted_perimeter; // correct wetted perimeter
179 
181  auto index = 0;
182  for (const auto & i_blockage : index_blockage)
183  {
184  if (i_ch == i_blockage && (Z >= z_blockage.front() && Z <= z_blockage.back()))
185  {
186  subchannel_area *= reduction_blockage[index];
187  }
188  index++;
189  }
190  _S_flow_soln->set(node, subchannel_area);
191  _w_perim_soln->set(node, wetted_perimeter);
192  }
193  }
195  for (unsigned int iz = 0; iz < _n_cells + 1; iz++)
196  {
197  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
198  {
199  auto gap_pins = _subchannel_mesh.getGapPins(i_gap);
200  auto pin_1 = gap_pins.first;
201  auto pin_2 = gap_pins.second;
202  auto * pin_node_1 = _subchannel_mesh.getPinNode(pin_1, iz);
203  auto * pin_node_2 = _subchannel_mesh.getPinNode(pin_2, iz);
204 
205  if (pin_1 == pin_2) // Corner or edge gap
206  {
207  auto displacement = 0.0;
208  auto counter = 0.0;
209  for (auto i_ch : _subchannel_mesh.getPinChannels(pin_1))
210  {
211  auto subch_type = _subchannel_mesh.getSubchannelType(i_ch);
212  auto * node = _subchannel_mesh.getChannelNode(i_ch, iz);
213  if (subch_type == EChannelType::EDGE || subch_type == EChannelType::CORNER)
214  {
215  displacement += (*_displacement_soln)(node);
216  counter += 1.0;
217  }
218  }
219  displacement = displacement / counter;
220  _tri_sch_mesh._gij_map[iz][i_gap] =
221  0.5 * (flat_to_flat - (n_rings - 1) * pitch * std::sqrt(3.0) -
222  (*_Dpin_soln)(pin_node_1)) +
223  displacement;
224  }
225  else // center gap
226  {
227  _tri_sch_mesh._gij_map[iz][i_gap] =
228  pitch - (*_Dpin_soln)(pin_node_1) / 2.0 - (*_Dpin_soln)(pin_node_2) / 2.0;
229  }
230  // if pins come in contact, the gap is zero
231  if (_tri_sch_mesh._gij_map[iz][i_gap] <= 0.0)
232  _tri_sch_mesh._gij_map[iz][i_gap] = 0.0;
233  }
234  }
235  }
236 
237  for (unsigned int iz = 1; iz < _n_cells + 1; iz++)
238  {
239  for (unsigned int i_ch = 0; i_ch < _n_channels; i_ch++)
240  {
241  auto * node_out = _subchannel_mesh.getChannelNode(i_ch, iz);
242  auto * node_in = _subchannel_mesh.getChannelNode(i_ch, iz - 1);
243  _mdot_soln->set(node_out, (*_mdot_soln)(node_in));
244  }
245  }
246 
247  // We must do a global assembly to make sure data is parallel consistent before we do things
248  // like compute L2 norms
249  _aux->solution().close();
250 }
virtual const std::pair< unsigned int, unsigned int > & getGapPins(unsigned int i_gap) const =0
Return a pair of pin indices for a given gap index.
virtual const Real & getPinDiameter() const
Return Pin diameter.
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 const Real & getDuctToPinGap() const
Return the the gap thickness between the duct and peripheral fuel pins.
virtual const std::vector< unsigned int > & getChannelPins(unsigned int i_chan) const =0
Return a vector of pin indices for a given channel index.
virtual const Real & getPitch() const
Return the pitch between 2 subchannels.
virtual EChannelType getSubchannelType(unsigned int index) const =0
Return the type of the subchannel for given subchannel index.
std::unique_ptr< SolutionHandle > _S_flow_soln
virtual Node * getPinNode(unsigned int i_pin, unsigned iz) const =0
Get the pin mesh node for a given pin index and elevation index.
virtual const unsigned int & getNumOfRings() const
Return the number of rings.
virtual const std::vector< unsigned int > & getChannelGaps(unsigned int i_chan) const =0
Return a vector of gap indices for a given channel index.
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.
std::vector< Real > _z_grid
axial location of nodes
static const std::string pitch
std::shared_ptr< AuxiliarySystem > _aux
std::vector< std::vector< Real > > _gij_map
gap size
std::unique_ptr< SolutionHandle > _Dpin_soln
virtual const std::vector< Real > & getReductionBlockage() const
Get area reduction of blocked subchannels.
virtual const Real & getFlatToFlat() const
Return flat to flat [m].
std::unique_ptr< SolutionHandle > _mdot_soln
static const std::string Z
Definition: NS.h:169
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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 const Real & getWireLeadLength() const
Return the wire lead length.
virtual const std::vector< unsigned int > & getIndexBlockage() const
Get index of blocked subchannels.
const bool _deformation
Flag that activates the effect of deformation (pin/duct) based on the auxvalues for displacement...
MooseUnits pow(const MooseUnits &, int)
std::unique_ptr< SolutionHandle > _w_perim_soln
const Real pi
virtual const Real & getWireDiameter() const
Return wire diameter.

◆ initialSetup()

void SubChannel1PhaseProblem::initialSetup ( )
overridevirtualinherited

Reimplemented from ExternalProblem.

Definition at line 243 of file SubChannel1PhaseProblem.C.

244 {
246  _fp = &getUserObject<SinglePhaseFluidProperties>(getParam<UserObjectName>("fp"));
247  _mdot_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::MASS_FLOW_RATE));
248  _SumWij_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::SUM_CROSSFLOW));
249  _P_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::PRESSURE));
250  _DP_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::PRESSURE_DROP));
251  _h_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::ENTHALPY));
252  _T_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::TEMPERATURE));
253  if (_pin_mesh_exist)
254  {
255  _Tpin_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::PIN_TEMPERATURE));
256  _Dpin_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::PIN_DIAMETER));
257  }
258  _rho_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::DENSITY));
259  _mu_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::VISCOSITY));
260  _S_flow_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::SURFACE_AREA));
261  _w_perim_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::WETTED_PERIMETER));
262  _q_prime_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::LINEAR_HEAT_RATE));
264  std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::DISPLACEMENT));
265  if (_duct_mesh_exist)
266  {
268  std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::DUCT_LINEAR_HEAT_RATE));
269  _Tduct_soln = std::make_unique<SolutionHandle>(getVariable(0, SubChannelApp::DUCT_TEMPERATURE));
270  }
271 }
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 1875 of file SubChannel1PhaseProblem.C.

Referenced by SubChannel1PhaseProblem::computeWijFromSolve().

1878 {
1879  SNES snes;
1880  KSP ksp;
1881  PC pc;
1882  Vec x, r;
1883  PetscMPIInt size;
1884  PetscScalar * xx;
1885 
1887  PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size));
1888  if (size > 1)
1889  SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_SUP, "Example is only for sequential runs");
1890  LibmeshPetscCall(SNESCreate(PETSC_COMM_WORLD, &snes));
1891  LibmeshPetscCall(VecCreate(PETSC_COMM_WORLD, &x));
1892  LibmeshPetscCall(VecSetSizes(x, PETSC_DECIDE, _block_size * _n_gaps));
1893  LibmeshPetscCall(VecSetFromOptions(x));
1894  LibmeshPetscCall(VecDuplicate(x, &r));
1895 
1896 #if PETSC_VERSION_LESS_THAN(3, 13, 0)
1897  LibmeshPetscCall(PetscOptionsSetValue(PETSC_NULL, "-snes_mf", PETSC_NULL));
1898 #else
1899  LibmeshPetscCall(SNESSetUseMatrixFree(snes, PETSC_FALSE, PETSC_TRUE));
1900 #endif
1901  Ctx ctx;
1902  ctx.iblock = iblock;
1903  ctx.schp = this;
1904  LibmeshPetscCall(SNESSetFunction(snes, r, formFunction, &ctx));
1905  LibmeshPetscCall(SNESGetKSP(snes, &ksp));
1906  LibmeshPetscCall(KSPGetPC(ksp, &pc));
1907  LibmeshPetscCall(PCSetType(pc, PCNONE));
1908  LibmeshPetscCall(KSPSetTolerances(ksp, _rtol, _atol, _dtol, _maxit));
1909  LibmeshPetscCall(SNESSetFromOptions(snes));
1910  LibmeshPetscCall(VecGetArray(x, &xx));
1911  for (unsigned int i = 0; i < _block_size * _n_gaps; i++)
1912  {
1913  xx[i] = solution(i);
1914  }
1915  LibmeshPetscCall(VecRestoreArray(x, &xx));
1916 
1917  LibmeshPetscCall(SNESSolve(snes, NULL, x));
1918  LibmeshPetscCall(VecGetArray(x, &xx));
1919  for (unsigned int i = 0; i < _block_size * _n_gaps; i++)
1920  root(i) = xx[i];
1921 
1922  LibmeshPetscCall(VecRestoreArray(x, &xx));
1923  LibmeshPetscCall(VecDestroy(&x));
1924  LibmeshPetscCall(VecDestroy(&r));
1925  LibmeshPetscCall(SNESDestroy(&snes));
1926  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
1927 }
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 333 of file SubChannel1PhaseProblem.h.

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

338 {
339  PetscScalar * xx;
340 
342  LibmeshPetscCall(VecGetArray(x, &xx));
343  for (unsigned int iz = first_axial_level; iz < last_axial_level + 1; iz++)
344  {
345  unsigned int iz_ind = iz - first_axial_level;
346  for (unsigned int i_l = 0; i_l < cross_dimension; i_l++)
347  {
348  loc_solution(i_l, iz) = xx[iz_ind * cross_dimension + i_l];
349  }
350  }
351  LibmeshPetscCall(VecRestoreArray(x, &xx));
352 
353  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
354 }
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 407 of file SubChannel1PhaseProblem.h.

412 {
413  PetscScalar * xx;
415  LibmeshPetscCall(VecGetArray(x, &xx));
416  Node * loc_node;
417  for (unsigned int iz = first_axial_level; iz < last_axial_level + 1; iz++)
418  {
419  unsigned int iz_ind = iz - first_axial_level;
420  for (unsigned int i_l = 0; i_l < cross_dimension; i_l++)
421  {
422  loc_node = _subchannel_mesh.getChannelNode(i_l, iz);
423  loc_solution.set(loc_node, xx[iz_ind * cross_dimension + i_l]);
424  }
425  }
426  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
427 }
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 431 of file SubChannel1PhaseProblem.h.

436 {
437  PetscScalar * xx;
439  LibmeshPetscCall(VecGetArray(x, &xx));
440  for (unsigned int iz = first_axial_level; iz < last_axial_level + 1; iz++)
441  {
442  unsigned int iz_ind = iz - first_axial_level;
443  for (unsigned int i_l = 0; i_l < cross_dimension; i_l++)
444  {
445  loc_solution(iz * cross_dimension + i_l) = xx[iz_ind * cross_dimension + i_l];
446  }
447  }
448  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
449 }
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 384 of file SubChannel1PhaseProblem.h.

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

389 {
390  PetscScalar * xx;
392  LibmeshPetscCall(VecGetArray(x, &xx));
393  for (unsigned int iz = first_axial_level; iz < last_axial_level; iz++)
394  {
395  unsigned int iz_ind = iz - first_axial_level;
396  for (unsigned int i_l = 0; i_l < cross_dimension; i_l++)
397  {
398  xx[iz_ind * cross_dimension + i_l] = loc_solution(i_l, iz);
399  }
400  }
401  LibmeshPetscCall(VecRestoreArray(x, &xx));
402  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
403 }
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 358 of file SubChannel1PhaseProblem.h.

363 {
364  PetscScalar * xx;
365 
367  LibmeshPetscCall(VecGetArray(x, &xx));
368  for (unsigned int iz = first_axial_level; iz < last_axial_level + 1; iz++)
369  {
370  unsigned int iz_ind = iz - first_axial_level;
371  for (unsigned int i_l = 0; i_l < cross_dimension; i_l++)
372  {
373  auto * loc_node = _subchannel_mesh.getChannelNode(i_l, iz);
374  xx[iz_ind * cross_dimension + i_l] = loc_solution(loc_node);
375  }
376  }
377  LibmeshPetscCall(VecRestoreArray(x, &xx));
378 
379  PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
380 }
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 1833 of file SubChannel1PhaseProblem.C.

Referenced by formFunction().

1834 {
1835  unsigned int last_node = (iblock + 1) * _block_size;
1836  unsigned int first_node = iblock * _block_size;
1837  libMesh::DenseVector<Real> Wij_residual_vector(_n_gaps * _block_size, 0.0);
1838  // Assign the solution to the cross-flow matrix
1839  int i = 0;
1840  for (unsigned int iz = first_node + 1; iz < last_node + 1; iz++)
1841  {
1842  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
1843  {
1844  _Wij(i_gap, iz) = solution(i);
1845  i++;
1846  }
1847  }
1848 
1849  // Calculating sum of crossflows
1850  computeSumWij(iblock);
1851  // Solving axial flux
1852  computeMdot(iblock);
1853  // Calculation of turbulent Crossflow
1854  computeWijPrime(iblock);
1855  // Solving for Pressure Drop
1856  computeDP(iblock);
1857  // Solving for pressure
1858  computeP(iblock);
1859  // Populating lateral crossflow residual matrix
1860  computeWijResidual(iblock);
1861 
1862  // Turn the residual matrix into a residual vector
1863  for (unsigned int iz = 0; iz < _block_size; iz++)
1864  {
1865  for (unsigned int i_gap = 0; i_gap < _n_gaps; i_gap++)
1866  {
1867  int i = _n_gaps * iz + i_gap; // column wise transfer
1868  Wij_residual_vector(i) = _Wij_residual_matrix(i_gap, iz);
1869  }
1870  }
1871  return Wij_residual_vector;
1872 }
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 338 of file SubChannel1PhaseProblem.C.

339 {
340  return _converged;
341 }
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 2757 of file SubChannel1PhaseProblem.C.

2758 {
2759 }

◆ validParams()

InputParameters TriSubChannel1PhaseProblem::validParams ( )
static

Definition at line 18 of file TriSubChannel1PhaseProblem.C.

19 {
21  params.addClassDescription("Solver class for subchannels in a triangular lattice assembly and "
22  "bare/wire-wrapped fuel pins");
23  return params;
24 }
static InputParameters validParams()
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 321 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 266 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 269 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 272 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 276 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 263 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 260 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

◆ _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 289 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 286 of file SubChannel1PhaseProblem.h.

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

◆ _cmc_time_derivative_rhs

Vec SubChannel1PhaseProblem::_cmc_time_derivative_rhs
protectedinherited

◆ _cmc_Wij_channel_dummy

Vec SubChannel1PhaseProblem::_cmc_Wij_channel_dummy
protectedinherited

◆ _compute_density

const bool SubChannel1PhaseProblem::_compute_density
protectedinherited

Flag that activates or deactivates the calculation of density.

Definition at line 126 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 130 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 128 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::externalSolve().

◆ _converged

bool SubChannel1PhaseProblem::_converged
protectedinherited

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

Definition at line 136 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 142 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::computeDP().

◆ _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 170 of file SubChannel1PhaseProblem.h.

Referenced by QuadSubChannel1PhaseProblem::initializeSolution(), and 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

◆ _dpz_error

Real SubChannel1PhaseProblem::_dpz_error
protectedinherited

average relative error in pressure drop of channels

Definition at line 119 of file SubChannel1PhaseProblem.h.

◆ _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 134 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 110 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::computeDP().

◆ _global_counter

PetscInt SubChannel1PhaseProblem::_global_counter = 0
protectedinherited

No implicit matrix.

Definition at line 318 of file SubChannel1PhaseProblem.h.

◆ _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 307 of file SubChannel1PhaseProblem.h.

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

◆ _hc_advective_derivative_rhs

Vec SubChannel1PhaseProblem::_hc_advective_derivative_rhs
protectedinherited

◆ _hc_axial_heat_conduction_mat

Mat TriSubChannel1PhaseProblem::_hc_axial_heat_conduction_mat
protected

Definition at line 40 of file TriSubChannel1PhaseProblem.h.

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

◆ _hc_axial_heat_conduction_rhs

Vec TriSubChannel1PhaseProblem::_hc_axial_heat_conduction_rhs
protected

Definition at line 41 of file TriSubChannel1PhaseProblem.h.

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

◆ _hc_cross_derivative_mat

Mat SubChannel1PhaseProblem::_hc_cross_derivative_mat
protectedinherited

◆ _hc_cross_derivative_rhs

Vec SubChannel1PhaseProblem::_hc_cross_derivative_rhs
protectedinherited

◆ _hc_radial_heat_conduction_mat

Mat TriSubChannel1PhaseProblem::_hc_radial_heat_conduction_mat
protected

Definition at line 42 of file TriSubChannel1PhaseProblem.h.

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

◆ _hc_radial_heat_conduction_rhs

Vec TriSubChannel1PhaseProblem::_hc_radial_heat_conduction_rhs
protected

Definition at line 43 of file TriSubChannel1PhaseProblem.h.

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

◆ _hc_sweep_enthalpy_mat

Mat TriSubChannel1PhaseProblem::_hc_sweep_enthalpy_mat
protected

Definition at line 44 of file TriSubChannel1PhaseProblem.h.

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

◆ _hc_sweep_enthalpy_rhs

Vec TriSubChannel1PhaseProblem::_hc_sweep_enthalpy_rhs
protected

Definition at line 45 of file TriSubChannel1PhaseProblem.h.

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

◆ _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

◆ _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 158 of file SubChannel1PhaseProblem.h.

Referenced by SubChannel1PhaseProblem::computeDP(), 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 248 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 122 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 144 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 187 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 162 of file SubChannel1PhaseProblem.h.

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

◆ _subchannel_mesh

SubChannelMesh& SubChannel1PhaseProblem::_subchannel_mesh
protectedinherited

◆ _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 148 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 146 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 124 of file SubChannel1PhaseProblem.h.

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

◆ _tri_sch_mesh

TriSubChannelMesh& TriSubChannel1PhaseProblem::_tri_sch_mesh
protected

◆ _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: