LCOV - code coverage report
Current view: top level - include/executioners - SIMPLESolveBase.h (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 2 5 40.0 %
Date: 2025-08-14 10:14:56 Functions: 1 3 33.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #pragma once
      11             : 
      12             : // Moose includes
      13             : #include "SolveObject.h"
      14             : #include "UserObjectInterface.h"
      15             : #include "PetscSupport.h"
      16             : #include "SolverParams.h"
      17             : #include "SegregatedSolverUtils.h"
      18             : 
      19             : // Libmesh includes
      20             : #include "libmesh/solver_configuration.h"
      21             : #include "libmesh/petsc_vector.h"
      22             : #include "libmesh/petsc_matrix.h"
      23             : #include "libmesh/equation_systems.h"
      24             : 
      25             : /**
      26             :  * Solver configuration class used with the linear solvers in a SIMPLE solver.
      27             :  */
      28       10857 : class SIMPLESolverConfiguration : public libMesh::SolverConfiguration
      29             : {
      30             :   /**
      31             :    * Override this to make sure the PETSc options are not overwritten in the linear solver
      32             :    */
      33      727508 :   virtual void configure_solver() override {}
      34             : };
      35             : 
      36             : /**
      37             :  * Solve class serving as a base class for the two SIMPLE solvers that operate with
      38             :  * different assembly algorithms. Includes base routines and variables for the coupling of
      39             :  * momentum and pressure.
      40             :  */
      41             : class SIMPLESolveBase : public SolveObject, public UserObjectInterface
      42             : {
      43             : public:
      44             :   SIMPLESolveBase(Executioner & ex);
      45             : 
      46             :   static InputParameters validParams();
      47             : 
      48           0 :   virtual void setInnerSolve(SolveObject &) override
      49             :   {
      50           0 :     mooseError("Cannot set inner solve object for solves that inherit from SIMPLESolveBase");
      51             :   }
      52             : 
      53             :   /// Fetch the Rhie Chow user object that is reponsible for determining face
      54             :   /// velocities and mass flux
      55             :   virtual void linkRhieChowUserObject() = 0;
      56             : 
      57             :   /// Setup pressure pin if there is need for one
      58             :   void setupPressurePin();
      59             : 
      60             :   /// Check if the user defined time kernels
      61           0 :   virtual void checkIntegrity() {}
      62             : 
      63             : protected:
      64             :   void checkDependentParameterError(const std::string & main_parameter,
      65             :                                     const std::vector<std::string> & dependent_parameters,
      66             :                                     const bool should_be_defined);
      67             : 
      68             :   /// Solve a momentum predictor step with a fixed pressure field
      69             :   /// @return A vector of (number of linear iterations, normalized residual norm) pairs for
      70             :   /// the momentum equations. The length of the vector equals the dimensionality of
      71             :   /// the domain.
      72             :   virtual std::vector<std::pair<unsigned int, Real>> solveMomentumPredictor() = 0;
      73             : 
      74             :   /// Solve a pressure corrector step.
      75             :   /// @return The number of linear iterations and the normalized residual norm of
      76             :   /// the pressure equation.
      77             :   virtual std::pair<unsigned int, Real> solvePressureCorrector() = 0;
      78             : 
      79             :   // ************************ Momentum Eq Variables ************************ //
      80             : 
      81             :   /// The names of the momentum systems.
      82             :   const std::vector<SolverSystemName> & _momentum_system_names;
      83             : 
      84             :   /// Options for the linear solver of the momentum equation
      85             :   SIMPLESolverConfiguration _momentum_linear_control;
      86             : 
      87             :   /// Absolute linear tolerance for the momentum equation(s). We need to store this, because
      88             :   /// it needs to be scaled with a representative flux.
      89             :   const Real _momentum_l_abs_tol;
      90             : 
      91             :   /// Options which hold the petsc settings for the momentum equation
      92             :   Moose::PetscSupport::PetscOptions _momentum_petsc_options;
      93             : 
      94             :   /// The user-defined relaxation parameter for the momentum equation
      95             :   const Real _momentum_equation_relaxation;
      96             : 
      97             :   // ************************ Pressure Eq Variables ************************ //
      98             : 
      99             :   /// The name of the pressure system
     100             :   const SolverSystemName & _pressure_system_name;
     101             : 
     102             :   /// Options for the linear solver of the pressure equation
     103             :   SIMPLESolverConfiguration _pressure_linear_control;
     104             : 
     105             :   /// Absolute linear tolerance for the pressure equation. We need to store this, because
     106             :   /// it needs to be scaled with a representative flux.
     107             :   const Real _pressure_l_abs_tol;
     108             : 
     109             :   /// Options which hold the petsc settings for the pressure equation
     110             :   Moose::PetscSupport::PetscOptions _pressure_petsc_options;
     111             : 
     112             :   /// The user-defined relaxation parameter for the pressure variable
     113             :   const Real _pressure_variable_relaxation;
     114             : 
     115             :   /// If the pressure needs to be pinned
     116             :   const bool _pin_pressure;
     117             : 
     118             :   /// The value we want to enforce for pressure
     119             :   const Real _pressure_pin_value;
     120             : 
     121             :   /// The dof ID where the pressure needs to be pinned
     122             :   dof_id_type _pressure_pin_dof;
     123             : 
     124             :   // ************************ Energy Eq Variables ************************** //
     125             : 
     126             :   /// Boolean for easy check if a fluid energy system shall be solved or not
     127             :   const bool _has_energy_system;
     128             : 
     129             :   /// The user-defined relaxation parameter for the energy equation
     130             :   const Real _energy_equation_relaxation;
     131             : 
     132             :   /// Options which hold the petsc settings for the fluid energy equation
     133             :   Moose::PetscSupport::PetscOptions _energy_petsc_options;
     134             : 
     135             :   /// Options for the linear solver of the energy equation
     136             :   SIMPLESolverConfiguration _energy_linear_control;
     137             : 
     138             :   /// Absolute linear tolerance for the energy equations. We need to store this, because
     139             :   /// it needs to be scaled with a representative flux.
     140             :   const Real _energy_l_abs_tol;
     141             : 
     142             :   // ************************ Solid Energy Eq Variables *********************** //
     143             : 
     144             :   /// Boolean for easy check if a solid energy system shall be solved or not
     145             :   const bool _has_solid_energy_system;
     146             : 
     147             :   /// Options which hold the petsc settings for the fluid energy equation
     148             :   Moose::PetscSupport::PetscOptions _solid_energy_petsc_options;
     149             : 
     150             :   /// Options for the linear solver of the energy equation
     151             :   SIMPLESolverConfiguration _solid_energy_linear_control;
     152             : 
     153             :   /// Absolute linear tolerance for the energy equations. We need to store this, because
     154             :   /// it needs to be scaled with a representative flux.
     155             :   const Real _solid_energy_l_abs_tol;
     156             : 
     157             :   // ************************ Passive Scalar Variables ************************ //
     158             : 
     159             :   /// The names of the passive scalar systems
     160             :   const std::vector<SolverSystemName> & _passive_scalar_system_names;
     161             : 
     162             :   /// Boolean for easy check if a passive scalar systems shall be solved or not
     163             :   const bool _has_passive_scalar_systems;
     164             : 
     165             :   // The number(s) of the system(s) corresponding to the passive scalar equation(s)
     166             :   std::vector<unsigned int> _passive_scalar_system_numbers;
     167             : 
     168             :   /// The user-defined relaxation parameter(s) for the passive scalar equation(s)
     169             :   const std::vector<Real> _passive_scalar_equation_relaxation;
     170             : 
     171             :   /// Options which hold the petsc settings for the passive scalar equation(s)
     172             :   Moose::PetscSupport::PetscOptions _passive_scalar_petsc_options;
     173             : 
     174             :   /// Options for the linear solver of the passive scalar equation(s)
     175             :   SIMPLESolverConfiguration _passive_scalar_linear_control;
     176             : 
     177             :   /// Absolute linear tolerance for the passive scalar equation(s). We need to store this, because
     178             :   /// it needs to be scaled with a representative flux.
     179             :   const Real _passive_scalar_l_abs_tol;
     180             : 
     181             :   // ************************ Turbulence Variables ************************ //
     182             : 
     183             :   /// The names of the turbulence systems
     184             :   const std::vector<SolverSystemName> & _turbulence_system_names;
     185             : 
     186             :   /// Boolean for easy check if a turbulence scalar systems shall be solved or not
     187             :   const bool _has_turbulence_systems;
     188             : 
     189             :   // The number(s) of the system(s) corresponding to the turbulence equation(s)
     190             :   std::vector<unsigned int> _turbulence_system_numbers;
     191             : 
     192             :   /// The user-defined relaxation parameter(s) for the turbulence equation(s)
     193             :   const std::vector<Real> _turbulence_equation_relaxation;
     194             : 
     195             :   /// The user-defined relaxation parameter(s) for the turbulence field(s)
     196             :   std::vector<Real> _turbulence_field_relaxation;
     197             : 
     198             :   /// The user-defined lower limit for turbulent quantities e.g. k, eps/omega, etc..
     199             :   std::vector<Real> _turbulence_field_min_limit;
     200             : 
     201             :   /// Options which hold the petsc settings for the turbulence equation(s)
     202             :   Moose::PetscSupport::PetscOptions _turbulence_petsc_options;
     203             : 
     204             :   /// Options for the linear solver of the turbulence equation(s)
     205             :   SIMPLESolverConfiguration _turbulence_linear_control;
     206             : 
     207             :   /// Absolute linear tolerance for the turbulence equation(s). We need to store this, because
     208             :   /// it needs to be scaled with a representative flux.
     209             :   const Real _turbulence_l_abs_tol;
     210             : 
     211             :   // ************************ Iteration control **************************** //
     212             : 
     213             :   /// The user-defined absolute tolerance for determining the convergence in momentum
     214             :   const Real _momentum_absolute_tolerance;
     215             : 
     216             :   /// The user-defined absolute tolerance for determining the convergence in pressure
     217             :   const Real _pressure_absolute_tolerance;
     218             : 
     219             :   /// The user-defined absolute tolerance for determining the convergence in energy
     220             :   const Real _energy_absolute_tolerance;
     221             : 
     222             :   /// The user-defined absolute tolerance for determining the convergence in solid energy
     223             :   const Real _solid_energy_absolute_tolerance;
     224             : 
     225             :   /// The user-defined absolute tolerance for determining the convergence in passive scalars
     226             :   const std::vector<Real> _passive_scalar_absolute_tolerance;
     227             : 
     228             :   /// The user-defined absolute tolerance for determining the convergence turbulence variables
     229             :   const std::vector<Real> _turbulence_absolute_tolerance;
     230             : 
     231             :   /// The maximum number of momentum-pressure iterations
     232             :   const unsigned int _num_iterations;
     233             : 
     234             :   /// If solve should continue if maximum number of iterations is hit
     235             :   const bool _continue_on_max_its;
     236             : 
     237             :   // ************************ Other Variables ****************************** //
     238             : 
     239             :   /// Debug parameter which allows printing the coupling and solution vectors/matrices
     240             :   const bool _print_fields;
     241             : };

Generated by: LCOV version 1.14