https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Private Member Functions | Private Attributes | List of all members
NS::FV::CHTHandler Class Reference

This class provides an interface for managing conjugate heat transfer (CHT) between fluid and solid domains. More...

#include <CHTHandler.h>

Inheritance diagram for NS::FV::CHTHandler:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 CHTHandler (const InputParameters &parameters)
 Constructor with initialization parameters.
 
void linkEnergySystems (SystemBase *solid_energy_system, SystemBase *fluid_energy_system, std::vector< SystemBase * > pm_radiation_systems)
 Link energy systems.
 
void setupConjugateHeatTransferContainers ()
 Set up the boundary condition pairs, functor maps, and every other necessary structure for the conjugate heat transfer routines.
 
void deduceCHTBoundaryCoupling ()
 Run error checks and make sure everything works.
 
void updateCHTBoundaryCouplingFields (const NS::CHTSide side)
 Update the coupling fields for.
 
void initializeCHTCouplingFields ()
 Initialize the coupling fields for the conjugate heat transfer routines.
 
bool converged () const
 Check if CHT iteration converged.
 
void resetCHTConvergence ()
 Reset the convergence data.
 
void incrementCHTIterators ()
 Increment CHT iterators in the loop.
 
void sumIntegratedFluxes ()
 Sum the integrated fluxes over all processors.
 
void printIntegratedFluxes () const
 Print the integrated heat fluxes.
 
void resetIntegratedFluxes ()
 Reset the heat fluxes to 0.
 
virtual bool enabled () const override final
 Check if CHT treatment is needed.
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
bool isKokkosObject () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParametersparameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const TgetParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const TqueryParam (const std::string &name) const
 
const TgetRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (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
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) 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
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 

Protected Member Functions

void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) const
 

Protected Attributes

FEProblemBase_problem
 Reference to FEProblem.
 
MooseMesh_mesh
 Mesh.
 
SystemBase_energy_system
 The energy system.
 
SystemBase_solid_energy_system
 The solid energy system.
 
std::vector< SystemBase * > _pm_radiation_systems
 The solid energy system.
 
std::vector< BoundaryName > _cht_boundary_names
 The names of the CHT boundaries.
 
std::vector< BoundaryID_cht_boundary_ids
 The IDs of the CHT boundaries.
 
const unsigned int _max_cht_fpi
 Maximum number of CHT fixed point iterations.
 
const Real _cht_heat_flux_tolerance
 Tolerance for heat flux at the CHT interfaces.
 
std::vector< std::vector< Real > > _cht_flux_relaxation_factor
 The relaxation factors for flux fields for the CHT boundaries first index is solid/fluid second is the interface.
 
std::vector< std::vector< Real > > _cht_temperature_relaxation_factor
 The relaxation factors for temperature fields for the CHT boundaries first index is solid/fluid second is the interface.
 
std::vector< unsigned int_cht_system_numbers
 The solid (0) and fluid (1) system numbers.
 
std::vector< unsigned int_cht_pm_radiation_system_numbers
 The participating media radiation system numbers.
 
std::vector< std::vector< const FaceInfo * > > _cht_face_info
 The subset of the FaceInfo objects that belong to the given boundaries.
 
std::vector< LinearFVFluxKernel * > _cht_conduction_kernels
 The conduction kernels from the solid/fluid domains. Can't be const, considering we are updating the inner structures for every face.
 
std::vector< LinearFVFluxKernel * > _cht_pm_radiation_kernels
 The conduction radiation kernels from the fluid domains.
 
std::vector< std::vector< LinearFVBoundaryCondition * > > _cht_boundary_conditions
 Vector of boundary conditions that describe the conjugate heat transfer from each side.
 
std::vector< std::vector< LinearFVBoundaryCondition * > > _cht_pm_radiation_boundary_conditions
 Vector of boundary conditions that describe the radiation pm bcs from each side.
 
std::vector< std::vector< FaceCenteredMapFunctor< Real, std::unordered_map< dof_id_type, Real > > > > _boundary_heat_flux
 Functors describing the heat flux on the conjugate heat transfer interfaces.
 
std::vector< std::vector< Real > > _integrated_boundary_heat_flux
 Integrated flux for the boundaries, first index is the boundary second is solid/fluid.
 
std::vector< std::vector< FaceCenteredMapFunctor< Real, std::unordered_map< dof_id_type, Real > > > > _boundary_temperature
 Functors describing the heat flux on the conjugate heat transfer interfaces.
 
const bool & _enabled
 
MooseApp_app
 
Factory_factory
 
ActionFactory_action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters_pars
 
const Parallel::Communicator & _communicator
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 

Private Attributes

unsigned int _fpi_it
 CHT fixed point iteration counter.
 
const ParallelParamObject_parent
 
const MooseBase_si_moose_base
 
const FEProblemBase_si_problem
 

Detailed Description

This class provides an interface for managing conjugate heat transfer (CHT) between fluid and solid domains.

Definition at line 29 of file CHTHandler.h.

Constructor & Destructor Documentation

◆ CHTHandler()

NS::FV::CHTHandler::CHTHandler ( const InputParameters parameters)

Constructor with initialization parameters.

Definition at line 76 of file CHTHandler.C.

