9.2
general documentation
cs_1d_wall_thermal.h
Go to the documentation of this file.
1#ifndef CS_1D_WALL_THERMAL_H
2#define CS_1D_WALL_THERMAL_H
3
4/*============================================================================
5 * Modelling the thermal wall with 1D approach
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2026 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26*/
27
28/*----------------------------------------------------------------------------*/
29
30/*----------------------------------------------------------------------------
31 * Standard C library headers
32 *----------------------------------------------------------------------------*/
33
34/*----------------------------------------------------------------------------
35 * Local headers
36 *----------------------------------------------------------------------------*/
37
38#include "base/cs_base.h"
39#include "base/cs_zone.h"
40#include "fvm/fvm_nodal.h"
41#include "fvm/fvm_writer.h"
42
43/*=============================================================================
44 * Macro definitions
45 *============================================================================*/
46
47/*============================================================================
48 * Type definitions
49 *============================================================================*/
50
51/*----------------------------------------------------------------------------
52 * 1D Wall Thermal local model type (local to a coupled boundary face)
53 *----------------------------------------------------------------------------*/
54
55typedef struct {
56
57 int nppt1d; /* Number of discretisation cells in the 1D wall
58 * at a given boundary face which is coupled
59 * with a 1D wall thermal module.*/
60
61 int iclt1d; /* Boundary condition type at the external (pseudo)
62 * wall:
63 - 1: Dirichlet,
64 - 2: Flux condition. */
65
66 cs_real_t eppt1d; /* Thickness of the 1D wall for the nfpt1d boundary faces
67 * which are coupled with a 1D wall thermal module. */
68
69 cs_real_t rgpt1d; /* Geometry of the pseudo wall mesh (refined as a fluid
70 * if rgt1d is smaller than 1.*/
71
72 cs_real_t tept1d; /* External temperature of the pseudo wall in the Dirichlet
73 * case. */
74
75 cs_real_t hept1d; /* External coefficient of transfer in the pseudo wall
76 * under Dirichlet conditions, in W.m^-2.K. */
77
78 cs_real_t fept1d; /* External heat flux in the pseudo wall under the flux
79 * conditions (in W.m^-2, negative value for energy
80 * entering the wall). */
81
82 cs_real_t xlmbt1; /* Thermal diffusivity. */
83
84 cs_real_t rcpt1d; /* Volumetric heat capacity rho C_p of the wall uniform
85 * in thickness (in J.m^-3.K^-1). */
86
87 cs_real_t dtpt1d; /* Physical time step associated with the solved 1D equation
88 * of the pseudo wall (which can be different from the time
89 * step of the calculation). */
90
91 cs_real_t *z; /* Discretization points coordinates. */
92
93 cs_real_t *t; /* Temperature at each point of discretization. */
94
96
97/*----------------------------------------------------------------------------
98 * 1D Wall Thermal module type
99 *----------------------------------------------------------------------------*/
100
101typedef struct {
102
103 cs_lnum_t nfpt1d; /* Number of boundary faces which are coupled
104 * with a 1D wall thermal module. */
105
106 cs_gnum_t nfpt1t; /* Global number of boundary faces which are coupled with
107 * a 1D wall thermal module, i.e. sum of nfpt1d over all
108 * ranks */
109
110 int nmxt1d; /* Maximum number of discretization cells in 1d wall */
111
112 bool use_restart; /* Use restart file if present ? */
113
114 cs_lnum_t *izft1d; /* Zones of t1d, dimensioned with nfabor */
115
116 cs_lnum_t *ifpt1d; /* Array allowing to mark out the numbers of
117 * the nfpt1d boundary faces which are coupled with
118 * a 1D wall. */
119
120 cs_real_t *tppt1d; /* Initialization temperature of the wall (uniform in
121 * thickness). During the calculation, the array stores
122 * the temperature of the solid at the fluid/solid
123 * interface. */
124
126
128
129/*============================================================================
130 * Static global variables
131 *============================================================================*/
132
133/* Pointer to the 1D wall thermal structure */
134
136
137/*============================================================================
138 * Public function prototypes
139 *============================================================================*/
140
141/*----------------------------------------------------------------------------*/
142/*
143 * \brief Initialize the cs_glob_1d_wall_thermal structure.
144 */
145/*----------------------------------------------------------------------------*/
146
147void
149
150/*--------------------------------------------------------------------------*/
151/*
152 * \brief Add faces of a boundary zone to 1D wall module
153 */
154/*--------------------------------------------------------------------------*/
155
156void
158(
159 const cs_zone_t *zone,
160 const int n_layers /*<[in] number of layers */
161);
162
163/*--------------------------------------------------------------------------*/
164/*
165 * \brief Define a layers' mesh
166 */
167/*--------------------------------------------------------------------------*/
168
169void
171(
172 const cs_zone_t *zone,
173 const int layer_id,
174 const int n_points,
175 const cs_real_t thickness,
176 const cs_real_t refine_factor
177);
178
179/*--------------------------------------------------------------------------*/
180/*
181 * \brief Define layer's physical properties
182 */
183/*--------------------------------------------------------------------------*/
184
185void
187(
188 const cs_zone_t *zone,
189 const int layer_id,
190 const cs_real_t initial_temperature,
191 const cs_real_t thermal_conductivity,
192 const cs_real_t density,
193 const cs_real_t heat_capacity
194);
195
196/*--------------------------------------------------------------------------*/
197/*
198 * \brief Define a dirichlet boundary condition
199 */
200/*--------------------------------------------------------------------------*/
201
202void
204(
205 const cs_zone_t *zone,
206 const cs_real_t t_ext
207);
208
209/*--------------------------------------------------------------------------*/
210/*
211 * \brief Define nuemann (flux) boundary conditions
212 */
213/*--------------------------------------------------------------------------*/
214
215void
217(
218 const cs_zone_t *zone,
219 const cs_real_t phi_ext
220);
221
222/*--------------------------------------------------------------------------*/
223/*
224 * \brief Define Robin boundary condition
225 *
226 */
227/*--------------------------------------------------------------------------*/
228
229void
231(
232 const cs_zone_t *zone,
233 const cs_real_t t_ext,
234 const cs_real_t h_ext
235);
236
237/*--------------------------------------------------------------------------*/
238/*
239 * \brief Compute total number of coupled faces.
240 */
241/*--------------------------------------------------------------------------*/
242
243void
245
246/*--------------------------------------------------------------------------*/
247/*
248 * \brief Initialization step based on zones
249 */
250/*--------------------------------------------------------------------------*/
251
252void
254
255/*--------------------------------------------------------------------------*/
256/*
257 * \brief Update properties, time step and boundary conditions before solve step
258 */
259/*--------------------------------------------------------------------------*/
260
261void
263(
264 const bool use_constant_time_step
265);
266
267/*--------------------------------------------------------------------------*/
268/*
269 * \brief Set postprocessing status
270 */
271/*--------------------------------------------------------------------------*/
272
273void
275(
276 bool new_status
277);
278
279/*--------------------------------------------------------------------------*/
280/*
281 * \brief Create and return a nodal fvm export of the 1D mesh
282 *
283 * \return fvm_nodal_t pointer. Lifecycle is handled by caller!
284 */
285/*--------------------------------------------------------------------------*/
286
287fvm_nodal_t *
289
290/*--------------------------------------------------------------------------*/
291/*
292 * \brief Create post-processing mesh
293 */
294/*--------------------------------------------------------------------------*/
295
296void
298
299/*--------------------------------------------------------------------------*/
300/*
301 * \brief Write temperature field (postprocessing)
302 */
303/*--------------------------------------------------------------------------*/
304
305void
307(
308 fvm_writer_t *writer,
309 const fvm_nodal_t *nm,
310 int nt_cur,
311 double t_cur
312);
313
314/*--------------------------------------------------------------------------*/
315/*
316 * \brief Check if postprocessing is activated
317 *
318 * \return true if postprocessing is used, false otherwise.
319 */
320/*--------------------------------------------------------------------------*/
321
322bool
324
325/*----------------------------------------------------------------------------*/
326/*
327 * \brief Allocate the array of structures local_models.
328 */
329/*----------------------------------------------------------------------------*/
330
331void
333
334/*----------------------------------------------------------------------------*/
335/*
336 * \brief Create the 1D mesh for each face and initialize the temperature.
337 */
338/*----------------------------------------------------------------------------*/
339
340void
342
343/*----------------------------------------------------------------------------*/
344/*
345 * \brief Solve the 1D equation for a given face
346 *
347 * parameters:
348 * \param[in] ii face number
349 * \param[in] tf fluid temperature at the boundarys
350 * \param[in] hf exchange coefficient for the fluid
351 */
352/*----------------------------------------------------------------------------*/
353
354void
356 cs_real_t tf,
357 cs_real_t hf);
358
359/*----------------------------------------------------------------------------*/
360/*
361 * \brief Read the restart file of the 1D-wall thermal module.
362 */
363/*----------------------------------------------------------------------------*/
364
365void
367
368/*----------------------------------------------------------------------------*/
369/*
370 * \brief Write the restart file of the 1D-wall thermal module.
371 */
372/*----------------------------------------------------------------------------*/
373
374void
376
377/*----------------------------------------------------------------------------*/
378/*
379 * \brief Free the array of structures local_models.
380 */
381/*----------------------------------------------------------------------------*/
382
383void
385
386/*----------------------------------------------------------------------------*/
387/*
388 * \brief Destroy the global 1d wall thermal structure.
389 */
390/*----------------------------------------------------------------------------*/
391
392void
394
395/*----------------------------------------------------------------------------*/
399/*----------------------------------------------------------------------------*/
400
403
404/*----------------------------------------------------------------------------*/
405/*
406 * \brief Print information about the 1d wall thermal computation
407 */
408/*----------------------------------------------------------------------------*/
409
410void
412
413/*----------------------------------------------------------------------------*/
414/*
415 * \brief Data checking for the 1D thermal wall module.
416 *
417 * \param[in] iappel Call number:
418 * - 1: first call during the initialization (called once)
419 * Checking the number of cells nfpt1d.
420 * - 2: second call during the initialization (called once)
421 * Checking ifpt1d, nppt1d, eppt1d and rgpt1d arrays.
422 * - 3: called at each time step
423 * Checking iclt1d, xlmbt1, rcpt1d and dtpt1d arrays.
424 */
425/*----------------------------------------------------------------------------*/
426
427void
428cs_1d_wall_thermal_check(int iappel);
429
430/*--------------------------------------------------------------------------*/
431/*
432 * \brief Check if 1d wall thermal module is used
433 *
434 * \return true if active, false otherwise
435 */
436/*--------------------------------------------------------------------------*/
437
438bool
440
441/*----------------------------------------------------------------------------*/
442
443#endif /* CS_1D_WALL_THERMAL_H */
void cs_1d_wall_thermal_local_models_create(void)
Allocate the array of structures local_models.
Definition: cs_1d_wall_thermal.cpp:908
void cs_1d_wall_post_temperature_field(fvm_writer_t *writer, const fvm_nodal_t *nm, int nt_cur, double t_cur)
Write temperature field (postprocessing)
Definition: cs_1d_wall_thermal.cpp:849
fvm_nodal_t * cs_1d_wall_thermal_export_nodal(void)
Create and return a nodal fvm export of the 1D mesh.
Definition: cs_1d_wall_thermal.cpp:737
void cs_1d_wall_thermal_create_post_mesh(void)
Create post-processing mesh.
Definition: cs_1d_wall_thermal.cpp:713
cs_1d_wall_thermal_t * cs_get_glob_1d_wall_thermal(void)
Provide access to cs_glob_1d_wall_thermal.
Definition: cs_1d_wall_thermal.cpp:1806
void cs_1d_wall_thermal_log(void)
Print information about the 1d wall thermal computation.
Definition: cs_1d_wall_thermal.cpp:1818
void cs_1d_wall_thermal_prepare_solve(const bool use_constant_time_step)
Update properties, time step and boundary conditions before solve step.
Definition: cs_1d_wall_thermal.cpp:682
void cs_1d_wall_thermal_compute_n_faces_from_definitions(void)
Compute total number of coupled faces.
Definition: cs_1d_wall_thermal.cpp:631
void cs_1d_wall_thermal_mesh_create(void)
Create the 1D mesh for each face and initialize the temperature.
Definition: cs_1d_wall_thermal.cpp:945
void cs_1d_wall_thermal_post_set_status(bool new_status)
Set postprocessing status.
Definition: cs_1d_wall_thermal.cpp:699
void cs_1d_wall_thermal_check(int iappel)
Data checking for the 1D thermal wall module.
Definition: cs_1d_wall_thermal.cpp:1871
void cs_1d_wall_thermal_create(void)
Initialize the cs_glob_1d_wall_thermal structure.
Definition: cs_1d_wall_thermal.cpp:440
void cs_1d_wall_thermal_finalize(void)
Destroy the global 1d wall thermal structure.
Definition: cs_1d_wall_thermal.cpp:1785
void cs_1d_wall_thermal_zone_define_neumann_bc_const(const cs_zone_t *zone, const cs_real_t phi_ext)
Define nuemann (flux) boundary conditions.
Definition: cs_1d_wall_thermal.cpp:591
void cs_1d_wall_thermal_zone_define_robin_bc_const(const cs_zone_t *zone, const cs_real_t t_ext, const cs_real_t h_ext)
Define Robin boundary condition.
Definition: cs_1d_wall_thermal.cpp:611
void cs_1d_wall_thermal_add_zone(const cs_zone_t *zone, const int n_layers)
Add faces of a boundary zone to 1D wall module.
Definition: cs_1d_wall_thermal.cpp:466
bool cs_1d_wall_thermal_is_used(void)
Check if 1d wall thermal module is used.
Definition: cs_1d_wall_thermal.cpp:1964
const cs_1d_wall_thermal_t * cs_glob_1d_wall_thermal
void cs_1d_wall_thermal_initialize(void)
Initialization step based on zones.
Definition: cs_1d_wall_thermal.cpp:651
bool cs_1d_wall_thermal_post_activated(void)
Check if postprocessing is activated.
Definition: cs_1d_wall_thermal.cpp:896
void cs_1d_wall_thermal_free(void)
Free the array of structures local_models.
Definition: cs_1d_wall_thermal.cpp:1769
void cs_1d_wall_thermal_read(void)
Read the restart file of the 1D-wall thermal module.
Definition: cs_1d_wall_thermal.cpp:1169
void cs_1d_wall_thermal_solve(cs_lnum_t ii, cs_real_t tf, cs_real_t hf)
Solve the 1D equation for a given face.
Definition: cs_1d_wall_thermal.cpp:1002
void cs_1d_wall_thermal_zone_define_dirichlet_bc_const(const cs_zone_t *zone, const cs_real_t t_ext)
Define a dirichlet boundary condition.
Definition: cs_1d_wall_thermal.cpp:572
void cs_1d_wall_thermal_zone_define_layer_properties_const(const cs_zone_t *zone, const int layer_id, const cs_real_t initial_temperature, const cs_real_t thermal_conductivity, const cs_real_t density, const cs_real_t heat_capacity)
Define layer's physical properties.
Definition: cs_1d_wall_thermal.cpp:541
void cs_1d_wall_thermal_zone_define_layer_mesh(const cs_zone_t *zone, const int layer_id, const int n_points, const cs_real_t thickness, const cs_real_t refine_factor)
Define a layers' mesh.
Definition: cs_1d_wall_thermal.cpp:512
void cs_1d_wall_thermal_write(void)
Write the restart file of the 1D-wall thermal module.
Definition: cs_1d_wall_thermal.cpp:1559
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
unsigned cs_gnum_t
global mesh entity number
Definition: cs_defs.h:317
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
Definition: cs_1d_wall_thermal.h:55
cs_real_t xlmbt1
Definition: cs_1d_wall_thermal.h:82
cs_real_t rgpt1d
Definition: cs_1d_wall_thermal.h:69
cs_real_t * z
Definition: cs_1d_wall_thermal.h:91
int iclt1d
Definition: cs_1d_wall_thermal.h:61
cs_real_t fept1d
Definition: cs_1d_wall_thermal.h:78
cs_real_t rcpt1d
Definition: cs_1d_wall_thermal.h:84
cs_real_t eppt1d
Definition: cs_1d_wall_thermal.h:66
cs_real_t * t
Definition: cs_1d_wall_thermal.h:93
cs_real_t dtpt1d
Definition: cs_1d_wall_thermal.h:87
int nppt1d
Definition: cs_1d_wall_thermal.h:57
cs_real_t hept1d
Definition: cs_1d_wall_thermal.h:75
cs_real_t tept1d
Definition: cs_1d_wall_thermal.h:72
1D wall thermal module descriptor.
Definition: cs_1d_wall_thermal.h:101
cs_gnum_t nfpt1t
Definition: cs_1d_wall_thermal.h:106
cs_lnum_t nfpt1d
Definition: cs_1d_wall_thermal.h:103
int nmxt1d
Definition: cs_1d_wall_thermal.h:110
cs_lnum_t * ifpt1d
Definition: cs_1d_wall_thermal.h:116
bool use_restart
Definition: cs_1d_wall_thermal.h:112
cs_lnum_t * izft1d
Definition: cs_1d_wall_thermal.h:114
cs_1d_wall_thermal_local_model_t * local_models
Definition: cs_1d_wall_thermal.h:125
cs_real_t * tppt1d
Definition: cs_1d_wall_thermal.h:120
Definition: cs_zone.h:51