9.1
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-2025 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
45
46#endif /* DOXYGEN_SHOULD_SKIP_THIS */
47
48/*=============================================================================
49 * Local Macro definitions
50 *============================================================================*/
51
52/*============================================================================
53 * Type definition
54 *============================================================================*/
55
56/*---------------------------------------------------------------------------
57 * Choice for porosity model
58 *---------------------------------------------------------------------------*/
59
60typedef enum
61{
62 CS_IBM_OFF = 0, /* No immersed boundary model */
63 CS_IBM_FIXED_SOLID = 1, /* Fix solid porosity model */
64
66
67/*---------------------------------------------------------------------------
68 * Detection of problem dimension type for immersed boundaries
69 *---------------------------------------------------------------------------*/
70
71typedef enum
72{
73 CS_IBM_3D = -1, /* 3D computation */
74 CS_IBM_2D_X = 0, /* 2D computation with symmetry in X direction */
75 CS_IBM_2D_Y = 1, /* 2D computation with symmetry in Y direction */
76 CS_IBM_2D_Z = 2 /* 2D computation with symmetry in Z direction */
77
79
80/*---------------------------------------------------------------------------
81 * Algorithm choice for porosity computation
82 *---------------------------------------------------------------------------*/
83
84typedef enum
85{
86 CS_IBM_ALGO_NONE , /* Default init before knowing the chosen algo */
87 CS_IBM_ALGO_CUT_CELLS , /* Cut-cells: optimised cutting */
88 CS_IBM_ALGO_MEDCOUPLING, /* MEDCoupling sequential volume interpolation */
89 CS_IBM_ALGO_STL , /* Computation from STL ASCII file */
90
91 CS_N_VAR_PORO_ALGO_TYPES /* Number of algo choices */
92
94
95/*---------------------------------------------------------------------------
96 * Choice for B.C. at walls
97 *---------------------------------------------------------------------------*/
98
99typedef enum
100{
101 CS_IBM_SLIP_WALL_CONDITION , /* Slip wall b.c. */
102 CS_IBM_NO_SLIP_WALL_CONDITION , /* No-Slip wall b.c. */
103 CS_IBM_WALL_LAW_WALL_CONDITION /* Wall law wall b.c. */
104
106
107/*---------------------------------------------------------------------------
108 * Objects mechanical or thermophysical properties
109 *---------------------------------------------------------------------------*/
110
111typedef enum
112{
113
126
128
130
131typedef enum
132{
140
142
144
145/*---------------------------------------------------------------------------
146 * Structure associated to objects management
147 *---------------------------------------------------------------------------*/
148
149typedef int
150(cs_cutcell_func_t)(const cs_lnum_t c_id,
151 const cs_real_3_t xyz,
152 const cs_real_t t,
153 const int num_object);
154
155/*---------------------------------------------------------------------------
156 * Structure associated to objects management
157 *---------------------------------------------------------------------------*/
158
159/*----------------------------------------------------------------------------
160 * Porosity immersed boundaries model options descriptor
161 *----------------------------------------------------------------------------*/
162
163typedef struct {
166
167/* Pointer to options structure */
169
170typedef struct
171{
172
173 /* --------------------------------------- */
174 /* Name of the object */
175 /* --------------------------------------- */
176 char *name;
177
178 /* --------------------------------------- */
179 /* Computation method */
180 /* --------------------------------------- */
182
183 /* --------------------------------------- */
184 /* Method specific pointers */
187 cs_medcoupling_intersector_t *mi;
188 /* --------------------------------------- */
189
190 /* --------------------------------------- */
191 /* Object thermophysical properties */
193 /* --------------------------------------- */
194
195 /* --------------------------------------- */
196 /* Initial parameters */
198 /* --------------------------------------- */
199
201
202/*---------------------------------------------------------------------------
203 * Structure associated to immersed boundaries management
204 *---------------------------------------------------------------------------*/
205
206typedef struct
207{
208 /* ---------------------------------------------- */
209 /* Objects defined using stl or medcoupling. */
212 /* ---------------------------------------------- */
213
214 /* Detection of prob dim type for immersed boundaries */
216 /* Algorithm choice for porosity computation */
218 /* Choice for velocity B.C. at walls */
220 /* Number of sub-cut for cells using the Cut-Cells algo */
222 /* Number of sub-cut for faces using the Cut-Cells algo */
224 /* Porosity dynamic modification */
226 /* Limitation area for porosity calculation */
228 /* Limitation area for porosity calculation */
230 /* Solid internal porosity */
232 /* Fluid volume at the first time step */
234 /* Keep same volume for porous object at each iteration */
236 /* Cell porosity based on nodes porosity (smoothing) */
238
239} cs_ibm_t;
240
241
242/*============================================================================
243 * Global variables
244 *============================================================================*/
245
246/* Pointer to the cs_ibm structure for various arrays */
247
248extern cs_ibm_t *cs_ibm;
249
250/*============================================================================
251 * Public function prototypes
252 *============================================================================*/
253
254/*----------------------------------------------------------------------------*/
262/*----------------------------------------------------------------------------*/
263
265cs_ibm_object_by_id(int obj_id);
266
267/*----------------------------------------------------------------------------*/
275/*----------------------------------------------------------------------------*/
276
278cs_ibm_object_by_name_try(const char *name);
279
280/*----------------------------------------------------------------------------*/
288/*----------------------------------------------------------------------------*/
289
291cs_ibm_object_by_name(const char *name);
292
293/*----------------------------------------------------------------------------
294 * Create an empty cs_ibm structure for various arrays
295 *
296 * returns:
297 * pointer to created cs_ibm structure
298 *----------------------------------------------------------------------------*/
299
300cs_ibm_t *
301cs_ibm_create(void);
302
303/*----------------------------------------------------------------------------
304 * Destroy a cs_ibm structure
305 *
306 * cs_ibm <-- pointer to a cs_ibm_t structure
307 *
308 * returns:
309 * NULL
310 *----------------------------------------------------------------------------*/
311
312void
313cs_ibm_finalize(void);
314
315/*----------------------------------------------------------------------------
316 * Define immersed boundaries in time and space (solid(s) interior part).
317 *----------------------------------------------------------------------------*/
318
319void
321 const cs_mesh_quantities_t *mesh_quantities);
322
323/*----------------------------------------------------------------------------
324 * Define space immersed boundaries on a set of zones defined by the user in the
325 * GUI
326 *----------------------------------------------------------------------------*/
327
328void
330
331/*----------------------------------------------------------------------------*/
339/*----------------------------------------------------------------------------*/
340
342cs_ibm_object_by_id(int obj_id);
343
344/*----------------------------------------------------------------------------*/
352/*----------------------------------------------------------------------------*/
353
355cs_ibm_object_by_name_try(const char *name);
356
357/*----------------------------------------------------------------------------*/
367/*----------------------------------------------------------------------------*/
368
369int
371 const cs_real_3_t xyz,
372 const cs_real_t t,
373 const int num_object);
374
375/*----------------------------------------------------------------------------*/
385/*----------------------------------------------------------------------------*/
386
387void
388cs_ibm_add_object_from_file(const char *name,
389 cs_ibm_algo_type_t method,
390 const char *file_name,
391 bool solve_fsi);
392
393/*----------------------------------------------------------------------------*/
404/*----------------------------------------------------------------------------*/
405
406void
407cs_ibm_add_object_from_func(const char *name,
408 cs_cutcell_func_t *cutcell_func,
409 bool solve_fsi,
410 int n_nodes);
411
412/*----------------------------------------------------------------------------*/
420/*----------------------------------------------------------------------------*/
421
422void
423cs_ibm_stl_define_ext_points(const char *name,
424 const int n_pts,
425 cs_real_t *pts_coords);
426
427/*----------------------------------------------------------------------------*/
436/*----------------------------------------------------------------------------*/
437
438void
439cs_ibm_object_rotate(const char *name,
440 cs_real_t angle,
441 cs_real_t axis[3],
442 cs_real_t center[3]);
443
444/*----------------------------------------------------------------------------*/
452/*----------------------------------------------------------------------------*/
453
454void
457 cs_real_t val);
458
459/*----------------------------------------------------------------------------*/
466/*----------------------------------------------------------------------------*/
467
468void
469cs_ibm_object_translate(const char *name,
470 cs_real_t vector[3]);
471
472/*----------------------------------------------------------------------------*/
479/*----------------------------------------------------------------------------*/
480
481void
482cs_ibm_object_scale(const char *name,
483 cs_real_t factor);
484
485/*----------------------------------------------------------------------------*/
489/*----------------------------------------------------------------------------*/
490
491void
493
494/*----------------------------------------------------------------------------*/
498/*----------------------------------------------------------------------------*/
499
500void
502
503/*----------------------------------------------------------------------------*/
511/*----------------------------------------------------------------------------*/
512
513void
515 cs_real_34_t matrix);
516
517/*----------------------------------------------------------------------------*/
527/*----------------------------------------------------------------------------*/
528
529void
531 const cs_mesh_t *m,
532 const cs_real_t *cell_vol,
533 cs_real_t *obj_frac_tot,
534 int *indic);
535
536/*----------------------------------------------------------------------------*/
543/*----------------------------------------------------------------------------*/
544
545void
546cs_ibm_volumic_zone(const cs_mesh_quantities_t *mesh_quantities);
547
548/*----------------------------------------------------------------------------*/
554/*----------------------------------------------------------------------------*/
555
556/*----------------------------------------------------------------------------*/
560/*----------------------------------------------------------------------------*/
561
562void
564
565/*----------------------------------------------------------------------------*/
570/*----------------------------------------------------------------------------*/
571
572void
574
575/*----------------------------------------------------------------------------*/
582/*----------------------------------------------------------------------------*/
583
584void
586
587/*----------------------------------------------------------------------------*/
596/*----------------------------------------------------------------------------*/
597
598void
600 const cs_real_3_t xyz,
601 const cs_real_t t,
602 const int num_object);
603
604/*----------------------------------------------------------------------------*/
611/*----------------------------------------------------------------------------*/
612
613/*----------------------------------------------------------------------------*/
625/*----------------------------------------------------------------------------*/
626
627void
629 const cs_mesh_quantities_t *mesh_quantities);
630
631/*----------------------------------------------------------------------------*/
632
634
635#endif /* __CS_IBM_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:554
double cs_real_t
Floating-point value.
Definition: cs_defs.h:357
cs_real_t cs_real_34_t[3][4]
Definition: cs_defs.h:389
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:374
#define END_C_DECLS
Definition: cs_defs.h:555
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:350
@ t
Definition: cs_field_pointer.h:95
void cs_user_ibm_parameters(void)
User function to set global parameters for the immersed boundaries module.
Definition: cs_user_ibm.cpp:70
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:4231
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:3861
void cs_ibm_user_parameters(void)
Apply user parameters.
Definition: cs_ibm.cpp:4452
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:3759
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:4651
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:4145
void cs_user_ibm_define_objects(void)
User function in which the user defines the objects to model.
Definition: cs_user_ibm.cpp:58
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:4573
void cs_ibm_init_writer(void)
Init writers for STL or MED objects.
Definition: cs_ibm.cpp:4470
cs_ibm_object_init_param_t
Definition: cs_ibm.h:132
@ CS_IBM_OBJ_INIT_FLUID_FORCE
Definition: cs_ibm.h:139
@ CS_IBM_OBJ_INIT_ANGLE
Definition: cs_ibm.h:135
@ CS_IBM_OBJ_INIT_ANGULAR_VEL
Definition: cs_ibm.h:138
@ CS_N_IBM_OBJ_INIT_TYPES
Definition: cs_ibm.h:141
@ CS_IBM_OBJ_INIT_COG
Definition: cs_ibm.h:134
@ CS_IBM_OBJ_INIT_VELOCITY
Definition: cs_ibm.h:136
@ CS_IBM_OBJ_INIT_ACCELERATION
Definition: cs_ibm.h:137
@ CS_IBM_OBJ_INIT_COG_EQ
Definition: cs_ibm.h:133
cs_ibm_object_property_type_t
Definition: cs_ibm.h:112
@ CS_IBM_OBJ_PROP_STIFFNESS
Definition: cs_ibm.h:119
@ CS_IBM_OBJ_PROP_DAMPING
Definition: cs_ibm.h:120
@ CS_IBM_OBJ_PROP_YOUNG_MODULE
Definition: cs_ibm.h:121
@ CS_IBM_OBJ_PROP_RAYLEIGH_DAMP_A
Definition: cs_ibm.h:124
@ CS_N_IBM_OBJ_PROP_TYPES
Definition: cs_ibm.h:127
@ NC_IBM_OBJ_PROP_INERTIA_MATRIX
Definition: cs_ibm.h:116
@ CS_IBM_OBJ_PROP_CROSS_SECTION
Definition: cs_ibm.h:123
@ CS_IBM_OBJ_PROP_CP
Definition: cs_ibm.h:117
@ CS_IBM_OBJ_PROP_DENSITY
Definition: cs_ibm.h:114
@ CS_IBM_OBJ_PROP_RAYLEIGH_DAMP_B
Definition: cs_ibm.h:125
@ CS_IBM_OBJ_PROP_INERTIA_MOM
Definition: cs_ibm.h:122
@ CS_IBM_OBJ_PROP_LAMBDA
Definition: cs_ibm.h:118
@ NC_IBM_OBJ_PROP_MASS
Definition: cs_ibm.h:115
cs_ibm_model_type_t
Definition: cs_ibm.h:61
@ CS_IBM_FIXED_SOLID
Definition: cs_ibm.h:63
@ CS_IBM_OFF
Definition: cs_ibm.h:62
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:3732
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:4538
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:68
void cs_ibm_object_scale(const char *name, cs_real_t factor)
Scale an object based on a factor.
Definition: cs_ibm.cpp:4416
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:4360
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:99
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:150
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:85
cs_ibm_algo_type_t
Definition: cs_ibm.h:85
@ CS_IBM_ALGO_CUT_CELLS
Definition: cs_ibm.h:87
@ CS_N_VAR_PORO_ALGO_TYPES
Definition: cs_ibm.h:91
@ CS_IBM_ALGO_MEDCOUPLING
Definition: cs_ibm.h:88
@ CS_IBM_ALGO_NONE
Definition: cs_ibm.h:86
@ CS_IBM_ALGO_STL
Definition: cs_ibm.h:89
cs_ibm_object_t * cs_ibm_object_by_id(int obj_id)
Get an object based on its id.
Definition: cs_ibm.cpp:3712
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:4377
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:4312
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:4179
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:4285
void cs_ibm_finalize(void)
Definition: cs_ibm.cpp:3825
cs_ibm_prob_dim_type_t
Definition: cs_ibm.h:72
@ CS_IBM_2D_Y
Definition: cs_ibm.h:75
@ CS_IBM_2D_Z
Definition: cs_ibm.h:76
@ CS_IBM_2D_X
Definition: cs_ibm.h:74
@ CS_IBM_3D
Definition: cs_ibm.h:73
cs_ibm_t * cs_ibm
Definition: cs_ibm.cpp:102
cs_ibm_t * cs_ibm_create(void)
Definition: cs_ibm.cpp:3787
cs_ibm_wall_cond_type_t
Definition: cs_ibm.h:100
@ CS_IBM_WALL_LAW_WALL_CONDITION
Definition: cs_ibm.h:103
@ CS_IBM_SLIP_WALL_CONDITION
Definition: cs_ibm.h:101
@ CS_IBM_NO_SLIP_WALL_CONDITION
Definition: cs_ibm.h:102
Definition: mesh.f90:26
Definition: cs_ibm.h:171
cs_medcoupling_intersector_t * mi
Definition: cs_ibm.h:187
char * name
Definition: cs_ibm.h:176
cs_ibm_algo_type_t method
Definition: cs_ibm.h:181
cs_stl_mesh_t * stl
Definition: cs_ibm.h:186
cs_cutcell_func_t * cutcell_func
Definition: cs_ibm.h:185
Definition: cs_ibm.h:207
bool porosity_from_nodes
Definition: cs_ibm.h:237
bool porosity_user_source_term_modification
Definition: cs_ibm.h:225
bool ensure_isovol
Definition: cs_ibm.h:235
int n_objects
Definition: cs_ibm.h:210
cs_ibm_prob_dim_type_t prob_dim
Definition: cs_ibm.h:215
cs_real_t isovol
Definition: cs_ibm.h:233
int nb_cut_faces
Definition: cs_ibm.h:223
cs_ibm_algo_type_t algo_choice
Definition: cs_ibm.h:217
cs_real_3_t xyzmax_moving_porosity
Definition: cs_ibm.h:229
cs_real_t * solid_porosity
Definition: cs_ibm.h:231
cs_real_3_t xyzmin_moving_porosity
Definition: cs_ibm.h:227
cs_ibm_object_t ** objects
Definition: cs_ibm.h:211
int nb_cut_cells
Definition: cs_ibm.h:221
cs_ibm_wall_cond_type_t wall_condition
Definition: cs_ibm.h:219
Definition: cs_mesh_quantities.h:92
Definition: cs_mesh.h:85
Definition: cs_ibm.h:163
int porosity_mode
Definition: cs_ibm.h:164
Definition: cs_stl.h:54
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:160