77 : MooseObject(params),
78 _problem(*getCheckedPointerParam<FEProblemBase *>(
79 "_fe_problem_base", "This might happen if you don't have a mesh")),
81 _cht_boundary_names(getParam<std::vector<BoundaryName>>("cht_interfaces")),
83 _max_cht_fpi(getParam<unsigned int>("max_cht_fpi")),
84 _cht_heat_flux_tolerance(getParam<Real>("cht_heat_flux_tolerance"))
85{
86 if (isParamSetByUser("cht_interfaces") && !_cht_boundary_names.size())
87 paramError("cht_interfaces", "You must declare at least one interface!");
88}
virtual MooseMesh & mesh() override
void paramError(const std::string &param, Args... args) const
bool isParamSetByUser(const std::string &name) const
const T & getParam(const std::string &name) const
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
const Real _cht_heat_flux_tolerance
Tolerance for heat flux at the CHT interfaces.
Definition CHTHandler.h:102
std::vector< BoundaryName > _cht_boundary_names
The names of the CHT boundaries.
Definition CHTHandler.h:93
MooseMesh & _mesh
Mesh.
Definition CHTHandler.h:81
std::vector< BoundaryID > _cht_boundary_ids
The IDs of the CHT boundaries.
Definition CHTHandler.h:96
FEProblemBase & _problem
Reference to FEProblem.
Definition CHTHandler.h:78
const unsigned int _max_cht_fpi
Maximum number of CHT fixed point iterations.
Definition CHTHandler.h:99

Member Function Documentation

◆ converged()

bool NS::FV::CHTHandler::converged ( ) const

Check if CHT iteration converged.

Definition at line 495 of file CHTHandler.C.

496{
497 if (_fpi_it >= _max_cht_fpi)
498 return true;
499
500 for (const auto & boundary_flux : _integrated_boundary_heat_flux)
501 {
502 const Real f1 = boundary_flux[0];
503 const Real f2 = boundary_flux[1];
504
505 // Special case: both are zero at startup not converged yet
506 if (_fpi_it != 0 && (f1 == 0.0 && f2 == 0.0))
507 return true;
508
509 // These fluxes should be of opposite sign
510 const Real diff = std::abs(f1 + f2);
511 const Real denom = std::max({std::fabs(f1), std::fabs(f2), Real(1e-14)});
512 const Real rel_diff = diff / denom;
513
514 if (rel_diff >= _cht_heat_flux_tolerance)
515 return false;
516 }
517
518 return _fpi_it;
519}
std::vector< std::vector< Real > > _integrated_boundary_heat_flux
Integrated flux for the boundaries, first index is the boundary second is solid/fluid.
Definition CHTHandler.h:139
unsigned int _fpi_it
CHT fixed point iteration counter.
Definition CHTHandler.h:148
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

Referenced by LinearAssemblySegregatedSolve::solve().

◆ deduceCHTBoundaryCoupling()

void NS::FV::CHTHandler::deduceCHTBoundaryCoupling ( )

Run error checks and make sure everything works.

Definition at line 106 of file CHTHandler.C.

