75 unsigned int i_pin = std::numeric_limits<unsigned int>::max();
80 NusseltStruct(Real Re_, Real Pr_,
unsigned int i_pin_,
unsigned int iz_,
unsigned int i_ch_)
117 return alpha * botValue + (1.0 - alpha) * topValue;
163 friend PetscErrorCode
formFunction(SNES snes, Vec
x, Vec
f,
void * ctx);
187 Mat M_ww, Mat M_wp, Vec b_w, Vec Wij_iter,
int iblock, PetscScalar & inv_dtau);
219 mooseError(
name(),
": Invalid gravity direction: expected counter_flow, co_flow, or none");
237 Mat
A, Vec rhs,
unsigned int first_node,
unsigned int last_node,
const char * ksp_prefix);
244 PetscErrorCode
addTermMatrices(Mat system,
const std::vector<Mat> & terms,
bool & pattern_set);
376 LibmeshPetscCall(VecCreate(PETSC_COMM_SELF, &
v));
377 LibmeshPetscCall(PetscObjectSetName((PetscObject)
v,
"Solution"));
378 LibmeshPetscCall(VecSetSizes(
v, PETSC_DECIDE, n));
379 LibmeshPetscCall(VecSetFromOptions(
v));
380 LibmeshPetscCall(VecZeroEntries(
v));
381 PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
387 LibmeshPetscCall(MatCreate(PETSC_COMM_SELF, &
M));
388 LibmeshPetscCall(MatSetSizes(
M, PETSC_DECIDE, PETSC_DECIDE, n, m));
389 LibmeshPetscCall(MatSetFromOptions(
M));
390 LibmeshPetscCall(MatSetUp(
M));
391 PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
397 const unsigned int first_axial_level,
398 const unsigned int last_axial_level,
399 const unsigned int cross_dimension);
403 const unsigned int first_axial_level,
404 const unsigned int last_axial_level,
405 const unsigned int cross_dimension);
409 const unsigned int first_axial_level,
410 const unsigned int last_axial_level,
411 const unsigned int cross_dimension);
415 const unsigned int first_axial_level,
416 const unsigned int last_axial_level,
417 const unsigned int cross_dimension);
519 const unsigned int first_axial_level,
520 const unsigned int last_axial_level,
521 const unsigned int cross_dimension)
526 LibmeshPetscCall(VecGetArray(
x, &xx));
527 for (
unsigned int iz = first_axial_level; iz < last_axial_level + 1; iz++)
529 unsigned int iz_ind = iz - first_axial_level;
530 for (
unsigned int i_l = 0; i_l < cross_dimension; i_l++)
532 loc_solution(i_l, iz) = xx[iz_ind * cross_dimension + i_l];
535 LibmeshPetscCall(VecRestoreArray(
x, &xx));
537 PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
543 const T & loc_solution,
544 const unsigned int first_axial_level,
545 const unsigned int last_axial_level,
546 const unsigned int cross_dimension)
551 LibmeshPetscCall(VecGetArray(
x, &xx));
552 for (
unsigned int iz = first_axial_level; iz < last_axial_level + 1; iz++)
554 unsigned int iz_ind = iz - first_axial_level;
555 for (
unsigned int i_l = 0; i_l < cross_dimension; i_l++)
558 xx[iz_ind * cross_dimension + i_l] = loc_solution(loc_node);
561 LibmeshPetscCall(VecRestoreArray(
x, &xx));
563 PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
569 const T & loc_solution,
570 const unsigned int first_axial_level,
571 const unsigned int last_axial_level,
572 const unsigned int cross_dimension)
576 LibmeshPetscCall(VecGetArray(
x, &xx));
577 for (
unsigned int iz = first_axial_level; iz < last_axial_level + 1; iz++)
579 unsigned int iz_ind = iz - first_axial_level;
580 for (
unsigned int i_l = 0; i_l < cross_dimension; i_l++)
582 xx[iz_ind * cross_dimension + i_l] = loc_solution(i_l, iz);
585 LibmeshPetscCall(VecRestoreArray(
x, &xx));
586 PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
593 const unsigned int first_axial_level,
594 const unsigned int last_axial_level,
595 const unsigned int cross_dimension)
599 LibmeshPetscCall(VecGetArray(
x, &xx));
601 for (
unsigned int iz = first_axial_level; iz < last_axial_level + 1; iz++)
603 unsigned int iz_ind = iz - first_axial_level;
604 for (
unsigned int i_l = 0; i_l < cross_dimension; i_l++)
607 loc_solution.set(loc_node, xx[iz_ind * cross_dimension + i_l]);
613 LibmeshPetscCall(VecRestoreArray(
x, &xx));
614 PetscFunctionReturn(LIBMESH_PETSC_SUCCESS);
Real f(Real x)
Test function for Brents method.
const std::vector< double > x
const std::string & name() const
void mooseError(Args &&... args) const
Base class for friction closures used in SCM.
Base class for the convective heat transfer coefficients (HTC) closures used in SCM.
Base class for turbulent mixing closures used in SCM.
Common class for single phase fluid properties.
Base class for the 1-phase steady-state/transient subchannel solver.
libMesh::DenseMatrix< Real > _DP
const PostprocessorValue & getOutletPressure() const
Get outlet pressure.
void computeP(int iblock)
Computes Pressure per channel for block iblock.
Mat _hc_sys_h_mat
System matrices.
PetscErrorCode populateSolutionChan(const Vec &x, T &solution, const unsigned int first_axial_level, const unsigned int last_axial_level, const unsigned int cross_dimension)
const Real & _mass_flow_equation_relaxation
Equation relaxation factor for mass flow rate in the monolithic solve.
Vec _mc_axial_convection_rhs
const Real & _pressure_equation_relaxation
Equation relaxation factor for pressure in the monolithic solve.
PetscErrorCode createPetscVector(Vec &v, PetscInt n)
Petsc Functions.
const PetscInt _monolithic_retry_maxit
Largest number of FGMRES iterations of a monolithic solve before it is retried with more damping.
virtual void syncSolutions(Direction direction) override
const bool _segregated_bool
Segregated solve.
PetscScalar computeInterpolatedValue(PetscScalar topValue, PetscScalar botValue, PetscScalar Peclet=0.0)
const SCMMixingClosureBase * _mixing_closure
Turbulent Mixing closure object.
PetscErrorCode shiftCrossflowDamping(Mat M_ww, Vec b_w, Vec Wij_iter, PetscScalar inv_dtau)
Add the damping of the inverse pseudo-time step inv_dtau to the cross-momentum equation: inv_dtau L_i...
Real computeSweepFlowMixingParameter(unsigned int i_gap, unsigned int iz) const
Computes and validates the sweep-flow mixing parameter.
virtual ~SubChannel1PhaseProblem()
const SCMHTCClosureBase * _pin_HTC_closure
HTC closure objects.
const SCMHTCClosureBase * _duct_HTC_closure
static constexpr Real _max_crossflow_pseudo_time_step_reduction
Cap on the pseudo-time step reduction: the reduction one fully retried monolithic solve provides.
Mat _cmc_friction_force_mat
Cross momentum conservation - friction force.
std::unique_ptr< SolutionHandle > _w_perim_soln
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.
PetscErrorCode addCrossflowDamping(Mat M_ww, Mat M_wp, Vec b_w, Vec Wij_iter, int iblock, PetscScalar &inv_dtau)
Add the pseudo-time damping added_K_ij (Wij - Wij_iter) to the cross-momentum equation of the monolit...
const PetscReal & _dtol
The divergence tolerance for the ksp linear solver.
PetscErrorCode createPetscMatrix(Mat &M, PetscInt n, PetscInt m)
Real getAddedHeatDuct(unsigned int i_ch, unsigned int iz) const
Return the added heat coming from the duct.
virtual void initializeSolution()=0
Function to initialize the solution & geometry fields.
std::unique_ptr< SolutionHandle > _displacement_soln
Mat _hc_time_derivative_mat
Enthalpy Enthalpy conservation - time derivative.
Mat _cmc_time_derivative_mat
Cross momentum Cross momentum conservation - time derivative.
const SCMFrictionClosureBase * _friction_closure
Friction closure object.
Mat _amc_turbulent_cross_flows_mat
Axial momentum Axial momentum conservation - compute turbulent cross fluxes.
bool _cmc_sys_Wij_pattern_set
static InputParameters validParams()
PetscErrorCode solveAndPopulateEnthalpy(Mat A, Vec rhs, unsigned int first_node, unsigned int last_node, const char *ksp_prefix)
Solve a linear system (A * x = rhs) with a simple PCJACOBI KSP and populate the enthalpy solution int...
const SCMHTCClosureBase * getDuctHTCClosure() const
const SinglePhaseFluidProperties * _fp
Non-owning pointer to fluid properties user object.
Mat _amc_sys_mdot_mat
Axial momentum system matrix.
Mat _cmc_sys_Wij_mat
Lateral momentum system matrix.
static constexpr unsigned int _max_crossflow_retries
Number of monolithic linear-solve retries, each halving the crossflow pseudo-time step.
libMesh::DenseMatrix< Real > _WijPrime
Vec _hc_cross_derivative_rhs
void computeRho(int iblock)
Computes Density per channel for block iblock.
const SCMFrictionClosureBase * getFrictionClosure() const
virtual Real getSubChannelPeripheralDuctWidth(unsigned int i_ch) const =0
Function that computes the width of the duct cell that the peripheral subchannel i_ch sees.
Real computeGravityDir(const MooseEnum &dir) const
inline function that is used to define the gravity direction
std::unique_ptr< SolutionHandle > _DP_soln
const MooseEnum _interpolation_scheme
The interpolation method used in constructing the systems.
std::unique_ptr< SolutionHandle > _rho_soln
Mat _mc_sumWij_mat
Matrices and vectors to be used in implicit assembly Mass conservation Mass conservation - sum of cro...
std::unique_ptr< SolutionHandle > _duct_heat_flux_soln
struct SubChannel1PhaseProblem::FrictionStruct _friction_args
bool _amc_sys_mdot_pattern_set
Whether the nonzero patterns of the assembled system matrices have been established.
void computeDP(int iblock)
Computes Pressure Drop per channel for block iblock.
const Real & _T_tol
Convergence tolerance for the temperature loop in internal solve.
const bool _duct_mesh_exist
Flag that informs if there is a duct mesh or not.
std::unique_ptr< SolutionHandle > _S_flow_soln
void computeWijResidual(int iblock)
Computes Residual Matrix based on the lateral momentum conservation equation for block iblock.
const bool _compute_power
Flag that informs if we need to solve the Enthalpy/Temperature equations or not.
const PostprocessorValue & _P_out
Outlet pressure postprocessor value.
Real getBulkVelocity() const
virtual void initialSetup() override
std::unique_ptr< SolutionHandle > _Dpin_soln
Mat _cmc_pressure_force_mat
Cross momentum conservation - pressure force.
const SinglePhaseFluidProperties * getSinglePhaseFluidProperties() const
Get fluid properties object.
std::unique_ptr< SolutionHandle > _P_soln
Real _bulk_Re
Assembly bulk Reynolds number.
Vec _hc_advective_derivative_rhs
Vec _amc_pressure_force_rhs
unsigned int _n_blocks
number of axial blocks
void detectDeformation()
Detects whether pin diameter or duct displacement fields require geometry recalculation.
Mat _amc_time_derivative_mat
Axial momentum conservation - time derivative.
libMesh::DenseMatrix< Real > & _Wij
std::unique_ptr< SolutionHandle > _Tduct_soln
bool _deformation
Flag that activates the effect of deformation (pin/duct) based on the auxvalues for displacement,...
libMesh::DenseMatrix< Real > _Wij_residual_matrix
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.
std::unique_ptr< SolutionHandle > _h_soln
std::unique_ptr< SolutionHandle > _T_soln
virtual void computeh(int iblock)=0
Computes Enthalpy per channel for block iblock.
std::unique_ptr< SolutionHandle > _mu_soln
Real _TR
Flag that activates or deactivates the transient parts of the equations we solve by multiplication.
Vec _hc_time_derivative_rhs
virtual void externalSolve() override
Mat _cmc_advective_derivative_mat
Cross momentum conservation - advective (Eulerian) derivative.
const PetscInt _maxit
The maximum number of iterations to use for the ksp linear solver.
bool _time_integrator_checked
Whether the time integrator has been checked for consistency with the implementation.
Vec _hc_added_heat_rhs
Enthalpy conservation - source and sink.
const Real & _P_tol
Convergence tolerance for the pressure loop in external solve.
Mat _amc_friction_force_mat
Axial momentum conservation - friction force.
Real _CT
Turbulent modeling parameter used in axial momentum equation.
virtual Real computeAddedHeatPin(unsigned int i_ch, unsigned int iz) const =0
Pure virtual: daughters provide different implementations.
PetscErrorCode populateDenseFromVector(const Vec &x, T &solution, const unsigned int first_axial_level, const unsigned int last_axial_level, const unsigned int cross_dimension)
Real _pressure_fixed_point_error
Maximum pressure fixed-point update before solution relaxation over the blocks.
Mat _mc_density_pressure_mat
Mass conservation - pressure derivative of transient density.
const bool _compute_viscosity
Flag that activates or deactivates the calculation of viscosity.
Mat _hc_advective_derivative_mat
Enthalpy conservation - advective (Eulerian) derivative;.
Vec _cmc_time_derivative_rhs
Real getBulkReynoldsNumber() const
Vec _cmc_advective_derivative_rhs
PetscErrorCode populateVectorFromHandle(Vec &x, const T &solution, const unsigned int first_axial_level, const unsigned int last_axial_level, const unsigned int cross_dimension)
PetscErrorCode implicitPetscSolve(int iblock)
Computes implicit solve using PetSc.
const bool _compute_density
Flag that activates or deactivates the calculation of density.
libMesh::DenseVector< Real > residualFunction(int iblock, libMesh::DenseVector< Real > solution)
Computes Residual Vector based on the lateral momentum conservation equation for block iblock & updat...
bool _converged
Variable that informs whether we exited external solve with a converged solution or not.
const Real & _crossflow_pseudo_time_step
Initial pseudo-time step of the crossflow damping.
void computeSumWij(int iblock)
Computes net diversion crossflow per channel for block iblock.
const int & _T_maxit
Maximum iterations for the inner temperature loop.
const Real & _T_relaxation
Relaxation factor for temperature updates in the inner thermal-hydraulic iteration.
const Real & _crossflow_relaxation
Relaxation factor for crossflow updates in the monolithic solve.
std::unique_ptr< SolutionHandle > _Tpin_soln
const bool _pin_mesh_exist
Flag that informs if there is a pin mesh or not.
Vec _amc_time_derivative_rhs
Mat _amc_pressure_force_mat
Axial momentum conservation - pressure force.
const bool _crossflow_pseudo_time_damping
Whether the crossflow of the monolithic solve is damped with a pseudo-time derivative.
void computeMdot(int iblock)
Computes mass flow per channel for block iblock.
Real _bulk_V
Assembly bulk velocity.
const SCMHTCClosureBase * getPinHTCClosure() const
bool isImplicit() const
Whether the flow and enthalpy equations are solved implicitly.
Vec _cmc_pseudo_time_inertia
Crossflow inertia L_ij S_ij rho* of each gap of the block, the coefficient of the pseudo-time derivat...
std::unique_ptr< SolutionHandle > _SumWij_soln
const bool _implicit_bool
Flag to define the usage of a implicit or explicit solution.
const int & _P_maxit
Maximum number of pressure iterations; zero selects the solver's existing automatic limit.
std::vector< Real > _z_grid
axial location of nodes
virtual bool solverSystemConverged(const unsigned int) override
Vec _cmc_pressure_force_rhs
const Real & _mass_flow_relaxation
Relaxation factor for mass flow rate updates in the monolithic solve.
Vec _amc_cross_derivative_rhs
Mat _amc_cross_derivative_mat
Axial momentum conservation - cross flux derivative.
bool _hc_sys_h_pattern_set
std::vector< Real > _crossflow_residual_ref
Per-block largest cross-momentum residual norm of the solve, which scales the crossflow damping in th...
void computeWijFromSolve(int iblock)
Computes diversion crossflow per gap for block iblock.
const unsigned int & _enthalpy_subcycles
Number of enthalpy, temperature, and property updates performed per flow solve.
void computeMu(int iblock)
Computes Viscosity per channel for block iblock.
Vec _amc_friction_force_rhs
Vec _amc_turbulent_cross_flows_rhs
PetscErrorCode populateVectorFromDense(Vec &x, const T &solution, const unsigned int first_axial_level, const unsigned int last_axial_level, const unsigned int cross_dimension)
libMesh::DenseMatrix< Real > & _Wij_old
SubChannelMesh & _subchannel_mesh
struct SubChannel1PhaseProblem::NusseltStruct _nusselt_args
std::unique_ptr< SolutionHandle > _mdot_soln
Solutions handles and link to TH tables properties.
const MooseEnum _gravity_direction
The direction of gravity.
std::unique_ptr< SolutionHandle > _q_prime_soln
PetscScalar computeInterpolationCoefficients(PetscScalar Peclet=0.0) const
Functions that computes the interpolation scheme given the Peclet number.
virtual Real computeAddedHeatDuct(unsigned int i_ch, unsigned int iz) const
Non-pure: implemented in the base (or override in a child if needed)
const PetscReal & _rtol
The relative convergence tolerance, (relative decrease) for the ksp linear solver.
const Real & _crossflow_equation_relaxation
Equation relaxation factor for crossflow in the monolithic solve.
Vec _amc_gravity_rhs
Axial momentum conservation - buoyancy force No implicit matrix.
Mat _mc_axial_convection_mat
Mass conservation - axial convection.
Vec _amc_advective_derivative_rhs
Mat _amc_advective_derivative_mat
Axial momentum conservation - advective (Eulerian) derivative.
Real getAddedHeatPin(unsigned int i_ch, unsigned int iz) const
Return the added heat coming from the fuel pins.
PetscScalar interpolateFaceValue(PetscScalar topValue, PetscScalar botValue) const
Interpolate a face value from its top and bottom nodes with the configured scheme.
void computeBulkReynoldsNumber()
Computes the assembly bulk Reynolds number from inlet flow conditions.
Real computeT(int iblock)
Computes and relaxes Temperature per channel for block iblock.
PetscErrorCode addTermMatrices(Mat system, const std::vector< Mat > &terms, bool &pattern_set)
Add the term matrices to a system matrix that was zeroed beforehand.
const MooseEnum _monolithic_preconditioner
Preconditioner of the monolithic flow system.
void computeWijPrime(int iblock)
Computes turbulent crossflow per gap for block iblock.
Real computeMixingParameter(unsigned int i_gap, unsigned int iz) const
Computes and validates the turbulent mixing parameter.
std::unique_ptr< SolutionHandle > _ff_soln
std::vector< Real > _crossflow_pseudo_time_step_reduction
Per-block factor, raised after monolithic linear-solve failures, that divides the crossflow pseudo-ti...
Vec _cmc_friction_force_rhs
const bool _verbose_subchannel
Boolean to printout information related to subchannel solve.
Mat _hc_cross_derivative_mat
Enthalpy conservation - cross flux derivative.
const PetscReal & _atol
The absolute convergence tolerance for the ksp linear solver.
const Real & _pressure_relaxation
Relaxation factor for pressure updates in the monolithic solve.
const PetscInt _monolithic_gmres_restart
Restart length of the FGMRES solver of the monolithic flow system.
std::unique_ptr< SolutionHandle > _HTC_soln
Base class for subchannel meshes.
virtual Node * getChannelNode(unsigned int i_chan, unsigned int iz) const =0
Get the subchannel mesh node for a given channel index and elevation index.
structure with the needed information to compute the friction factor at a specific subchannel cell
FrictionStruct(unsigned int i_ch_, Real Re_, Real S_, Real w_perim_)
structure with the needed information to compute the Nusselt number at a specific subchannel cell and...
NusseltStruct(Real Re_, Real Pr_, unsigned int i_pin_, unsigned int iz_, unsigned int i_ch_)