28 params.addParam<std::vector<BoundaryName>>(
31 "The interfaces where we would like to add conjugate heat transfer handling.");
33 params.addRangeCheckedParam<
unsigned int>(
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.");
42 params.addRangeCheckedParam<
Real>(
43 "cht_heat_flux_tolerance",
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.");
50 params.addParam<std::vector<Real>>(
51 "cht_fluid_temperature_relaxation",
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",
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",
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",
65 "The relaxation factors for the boundary flux when being updated on the solid side.");
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");
79 "_fe_problem_base",
"This might happen if you don't have a mesh")),
80 _mesh(_problem.
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"))
87 paramError(
"cht_interfaces",
"You must declare at least one interface!");
93 std::vector<SystemBase *> pm_radiation_systems)
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.");
109 mooseError(
"We should have only one variable in the solid energy system: ",
111 "! Right now we have: ",
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"});
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"});
152 for (
const auto region_index :
index_range(solid_fluid))
155 const auto & flux_param_value =
156 getParam<std::vector<Real>>(flux_relaxation_param_names[region_index]);
158 paramError(flux_relaxation_param_names[region_index],
159 "The number of relaxation factors is not the same as the number of interfaces!");
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!");
169 const auto & temperature_param_value =
170 getParam<std::vector<Real>>(temperature_relaxation_param_names[region_index]);
171 if (temperature_param_value.empty() ||
173 paramError(temperature_relaxation_param_names[region_index],
174 "The number of relaxation factors is not the same as the number of interfaces!");
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!");
185 std::vector<LinearFVFluxKernel *> flux_kernels;
188 .template condition<AttribSystem>(
"LinearFVFluxKernel")
189 .
template condition<AttribVar>(0)
191 .queryInto(flux_kernels);
198 std::vector<LinearFVFluxKernel *> radiation_kernels;
201 .template condition<AttribSystem>(
"LinearFVFluxKernel")
202 .
template condition<AttribVar>(0)
204 .queryInto(radiation_kernels);
206 if (radiation_kernels.size() > 1)
208 "We already have a kernel that describes the participating media radiation diffusion " 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.");
220 for (
auto kernel : flux_kernels)
225 mooseError(
"We already have a kernel that describes the heat conduction for the ",
226 solid_fluid[region_index],
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],
235 if (check_diff || check_aniso_diff)
246 std::vector<LinearFVBoundaryCondition *> bcs;
250 .template condition<AttribSystem>(
"LinearFVBoundaryCondition")
251 .
template condition<AttribVar>(0)
253 .
template condition<AttribBoundaries>(boundary_id)
260 std::vector<LinearFVBoundaryCondition *> rad_bcs;
263 .template condition<AttribSystem>(
"LinearFVBoundaryCondition")
264 .
template condition<AttribVar>(0)
266 .
template condition<AttribBoundaries>(boundary_id)
269 if (!rad_bcs.empty())
272 mooseError(
"No LinearFVBoundaryCondition found for the given boundary or system.");
276 mooseError(
"We found multiple or no boundary conditions for solid energy on boundary ",
280 "). Make sure you define exactly one for conjugate heat transfer applications!");
284 mooseError(
"The selected boundary condition cannot be used with CHT problems! Make sure it " 285 "inherits from LinearFVCHTBCInterface!");
294 const auto * fluid_variable =
296 const auto * solid_variable =
313 if (fi->boundaryIDs().count(bd_id))
314 bd_fi_container.push_back(fi);
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()));
327 _problem.
mesh(), combined_set,
"heat_flux_to_solid_" + bd_name);
329 _problem.
mesh(), combined_set,
"heat_flux_to_fluid_" + bd_name);
333 {std::move(solid_bd_flux), std::move(fluid_bd_flux)}));
339 _problem.
mesh(), combined_set,
"interface_temperature_solid_" + bd_name);
341 _problem.
mesh(), combined_set,
"interface_temperature_fluid_" + bd_name);
345 {std::move(solid_bd_temperature), std::move(fluid_bd_temperature)}));
354 "interface_temperature_solid_" + bd_name, temperature_container[
NS::CHTSide::SOLID], tid);
356 "interface_temperature_fluid_" + bd_name, temperature_container[
NS::CHTSide::FLUID], tid);
362 for (
auto & fi : bd_fi_container)
364 flux_container[region_index][fi->id()] = 0.0;
365 temperature_container[region_index][fi->id()] = 0.0;
382 for (
const auto & fi : bd_fi_container)
385 temperature_container[1 - region_index][fi->id()] = bc->computeBoundaryValue();
415 integrated_flux = 0.0;
420 for (
const auto & fi : bd_fi_container)
422 other_kernel->setupFaceData(fi);
428 other_kernel->setCurrentFaceArea(1.0);
429 other_bc->setupFaceData(fi, fi->faceType(std::make_pair(0,
_cht_system_numbers[other_side])));
432 temperature_container[fi->id()] =
433 temperature_relaxation * other_bc->computeBoundaryValue() +
434 (1 - temperature_relaxation) * temperature_container[fi->id()];
440 auto flux = other_kernel->computeBoundaryFlux(*other_bc);
455 flux_container[fi->id()] =
456 flux_relaxation * flux + (1 - flux_relaxation) * flux_container[fi->id()];
459 integrated_flux += flux * fi->faceArea() * fi->faceCoord();
502 const Real f1 = boundary_flux[0];
503 const Real f2 = boundary_flux[1];
506 if (
_fpi_it != 0 && (f1 == 0.0 && f2 == 0.0))
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;
std::vector< unsigned int > _cht_system_numbers
The solid (0) and fluid (1) system numbers.
void updateCHTBoundaryCouplingFields(const NS::CHTSide side)
Update the coupling fields for.
A functor whose evaluation relies on querying a map where the keys are face info ids and the values c...
std::vector< LinearFVFluxKernel * > _cht_pm_radiation_kernels
The conduction radiation kernels from the fluid domains.
void paramError(const std::string ¶m, Args... args) const
std::vector< BoundaryID > _cht_boundary_ids
The IDs of the CHT boundaries.
FEProblemBase & _problem
Reference to FEProblem.
void resetIntegratedFluxes()
Reset the heat fluxes to 0.
void addFunctor(const std::string &name, const Moose::FunctorBase< T > &functor, const THREAD_ID tid)
void printIntegratedFluxes() const
Print the integrated heat fluxes.
const Parallel::Communicator & comm() const
void initializeCHTCouplingFields()
Initialize the coupling fields for the conjugate heat transfer routines.
SystemBase * _energy_system
The energy system.
void setupConjugateHeatTransferContainers()
Set up the boundary condition pairs, functor maps, and every other necessary structure for the conjug...
MooseApp & getMooseApp() const
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.
virtual unsigned int nVariables() const
virtual const std::string & name() const
const std::vector< const FaceInfo *> & faceInfo() const
std::vector< std::vector< Real > > _integrated_boundary_heat_flux
Integrated flux for the boundaries, first index is the boundary second is solid/fluid.
const std::string & name() const
void linkEnergySystems(SystemBase *solid_energy_system, SystemBase *fluid_energy_system, std::vector< SystemBase *> pm_radiation_systems)
Link energy systems.
CHTSide
CHT side options, we want to make sure these can be used as integers so we are avoiding the enum clas...
unsigned int _fpi_it
CHT fixed point iteration counter.
bool converged() const
Check if CHT iteration converged.
std::vector< std::vector< const FaceInfo * > > _cht_face_info
The subset of the FaceInfo objects that belong to the given boundaries.
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...
const Real _cht_heat_flux_tolerance
Tolerance for heat flux at the CHT interfaces.
std::vector< BoundaryID > getBoundaryIDs(const libMesh::MeshBase &mesh, const std::vector< BoundaryName > &boundary_name, bool generate_unknown, const std::set< BoundaryID > &mesh_boundary_ids)
unsigned int number() const
std::string stringify(const T &t)
std::vector< SystemBase * > _pm_radiation_systems
The solid energy system.
void sumIntegratedFluxes()
Sum the integrated fluxes over all processors.
SystemBase * _solid_energy_system
The solid energy system.
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< unsigned int > _cht_pm_radiation_system_numbers
The participating media radiation system numbers.
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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< BoundaryName > _cht_boundary_names
The names of the CHT boundaries.
IntRange< T > make_range(T beg, T end)
virtual MooseMesh & mesh() override
void mooseError(Args &&... args) const
void deduceCHTBoundaryCoupling()
Run error checks and make sure everything works.
const std::vector< VariableName > & getVariableNames() const
TheWarehouse & theWarehouse()
const ConsoleStream _console
static InputParameters validParams()
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
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< Real > > _cht_flux_relaxation_factor
The relaxation factors for flux fields for the CHT boundaries first index is solid/fluid second is th...
bool isParamSetByUser(const std::string &name) const
std::vector< LinearFVFluxKernel * > _cht_conduction_kernels
The conduction kernels from the solid/fluid domains. Can't be const, considering we are updating the ...
const unsigned int _max_cht_fpi
Maximum number of CHT fixed point iterations.
void ErrorVector unsigned int
auto index_range(const T &sizable)
CHTHandler(const InputParameters ¶meters)
Constructor with initialization parameters.