107{
109 mooseError("We should have only one variable in the solid energy system: ",
111 "! Right now we have: ",
113 if (_energy_system->nVariables() != 1)
114 mooseError("We should have only one variable in the fluid energy system: ",
116 "! Right now we have: ",
118 const std::vector<std::string> solid_fluid({"solid", "fluid"});
119
120 // We do some setup at the beginning to make sure the container sizes are good
122 std::vector<unsigned int>({_solid_energy_system->number(), _energy_system->number()});
123 _cht_conduction_kernels = std::vector<LinearFVFluxKernel *>({nullptr, nullptr});
125 _cht_boundary_conditions.resize(_cht_boundary_names.size(), {nullptr, nullptr});
126
127 // Populate the PM radiation system numbers
128 if (!_pm_radiation_systems.empty())
129 {
130 for (const auto sys_i : index_range(_pm_radiation_systems))
132
133 // Reserve space for _cht_pm_radiation_kernels based on the size of
134 // _cht_pm_radiation_system_numbers
136 // Reserve space for pm radiation boundary conditions
139 _cht_boundary_names.size(),
140 std::vector<LinearFVBoundaryCondition *>(_cht_pm_radiation_system_numbers.size(), nullptr));
141 }
142
143 const auto flux_relaxation_param_names =
144 std::vector<std::string>({"cht_solid_flux_relaxation", "cht_fluid_flux_relaxation"});
145 const auto temperature_relaxation_param_names = std::vector<std::string>(
146 {"cht_solid_temperature_relaxation", "cht_fluid_temperature_relaxation"});
148 _cht_flux_relaxation_factor.resize(2, std::vector<Real>(_cht_boundary_names.size(), 1.0));
150 _cht_temperature_relaxation_factor.resize(2, std::vector<Real>(_cht_boundary_names.size(), 1.0));
151
152 for (const auto region_index : index_range(solid_fluid))
153 {
154 // First thing, we fetch the relaxation parameter values
155 const auto & flux_param_value =
156 getParam<std::vector<Real>>(flux_relaxation_param_names[region_index]);
157 if (flux_param_value.empty() || (flux_param_value.size() != _cht_boundary_names.size()))
158 paramError(flux_relaxation_param_names[region_index],
159 "The number of relaxation factors is not the same as the number of interfaces!");
160
161 _cht_flux_relaxation_factor[region_index] = flux_param_value;
162 // We have to do the range check here because the intput parameter check errors if the vector is
163 // empty
164 for (const auto param : _cht_flux_relaxation_factor[region_index])
165 if (param <= 0 || param > 1.0)
166 paramError(flux_relaxation_param_names[region_index],
167 "The relaxation parameter should be between 0 and 1!");
168
169 const auto & temperature_param_value =
170 getParam<std::vector<Real>>(temperature_relaxation_param_names[region_index]);
171 if (temperature_param_value.empty() ||
172 (temperature_param_value.size() != _cht_boundary_names.size()))
173 paramError(temperature_relaxation_param_names[region_index],
174 "The number of relaxation factors is not the same as the number of interfaces!");
175
176 _cht_temperature_relaxation_factor[region_index] = temperature_param_value;
177 // We have to do the range check here because the intput parameter check errors if the vector is
178 // empty
179 for (const auto param : _cht_temperature_relaxation_factor[region_index])
180 if (param <= 0 || param > 1.0)
181 paramError(temperature_relaxation_param_names[region_index],
182 "The relaxation parameter should be between 0 and 1!");
183
184 // We then fetch the conduction kernels
185 std::vector<LinearFVFluxKernel *> flux_kernels;
187 .query()
188 .template condition<AttribSystem>("LinearFVFluxKernel")
189 .template condition<AttribVar>(0)
190 .template condition<AttribSysNum>(_cht_system_numbers[region_index])
191 .queryInto(flux_kernels);
192
193 // We then fetch the radiation conduction kernels in the fluid region
194 if (!_pm_radiation_systems.empty() && region_index == 1)
195 for (const auto sys_i : index_range(_pm_radiation_systems))
196 {
197 // We then fetch the radiation conduction kernels
198 std::vector<LinearFVFluxKernel *> radiation_kernels;
200 .query()
201 .template condition<AttribSystem>("LinearFVFluxKernel")
202 .template condition<AttribVar>(0)
203 .template condition<AttribSysNum>(_cht_pm_radiation_system_numbers[sys_i])
204 .queryInto(radiation_kernels);
205
206 if (radiation_kernels.size() > 1)
208 "We already have a kernel that describes the participating media radiation diffusion "
209 "with the name: ",
210 radiation_kernels[0]->name(),
211 ". Make sure that you have only one conduction kernel.");
212 else if (radiation_kernels.empty())
213 mooseError("We did not find a diffusion kernel for the participating media radiation "
214 "diffusion to compute the "
215 "radiative heat flux. Please add a diffusion kernel.");
216 else
217 _cht_pm_radiation_kernels.push_back(radiation_kernels[0]);
218 }
219
220 for (auto kernel : flux_kernels)
221 {
222 auto check_diff = dynamic_cast<LinearFVDiffusion *>(kernel);
223 auto check_aniso_diff = dynamic_cast<LinearFVAnisotropicDiffusion *>(kernel);
224 if (_cht_conduction_kernels[region_index] && (check_diff || check_aniso_diff))
225 mooseError("We already have a kernel that describes the heat conduction for the ",
226 solid_fluid[region_index],
227 " domain: ",
228 _cht_conduction_kernels[region_index]->name(),
229 " We found another one with the name: ",
230 (check_diff ? check_diff->name() : check_aniso_diff->name()),
231 " Make sure that you have only one conduction kernel on the ",
232 solid_fluid[region_index],
233 " side!");
234
235 if (check_diff || check_aniso_diff)
236 _cht_conduction_kernels[region_index] = kernel;
237 }
238
239 // Then we check the boundary conditions, to make sure at least there is something defined
240 // from both sides
241 for (const auto bd_index : index_range(_cht_boundary_names))
242 {
243 const auto & boundary_name = _cht_boundary_names[bd_index];
244 const auto boundary_id = _cht_boundary_ids[bd_index];
245
246 std::vector<LinearFVBoundaryCondition *> bcs;
248 .theWarehouse()
249 .query()
250 .template condition<AttribSystem>("LinearFVBoundaryCondition")
251 .template condition<AttribVar>(0)
252 .template condition<AttribSysNum>(_cht_system_numbers[region_index])
253 .template condition<AttribBoundaries>(boundary_id)
254 .queryInto(bcs);
255
256 // We then fetch the radiation conduction bcs in the fluid region (i.e MarshakBC in P1)
257 if (!_pm_radiation_systems.empty() && region_index == 1)
258 for (const auto sys_i : index_range(_pm_radiation_systems))
259 {
260 std::vector<LinearFVBoundaryCondition *> rad_bcs;
262 .query()
263 .template condition<AttribSystem>("LinearFVBoundaryCondition")
264 .template condition<AttribVar>(0)
265 .template condition<AttribSysNum>(_cht_pm_radiation_system_numbers[sys_i])
266 .template condition<AttribBoundaries>(boundary_id)
267 .queryInto(rad_bcs);
268
269 if (!rad_bcs.empty())
270 _cht_pm_radiation_boundary_conditions[bd_index][sys_i] = rad_bcs[0];
271 else
272 mooseError("No LinearFVBoundaryCondition found for the given boundary or system.");
273 }
274
275 if (bcs.size() != 1)
276 mooseError("We found multiple or no boundary conditions for solid energy on boundary ",
277 boundary_name,
278 " (ID: ",
279 boundary_id,
280 "). Make sure you define exactly one for conjugate heat transfer applications!");
281 _cht_boundary_conditions[bd_index][region_index] = bcs[0];
282
283 if (!dynamic_cast<LinearFVCHTBCInterface *>(_cht_boundary_conditions[bd_index][region_index]))
284 mooseError("The selected boundary condition cannot be used with CHT problems! Make sure it "
285 "inherits from LinearFVCHTBCInterface!");
286 }
287 }
288}
Base class that allows error checking for CHT applications.
TheWarehouse & theWarehouse()
const std::string & name() const
void mooseError(Args &&... args) const
MooseApp & getMooseApp() const
MooseApp & _app
SystemBase * _energy_system
The energy system.
Definition CHTHandler.h:84
std::vector< unsigned int > _cht_pm_radiation_system_numbers
The participating media radiation system numbers.
Definition CHTHandler.h:116
std::vector< LinearFVFluxKernel * > _cht_conduction_kernels
The conduction kernels from the solid/fluid domains. Can't be const, considering we are updating the ...
Definition CHTHandler.h:122
std::vector< unsigned int > _cht_system_numbers
The solid (0) and fluid (1) system numbers.
Definition CHTHandler.h:113
std::vector< LinearFVFluxKernel * > _cht_pm_radiation_kernels
The conduction radiation kernels from the fluid domains.
Definition CHTHandler.h:125
std::vector< std::vector< Real > > _cht_flux_relaxation_factor
The relaxation factors for flux fields for the CHT boundaries first index is solid/fluid second is th...
Definition CHTHandler.h:106
SystemBase * _solid_energy_system
The solid energy system.
Definition CHTHandler.h:87
std::vector< SystemBase * > _pm_radiation_systems
The solid energy system.
Definition CHTHandler.h:90
std::vector< std::vector< LinearFVBoundaryCondition * > > _cht_boundary_conditions
Vector of boundary conditions that describe the conjugate heat transfer from each side.
Definition CHTHandler.h:128
std::vector< std::vector< LinearFVBoundaryCondition * > > _cht_pm_radiation_boundary_conditions
Vector of boundary conditions that describe the radiation pm bcs from each side.
Definition CHTHandler.h:131
std::vector< std::vector< Real > > _cht_temperature_relaxation_factor
The relaxation factors for temperature fields for the CHT boundaries first index is solid/fluid secon...
Definition CHTHandler.h:110
virtual unsigned int nVariables() const
unsigned int number() const
const std::vector< VariableName > & getVariableNames() const
virtual const std::string & name() const
Query query()
std::string stringify(const T &t)
auto index_range(const T &sizable)
if(subdm)

