LCOV - code coverage report
Current view: top level - include/utils - CHTHandler.h (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 2bd28b Lines: 4 6 66.7 %
Date: 2025-10-23 22:11:45 Functions: 0 1 0.0 %
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             : #include "MooseObject.h"
      13             : #include "FaceCenteredMapFunctor.h"
      14             : #include "SystemBase.h"
      15             : #include "NS.h"
      16             : 
      17             : class LinearFVFluxKernel;
      18             : class LinearFVBoundaryCondition;
      19             : 
      20             : namespace NS
      21             : {
      22             : namespace FV
      23             : {
      24             : 
      25             : /**
      26             :  * This class provides an interface for managing  conjugate heat transfer (CHT)
      27             :  * between fluid and solid domains.
      28             :  */
      29             : class CHTHandler : public MooseObject
      30             : {
      31             : public:
      32             :   /// Constructor with initialization parameters
      33             :   CHTHandler(const InputParameters & parameters);
      34             : 
      35             :   static InputParameters validParams();
      36             : 
      37             :   /// Link energy systems
      38             :   void linkEnergySystems(SystemBase * solid_energy_system, SystemBase * fluid_energy_system);
      39             : 
      40             :   /// Set up the boundary condition pairs, functor maps, and every other necessary
      41             :   /// structure for the conjugate heat transfer routines
      42             :   void setupConjugateHeatTransferContainers();
      43             : 
      44             :   /// Run error checks and make sure everything works
      45             :   void deduceCHTBoundaryCoupling();
      46             : 
      47             :   /// Update the coupling fields for \param side
      48             :   void updateCHTBoundaryCouplingFields(const NS::CHTSide side);
      49             : 
      50             :   /// Initialize the coupling fields for the conjugate heat transfer routines
      51             :   void initializeCHTCouplingFields();
      52             : 
      53             :   /// Check if CHT iteration converged
      54             :   bool converged() const;
      55             : 
      56             :   /// Reset the convergence data
      57             :   void resetCHTConvergence();
      58             : 
      59             :   /// Increment CHT iterators in the loop
      60             :   void incrementCHTIterators();
      61             : 
      62             :   /// Sum the integrated fluxes over all processors
      63             :   void sumIntegratedFluxes();
      64             : 
      65             :   /// Print the integrated heat fluxes
      66             :   void printIntegratedFluxes() const;
      67             : 
      68             :   /// Reset the heat fluxes to 0
      69             :   void resetIntegratedFluxes();
      70             : 
      71             :   /// Check if CHT treatment is needed
      72             :   virtual bool enabled() const override final;
      73             : 
      74             : protected:
      75             :   /// Reference to FEProblem
      76             :   FEProblemBase & _problem;
      77             : 
      78             :   /// Mesh
      79             :   MooseMesh & _mesh;
      80             : 
      81             :   /// The energy system
      82             :   SystemBase * _energy_system;
      83             : 
      84             :   /// The solid energy system
      85             :   SystemBase * _solid_energy_system;
      86             : 
      87             :   /// The names of the CHT boundaries
      88             :   std::vector<BoundaryName> _cht_boundary_names;
      89             : 
      90             :   /// The IDs of the CHT boundaries
      91             :   std::vector<BoundaryID> _cht_boundary_ids;
      92             : 
      93             :   /// Maximum number of CHT fixed point iterations.
      94             :   const unsigned int _max_cht_fpi;
      95             : 
      96             :   /// Tolerance for heat flux at the CHT interfaces
      97             :   const Real _cht_heat_flux_tolerance;
      98             : 
      99             :   /// The relaxation factors for flux fields for the CHT boundaries
     100             :   /// first index is solid/fluid second is the interface
     101             :   std::vector<std::vector<Real>> _cht_flux_relaxation_factor;
     102             : 
     103             :   /// The relaxation factors for temperature fields for the CHT boundaries
     104             :   /// first index is solid/fluid second is the interface
     105             :   std::vector<std::vector<Real>> _cht_temperature_relaxation_factor;
     106             : 
     107             :   /// The solid (0) and fluid (1) system numbers.
     108             :   std::vector<unsigned int> _cht_system_numbers;
     109             : 
     110             :   /// The subset of the FaceInfo objects that belong to the given boundaries.
     111             :   std::vector<std::vector<const FaceInfo *>> _cht_face_info;
     112             : 
     113             :   /// The conduction kernels from the solid/fluid domains. Can't be const, considering we are updating the inner structures for every face.
     114             :   std::vector<LinearFVFluxKernel *> _cht_conduction_kernels;
     115             : 
     116             :   /// Vector of boundary conditions that describe the conjugate heat transfer from each side.
     117             :   std::vector<std::vector<LinearFVBoundaryCondition *>> _cht_boundary_conditions;
     118             : 
     119             :   /// Functors describing the heat flux on the conjugate heat transfer interfaces.
     120             :   /// Two functors per sideset, first is solid second is fluid.
     121             :   std::vector<std::vector<FaceCenteredMapFunctor<Real, std::unordered_map<dof_id_type, Real>>>>
     122             :       _boundary_heat_flux;
     123             : 
     124             :   /// Integrated flux for the boundaries, first index is the boundary second is solid/fluid.
     125             :   std::vector<std::vector<Real>> _integrated_boundary_heat_flux;
     126             : 
     127             :   /// Functors describing the heat flux on the conjugate heat transfer interfaces.
     128             :   /// Two functors per sideset, first is solid second is fluid.
     129             :   std::vector<std::vector<FaceCenteredMapFunctor<Real, std::unordered_map<dof_id_type, Real>>>>
     130             :       _boundary_temperature;
     131             : 
     132             : private:
     133             :   /// CHT fixed point iteration counter
     134             :   unsigned int _fpi_it;
     135             : };
     136             : 
     137             : inline bool
     138           0 : CHTHandler::enabled() const
     139             : {
     140           0 :   return !_cht_boundary_names.empty();
     141             : }
     142             : 
     143             : inline void
     144             : CHTHandler::resetCHTConvergence()
     145             : {
     146       32235 :   _fpi_it = 0;
     147       32235 : }
     148             : 
     149             : inline void
     150             : CHTHandler::incrementCHTIterators()
     151             : {
     152       35529 :   _fpi_it++;
     153       35529 : }
     154             : 
     155             : } // End FV namespace
     156             : } // End Moose namespace

Generated by: LCOV version 1.14