Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
heat_transfer_boundary_conditions.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
5#include <core/utilities.h>
6
7#include <deal.II/base/parameter_handler.h>
8#include <deal.II/base/parsed_function.h>
9#include <deal.II/base/patterns.h>
10
11#include <memory>
12#include <string>
13#include <vector>
14
15using namespace dealii;
16
17DeclException1(HeatTransferBoundaryDuplicated,
18 types::boundary_id,
19 << "Heat transfer boundary id: " << arg1
20 << " has already been declared as a boundary condition");
21
22namespace BoundaryConditions
23{
24 template <int dim>
25 void
27 ParameterHandler &prm,
28 const types::boundary_id default_boundary_id)
29 {
31 "type",
33 "Type of boundary condition for heat transfer.",
36
37 prm.declare_entry("id",
38 Utilities::to_string(default_boundary_id, 2),
39 Patterns::List(Patterns::Integer()),
40 "Mesh id for boundary conditions");
41
42 Functions::ParsedFunction<dim> temporary_function;
43
44 // Expression for the temperature for an imposed temperature at bc
45 prm.enter_subsection("value");
46 temporary_function.declare_parameters(prm);
47 prm.leave_subsection();
48
49 // Expression for the h coefficient of convection-radiation-flux bc
50 prm.enter_subsection("h");
51 temporary_function.declare_parameters(prm);
52 prm.leave_subsection();
53
54 // Temperature of environment for convection-radiation-flux bc
55 prm.enter_subsection("Tinf");
56 temporary_function.declare_parameters(prm);
57 prm.leave_subsection();
58
59 // Emissivity of the boundary for convection-radiation-flux bc
60 prm.enter_subsection("emissivity");
61 temporary_function.declare_parameters(prm);
62 prm.leave_subsection();
63
64 // Heat flux (Neumann) at the boundary for convection-radiation-flux bc
65 prm.enter_subsection("heat_flux");
66 temporary_function.declare_parameters(prm);
67 prm.leave_subsection();
68
69 // Periodic boundary condition parameters for HT physics
70 prm.declare_entry(
71 "periodic id",
72 "-1",
73 Patterns::Integer(),
74 "Mesh id for periodic face matching. Default entry is -1 to ensure that the periodic id is set by the user");
75
76 prm.declare_entry("periodic direction",
77 "0",
78 Patterns::Integer(),
79 "Direction for periodic boundary condition");
80 }
81
82 template <int dim>
83 void
85 ParameterHandler &prm,
86 const unsigned int number_of_boundary_conditions)
87 {
88 prm.enter_subsection("boundary conditions heat transfer");
89 {
90 prm.declare_entry("number",
91 "0",
92 Patterns::Integer(),
93 "Number of boundary conditions");
94
95 prm.declare_entry(
96 "time dependent",
97 "false",
98 Patterns::Bool(),
99 "Bool to define if the boundary condition is time-dependent");
100
101 for (unsigned int n = 0; n < number_of_boundary_conditions; n++)
102 {
103 prm.enter_subsection("bc " + std::to_string(n));
104 {
105 declare_default_entry(prm, n);
106 }
107 prm.leave_subsection();
108 }
109 prm.declare_entry("Stefan-Boltzmann constant",
110 "0.000000056703",
111 Patterns::Double(),
112 "Stefan-Boltzmann constant");
113 }
114 prm.leave_subsection();
115 }
116
117 template <int dim>
118 void
120 {
121 // Parse the list of boundary ids
122 std::vector<types::boundary_id> boundary_ids =
124
125 // Check if the list contains at least one boundary id
126 AssertThrow(
127 boundary_ids.size() > 0,
128 ExcMessage(
129 "A boundary id has not been set for one of the heat transfer boundary conditions. Please ensure that the id is set for every boundary condition."));
130
131 // Loop through all boundary ids to ensure that they are all non-negative
132 // and unique
133 for (const auto boundary_id : boundary_ids)
134 {
135 AssertThrow(this->type.find(boundary_id) == this->type.end(),
136 HeatTransferBoundaryDuplicated(boundary_id));
137
138
139 const HeatTransferBoundaryType boundary_type =
141 prm.get("type"),
143 "type");
144 this->type[boundary_id] = boundary_type;
146 {
147 this->has_convection_radiation_bc = true;
148
149 // Emissivity validity (0 <= emissivity <= 1) will be checked at
150 // evaluation.
151 }
152 else if (boundary_type == HeatTransferBoundaryType::periodic)
153 {
154 types::boundary_id periodic_boundary_id =
155 prm.get_integer("periodic id");
156
157 // We attribute a periodic neighbor boundary type to the neighbor
158 // boundary to ensure that all boundaries have a defined type
159 this->type[periodic_boundary_id] =
161
162 // We store the periodic id and direction
163 this->periodic_boundaries[boundary_id] = {
164 .neighbor_id = periodic_boundary_id,
165 .direction = static_cast<unsigned int>(
166 prm.get_integer("periodic direction"))};
167 }
168
169 // All the functions are parsed since they might be used for
170 // post-processing
171 prm.enter_subsection("value");
172 this->dirichlet_value[boundary_id] =
173 std::make_shared<Functions::ParsedFunction<dim>>();
174 this->dirichlet_value[boundary_id]->parse_parameters(prm);
175 prm.leave_subsection();
176 prm.enter_subsection("h");
177 this->h[boundary_id] =
178 std::make_shared<Functions::ParsedFunction<dim>>();
179 this->h[boundary_id]->parse_parameters(prm);
180 prm.leave_subsection();
181 prm.enter_subsection("Tinf");
182 this->Tinf[boundary_id] =
183 std::make_shared<Functions::ParsedFunction<dim>>();
184 this->Tinf[boundary_id]->parse_parameters(prm);
185 prm.leave_subsection();
186 prm.enter_subsection("emissivity");
187 this->emissivity[boundary_id] =
188 std::make_shared<Functions::ParsedFunction<dim>>();
189 this->emissivity[boundary_id]->parse_parameters(prm);
190 prm.leave_subsection();
191 prm.enter_subsection("heat_flux");
192 this->heat_flux_bc[boundary_id] =
193 std::make_shared<Functions::ParsedFunction<dim>>();
194 this->heat_flux_bc[boundary_id]->parse_parameters(prm);
195 prm.leave_subsection();
196 }
197 }
198
199 template <int dim>
200 void
202 {
203 prm.enter_subsection("boundary conditions heat transfer");
204 {
205 this->number_of_boundary_conditions = prm.get_integer("number");
206 this->time_dependent = prm.get_bool("time dependent");
207 for (unsigned int n = 0; n < this->number_of_boundary_conditions; n++)
208 {
209 prm.enter_subsection("bc " + std::to_string(n));
210 {
211 parse_boundary(prm);
212 }
213 prm.leave_subsection();
214 }
216 prm.get_double("Stefan-Boltzmann constant");
217 }
218 prm.leave_subsection();
219 }
220
223} // namespace BoundaryConditions
std::map< types::boundary_id, HeatTransferBoundaryType > type
This class manages the boundary conditions for Heat-Transfer solver It introduces the boundary functi...
std::map< types::boundary_id, std::shared_ptr< Functions::ParsedFunction< dim > > > heat_flux_bc
Heat-flux values for flux boundary conditions.
std::map< types::boundary_id, std::shared_ptr< Functions::ParsedFunction< dim > > > emissivity
Emissivity coefficients for radiation boundary conditions.
std::map< types::boundary_id, std::shared_ptr< Functions::ParsedFunction< dim > > > h
Convective heat transfer coefficients for Robin conditions.
void declare_parameters(ParameterHandler &prm, unsigned int number_of_boundary_conditions)
Declare the heat transfer boundary condition parameters.
void declare_default_entry(ParameterHandler &prm, types::boundary_id default_boundary_id)
Declare the default parameters for one heat transfer boundary condition.
void parse_parameters(ParameterHandler &prm)
Parse the heat transfer boundary condition parameters.
std::map< types::boundary_id, std::shared_ptr< Functions::ParsedFunction< dim > > > Tinf
Environment temperatures for Robin conditions.
void parse_boundary(ParameterHandler &prm)
Parse the information for one heat transfer boundary condition.
std::map< types::boundary_id, std::shared_ptr< Functions::ParsedFunction< dim > > > dirichlet_value
Temperature values for Dirichlet boundary conditions.
double Stefan_Boltzmann_constant
Stefan-Boltzmann constant used in radiation boundary conditions.
std::vector< T > convert_string_to_vector(const ParameterHandler &prm, const std::string &entry_string)
Return the vector of size N of entry @entry_string. If the entry is specified in the ....
Definition utilities.h:1330
EnumType string_to_enum(const std::string &name)
Return the enumerator whose identifier is name, e.g. to parse the value of a parameter entry into its...
Definition utilities.h:734
void declare_enum_entry(ParameterHandler &prm, const std::string &entry_name, const EnumType default_value, const std::string &description, const DeprecatedEnumNames< EnumType > &deprecated_names={}, const std::vector< EnumType > &allowed_values={})
Declare a parameter entry whose value is an enumerator. The default value, the accepted values and th...
Definition utilities.h:888
DeclException1(HeatTransferBoundaryDuplicated, types::boundary_id,<< "Heat transfer boundary id: "<< arg1<< " has already been declared as a boundary condition")
const std::vector< HeatTransferBoundaryType > heat_transfer_boundary_types
const DeprecatedEnumNames< HeatTransferBoundaryType > deprecated_heat_transfer_boundary_type_names