Referenced by LinearAssemblySegregatedSolve::initialSetup().

◆ enabled()

bool NS::FV::CHTHandler::enabled ( ) const
inlinefinaloverridevirtual

Check if CHT treatment is needed.

Reimplemented from MooseObject.

Definition at line 152 of file CHTHandler.h.

153{
154 return !_cht_boundary_names.empty();
155}

Referenced by LinearAssemblySegregatedSolve::initialSetup(), LinearAssemblySegregatedSolve::LinearAssemblySegregatedSolve(), and LinearAssemblySegregatedSolve::solve().

◆ incrementCHTIterators()

void NS::FV::CHTHandler::incrementCHTIterators ( )
inline

Increment CHT iterators in the loop.

Definition at line 164 of file CHTHandler.h.

165{
166 _fpi_it++;
167}

Referenced by LinearAssemblySegregatedSolve::solve().

◆ initializeCHTCouplingFields()

void NS::FV::CHTHandler::initializeCHTCouplingFields ( )

Initialize the coupling fields for the conjugate heat transfer routines.

Definition at line 371 of file CHTHandler.C.

372{
373 for (const auto bd_index : index_range(_cht_boundary_ids))
374 {
375 const auto & bd_fi_container = _cht_face_info[bd_index];
376 auto & temperature_container = _boundary_temperature[bd_index];
377
378 for (const auto region_index : make_range(2))
379 {
380 // Can't be const considering we will update members from here
381 auto bc = _cht_boundary_conditions[bd_index][region_index];
382 for (const auto & fi : bd_fi_container)
383 {
384 bc->setupFaceData(fi, fi->faceType(std::make_pair(0, _cht_system_numbers[region_index])));
385 temperature_container[1 - region_index][fi->id()] = bc->computeBoundaryValue();
386 }
387 }
388 }
389}
std::vector< std::vector< const FaceInfo * > > _cht_face_info
The subset of the FaceInfo objects that belong to the given boundaries.
Definition CHTHandler.h:119
std::vector< std::vector< FaceCenteredMapFunctor< Real, std::unordered_map< dof_id_type, Real > > > > _boundary_temperature
Functors describing the heat flux on the conjugate heat transfer interfaces.
Definition CHTHandler.h:144
IntRange< T > make_range(T beg, T end)

Referenced by LinearAssemblySegregatedSolve::solve().

◆ linkEnergySystems()

void NS::FV::CHTHandler::linkEnergySystems ( SystemBase solid_energy_system,
SystemBase fluid_energy_system,
std::vector< SystemBase * >  pm_radiation_systems 
)

Link energy systems.

Definition at line 91 of file CHTHandler.C.

