9.2
general documentation
Data setting for the 1D-wall thermal module (cs_user_1d_wall_thermal.cpp)

The cs_user_1d_wall_thermal_setup subroutine is used to set global parameters for the 1D-wall thermal module, and will soon replace the cs_user_1d_wall_thermal subroutine.

Postprocessing for the module thermal field can be activated as follows:

void cs_1d_wall_thermal_post_set_status(bool new_status)
Set postprocessing status.
Definition: cs_1d_wall_thermal.cpp:699

To add a 1D wall thermal condition to a given boundary zone, one first needs to define in cs_user_1d_wall_thermal_setup the different parameters related to the zone.

First the zone to couple and number of layers in the 1D mesh:

// Get pointer to boundary zone to couple
const cs_zone_t *zone = cs_boundary_zone_by_name("BC_1");
// Define a one layer 1D wall
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
const cs_zone_t * cs_boundary_zone_by_name(const char *name)
Return a pointer to a boundary zone based on its name if present.
Definition: cs_boundary_zone.cpp:708
Definition: cs_zone.h:51

Define the mesh parameters for each layer:

// Define layer's mesh properties
{
const int layer_id = 0; /* layer id */
const int n_pts = 8; /* number of points in 1D mesh */
const cs_real_t thickness = 0.01144; /* layer's thickness */
const cs_real_t geom_factor = 1.; /* mesh geometrical factor */
layer_id,
n_pts,
thickness,
geom_factor);
}
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
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332

Define layer's properties:

{
// Define layer's initial Temperature and physical properties
const int layer_id = 0; /* layer id */
const cs_real_t T_ini = 20.; /* Initial temperature in 1D wall */
const cs_real_t lambda = 0.16; /* thermal conductivity */
const cs_real_t rho = 900.; /* density */
const cs_real_t Cp = 790.; /* heat capacity */
layer_id,
T_ini,
lambda, rho, Cp);
}
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
@ rho
Definition: cs_field_pointer.h:96
@ lambda
Definition: cs_field_pointer.h:105

And finally define a boundary condition, which is either a Dirichlet, Neumann or a Robin boundary condition:

{
// Define layer's Dirichlet boundary condition
const cs_real_t Text = 70.; /* Exterior temperature */
}
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
{
// Define layer's Neumann boundary condition
const cs_real_t phi_ext = 1000.; /* Exterior flux */
}
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
{
// Define layer's Robin boundary condition
const cs_real_t Text = 70.; /* Exterior temperature */
const cs_real_t hext = 10.; /* Exterior exchange coefficient */
}
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

The cs_user_1d_wall_thermal subroutine, which is now deprecated, is used to set the 1D-wall thermal module parameters.

This function is called 3 times:

  • A first call (iappel == 1) to count faces in the selected zones.
  • A second call (iappel == 2) to initialize associated arrays.
  • Subsequent calls (iappel == 3) at each time step to define and update additional arrays.

Local variables declaration

The values in this example should be defined for each call.

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
1D wall thermal module descriptor.
Definition: cs_1d_wall_thermal.h:101

The restart behavior of this module can be modified by adapting the following snippet:

wall_thermal->use_restart = cs_restart_present() ? true : false;
int cs_restart_present(void)
Check if we have a restart directory.
Definition: cs_restart.cpp:2170
bool use_restart
Definition: cs_1d_wall_thermal.h:112

Associatation with boundary zones.

For the first and second initialization passes (iappel = 1 or 2), the associated faces must be determined.

At the first pass, the faces must simply be counted. At the second pass, the list of associated faces is actually set.

The following code illustrates how this can be handled.

if (iappel == 1 || iappel == 2) {
/*-------------------------------------------------------------------------*
* Faces determining with the 1-D thermal module:
*----------------------------------------------
*
* nfpt1d : Total number of faces with the 1D thermal module
* ifpt1d[ii]: Number of the [ii]th face with the 1D thermal module
* Remarks:
*--------
* During the rereading of the restart file, nfpt1d and ifpt1d are
* compared with the other values from the restart file being the result of
* the start or restarting computation.
*
* A total similarity is required to continue with the previous computation.
* Regarding the test case on ifpt1d, it is necessary that the array be
* arranged in increasing order (ifpt1[jj] > ifpt1d[ii] if jj > ii).
*
* If it is impossible, contact the developer team to deactivate this test.
*-------------------------------------------------------------------------*/
/* Get the list of boundary faces that will be coupled */
cs_lnum_t nlelt = 0;
cs_selector_get_b_face_list("2 or 3 or 5 or 6 or 7 or 8 or 9 or 10",
&nlelt, lstelt);
if (iappel == 1) {
wall_thermal->nfpt1d = nlelt;
}
else if (iappel == 2) {
/* Fill the ifpt1d array */
cs_lnum_t ifbt1d = 0;
for (cs_lnum_t ilelt = 0 ; ilelt < nlelt ; ilelt++) {
cs_lnum_t ifac = lstelt[ilelt];
wall_thermal->ifpt1d[ifbt1d] = ifac+1;
ifbt1d++;
}
}
}
Define a templated array class (owner of data)
Definition: cs_array.h:1118
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
cs_mesh_t * cs_glob_mesh
void cs_selector_get_b_face_list(const char *criteria, cs_lnum_t *n_b_faces, cs_lnum_t b_face_list[])
Fill a list of boundary faces verifying a given selection criteria.
Definition: cs_selector.cpp:89
cs_lnum_t nfpt1d
Definition: cs_1d_wall_thermal.h:103
cs_lnum_t * ifpt1d
Definition: cs_1d_wall_thermal.h:116
cs_lnum_t n_b_faces
Definition: cs_mesh.h:99

