8.3
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-2024 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 "cs_defs.h"
35#include "cs_mesh_quantities.h"
37#include "cs_stl.h"
38#include "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
320 const cs_mesh_quantities_t *mesh_quantities);
321
322/*----------------------------------------------------------------------------
323 * Define space immersed boundaries on a set of zones defined by the user in the
324 * GUI
325 *----------------------------------------------------------------------------*/
326
328
329/*----------------------------------------------------------------------------*
330 * User function. Locally Modify porosity (erosion, fouling effects, ...)
331 *----------------------------------------------------------------------------*/
332
334 const cs_mesh_quantities_t *mesh_quantities);
335
336/*----------------------------------------------------------------------------*/
344/*----------------------------------------------------------------------------*/
345
347cs_ibm_object_by_id(int obj_id);
348
349/*----------------------------------------------------------------------------*/
357/*----------------------------------------------------------------------------*/
358
360cs_ibm_object_by_name_try(const char *name);
361
362/*----------------------------------------------------------------------------*/
372/*----------------------------------------------------------------------------*/
373
374int
376 const cs_real_3_t xyz,
377 const cs_real_t t,
378 const int num_object);
379
380/*----------------------------------------------------------------------------*/
390/*----------------------------------------------------------------------------*/
391
392void
393cs_ibm_add_object_from_file(const char *name,
394 cs_ibm_algo_type_t method,
395 const char *file_name,
396 bool solve_fsi);
397
398/*----------------------------------------------------------------------------*/
409/*----------------------------------------------------------------------------*/
410
411void
412cs_ibm_add_object_from_func(const char *name,
413 cs_cutcell_func_t *cutcell_func,
414 bool solve_fsi,
415 int n_nodes);
416
417/*----------------------------------------------------------------------------*/
425/*----------------------------------------------------------------------------*/
426
427void
428cs_ibm_stl_define_ext_points(const char *name,
429 const int n_pts,
430 cs_real_t *pts_coords);
431
432/*----------------------------------------------------------------------------*/
441/*----------------------------------------------------------------------------*/
442
443void
444cs_ibm_object_rotate(const char *name,
445 cs_real_t angle,
446 cs_real_t axis[3],
447 cs_real_t center[3]);
448
449/*----------------------------------------------------------------------------*/
457/*----------------------------------------------------------------------------*/
458
459void
462 cs_real_t val);
463
464/*----------------------------------------------------------------------------*/
471/*----------------------------------------------------------------------------*/
472
473void
474cs_ibm_object_translate(const char *name,
475 cs_real_t vector[3]);
476
477/*----------------------------------------------------------------------------*/
484/*----------------------------------------------------------------------------*/
485
486void
487cs_ibm_object_scale(const char *name,
488 cs_real_t factor);
489
490/*----------------------------------------------------------------------------*/
494/*----------------------------------------------------------------------------*/
495
496void
498
499/*----------------------------------------------------------------------------*/
503/*----------------------------------------------------------------------------*/
504
505void
507
508/*----------------------------------------------------------------------------*/
516/*----------------------------------------------------------------------------*/
517
518void
520 cs_real_34_t matrix);
521
522/*----------------------------------------------------------------------------*/
532/*----------------------------------------------------------------------------*/
533
534void
536 const cs_mesh_t *m,
537 const cs_real_t *cell_vol,
538 cs_real_t *obj_frac_tot,
539 int *indic);
540
541/*----------------------------------------------------------------------------*/
545/*----------------------------------------------------------------------------*/
546
547void
549
550/*----------------------------------------------------------------------------*/
555/*----------------------------------------------------------------------------*/
556
557void
559
560/*----------------------------------------------------------------------------*/
567/*----------------------------------------------------------------------------*/
568
569void
571
572/*----------------------------------------------------------------------------*/
581/*----------------------------------------------------------------------------*/
582
583void
585 const cs_real_3_t xyz,
586 const cs_real_t t,
587 const int num_object);
588
589/*----------------------------------------------------------------------------*/
596/*----------------------------------------------------------------------------*/
597
598void
599cs_ibm_volumic_zone(const cs_mesh_quantities_t *mesh_quantities);
600
601/*----------------------------------------------------------------------------*/
602
604
605#endif /* __CS_IBM_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
double cs_real_t
Floating-point value.
Definition: cs_defs.h:342
cs_real_t cs_real_34_t[3][4]
Definition: cs_defs.h:374
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:359
#define END_C_DECLS
Definition: cs_defs.h:543
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:335
@ t
Definition: cs_field_pointer.h:94
void cs_user_ibm_parameters(void)
User function to set global parameters for the immersed boundaries module.
Definition: cs_user_ibm.cpp:84
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:4200
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:3835
void cs_ibm_user_parameters(void)
Apply user parameters.
Definition: cs_ibm.cpp:4423
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:3733
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:4624
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:4112
void cs_user_ibm_define_objects(void)
User function in which the user defines the objects to model.
Definition: cs_user_ibm.cpp:70
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:4546
void cs_ibm_init_writer(void)
Init writers for STL or MED objects.
Definition: cs_ibm.cpp:4442
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:3706
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:4510
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:79
void cs_ibm_object_scale(const char *name, cs_real_t factor)
Scale an object based on a factor.
Definition: cs_ibm.cpp:4387
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:4331
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.
Definition: cs_user_ibm.cpp:120
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:101
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:3686
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:4348
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:4283
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:4147
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:4254
void cs_ibm_finalize(void)
Definition: cs_ibm.cpp:3799
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:3761
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