94{
95 _energy_system = fluid_energy_system;
96 _solid_energy_system = solid_energy_system;
97 _pm_radiation_systems = pm_radiation_systems;
98
100 paramError("cht_interfaces",
101 "You selected to do conjugate heat transfer treatment, but it needs two energy "
102 "systems: a solid and a fluid. One of these systems is missing.");
103}

Referenced by LinearAssemblySegregatedSolve::LinearAssemblySegregatedSolve().

◆ printIntegratedFluxes()

void NS::FV::CHTHandler::printIntegratedFluxes ( ) const

Print the integrated heat fluxes.

Definition at line 476 of file CHTHandler.C.

477{
478 for (const auto i : index_range(_integrated_boundary_heat_flux))
479 {
480 auto & integrated_fluxes = _integrated_boundary_heat_flux[i];
481 _console << " Iteration " << _fpi_it << " Boundary " << _cht_boundary_names[i]
482 << " flux on solid side " << integrated_fluxes[NS::CHTSide::SOLID]
483 << " flux on fluid side: " << integrated_fluxes[NS::CHTSide::FLUID] << std::endl;
484 }
485}
const ConsoleStream _console
@ SOLID
Definition NS.h:200
@ FLUID
Definition NS.h:201

Referenced by LinearAssemblySegregatedSolve::solve().

◆ resetCHTConvergence()

void NS::FV::CHTHandler::resetCHTConvergence ( )
inline

Reset the convergence data.

Definition at line 158 of file CHTHandler.h.

159{
160 _fpi_it = 0;
161}

Referenced by LinearAssemblySegregatedSolve::solve().

◆ resetIntegratedFluxes()

void NS::FV::CHTHandler::resetIntegratedFluxes ( )

Reset the heat fluxes to 0.

Definition at line 488 of file CHTHandler.C.

489{
490 for (const auto i : index_range(_integrated_boundary_heat_flux))
491 _integrated_boundary_heat_flux[i] = std::vector<Real>({0.0, 0.0});
492}

Referenced by LinearAssemblySegregatedSolve::solve().

◆ setupConjugateHeatTransferContainers()

void NS::FV::CHTHandler::setupConjugateHeatTransferContainers ( )

Set up the boundary condition pairs, functor maps, and every other necessary structure for the conjugate heat transfer routines.

Definition at line 291 of file CHTHandler.C.

292{
293 // We already error in initialSetup if we have more variables
294 const auto * fluid_variable =
295 dynamic_cast<const MooseLinearVariableFVReal *>(&_energy_system->getVariable(0, 0));
296 const auto * solid_variable =
297 dynamic_cast<const MooseLinearVariableFVReal *>(&_solid_energy_system->getVariable(0, 0));
298
299 _cht_face_info.clear();
300 _cht_face_info.resize(_cht_boundary_ids.size());
301 _boundary_heat_flux.clear();
302 _boundary_temperature.clear();
304
305 for (const auto bd_index : index_range(_cht_boundary_ids))
306 {
307 const auto bd_id = _cht_boundary_ids[bd_index];
308 const auto & bd_name = _cht_boundary_names[bd_index];
309
310 // We populate the face infos for every interface
311 auto & bd_fi_container = _cht_face_info[bd_index];
312 for (auto & fi : _problem.mesh().faceInfo())
313 if (fi->boundaryIDs().count(bd_id))
314 bd_fi_container.push_back(fi);
315
316 // We do this because the coupling functors should be evaluated on both sides
317 // of the interface and there are rigorous checks if the functors don't support a subdomain
318 std::set<SubdomainID> combined_set;
319 std::set_union(solid_variable->blockIDs().begin(),
320 solid_variable->blockIDs().end(),
321 fluid_variable->blockIDs().begin(),
322 fluid_variable->blockIDs().end(),
323 std::inserter(combined_set, combined_set.begin()));
324
325 // We instantiate the coupling fuctors for heat flux and temperature
327 _problem.mesh(), combined_set, "heat_flux_to_solid_" + bd_name);
329 _problem.mesh(), combined_set, "heat_flux_to_fluid_" + bd_name);
330
331 _boundary_heat_flux.push_back(
332 std::vector<FaceCenteredMapFunctor<Real, std::unordered_map<dof_id_type, Real>>>(
333 {std::move(solid_bd_flux), std::move(fluid_bd_flux)}));
334 auto & flux_container = _boundary_heat_flux.back();
335
336 _integrated_boundary_heat_flux.push_back(std::vector<Real>({0.0, 0.0}));
337
339 _problem.mesh(), combined_set, "interface_temperature_solid_" + bd_name);
341 _problem.mesh(), combined_set, "interface_temperature_fluid_" + bd_name);
342
343 _boundary_temperature.push_back(
344 std::vector<FaceCenteredMapFunctor<Real, std::unordered_map<dof_id_type, Real>>>(
345 {std::move(solid_bd_temperature), std::move(fluid_bd_temperature)}));
346 auto & temperature_container = _boundary_temperature.back();
347
348 // Time to register the functors on all of the threads
349 for (const auto tid : make_range(libMesh::n_threads()))
350 {
351 _problem.addFunctor("heat_flux_to_solid_" + bd_name, flux_container[NS::CHTSide::SOLID], tid);
352 _problem.addFunctor("heat_flux_to_fluid_" + bd_name, flux_container[NS::CHTSide::FLUID], tid);
354 "interface_temperature_solid_" + bd_name, temperature_container[NS::CHTSide::SOLID], tid);
356 "interface_temperature_fluid_" + bd_name, temperature_container[NS::CHTSide::FLUID], tid);
357 }
358
359 // Initialize the containers, they will be filled with correct values soon.
360 // Before any solve happens.
361 for (const auto region_index : make_range(2))
362 for (auto & fi : bd_fi_container)
363 {
364 flux_container[region_index][fi->id()] = 0.0;
365 temperature_container[region_index][fi->id()] = 0.0;
366 }
367 }
368}
unsigned int count
for(PetscInt i=0;i< nvars;++i)
A functor whose evaluation relies on querying a map where the keys are face info ids and the values c...
std::vector< std::vector< FaceCenteredMapFunctor< Real, std::unordered_map< dof_id_type, Real > > > > _boundary_heat_flux
Functors describing the heat flux on the conjugate heat transfer interfaces.
Definition CHTHandler.h:136
void addFunctor(const std::string &name, const Moose::FunctorBase< T > &functor, const THREAD_ID tid)
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
MeshBase & mesh
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
unsigned int n_threads()

