8.0
general documentation
Loading...
Searching...
No Matches
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-2023 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
130
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/*----------------------------------------------------------------------------*/
389/*----------------------------------------------------------------------------*/
390void
391cs_ibm_add_object_from_file(const char *name,
392 cs_ibm_algo_type_t method,
393 const char *file_name,
394 bool solve_fsi);
395
396/*----------------------------------------------------------------------------*/
405/*----------------------------------------------------------------------------*/
406
407void
408cs_ibm_add_object_from_func(const char *name,
409 cs_cutcell_func_t *cutcell_func,
410 bool solve_fsi,
411 int n_nodes);
412
413/*----------------------------------------------------------------------------*/
421/*----------------------------------------------------------------------------*/
422
423void
424cs_ibm_stl_define_ext_points(const char *name,
425 const int n_pts,
426 cs_real_t *pts_coords);
427
428/*----------------------------------------------------------------------------*/
437/*----------------------------------------------------------------------------*/
438
439void
440cs_ibm_object_rotate(const char *name,
441 cs_real_t angle,
442 cs_real_t axis[3],
443 cs_real_t center[3]);
444
445/*----------------------------------------------------------------------------*/
453/*----------------------------------------------------------------------------*/
454
455void
458 cs_real_t val);
459
460/*----------------------------------------------------------------------------*/
467/*----------------------------------------------------------------------------*/
468
469void
470cs_ibm_object_translate(const char *name,
471 cs_real_t vector[3]);
472
473/*----------------------------------------------------------------------------*/
480/*----------------------------------------------------------------------------*/
481
482void
483cs_ibm_object_scale(const char *name,
484 cs_real_t factor);
485
486/*----------------------------------------------------------------------------*/
490/*----------------------------------------------------------------------------*/
491
492void
494
495/*----------------------------------------------------------------------------*/
499/*----------------------------------------------------------------------------*/
500
501void
503
504/*----------------------------------------------------------------------------*/
512/*----------------------------------------------------------------------------*/
513
514void
517
518/*----------------------------------------------------------------------------*/
528/*----------------------------------------------------------------------------*/
529
530void
532 const cs_mesh_t *m,
533 const cs_real_t *cell_vol,
534 cs_real_t *obj_frac_tot,
535 int *indic);
536
537/*----------------------------------------------------------------------------*/
541/*----------------------------------------------------------------------------*/
542
543void
545
546/*----------------------------------------------------------------------------*/
551/*----------------------------------------------------------------------------*/
552
553void
555
556/*----------------------------------------------------------------------------*/
563/*----------------------------------------------------------------------------*/
564
565void
567
568/*----------------------------------------------------------------------------*/
577/*----------------------------------------------------------------------------*/
578
579void
581 const cs_real_3_t xyz,
582 const cs_real_t t,
583 const int num_object);
584
585/*----------------------------------------------------------------------------*/
592/*----------------------------------------------------------------------------*/
593
594void
595cs_ibm_volumic_zone(const cs_mesh_quantities_t *mesh_quantities);
596
597/*----------------------------------------------------------------------------*/
598
600
601#endif /* __CS_IBM_H__ */
#define BEGIN_C_DECLS
Definition cs_defs.h:509
double cs_real_t
Floating-point value.
Definition cs_defs.h:319
cs_real_t cs_real_34_t[3][4]
Definition cs_defs.h:347
#define END_C_DECLS
Definition cs_defs.h:510
int cs_lnum_t
local mesh entity id
Definition cs_defs.h:313
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition cs_defs.h:332
@ t
Definition cs_field_pointer.h:92
cs_porosity_ibm_opt_t * cs_glob_porosity_ibm_opt
Definition cs_ibm.c:98
cs_ibm_t * cs_ibm
Definition cs_ibm.c:101
void cs_user_ibm_parameters(void)
User function to set global parameters for the immersed boundaries module.
Definition cs_user_ibm.c: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.c:4241
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.c:3804
void cs_ibm_user_parameters(void)
Apply user parameters.
Definition cs_ibm.c:4470
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.c:3702
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.c:4673
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.c:4158
void cs_user_ibm_define_objects(void)
User function in which the user defines the objects to model.
Definition cs_user_ibm.c: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.c:4596
void cs_ibm_init_writer(void)
Init writers for STL or MED objects.
Definition cs_ibm.c:4489
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
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
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.c:3675
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.c:4558
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.c:79
void cs_ibm_object_scale(const char *name, cs_real_t factor)
Scale an object based on a factor.
Definition cs_ibm.c:4432
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.c:4372
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.c:120
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.c: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.c:3655
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.c:4391
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.c:4322
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.c:4191
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.c:4293
void cs_ibm_finalize(void)
Definition cs_ibm.c:3768
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_create(void)
Definition cs_ibm.c:3730
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
void matrix(const int *iconvp, const int *idiffp, const int *ndircp, const int *isym, const cs_real_t *thetap, const int *imucpp, const cs_real_t coefbp[], const cs_real_t cofbfp[], const cs_real_t rovsdt[], const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_visc[], const cs_real_t b_visc[], const cs_real_t xcpp[], cs_real_t da[], cs_real_t xa[])
Definition cs_matrix_building.c:111
Definition mesh.f90:26
Definition cs_ibm.h:171
cs_xdef_t * property_defs[CS_N_IBM_OBJ_PROP_TYPES]
Definition cs_ibm.h:192
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_xdef_t * init_vals_defs[CS_N_IBM_OBJ_INIT_TYPES]
Definition cs_ibm.h:197
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