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!");
98 "You selected to do conjugate heat transfer treatment, but it needs two energy " 99 "systems: a solid and a fluid. One of these systems is missing.");
106 mooseError(
"We should have only one variable in the solid energy system: ",
108 "! Right now we have: ",
111 mooseError(
"We should have only one variable in the fluid energy system: ",
113 "! Right now we have: ",
115 const std::vector<std::string> solid_fluid({
"solid",
"fluid"});
124 const auto flux_relaxation_param_names =
125 std::vector<std::string>({
"cht_solid_flux_relaxation",
"cht_fluid_flux_relaxation"});
126 const auto temperature_relaxation_param_names = std::vector<std::string>(
127 {
"cht_solid_temperature_relaxation",
"cht_fluid_temperature_relaxation"});
133 for (
const auto region_index :
index_range(solid_fluid))
136 const auto & flux_param_value =
137 getParam<std::vector<Real>>(flux_relaxation_param_names[region_index]);
139 paramError(flux_relaxation_param_names[region_index],
140 "The number of relaxation factors is not the same as the number of interfaces!");
146 if (param <= 0 || param > 1.0)
147 paramError(flux_relaxation_param_names[region_index],
148 "The relaxation parameter should be between 0 and 1!");
150 const auto & temperature_param_value =
151 getParam<std::vector<Real>>(temperature_relaxation_param_names[region_index]);
152 if (temperature_param_value.empty() ||
154 paramError(temperature_relaxation_param_names[region_index],
155 "The number of relaxation factors is not the same as the number of interfaces!");
161 if (param <= 0 || param > 1.0)
162 paramError(temperature_relaxation_param_names[region_index],
163 "The relaxation parameter should be between 0 and 1!");
166 std::vector<LinearFVFluxKernel *> flux_kernels;
169 .template condition<AttribSystem>(
"LinearFVFluxKernel")
170 .
template condition<AttribVar>(0)
172 .queryInto(flux_kernels);
174 for (
auto kernel : flux_kernels)
179 mooseError(
"We already have a kernel that describes the heat conduction for the ",
180 solid_fluid[region_index],
183 " We found another one with the name: ",
184 (check_diff ? check_diff->name() : check_aniso_diff->name()),
185 " Make sure that you have only one conduction kernel on the ",
186 solid_fluid[region_index],
189 if (check_diff || check_aniso_diff)
200 std::vector<LinearFVBoundaryCondition *> bcs;
204 .template condition<AttribSystem>(
"LinearFVBoundaryCondition")
205 .
template condition<AttribVar>(0)
207 .
template condition<AttribBoundaries>(boundary_id)
211 mooseError(
"We found multiple or no boundary conditions for solid energy on boundary ",
215 "). Make sure you define exactly one for conjugate heat transfer applications!");
219 mooseError(
"The selected boundary condition cannot be used with CHT problems! Make sure it " 220 "inherits from LinearFVCHTBCInterface!");
229 const auto * fluid_variable =
231 const auto * solid_variable =
248 if (fi->boundaryIDs().count(bd_id))
249 bd_fi_container.push_back(fi);
253 std::set<SubdomainID> combined_set;
254 std::set_union(solid_variable->blockIDs().begin(),
255 solid_variable->blockIDs().end(),
256 fluid_variable->blockIDs().begin(),
257 fluid_variable->blockIDs().end(),
258 std::inserter(combined_set, combined_set.begin()));
262 _problem.
mesh(), combined_set,
"heat_flux_to_solid_" + bd_name);
264 _problem.
mesh(), combined_set,
"heat_flux_to_fluid_" + bd_name);
268 {std::move(solid_bd_flux), std::move(fluid_bd_flux)}));
274 _problem.
mesh(), combined_set,
"interface_temperature_solid_" + bd_name);
276 _problem.
mesh(), combined_set,
"interface_temperature_fluid_" + bd_name);
280 {std::move(solid_bd_temperature), std::move(fluid_bd_temperature)}));
289 "interface_temperature_solid_" + bd_name, temperature_container[
NS::CHTSide::SOLID], tid);
291 "interface_temperature_fluid_" + bd_name, temperature_container[
NS::CHTSide::FLUID], tid);
297 for (
auto & fi : bd_fi_container)
299 flux_container[region_index][fi->id()] = 0.0;
300 temperature_container[region_index][fi->id()] = 0.0;
317 for (
const auto & fi : bd_fi_container)
320 temperature_container[1 - region_index][fi->id()] = bc->computeBoundaryValue();
350 integrated_flux = 0.0;
355 for (
const auto & fi : bd_fi_container)
357 other_kernel->setupFaceData(fi);
363 other_kernel->setCurrentFaceArea(1.0);
364 other_bc->setupFaceData(fi, fi->faceType(std::make_pair(0,
_cht_system_numbers[other_side])));
367 temperature_container[fi->id()] =
368 temperature_relaxation * other_bc->computeBoundaryValue() +
369 (1 - temperature_relaxation) * temperature_container[fi->id()];
373 const auto flux = flux_relaxation * other_kernel->computeBoundaryFlux(*other_bc) +
374 (1 - flux_relaxation) * flux_container[fi->id()];
376 flux_container[fi->id()] = flux;
379 integrated_flux += flux * fi->faceArea() * fi->faceCoord();
422 const Real f1 = boundary_flux[0];
423 const Real f2 = boundary_flux[1];
426 if (
_fpi_it != 0 && (f1 == 0.0 && f2 == 0.0))
430 const Real diff = std::abs(f1 + f2);
431 const Real denom = std::max({std::fabs(f1), std::fabs(f2),
Real(1e-14)});
432 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...
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
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.
void linkEnergySystems(SystemBase *solid_energy_system, SystemBase *fluid_energy_system)
Link energy systems.
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)
void sumIntegratedFluxes()
Sum the integrated fluxes over all processors.
SystemBase * _solid_energy_system
The solid energy system.
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.