Referenced by LinearAssemblySegregatedSolve::initialSetup().

◆ sumIntegratedFluxes()

void NS::FV::CHTHandler::sumIntegratedFluxes ( )

Sum the integrated fluxes over all processors.

Definition at line 465 of file CHTHandler.C.

466{
467 for (const auto i : index_range(_integrated_boundary_heat_flux))
468 {
469 auto & integrated_fluxes = _integrated_boundary_heat_flux[i];
470 _problem.comm().sum(integrated_fluxes[NS::CHTSide::SOLID]);
471 _problem.comm().sum(integrated_fluxes[NS::CHTSide::FLUID]);
472 }
473}
const Parallel::Communicator & comm() const

Referenced by LinearAssemblySegregatedSolve::solve().

◆ updateCHTBoundaryCouplingFields()

void NS::FV::CHTHandler::updateCHTBoundaryCouplingFields ( const NS::CHTSide  side)

Update the coupling fields for.

Parameters
side

Definition at line 392 of file CHTHandler.C.

393{
394 // Well we can just use the face that this enum casts into int very nicely
395 // we can use it to get the index of the other side
396 const NS::CHTSide other_side = static_cast<NS::CHTSide>(1 - side);
397
398 for (const auto bd_index : index_range(_cht_boundary_ids))
399 {
400 auto & other_bc = _cht_boundary_conditions[bd_index][other_side];
401 auto & other_kernel = _cht_conduction_kernels[other_side];
402
403 // We get the relaxation from the other side, so if we are fluid side we get the solid
404 // relaxation
405 const auto temperature_relaxation = _cht_flux_relaxation_factor[other_side][bd_index];
406 const auto flux_relaxation = _cht_temperature_relaxation_factor[other_side][bd_index];
407
408 // Fetching the right container here, if side is fluid we fetch "heat_flux_to_fluid"
409 auto & flux_container = _boundary_heat_flux[bd_index][side];
410 // Fetching the other side's contaienr here, if side is fluid we fetch the solid temperature
411 auto & temperature_container = _boundary_temperature[bd_index][other_side];
412 // We will also update the integrated flux for output info
413 auto & integrated_flux = _integrated_boundary_heat_flux[bd_index][side];
414 // We are recomputing this so, time to zero this out
415 integrated_flux = 0.0;
416
417 const auto & bd_fi_container = _cht_face_info[bd_index];
418
419 // We enter the face loop to update the coupling fields
420 for (const auto & fi : bd_fi_container)
421 {
422 other_kernel->setupFaceData(fi);
423 // We will want the flux in W/m2 for the coupling so no face integral for now,
424 // this can cause issues if we start using face area in the kernels
425 // for more than just face integral multipliers.
426 // Also, if we decide to not require overlapping meshes on the boundary
427 // this will probably have to change.
428 other_kernel->setCurrentFaceArea(1.0);
429 other_bc->setupFaceData(fi, fi->faceType(std::make_pair(0, _cht_system_numbers[other_side])));
430
431 // T_new = relaxation * T_boundary + (1-relaxation) * T_old
432 temperature_container[fi->id()] =
433 temperature_relaxation * other_bc->computeBoundaryValue() +
434 (1 - temperature_relaxation) * temperature_container[fi->id()];
435
436 // Flux_new = relaxation * Flux_boundary + (1-relaxation) * Flux_old,
437 // minus sign is due to the normal differences
438
439 // Conductive flux
440 auto flux = other_kernel->computeBoundaryFlux(*other_bc);
441
442 // If participating media radiation system exists we add the heat flux from the fluid
443 // to the solid region.
444 if (!_pm_radiation_systems.empty() && side == NS::CHTSide::SOLID)
445 for (const auto sys_i : index_range(_pm_radiation_systems))
446 {
447 _cht_pm_radiation_kernels[sys_i]->setupFaceData(fi);
448 _cht_pm_radiation_kernels[sys_i]->setCurrentFaceArea(1.0);
449 _cht_pm_radiation_boundary_conditions[bd_index][sys_i]->setupFaceData(
450 fi, fi->faceType(std::make_pair(0, _cht_pm_radiation_system_numbers[sys_i])));
451 flux += _cht_pm_radiation_kernels[sys_i]->computeBoundaryFlux(
452 *_cht_pm_radiation_boundary_conditions[bd_index][sys_i]);
453 }
454
455 flux_container[fi->id()] =
456 flux_relaxation * flux + (1 - flux_relaxation) * flux_container[fi->id()];
457
458 // We do the integral here
459 integrated_flux += flux * fi->faceArea() * fi->faceCoord();
460 }
461 }
462}
CHTSide
CHT side options, we want to make sure these can be used as integers so we are avoiding the enum clas...
Definition NS.h:199

