#include "cs_defs.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bft_mem.h"
#include "bft_error.h"
#include "bft_printf.h"
#include "fvm_writer.h"
#include "cs_array.h"
#include "cs_cell_to_vertex.h"
#include "cs_field_operator.h"
#include "cs_field_pointer.h"
#include "cs_medcoupling_intersector.h"
#include "cs_meg_prototypes.h"
#include "cs_mesh_adjacencies.h"
#include "cs_parameters.h"
#include "cs_post.h"
#include "cs_prototypes.h"
#include "cs_stl.h"
#include "cs_turbomachinery.h"
#include "cs_velocity_pressure.h"
#include "cs_vertex_to_cell.h"
#include "cs_zone.h"
#include "cs_ibm.h"
Functions | |
static cs_real_t | _geom_face_fraction (cs_real_t alphai, cs_real_t alphaj, cs_real_t sizei, cs_real_t sizej) |
Compute the face porosity depending on the neighbouring cells porosities based on geometry. More... | |
static cs_real_t | _imm_lgth_cutcell (cs_real_3_t x1, cs_real_3_t x2, cs_real_t t, int num_object) |
Compute by dichotomy the length of the immersed part of a line between two points (i.e. the distance between the point in the solid and the immersed boundary) based on the cut-cell method. More... | |
static cs_real_t | _imm_lgth_poro (cs_real_3_t x1, cs_real_t por1, cs_real_3_t x2, cs_real_t por2) |
Compute by dichotomy the length of the immersed part of a line between two points (i.e. the distance between the point in the solid and the immersed boundary) based on the input porosities. More... | |
static cs_real_t | _tetra_vol (cs_real_3_t x1, cs_real_3_t x2, cs_real_3_t x3, cs_real_3_t x4) |
Compute the volume of a tetrahedron described by its vertices (x1,x2,x3,x4). More... | |
static cs_real_t | _pyram_vol (cs_real_3_t x1, cs_real_3_t x2, cs_real_3_t x3, cs_real_3_t x4, cs_real_3_t x5) |
Compute the volume of a pyramid with a quadrangle base (x1,x2,x3,x4) and apex (x5). More... | |
static cs_real_t | _prism_vol (cs_real_3_t x1, cs_real_3_t x2, cs_real_3_t x3, cs_real_3_t x4, cs_real_3_t x5, cs_real_3_t x6) |
Compute the volume of a prism with a quadrangle base (x3,x4,x5,x6) and edge (x1 x2). More... | |
static void | _tetra_vol_poro (cs_real_t *vol, cs_real_3_t cog, cs_real_3_t x1, cs_real_t por1, cs_real_3_t x2, cs_real_t por2, cs_real_3_t x3, cs_real_t por3, cs_real_3_t x4, cs_real_t por4, int icut) |
Compute the volume and center of gravity of a tetrahedron described by its vertices (x1,x2,x3,x4) but truncated due to solid parts identified with porosities, through a recursive approach. More... | |
static cs_real_t | _tri_surf_trunc (cs_real_3_t x1, cs_real_t por1, cs_real_3_t x2, cs_real_t por2, cs_real_3_t x3, cs_real_t por3, int icut) |
Compute by dichotomy the area of the immersed part of a triangle (x1,x2,x3) based on the input porosities at its vertices through a recursive approach. More... | |
static void | _tetra_vol_cutcell (cs_real_t *vol, cs_real_3_t x1, cs_real_3_t x2, cs_real_3_t x3, cs_real_3_t x4, cs_real_t t, int icut, int num_object) |
Compute (using bisection) the volume of the immersed part of a tetrahedron described by its vertices (x1,x2,x3,x4) based on the cut-cell method and recursive approach. More... | |
static int | _penal_glob (const cs_lnum_t c_id, const cs_real_3_t xyz, const cs_real_t t, const int num_object) |
Call to user function to know whether we are in the solid or not. More... | |
static void | _compute_cell_cut_porosity (const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities, int *comp_cell) |
Compute cell porosity using the cut cell method. More... | |
static void | _compute_cell_cog (const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities, cs_real_t *v_poro, cs_real_t *por_init, int *comp_cell) |
Compute cell cog (and cell porosity from porosity at vertices) Cut method into sub-tetras. More... | |
static void | _compute_b_fac_porosity (const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities, cs_real_t *c_poro, cs_real_t *v_poro, cs_real_t *bfpro_poro) |
Compute boundary faces porosity. More... | |
static void | _compute_i_fac_porosity (const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities, cs_real_t *c_poro, cs_real_t *v_poro, cs_real_t *ifpro_poro) |
Compute internal faces porosity. More... | |
static void | _compute_iso_vol_porosity (const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities, cs_real_t *c_poro, int *comp_cell) |
Iso-volume porosity check. More... | |
static void | _compute_solid_porosity (const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities, cs_real_t *c_poro, int *comp_cell) |
Take into account internal solid porosity. More... | |
static void | _compute_cell_list_porosity (const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities, cs_lnum_t *comp_cell) |
Compute list of cells for porosity computing. More... | |
static void | _compute_solid_surface_vector (const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities, cs_real_t *i_poro, cs_real_t *b_poro) |
Compute porosity solid surface. More... | |
static void | _compute_solid_surface_cog (const cs_mesh_t *mesh, const cs_mesh_quantities_t *mesh_quantities, cs_real_t *c_poro, cs_real_t *v_poro, cs_real_t *i_poro, cs_real_t *b_poro) |
Compute porosity solid surface cog (dist and ponderation coeff) More... | |
static cs_ibm_object_t * | _create_ibm_object (const char *name, cs_ibm_algo_type_t method) |
Create a new immersed boundary object with a given name and method. More... | |
static int | _add_ibm_object (const char *name, cs_ibm_algo_type_t method) |
Adds a new immersed boundary object with a given name and method. More... | |
static void | _free_ibm_object (cs_ibm_object_t *obj) |
Free a cs_ibm_object_t structure. More... | |
static void | _ibm_object_define_property_def (cs_ibm_object_t *obj, cs_ibm_object_property_type_t ppty_id, int n_vals, cs_real_t *vals) |
Define a new property definition for an object. More... | |
static void | _ibm_object_define_initial_val_def (cs_ibm_object_t *obj, cs_ibm_object_init_param_t p_id, int n_vals, cs_real_t *vals) |
Set initial value xdef for an object. More... | |
static cs_real_t | _get_xdef_val_at_object_elt (const cs_xdef_t *def, const int elt_id) |
Get xdef value at object element. More... | |
cs_ibm_object_t * | cs_ibm_object_by_id (int obj_id) |
Get an object based on its id. More... | |
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. More... | |
cs_ibm_object_t * | cs_ibm_object_by_name (const char *name) |
Get an object based on its name. Error if not found. More... | |
cs_ibm_t * | cs_ibm_create (void) |
void | cs_ibm_finalize (void) |
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). More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | cs_ibm_object_translate (const char *name, cs_real_t vector[3]) |
Translate an object based on the STL or MED algorithms. More... | |
void | cs_ibm_object_scale (const char *name, cs_real_t factor) |
Scale an object based on a factor. More... | |
void | cs_ibm_user_parameters (void) |
Apply user parameters. More... | |
void | cs_ibm_init_writer (void) |
Init writers for STL or MED objects. More... | |
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. More... | |
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. More... | |
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. More... | |
Variables | |
static cs_porosity_ibm_opt_t | _porosity_ibm_opt |
cs_porosity_ibm_opt_t * | cs_glob_porosity_ibm_opt = &(_porosity_ibm_opt) |
cs_ibm_t * | cs_ibm = nullptr |
const char * | _ibm_algo_names [] |
const char * | _ibm_obj_property_names [] |
const char * | _ibm_obj_init_vals_names [] |
Define immersed boundaries based on user inputs (experimental). Cloud of points are dealt with porosity from scan files.
|
static |
Adds a new immersed boundary object with a given name and method.
[in] | name | name of the new object |
[in] | method | method used to compute the object porosity |
|
static |
Compute boundary faces porosity.
[in] | mesh | pointer to associated mesh structure |
[in] | mesh_quantities | pointer to associated mesh quantities |
[in] | c_poro | cell porosity |
[in] | v_poro | vertex porosity |
[out] | bfpro_poro | boundary face porosity |
|
static |
Compute cell cog (and cell porosity from porosity at vertices) Cut method into sub-tetras.
[in] | mesh | pointer to associated mesh structure |
[in] | mesh_quantities | pointer to associated mesh quantities |
[in] | por_vtx | vertex porosity |
[in] | por_init | initialization porosity |
[in] | comp_cell | list of cells to recompute porosity |
|
static |
Compute cell porosity using the cut cell method.
[in] | mesh | pointer to associated mesh structure |
[in] | mesh_quantities | pointer to associated mesh quantities |
[in] | comp_cell | list of cells to recompute porosity |
|
static |
Compute list of cells for porosity computing.
[in] | mesh | pointer to associated mesh structure |
[in] | mesh_quantities | pointer to associated mesh quantities |
[out] | comp_cell | list of cells to recompute porosity |
|
static |
Compute internal faces porosity.
[in] | mesh | pointer to associated mesh structure |
[in] | mesh_quantities | pointer to associated mesh quantities |
[in] | c_poro | cell porosity |
[in] | v_poro | vertex porosity |
[out] | ifpro_poro | internal face porosity |
|
static |
Iso-volume porosity check.
[in] | mesh | pointer to associated mesh structure |
[in] | mesh_quantities | pointer to associated mesh quantities |
[in] | c_poro | cell porosity |
[in] | comp_cell | list of cells to recompute porosity |
|
static |
Take into account internal solid porosity.
[in] | mesh | pointer to associated mesh structure |
[in] | mesh_quantities | pointer to associated mesh quantities |
[in] | c_poro | cell porosity |
[in] | comp_cell | list of cells to recompute porosity |
|
static |
Compute porosity solid surface cog (dist and ponderation coeff)
[in] | mesh | pointer to associated mesh structure |
[in] | mesh_quantities | pointer to associated mesh quantities |
[in] | c_poro | cell porosity |
[in] | v_poro | vertex porosity |
[in] | i_poro | internal face porosity |
[in] | b_poro | boundary face porosity |
|
static |
Compute porosity solid surface.
[in] | mesh | pointer to associated mesh structure |
[in] | mesh_quantities | pointer to associated mesh quantities |
[in] | i_poro | internal face porosity |
[in] | b_poro | boundary face porosity |
|
static |
Create a new immersed boundary object with a given name and method.
[in] | name | name of the new object |
[in] | method | method used to compute the object porosity |
|
static |
Free a cs_ibm_object_t structure.
[in] | obj | pointer to structure to free |
|
static |
Compute the face porosity depending on the neighbouring cells porosities based on geometry.
[in] | alphai | value at neighbouring cell i |
[in] | alphaj | value at neighbouring cell j |
[in] | sizei | distance face - center of gravity cell i |
[in] | sizej | distance face - center of gravity cell j |
|
inlinestatic |
Get xdef value at object element.
[in] | def | Pointer to cs_xdef_t definition |
[in] | elt_id | Element id (int) |
|
static |
Set initial value xdef for an object.
[in] | obj | Pointer to object |
[in] | p_id | Property id (enum) |
[in] | n_vals | Number of values (array size) |
[in] | vals | Values array (size n_vals) |
|
static |
Define a new property definition for an object.
[in] | obj | pointer to object |
[in] | ppty_id | property id (si enum for list) |
[in] | n_vals | number of values (array size) |
[in] | vals | array of values |
|
static |
Compute by dichotomy the length of the immersed part of a line between two points (i.e. the distance between the point in the solid and the immersed boundary) based on the cut-cell method.
[in] | x1 | point 1 |
[in] | x2 | point 2 |
[in] | t | time value for the current time step |
[in] | num_object | num of fsi object (if fsi activated) |
|
inlinestatic |
Compute by dichotomy the length of the immersed part of a line between two points (i.e. the distance between the point in the solid and the immersed boundary) based on the input porosities.
[in] | x1 | point 1 |
[in] | por1 | porosity at 1 |
[in] | x2 | point 2 |
[in] | por2 | porosity at 2 |
|
static |
Call to user function to know whether we are in the solid or not.
[in] | c_id | local cell number |
[in] | xyz | x, y, z coordinates of the current position |
[in] | t | time value for the current time step |
[in] | num_object | num of fsi object (if fsi activated) |
|
static |
Compute the volume of a prism with a quadrangle base (x3,x4,x5,x6) and edge (x1 x2).
[in] | x1 | point 1 |
[in] | x2 | point 2 |
[in] | x3 | point 3 |
[in] | x4 | point 4 |
[in] | x5 | point 5 |
[in] | x6 | point 6 |
|
static |
Compute the volume of a pyramid with a quadrangle base (x1,x2,x3,x4) and apex (x5).
[in] | x1 | point 1 |
[in] | x2 | point 2 |
[in] | x3 | point 3 |
[in] | x4 | point 4 |
[in] | x5 | point 5 (apex) |
|
inlinestatic |
Compute the volume of a tetrahedron described by its vertices (x1,x2,x3,x4).
[in] | x1 | point 1 |
[in] | x2 | point 2 |
[in] | x3 | point 3 |
[in] | x4 | point 4 |
|
static |
Compute (using bisection) the volume of the immersed part of a tetrahedron described by its vertices (x1,x2,x3,x4) based on the cut-cell method and recursive approach.
[out] | vol | volume |
[in] | x1 | point 1 |
[in] | x2 | point 2 |
[in] | x3 | point 3 |
[in] | x4 | point 4 |
[in] | t | time value for the current time step |
[in] | icut | number of bisections |
[in] | num_object | num of fsi object (if fsi activated) |
|
static |
Compute the volume and center of gravity of a tetrahedron described by its vertices (x1,x2,x3,x4) but truncated due to solid parts identified with porosities, through a recursive approach.
[out] | vol | volume |
[out] | cog | center of gravity |
[in] | x1 | point 1 |
[in] | por1 | porosity at point 1 |
[in] | x2 | point 2 |
[in] | por2 | porosity at point 2 |
[in] | x3 | point 3 |
[in] | por3 | porosity at point 3 |
[in] | x4 | point 4 |
[in] | por4 | porosity at point 4 |
[in] | icut | number of sub-cut for cells in cut-cells algorithm |
|
static |
Compute by dichotomy the area of the immersed part of a triangle (x1,x2,x3) based on the input porosities at its vertices through a recursive approach.
[in] | x1 | point 1 |
[in] | por1 | porosity at 1 |
[in] | x2 | point 2 |
[in] | por2 | porosity at 2 |
[in] | x3 | point 3 |
[in] | por3 | porosity at 3 |
[in] | icut | number of sub-cut for cells in cut-cells algorithm |
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.
[in] | name | name of the object |
[in] | method | Porosity computation method |
[in] | file_name | file name |
[in] | solve_fsi | Is the object used in the FSI resolution ? (currently ignored) |
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.
[in] | name | name of the object |
[in] | cutcell_func | pointer to the cutcell function of the object |
[in] | solve_fsi | Is the object used in the FSI resolution ? (currently ignored) |
[in] | n_nodes | Number of nodes if the object is deformable (currently ignored) |
cs_ibm_t * cs_ibm_create | ( | void | ) |
void cs_ibm_finalize | ( | void | ) |
void cs_ibm_init_writer | ( | void | ) |
Init writers for STL or MED objects.
cs_ibm_object_t * cs_ibm_object_by_id | ( | int | obj_id | ) |
Get an object based on its id.
[in] | obj_id | id of the object |
cs_ibm_object_t * cs_ibm_object_by_name | ( | const char * | name | ) |
Get an object based on its name. Error if not found.
[in] | name | name of the object to get |
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.
Try to get an object based on its name. Returns NULL if not found.
Get an object based on its name.
[in] | name | name of the object to get |
[in] | name | name of the object to get |
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.
[in] | c_id | local cell number |
[in] | xyz | x, y, z coordinates of the current position |
[in] | t | time value for the current time step |
[in] | num_object | num of fsi object (if fsi activated) |
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.
[in] | obj | pointer to object structure |
[in] | m | pointer to mesh structure |
[in] | cell_vol | pointer to cell volume array |
[out] | obj_frac_tot | array containing the total vol fraction of solids |
[in] | indic | indicator array (currently ignored) |
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.
[in] | name | name of the object |
[in] | angle | angle of rotation |
[in] | axis | axis of rotation |
[in] | center | center of rotation |
void cs_ibm_object_scale | ( | const char * | name, |
cs_real_t | factor | ||
) |
Scale an object based on a factor.
[in] | name | name of the object |
[in] | factor | scaling factor |
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.
[in] | obj | pointer to object |
[in] | ppty_id | property id (si enum for list) |
[in] | val | property constant value |
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.
[in] | obj | pointer to object structure |
[in] | matrix | transformation matrix |
void cs_ibm_object_translate | ( | const char * | name, |
cs_real_t | vector[3] | ||
) |
Translate an object based on the STL or MED algorithms.
[in] | name | name of the object |
[in] | vector | translation vector |
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.
Define exterior points for an STL object.
[in] | name | name of the object |
[in] | n_pts | number of points |
[in] | pts_coords | coordinates of the points |
void cs_ibm_user_parameters | ( | void | ) |
Apply user parameters.
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.
[in] | mesh_quantities | pointer to associated mesh quantities structure |
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).
This function is called several times during each time step.
Ipenal: 1 means only solid and 0 only fluid.
Warning, porosity values have to be 0 or 1.
The solid(s) velocities and porosity are prescirbed within the user function (cs_user_ibm).
[in] | mesh | pointer to associated mesh structure |
[in] | mesh_quantities | pointer to associated mesh quantities |
const char* _ibm_algo_names[] |
const char* _ibm_obj_init_vals_names[] |
const char* _ibm_obj_property_names[] |
|
static |
cs_porosity_ibm_opt_t* cs_glob_porosity_ibm_opt = &(_porosity_ibm_opt) |
cs_ibm_t* cs_ibm = nullptr |