Thermal model setup.

At the second initialization pass (iappel 2), the number of discretization points along each 1d segment, their distribution (based on a geometric progression ratio), the wall thickness, and initial temperature must also be defined:

For the second initialization pass (iappel 2), The list of associated faces is actualley set. Also, the number of discretization points along each 1d segment, their distribution (based on a geometric progression ratio), the wall thickness, and initial temperature must also be defined.

/*--------------------------------------------------------------------------*
* Parameters padding of the mesh and initialization:
*--------------------------------------------------
*
* (Only one pass during the beginning of the computation)
* local_models[ii].nppt1d: number of discretized points associated
* to the (ii)th face with the 1-D thermal module.
* local_models[ii].eppt1d: wall thickness associated to the (ii)th face
* with the 1-D thermal module.
* local_models[ii].rgpt1d: geometric progression ratio of the
* meshing refinement associated to the (ii)th face with the
* 1-D thermal module. (with : rgpt1d > 1 => small meshes on the fluid side)
* local_models[ii].tppt1d: wall temperature initialization associated to the
* (ii)th face with the 1-D thermal module.
* Remarks:
*--------
* During the rereading of the restart file for the 1-D thermal module,
* the tppt1d variable is not used.
*
* The nfpt1d, eppt1d and rgpt1d variables are compared to the previous
* values being the result of the restart file.
*
* An exact similarity is necessary to continue with the previous computation.
*---------------------------------------------------------------------------*/
if (iappel == 2) {
for (cs_lnum_t ii = 0 ; ii < wall_thermal->nfpt1d ; ii++) {
wall_thermal->local_models[ii].nppt1d = 8;
wall_thermal->local_models[ii].eppt1d = 0.01144;
wall_thermal->local_models[ii].rgpt1d = 1.;
wall_thermal->tppt1d[ii] = cs_glob_fluid_properties->t0;
}
}
const cs_fluid_properties_t * cs_glob_fluid_properties
Definition: cs_physical_constants.cpp:462
cs_real_t rgpt1d
Definition: cs_1d_wall_thermal.h:69
cs_real_t eppt1d
Definition: cs_1d_wall_thermal.h:66
int nppt1d
Definition: cs_1d_wall_thermal.h:57
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
double t0
Definition: cs_physical_constants.h:84

Computation

In the solution steps, the solid thermal properties and boundary conditions can be updated at each time step, where the function is called with parameter iappel = 3.

/*--------------------------------------------------------------------------*
* Padding of the wall exterior boundary conditions:
*-------------------------------------------------
*
* local_models[ii].iclt1d: boundary condition type
* ------------
* local_models[ii].iclt1d = 1: dirichlet condition,
* with exchange coefficient
* local_models[ii].iclt1d = 3: flux condition
*
* local_models[ii].tept1d: exterior temperature
* local_models[ii].hept1d: exterior exchange coefficient
* local_models[ii].fept1d: flux applied to the exterior (flux<0 = coming flux)
* local_models[ii].xlmt1d: lambda wall conductivity coefficient (W/m/C)
* local_models[ii].rcpt1d: wall coefficient rho*Cp (J/m3/C)
* local_models[ii].dtpt1d: time step resolution of the thermal equation
* to the (ii)th boundary face with the
* 1-D thermal module (s)
*--------------------------------------------------------------------------*/
if (iappel == 3) {
const cs_lnum_t *b_face_cells = cs_glob_mesh->b_face_cells;
const auto cpro_dt = CS_F_(dt)->get_val_s();
for (cs_lnum_t ii = 0 ; ii < wall_thermal->nfpt1d ; ii++) {
wall_thermal->local_models[ii].iclt1d = 1;
/* Physical parameters */
cs_lnum_t face_id = wall_thermal->ifpt1d[ii] - 1;
/* Floor: plate */
if (cdgfbo[face_id][2] <= 1.e-3) {
wall_thermal->local_models[ii].xlmbt1 = 0.16;
wall_thermal->local_models[ii].rcpt1d = 790.*900.;
/* Wall and ceiling: marinite */
}
else {
wall_thermal->local_models[ii].xlmbt1 = 0.11;
wall_thermal->local_models[ii].rcpt1d = 670.*778.;
}
cs_lnum_t c_id = b_face_cells[face_id];
wall_thermal->local_models[ii].dtpt1d = cpro_dt[c_id];
}
}
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:349
@ dt
Definition: cs_field_pointer.h:61
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:47
cs_mesh_quantities_t * cs_glob_mesh_quantities
double precision, dimension(:,:), pointer cdgfbo
coordinates of the centers of the boundary faces
Definition: mesh.f90:65
cs_real_t xlmbt1
Definition: cs_1d_wall_thermal.h:82
int iclt1d
Definition: cs_1d_wall_thermal.h:61
cs_real_t rcpt1d
Definition: cs_1d_wall_thermal.h:84
cs_real_t dtpt1d
Definition: cs_1d_wall_thermal.h:87
cs_real_t tept1d
Definition: cs_1d_wall_thermal.h:72
cs_real_3_t * b_face_cog
Definition: cs_mesh_quantities.h:102
cs_lnum_t * b_face_cells
Definition: cs_mesh.h:112