Referenced by LinearAssemblySegregatedSolve::solve().

◆ validParams()

InputParameters NS::FV::CHTHandler::validParams ( )
static

Definition at line 25 of file CHTHandler.C.

26{
27 auto params = emptyInputParameters();
28 params.addParam<std::vector<BoundaryName>>(
29 "cht_interfaces",
30 {},
31 "The interfaces where we would like to add conjugate heat transfer handling.");
32
33 params.addRangeCheckedParam<unsigned int>(
34 "max_cht_fpi",
35 1,
36 "max_cht_fpi >= 1",
37 "Number of maximum fixed point iterations (FPI). Currently only applied to"
38 " conjugate heat transfer simulations. The default value of 1 essentially keeps"
39 " the FPI feature turned off. CHT iteration ends after this number of iteration even if the "
40 "tolerance is not met.");
41
42 params.addRangeCheckedParam<Real>(
43 "cht_heat_flux_tolerance",
44 1e-5,
45 "cht_heat_flux_tolerance > 0 & cht_heat_flux_tolerance <= 1.0",
46 "The relative tolerance for terminating conjugate heat transfer iteration before the maximum "
47 "number of CHT iterations. Relative tolerance is ignore if the maximum number of CHT "
48 "iterations is reached.");
49
50 params.addParam<std::vector<Real>>(
51 "cht_fluid_temperature_relaxation",
52 {},
53 "The relaxation factors for the boundary temperature when being updated on the fluid side.");
54 params.addParam<std::vector<Real>>(
55 "cht_solid_temperature_relaxation",
56 {},
57 "The relaxation factors for the boundary temperature when being updated on the solid side.");
58 params.addParam<std::vector<Real>>(
59 "cht_fluid_flux_relaxation",
60 {},
61 "The relaxation factors for the boundary flux when being updated on the fluid side.");
62 params.addParam<std::vector<Real>>(
63 "cht_solid_flux_relaxation",
64 {},
65 "The relaxation factors for the boundary flux when being updated on the solid side.");
66
67 params.addParamNamesToGroup(
68 "cht_interfaces max_cht_fpi cht_heat_flux_tolerance cht_fluid_temperature_relaxation "
69 "cht_solid_temperature_relaxation cht_fluid_flux_relaxation "
70 "cht_solid_flux_relaxation",
71 "Conjugate Heat Transfer");
72
73 return params;
74}
InputParameters emptyInputParameters()

Referenced by LinearAssemblySegregatedSolve::validParams().

Member Data Documentation

◆ _boundary_heat_flux

std::vector<std::vector<FaceCenteredMapFunctor<Real, std::unordered_map<dof_id_type, Real> > > > NS::FV::CHTHandler::_boundary_heat_flux
protected

Functors describing the heat flux on the conjugate heat transfer interfaces.

Two functors per sideset, first is solid second is fluid.

Definition at line 136 of file CHTHandler.h.

Referenced by setupConjugateHeatTransferContainers(), and updateCHTBoundaryCouplingFields().

◆ _boundary_temperature

std::vector<std::vector<FaceCenteredMapFunctor<Real, std::unordered_map<dof_id_type, Real> > > > NS::FV::CHTHandler::_boundary_temperature
protected

Functors describing the heat flux on the conjugate heat transfer interfaces.

Two functors per sideset, first is solid second is fluid.

Definition at line 144 of file CHTHandler.h.

Referenced by initializeCHTCouplingFields(), setupConjugateHeatTransferContainers(), and updateCHTBoundaryCouplingFields().

◆ _cht_boundary_conditions

std::vector<std::vector<LinearFVBoundaryCondition *> > NS::FV::CHTHandler::_cht_boundary_conditions
protected

Vector of boundary conditions that describe the conjugate heat transfer from each side.

Definition at line 128 of file CHTHandler.h.

Referenced by deduceCHTBoundaryCoupling(), initializeCHTCouplingFields(), and updateCHTBoundaryCouplingFields().

◆ _cht_boundary_ids

std::vector<BoundaryID> NS::FV::CHTHandler::_cht_boundary_ids
protected

◆ _cht_boundary_names

std::vector<BoundaryName> NS::FV::CHTHandler::_cht_boundary_names
protected

The names of the CHT boundaries.

Definition at line 93 of file CHTHandler.h.

Referenced by CHTHandler(), deduceCHTBoundaryCoupling(), enabled(), printIntegratedFluxes(), and setupConjugateHeatTransferContainers().

◆ _cht_conduction_kernels

std::vector<LinearFVFluxKernel *> NS::FV::CHTHandler::_cht_conduction_kernels
protected

The conduction kernels from the solid/fluid domains. Can't be const, considering we are updating the inner structures for every face.

