9.2
general documentation
cs_ibm.h
Go to the documentation of this file.
1#ifndef CS_IBM_H
2#define CS_IBM_H
3
4/*============================================================================
5 * Time and space immersed boundaries model.
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 * Local headers
32 *----------------------------------------------------------------------------*/
33
34#include "base/cs_defs.h"
37#include "mesh/cs_stl.h"
38#include "cdo/cs_xdef.h"
39
40/*----------------------------------------------------------------------------*/
41
42#ifndef DOXYGEN_SHOULD_SKIP_THIS
43
44#endif /* DOXYGEN_SHOULD_SKIP_THIS */
45
46/*=============================================================================
47 * Local Macro definitions
48 *============================================================================*/
49
50/*============================================================================
51 * Type definition
52 *============================================================================*/
53
54/*---------------------------------------------------------------------------
55 * Choice for porosity model
56 *---------------------------------------------------------------------------*/
57
58typedef enum
59{
60 CS_IBM_OFF = 0, /* No immersed boundary model */
61 CS_IBM_FIXED_SOLID = 1, /* Fix solid porosity model */
62
64
65/*---------------------------------------------------------------------------
66 * Detection of problem dimension type for immersed boundaries
67 *---------------------------------------------------------------------------*/
68
69typedef enum
70{
71 CS_IBM_3D = -1, /* 3D computation */
72 CS_IBM_2D_X = 0, /* 2D computation with symmetry in X direction */
73 CS_IBM_2D_Y = 1, /* 2D computation with symmetry in Y direction */
74 CS_IBM_2D_Z = 2 /* 2D computation with symmetry in Z direction */
75
77
78/*---------------------------------------------------------------------------
79 * Algorithm choice for porosity computation
80 *---------------------------------------------------------------------------*/
81
82typedef enum
83{
84 CS_IBM_ALGO_NONE , /* Default init before knowing the chosen algo */
85 CS_IBM_ALGO_CUT_CELLS , /* Cut-cells: optimised cutting */
86 CS_IBM_ALGO_MEDCOUPLING, /* MEDCoupling sequential volume interpolation */
87 CS_IBM_ALGO_STL , /* Computation from STL ASCII file */
88
89 CS_N_VAR_PORO_ALGO_TYPES /* Number of algo choices */
90
92
93/*---------------------------------------------------------------------------
94 * Choice for B.C. at walls
95 *---------------------------------------------------------------------------*/
96
97typedef enum
98{
99 CS_IBM_SLIP_WALL_CONDITION , /* Slip wall b.c. */
100 CS_IBM_NO_SLIP_WALL_CONDITION , /* No-Slip wall b.c. */
101 CS_IBM_WALL_LAW_WALL_CONDITION /* Wall law wall b.c. */
102
104
105/*---------------------------------------------------------------------------
106 * Objects mechanical or thermophysical properties
107 *---------------------------------------------------------------------------*/
108
109typedef enum
110{
111
124
126
128
129typedef enum
130{
138
140
142
143/*---------------------------------------------------------------------------
144 * Structure associated to objects management
145 *---------------------------------------------------------------------------*/
146
147typedef int
148(cs_cutcell_func_t)(const cs_lnum_t c_id,
149 const cs_real_3_t xyz,
150 const cs_real_t t,
151 const int num_object);
152
153/*---------------------------------------------------------------------------
154 * Structure associated to objects management
155 *---------------------------------------------------------------------------*/
156
157/*----------------------------------------------------------------------------
158 * Porosity immersed boundaries model options descriptor
159 *----------------------------------------------------------------------------*/
160
161typedef struct {
164
165/* Pointer to options structure */
167
168typedef struct
169{
170
171 /* --------------------------------------- */
172 /* Name of the object */
173 /* --------------------------------------- */
174 char *name;
175
176 /* --------------------------------------- */
177 /* Computation method */
178 /* --------------------------------------- */
180
181 /* --------------------------------------- */
182 /* Method specific pointers */
185 cs_medcoupling_intersector_t *mi;
186 /* --------------------------------------- */
187
188 /* --------------------------------------- */
189 /* Object thermophysical properties */
191 /* --------------------------------------- */
192
193 /* --------------------------------------- */
194 /* Initial parameters */
196 /* --------------------------------------- */
197
199
200/*---------------------------------------------------------------------------
201 * Structure associated to immersed boundaries management
202 *---------------------------------------------------------------------------*/
203
204typedef struct
205{
206 /* ---------------------------------------------- */
207 /* Objects defined using stl or medcoupling. */
210 /* ---------------------------------------------- */
211
212 /* Detection of prob dim type for immersed boundaries */
214 /* Algorithm choice for porosity computation */
216 /* Choice for velocity B.C. at walls */
218 /* Number of sub-cut for cells using the Cut-Cells algo */
220 /* Number of sub-cut for faces using the Cut-Cells algo */
222 /* Porosity dynamic modification */
224 /* Limitation area for porosity calculation */
226 /* Limitation area for porosity calculation */
228 /* Solid internal porosity */
230 /* Fluid volume at the first time step */
232 /* Keep same volume for porous object at each iteration */
234 /* Cell porosity based on nodes porosity (smoothing) */
236
237} cs_ibm_t;
238
239
240/*============================================================================
241 * Global variables
242 *============================================================================*/
243
244/* Pointer to the cs_ibm structure for various arrays */
245
246extern cs_ibm_t *cs_ibm;
247
248/*============================================================================
249 * Public function prototypes
250 *============================================================================*/
251
252/*----------------------------------------------------------------------------*/
260/*----------------------------------------------------------------------------*/
261
263cs_ibm_object_by_id(int obj_id);
264
265/*----------------------------------------------------------------------------*/
273/*----------------------------------------------------------------------------*/
274
276cs_ibm_object_by_name_try(const char *name);
277
278/*----------------------------------------------------------------------------*/
286/*----------------------------------------------------------------------------*/
287
289cs_ibm_object_by_name(const char *name);
290
291/*----------------------------------------------------------------------------
292 * Create an empty cs_ibm structure for various arrays
293 *
294 * returns:
295 * pointer to created cs_ibm structure
296 *----------------------------------------------------------------------------*/
297
298cs_ibm_t *
299cs_ibm_create(void);
300
301/*----------------------------------------------------------------------------
302 * Destroy a cs_ibm structure
303 *
304 * cs_ibm <-- pointer to a cs_ibm_t structure
305 *
306 * returns:
307 * NULL
308 *----------------------------------------------------------------------------*/
309
310void
311cs_ibm_finalize(void);
312
313/*----------------------------------------------------------------------------
314 * Define immersed boundaries in time and space (solid(s) interior part).
315 *----------------------------------------------------------------------------*/
316
317void
319 const cs_mesh_quantities_t *mesh_quantities);
320
321/*----------------------------------------------------------------------------
322 * Define space immersed boundaries on a set of zones defined by the user in the
323 * GUI
324 *----------------------------------------------------------------------------*/
325
326void
328
329/*----------------------------------------------------------------------------*/
337/*----------------------------------------------------------------------------*/
338
340cs_ibm_object_by_id(int obj_id);
341
342/*----------------------------------------------------------------------------*/
350/*----------------------------------------------------------------------------*/
351
353cs_ibm_object_by_name_try(const char *name);
354
355/*----------------------------------------------------------------------------*/
365/*----------------------------------------------------------------------------*/
366
367int
369 const cs_real_3_t xyz,
370 const cs_real_t t,
371 const int num_object);
372
373/*----------------------------------------------------------------------------*/
383/*----------------------------------------------------------------------------*/
384
385void
386cs_ibm_add_object_from_file(const char *name,
387 cs_ibm_algo_type_t method,
388 const char *file_name,
389 bool solve_fsi);
390
391/*----------------------------------------------------------------------------*/
402/*----------------------------------------------------------------------------*/
403
404void
405cs_ibm_add_object_from_func(const char *name,
406 cs_cutcell_func_t *cutcell_func,
407 bool solve_fsi,
408 int n_nodes);
409
410/*----------------------------------------------------------------------------*/
418/*----------------------------------------------------------------------------*/
419
420void
421cs_ibm_stl_define_ext_points(const char *name,
422 const int n_pts,
423 cs_real_t *pts_coords);
424
425/*----------------------------------------------------------------------------*/
434/*----------------------------------------------------------------------------*/
435
436void
437cs_ibm_object_rotate(const char *name,
438 cs_real_t angle,
439 cs_real_t axis[3],
440 cs_real_t center[3]);
441
442/*----------------------------------------------------------------------------*/
450/*----------------------------------------------------------------------------*/
451
452void
455 cs_real_t val);
456
457/*----------------------------------------------------------------------------*/
464/*----------------------------------------------------------------------------*/
465
466void
467cs_ibm_object_translate(const char *name,
468 cs_real_t vector[3]);
469
470/*----------------------------------------------------------------------------*/
477/*----------------------------------------------------------------------------*/
478
479void
480cs_ibm_object_scale(const char *name,
481 cs_real_t factor);
482
483/*----------------------------------------------------------------------------*/
487/*----------------------------------------------------------------------------*/
488
489void
491
492/*----------------------------------------------------------------------------*/
496/*----------------------------------------------------------------------------*/
497
498extern "C" void
500
501/*----------------------------------------------------------------------------*/
509/*----------------------------------------------------------------------------*/
510
511extern "C" void
513 cs_real_34_t matrix);
514
515/*----------------------------------------------------------------------------*/
525/*----------------------------------------------------------------------------*/
526
527void
529 const cs_mesh_t *m,
530 const cs_real_t *cell_vol,
531 cs_real_t *obj_frac_tot,
532 int *indic);
533
534/*----------------------------------------------------------------------------*/
541/*----------------------------------------------------------------------------*/
542
543void
544cs_ibm_volumic_zone(const cs_mesh_quantities_t *mesh_quantities);
545
546/*----------------------------------------------------------------------------*/
550/*----------------------------------------------------------------------------*/
551
552extern "C" void
554
555/*----------------------------------------------------------------------------*/
560/*----------------------------------------------------------------------------*/
561
562extern "C" void
564
565/*----------------------------------------------------------------------------*/
572/*----------------------------------------------------------------------------*/
573
574extern "C" void
576
577/*----------------------------------------------------------------------------*/
586/*----------------------------------------------------------------------------*/
587
588extern "C" void
590 const cs_real_3_t xyz,
591 const cs_real_t t,
592 const int num_object);
593
594/*----------------------------------------------------------------------------*/
606/*----------------------------------------------------------------------------*/
607
608extern "C" void
610 const cs_mesh_quantities_t *mesh_quantities);
611
612/*----------------------------------------------------------------------------*/
613
614#endif /* CS_IBM_H */
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_real_t cs_real_34_t[3][4]
Definition: cs_defs.h:364
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:349
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
@ t
Definition: cs_field_pointer.h:91
void cs_user_ibm_parameters(void)
User function to set global parameters for the immersed boundaries module.
Definition: cs_user_ibm.cpp:66
void cs_ibm_add_object_from_func(const char *name, cs_cutcell_func_t *cutcell_func, bool solve_fsi, int n_nodes)
Define an object from a function used in the cutcell algorithm.
Definition: cs_ibm.cpp:4225
void cs_immersed_boundaries(const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities)
Define immersed boundaries in time and space (solid(s) interior part).
Definition: cs_ibm.cpp:3855
void cs_ibm_user_parameters(void)
Apply user parameters.
Definition: cs_ibm.cpp:4446
cs_ibm_object_t * cs_ibm_object_by_name(const char *name)
Get an object based on its name. Error if not found.
Definition: cs_ibm.cpp:3753
void cs_ibm_volumic_zone(const cs_mesh_quantities_t *mesh_quantities)
Define space immersed boundaries on a set of zones defined by the user in the GUI.
Definition: cs_ibm.cpp:4645
int cs_ibm_object_compute_cut_porosity(const cs_lnum_t c_id, const cs_real_3_t xyz, const cs_real_t t, const int num_object)
Check if a point is solid or fluid based on the cut-cell method.
Definition: cs_ibm.cpp:4139
void cs_user_ibm_define_objects(void)
User function in which the user defines the objects to model.
Definition: cs_user_ibm.cpp:54
void cs_ibm_object_compute_intersect_vol(cs_ibm_object_t *obj, const cs_mesh_t *m, const cs_real_t *cell_vol, cs_real_t *obj_frac_tot, int *indic)
Compute the volume fraction of an object over all cells.
Definition: cs_ibm.cpp:4567
void cs_ibm_init_writer(void)
Init writers for STL or MED objects.
Definition: cs_ibm.cpp:4464
cs_ibm_object_init_param_t
Definition: cs_ibm.h:130
@ CS_IBM_OBJ_INIT_FLUID_FORCE
Definition: cs_ibm.h:137
@ CS_IBM_OBJ_INIT_ANGLE
Definition: cs_ibm.h:133
@ CS_IBM_OBJ_INIT_ANGULAR_VEL
Definition: cs_ibm.h:136
@ CS_N_IBM_OBJ_INIT_TYPES
Definition: cs_ibm.h:139
@ CS_IBM_OBJ_INIT_COG
Definition: cs_ibm.h:132
@ CS_IBM_OBJ_INIT_VELOCITY
Definition: cs_ibm.h:134
@ CS_IBM_OBJ_INIT_ACCELERATION
Definition: cs_ibm.h:135
@ CS_IBM_OBJ_INIT_COG_EQ
Definition: cs_ibm.h:131
cs_ibm_object_property_type_t
Definition: cs_ibm.h:110
@ CS_IBM_OBJ_PROP_STIFFNESS
Definition: cs_ibm.h:117
@ CS_IBM_OBJ_PROP_DAMPING
Definition: cs_ibm.h:118
@ CS_IBM_OBJ_PROP_YOUNG_MODULE
Definition: cs_ibm.h:119
@ CS_IBM_OBJ_PROP_RAYLEIGH_DAMP_A
Definition: cs_ibm.h:122
@ CS_N_IBM_OBJ_PROP_TYPES
Definition: cs_ibm.h:125
@ NC_IBM_OBJ_PROP_INERTIA_MATRIX
Definition: cs_ibm.h:114
@ CS_IBM_OBJ_PROP_CROSS_SECTION
Definition: cs_ibm.h:121
@ CS_IBM_OBJ_PROP_CP
Definition: cs_ibm.h:115
@ CS_IBM_OBJ_PROP_DENSITY
Definition: cs_ibm.h:112
@ CS_IBM_OBJ_PROP_RAYLEIGH_DAMP_B
Definition: cs_ibm.h:123
@ CS_IBM_OBJ_PROP_INERTIA_MOM
Definition: cs_ibm.h:120
@ CS_IBM_OBJ_PROP_LAMBDA
Definition: cs_ibm.h:116
@ NC_IBM_OBJ_PROP_MASS
Definition: cs_ibm.h:113
cs_ibm_model_type_t
Definition: cs_ibm.h:59
@ CS_IBM_FIXED_SOLID
Definition: cs_ibm.h:61
@ CS_IBM_OFF
Definition: cs_ibm.h:60
cs_ibm_object_t * cs_ibm_object_by_name_try(const char *name)
Try to get an object based on its name. Returns NULL if not found.
Definition: cs_ibm.cpp:3726
void cs_ibm_object_transform_from_init(cs_ibm_object_t *obj, cs_real_34_t matrix)
Transform an object from its initial state using a transformation matrix.
Definition: cs_ibm.cpp:4532
void cs_volumic_zone_porosity(const cs_mesh_quantities_t *mesh_quantities)
void cs_user_ibm_modify(const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities)
User function. Locally modify a given porosity to take into account erosion effect (for instance).
Definition: cs_user_ibm_modify.cpp:64
void cs_ibm_object_scale(const char *name, cs_real_t factor)
Scale an object based on a factor.
Definition: cs_ibm.cpp:4410
void cs_ibm_object_set_property_const(cs_ibm_object_t *obj, cs_ibm_object_property_type_t ppty_id, cs_real_t val)
Define a new constant property definition for an object.
Definition: cs_ibm.cpp:4354
void cs_user_ibm_solid_por(const cs_lnum_t c_id, const cs_real_3_t xyz, const cs_real_t t, const int num_object)
User function which allows the definition of a 'porous' object.
cs_porosity_ibm_opt_t * cs_glob_porosity_ibm_opt
Definition: cs_ibm.cpp:91
int() cs_cutcell_func_t(const cs_lnum_t c_id, const cs_real_3_t xyz, const cs_real_t t, const int num_object)
Definition: cs_ibm.h:148
void cs_user_ibm_object_transformations(const cs_real_t time)
User function where to apply predefined transformations to MED/STL based objects.
Definition: cs_user_ibm.cpp:81
cs_ibm_algo_type_t
Definition: cs_ibm.h:83
@ CS_IBM_ALGO_CUT_CELLS
Definition: cs_ibm.h:85
@ CS_N_VAR_PORO_ALGO_TYPES
Definition: cs_ibm.h:89
@ CS_IBM_ALGO_MEDCOUPLING
Definition: cs_ibm.h:86
@ CS_IBM_ALGO_NONE
Definition: cs_ibm.h:84
@ CS_IBM_ALGO_STL
Definition: cs_ibm.h:87
cs_ibm_object_t * cs_ibm_object_by_id(int obj_id)
Get an object based on its id.
Definition: cs_ibm.cpp:3706
void cs_ibm_object_translate(const char *name, cs_real_t vector[3])
Translate an object based on the STL or MED algorithms.
Definition: cs_ibm.cpp:4371
void cs_ibm_object_rotate(const char *name, cs_real_t angle, cs_real_t axis[3], cs_real_t center[3])
Rotate an object based on the STL or MED algorithms.
Definition: cs_ibm.cpp:4306
void cs_ibm_add_object_from_file(const char *name, cs_ibm_algo_type_t method, const char *file_name, bool solve_fsi)
Define an object from a file using STL or MED formats.
Definition: cs_ibm.cpp:4173
void cs_ibm_stl_define_ext_points(const char *name, const int n_pts, cs_real_t *pts_coords)
Define exterior points for an STL object.
Definition: cs_ibm.cpp:4279
void cs_ibm_finalize(void)
Definition: cs_ibm.cpp:3819
cs_ibm_prob_dim_type_t
Definition: cs_ibm.h:70
@ CS_IBM_2D_Y
Definition: cs_ibm.h:73
@ CS_IBM_2D_Z
Definition: cs_ibm.h:74
@ CS_IBM_2D_X
Definition: cs_ibm.h:72
@ CS_IBM_3D
Definition: cs_ibm.h:71
cs_ibm_t * cs_ibm
Definition: cs_ibm.cpp:94
cs_ibm_t * cs_ibm_create(void)
Definition: cs_ibm.cpp:3781
cs_ibm_wall_cond_type_t
Definition: cs_ibm.h:98
@ CS_IBM_WALL_LAW_WALL_CONDITION
Definition: cs_ibm.h:101
@ CS_IBM_SLIP_WALL_CONDITION
Definition: cs_ibm.h:99
@ CS_IBM_NO_SLIP_WALL_CONDITION
Definition: cs_ibm.h:100
Definition: mesh.f90:26
Definition: cs_ibm.h:169
cs_medcoupling_intersector_t * mi
Definition: cs_ibm.h:185
char * name
Definition: cs_ibm.h:174
cs_ibm_algo_type_t method
Definition: cs_ibm.h:179
cs_stl_mesh_t * stl
Definition: cs_ibm.h:184
cs_cutcell_func_t * cutcell_func
Definition: cs_ibm.h:183
Definition: cs_ibm.h:205
bool porosity_from_nodes
Definition: cs_ibm.h:235
bool porosity_user_source_term_modification
Definition: cs_ibm.h:223
bool ensure_isovol
Definition: cs_ibm.h:233
int n_objects
Definition: cs_ibm.h:208
cs_ibm_prob_dim_type_t prob_dim
Definition: cs_ibm.h:213
cs_real_t isovol
Definition: cs_ibm.h:231
int nb_cut_faces
Definition: cs_ibm.h:221
cs_ibm_algo_type_t algo_choice
Definition: cs_ibm.h:215
cs_real_3_t xyzmax_moving_porosity
Definition: cs_ibm.h:227
cs_real_t * solid_porosity
Definition: cs_ibm.h:229
cs_real_3_t xyzmin_moving_porosity
Definition: cs_ibm.h:225
cs_ibm_object_t ** objects
Definition: cs_ibm.h:209
int nb_cut_cells
Definition: cs_ibm.h:219
cs_ibm_wall_cond_type_t wall_condition
Definition: cs_ibm.h:217
Definition: cs_mesh_quantities.h:88
Definition: cs_mesh.h:85
Definition: cs_ibm.h:161
int porosity_mode
Definition: cs_ibm.h:162
Definition: cs_stl.h:50
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:156