Definition at line 122 of file CHTHandler.h.

Referenced by deduceCHTBoundaryCoupling(), and updateCHTBoundaryCouplingFields().

◆ _cht_face_info

std::vector<std::vector<const FaceInfo *> > NS::FV::CHTHandler::_cht_face_info
protected

The subset of the FaceInfo objects that belong to the given boundaries.

Definition at line 119 of file CHTHandler.h.

Referenced by initializeCHTCouplingFields(), setupConjugateHeatTransferContainers(), and updateCHTBoundaryCouplingFields().

◆ _cht_flux_relaxation_factor

std::vector<std::vector<Real> > NS::FV::CHTHandler::_cht_flux_relaxation_factor
protected

The relaxation factors for flux fields for the CHT boundaries first index is solid/fluid second is the interface.

Definition at line 106 of file CHTHandler.h.

Referenced by deduceCHTBoundaryCoupling(), and updateCHTBoundaryCouplingFields().

◆ _cht_heat_flux_tolerance

const Real NS::FV::CHTHandler::_cht_heat_flux_tolerance
protected

Tolerance for heat flux at the CHT interfaces.

Definition at line 102 of file CHTHandler.h.

Referenced by converged().

◆ _cht_pm_radiation_boundary_conditions

std::vector<std::vector<LinearFVBoundaryCondition *> > NS::FV::CHTHandler::_cht_pm_radiation_boundary_conditions
protected

Vector of boundary conditions that describe the radiation pm bcs from each side.

Definition at line 131 of file CHTHandler.h.

Referenced by deduceCHTBoundaryCoupling(), and updateCHTBoundaryCouplingFields().

◆ _cht_pm_radiation_kernels

std::vector<LinearFVFluxKernel *> NS::FV::CHTHandler::_cht_pm_radiation_kernels
protected

The conduction radiation kernels from the fluid domains.

Definition at line 125 of file CHTHandler.h.

Referenced by deduceCHTBoundaryCoupling(), and updateCHTBoundaryCouplingFields().

◆ _cht_pm_radiation_system_numbers

std::vector<unsigned int> NS::FV::CHTHandler::_cht_pm_radiation_system_numbers
protected

The participating media radiation system numbers.

Definition at line 116 of file CHTHandler.h.

Referenced by deduceCHTBoundaryCoupling(), and updateCHTBoundaryCouplingFields().

◆ _cht_system_numbers

std::vector<unsigned int> NS::FV::CHTHandler::_cht_system_numbers
protected

The solid (0) and fluid (1) system numbers.

Definition at line 113 of file CHTHandler.h.

Referenced by deduceCHTBoundaryCoupling(), initializeCHTCouplingFields(), and updateCHTBoundaryCouplingFields().

◆ _cht_temperature_relaxation_factor

std::vector<std::vector<Real> > NS::FV::CHTHandler::_cht_temperature_relaxation_factor
protected

The relaxation factors for temperature fields for the CHT boundaries first index is solid/fluid second is the interface.

Definition at line 110 of file CHTHandler.h.

Referenced by deduceCHTBoundaryCoupling(), and updateCHTBoundaryCouplingFields().

◆ _energy_system

SystemBase* NS::FV::CHTHandler::_energy_system
protected

The energy system.

Definition at line 84 of file CHTHandler.h.

Referenced by deduceCHTBoundaryCoupling(), linkEnergySystems(), and setupConjugateHeatTransferContainers().

◆ _fpi_it

unsigned int NS::FV::CHTHandler::_fpi_it
private

CHT fixed point iteration counter.

Definition at line 148 of file CHTHandler.h.

Referenced by converged(), incrementCHTIterators(), printIntegratedFluxes(), and resetCHTConvergence().

◆ _integrated_boundary_heat_flux

std::vector<std::vector<Real> > NS::FV::CHTHandler::_integrated_boundary_heat_flux
protected

Integrated flux for the boundaries, first index is the boundary second is solid/fluid.

Definition at line 139 of file CHTHandler.h.

Referenced by converged(), printIntegratedFluxes(), resetIntegratedFluxes(), setupConjugateHeatTransferContainers(), sumIntegratedFluxes(), and updateCHTBoundaryCouplingFields().

◆ _max_cht_fpi

const unsigned int NS::FV::CHTHandler::_max_cht_fpi
protected

Maximum number of CHT fixed point iterations.

Definition at line 99 of file CHTHandler.h.

Referenced by converged().

◆ _mesh

MooseMesh& NS::FV::CHTHandler::_mesh
protected

Mesh.

Definition at line 81 of file CHTHandler.h.

◆ _pm_radiation_systems

std::vector<SystemBase *> NS::FV::CHTHandler::_pm_radiation_systems
protected

The solid energy system.

Definition at line 90 of file CHTHandler.h.

Referenced by deduceCHTBoundaryCoupling(), linkEnergySystems(), and updateCHTBoundaryCouplingFields().

◆ _problem

FEProblemBase& NS::FV::CHTHandler::_problem
protected

◆ _solid_energy_system

SystemBase* NS::FV::CHTHandler::_solid_energy_system
protected

The solid energy system.

Definition at line 87 of file CHTHandler.h.

Referenced by deduceCHTBoundaryCoupling(), linkEnergySystems(), and setupConjugateHeatTransferContainers().


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