#include "cs_defs.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <mpi.h>
#include <ple_locator.h>
#include "bft_mem.h"
#include "bft_error.h"
#include "bft_printf.h"
#include "cs_ale.h"
#include "cs_base.h"
#include "cs_base_accel.h"
#include "cs_blas.h"
#include "cs_boundary.h"
#include "cs_cf_thermo.h"
#include "cs_coupling.h"
#include "cs_equation.h"
#include "cs_function.h"
#include "cs_gradient.h"
#include "cs_gui_util.h"
#include "cs_field.h"
#include "cs_field_default.h"
#include "cs_field_operator.h"
#include "cs_field_pointer.h"
#include "cs_flag_check.h"
#include "cs_halo.h"
#include "cs_math.h"
#include "cs_mesh.h"
#include "cs_mesh_connect.h"
#include "cs_mesh_quantities.h"
#include "cs_parall.h"
#include "cs_parameters.h"
#include "cs_physical_model.h"
#include "cs_prototypes.h"
#include "cs_post.h"
#include "cs_time_control.h"
#include "cs_turbulence_bc.h"
#include "cs_turbulence_model.h"
#include "cs_xdef_eval_at_zone.h"
#include "fvm_nodal.h"
#include "cs_boundary_conditions.h"
#include "cs_boundary_conditions_priv.h"
Functions | |
void | cs_boundary_conditions_open_turb (void) |
cs_boundary_conditions_open_t * | cs_boundary_conditions_open_find_or_add (const cs_zone_t *zone) |
Find or add an open boundary context for a given zone. More... | |
cs_boundary_conditions_open_t * | cs_boundary_conditions_open_find (const cs_zone_t *zone) |
Get an open boundary context structure for a given zone. More... | |
void | cs_boundary_conditions_error (const int *bc_flag, const char *type_name) |
Handling of boundary condition definition errors and associated output. More... | |
ple_locator_t * | cs_boundary_conditions_map (cs_mesh_location_type_t location_type, cs_lnum_t n_location_elts, cs_lnum_t n_faces, const cs_lnum_t *location_elts, const cs_lnum_t *faces, cs_real_3_t *coord_shift, int coord_stride, double tolerance) |
Locate shifted boundary face coordinates on possibly filtered cells or boundary faces for later interpolation. More... | |
void | cs_boundary_conditions_mapped_set (const cs_field_t *f, ple_locator_t *locator, cs_mesh_location_type_t location_type, int normalize, int interpolate, cs_lnum_t n_faces, const cs_lnum_t *faces, cs_real_t *balance_w) |
Set mapped boundary conditions for a given field and mapping locator. More... | |
int | cs_boundary_conditions_add_map (int bc_location_id, int source_location_id, cs_real_t coord_shift[3], double tolerance) |
Add location of locate shifted boundary face coordinates on cells or boundary faces for automatic interpolation. More... | |
void | cs_boundary_conditions_create_legacy_zone_data (void) |
Create the legacy boundary conditions zone data arrays. More... | |
void | cs_boundary_conditions_create (void) |
Create the legacy boundary conditions face type and face zone arrays. More... | |
void | cs_boundary_conditions_free (void) |
Free the boundary conditions face type and face zone arrays. More... | |
void | cs_boundary_conditions_reset (void) |
Prepare (reset) condition coefficients for all variable fields. More... | |
int * | cs_boundary_conditions_get_bc_type (void) |
Return pointer to boundary conditions BC type array. More... | |
void | cs_boundary_conditions_compute (int bc_type[]) |
Update per variable boundary condition codes. More... | |
void | cs_boundary_conditions_legacy_turbulence (int bc_type[]) |
Define automatic turbulence values for specific physical modules. More... | |
void | cs_boundary_conditions_complete (int bc_type[]) |
Automatic adjustments for boundary condition codes. More... | |
void * | cs_boundary_conditions_get_model_inlet (const cs_zone_t *zone) |
Return pointer to model inlet structure associated with a given open (inlet/outlet) boundary. More... | |
int | cs_boundary_conditions_get_legacy_zone_num (const cs_zone_t *z) |
cs_real_t * | cs_boundary_conditions_get_b_head_loss (bool alloc_if_null) |
Return pointer to boundary head losses array. More... | |
void | cs_boundary_conditions_assign_model_inlet (const cs_zone_t *zone, void *s_ptr, void *s_del) |
Assign pointer to model inlet structure associated with a given open (inlet/outlet) boundary. More... | |
cs_time_control_t * | cs_boundary_conditions_open_get_time_control (const cs_zone_t *zone) |
Acess the time control structure of an open (inlet/outlet) boundary. More... | |
void | cs_boundary_conditions_open_set_velocity_by_value (const cs_zone_t *z, const cs_real_t u[3]) |
Assign a constant velocity to an open (inlet/outlet) boundary. More... | |
void | cs_boundary_conditions_open_set_velocity_by_normal_value (const cs_zone_t *z, cs_real_t u_norm) |
Assign a constant velocity normal to an inlet. More... | |
void | cs_boundary_conditions_open_set_velocity_by_func (const cs_zone_t *z, cs_eval_at_location_t *func, void *input) |
Assign a normal velocity to an inlet using a provided function. More... | |
cs_real_t | cs_boundary_conditions_open_get_mass_flow_rate (const cs_zone_t *z) |
Return the volume flow rate to an inlet or outlet. More... | |
void | cs_boundary_conditions_open_set_mass_flow_rate_by_value (const cs_zone_t *z, cs_real_t q) |
Assign a constant mass flow rate to an inlet or outlet. More... | |
void | cs_boundary_conditions_open_set_mass_flow_rate_by_func (const cs_zone_t *z, cs_eval_at_location_t *func, void *input) |
Assign a mass flow rate to an inlet or outlet based on provided function. More... | |
void | cs_boundary_conditions_open_set_volume_flow_rate_by_value (const cs_zone_t *z, cs_real_t q) |
Assign a constant volume flow rate to an inlet or outlet. More... | |
void | cs_boundary_conditions_open_set_volume_flow_rate_by_func (const cs_zone_t *z, cs_eval_at_location_t *func, void *input) |
Assign a volume flow rate to an inlet or outlet based on provided function. More... | |
void | cs_boundary_conditions_inlet_set_turbulence_hyd_diam (const cs_zone_t *zone, cs_real_t hd) |
Base the inlet turbulence values on a a circular duct with smooth wall (see ref cs_turbulence_bc_ke_hyd_diam). More... | |
void | cs_boundary_conditions_inlet_set_turbulence_intensity (const cs_zone_t *zone, cs_real_t ti) |
Base the inlet turbulence values on a a circular duct with smooth wall (see ref cs_turbulence_bc_ke_hyd_diam). More... | |
Boundary condition handling.
int cs_boundary_conditions_add_map | ( | int | bc_location_id, |
int | source_location_id, | ||
cs_real_t | coord_shift[3], | ||
double | tolerance | ||
) |
Add location of locate shifted boundary face coordinates on cells or boundary faces for automatic interpolation.
[in] | bc_location_id | id of selected boundary mesh location; currently restricted to subsets of boundary faces (i.e. boundary zone location ids). |
[in] | source_location_id | id of selected location mesh location (usually CS_MESH_LOCATION_CELLS but can be a more restricted cell or boundary face zone location location id). |
[in] | coord_shift | coordinates shift relative to selected boundary faces |
[in] | tolerance | relative tolerance for point location. |
void cs_boundary_conditions_assign_model_inlet | ( | const cs_zone_t * | zone, |
void * | s_ptr, | ||
void * | s_del | ||
) |
Assign pointer to model inlet structure associated with a given open (inlet/outlet) boundary.
The returned pointer is of type void * as it should be cast to the appropriate (model-dependent) type.
If no matching parent open boundary has been created yet, it is created.
[in] | zone | pointer to associated zone |
[in] | s_ptr | pointer to associated structure |
[in] | s_del | destructor for associated structure, or nullptr |
void cs_boundary_conditions_complete | ( | int | bc_type[] | ) |
Automatic adjustments for boundary condition codes.
Currently handles mapped inlets, after the call to stdtcl. As portions of stdtcl are migrated to C, they should be called here, before mapped inlets.
[in] | bc_type | type of boundary for each face |
void cs_boundary_conditions_compute | ( | int | bc_type[] | ) |
Update per variable boundary condition codes.
[in] | bc_type | type of boundary for each face |
void cs_boundary_conditions_create | ( | void | ) |
Create the legacy boundary conditions face type and face zone arrays.
void cs_boundary_conditions_create_legacy_zone_data | ( | void | ) |
Create the legacy boundary conditions zone data arrays.
void cs_boundary_conditions_error | ( | const int * | bc_flag, |
const char * | type_name | ||
) |
Handling of boundary condition definition errors and associated output.
(DOXYGEN_SHOULD_SKIP_THIS)
This function checks for errors, and simply returns if no error is encountered. In case of error, it outputs helpful information so as to make it easier to locate the matching faces.
For each boundary face, bc_type defines the boundary condition type. As a convention here, zero values correspond to undefined types, positive values to defined types (with no error), and negative values to defined types with inconsistent or incompatible values, the absolute value indicating the original boundary condition type.
An optional label may be used if the error is related to another attribute than the boundary type, for appropriate error reporting.
[in] | bc_flag | array of BC type ids |
[in] | type_name | name of attribute in error, or nullptr |
void cs_boundary_conditions_free | ( | void | ) |
Free the boundary conditions face type and face zone arrays.
This also frees boundary condition mappings which may have been defined.
cs_real_t * cs_boundary_conditions_get_b_head_loss | ( | bool | alloc_if_null | ) |
Return pointer to boundary head losses array.
The array is allocated if not previously available.
[in] | alloc_if_null | do we need to allocate this if not present ? |
int * cs_boundary_conditions_get_bc_type | ( | void | ) |
Return pointer to boundary conditions BC type array.
int cs_boundary_conditions_get_legacy_zone_num | ( | const cs_zone_t * | z | ) |
void * cs_boundary_conditions_get_model_inlet | ( | const cs_zone_t * | zone | ) |
Return pointer to model inlet structure associated with a given open (inlet/outlet) boundary.
The returned pointer is of type void * as it should be cast to the appropriate (model-dependent) type.
If no matching parent open boundary has been created yet, it is created.
[in] | zone | pointer to associated zone |
Base the inlet turbulence values on a a circular duct with smooth wall (see ref cs_turbulence_bc_ke_hyd_diam).
[in] | zone | pointer to associated zone |
[in] | hd | associated hydraulic diameter |
Base the inlet turbulence values on a a circular duct with smooth wall (see ref cs_turbulence_bc_ke_hyd_diam).
[in] | zone | pointer to associated zone |
[in] | ti | associated turbulence intensity |
void cs_boundary_conditions_legacy_turbulence | ( | int | bc_type[] | ) |
Define automatic turbulence values for specific physical modules.
The definitions are similar to those of the standard case, though wall shear direction is not computed for second-order models, and determination of face BC types is done using the legacy physical model zone info (cs_glob_bc_pm_info->izfpp, ...).
[in] | bc_type | type of boundary for each face |
ple_locator_t * cs_boundary_conditions_map | ( | cs_mesh_location_type_t | location_type, |
cs_lnum_t | n_location_elts, | ||
cs_lnum_t | n_faces, | ||
const cs_lnum_t * | location_elts, | ||
const cs_lnum_t * | faces, | ||
cs_real_3_t * | coord_shift, | ||
int | coord_stride, | ||
double | tolerance | ||
) |
Locate shifted boundary face coordinates on possibly filtered cells or boundary faces for later interpolation.
[in] | location_type | matching values location (CS_MESH_LOCATION_CELLS or CS_MESH_LOCATION_BOUNDARY_FACES) |
[in] | n_location_elts | number of selected location elements |
[in] | n_faces | number of selected boundary faces |
[in] | location_elts | list of selected location elements (0 to n-1), or nullptr if no indirection is needed |
[in] | faces | list of selected boundary faces (0 to n-1), or nullptr if no indirection is needed |
[in] | coord_shift | array of coordinates shift relative to selected boundary faces |
[in] | coord_stride | access stride in coord_shift: 0 for uniform shift, 1 for "per face" shift. |
[in] | tolerance | relative tolerance for point location. |
void cs_boundary_conditions_mapped_set | ( | const cs_field_t * | f, |
ple_locator_t * | locator, | ||
cs_mesh_location_type_t | location_type, | ||
int | normalize, | ||
int | interpolate, | ||
cs_lnum_t | n_faces, | ||
const cs_lnum_t * | faces, | ||
cs_real_t * | balance_w | ||
) |
Set mapped boundary conditions for a given field and mapping locator.
[in] | f | field whose boundary conditions are set |
[in] | locator | associated mapping locator, as returned by cs_boundary_conditions_map. |
[in] | location_type | matching values location (CS_MESH_LOCATION_CELLS or CS_MESH_LOCATION_BOUNDARY_FACES) |
[in] | normalize | normalization option: 0: values are simply mapped 1: values are mapped, then multiplied by a constant factor so that their surface integral on selected faces is preserved (relative to the input values) 2: as 1, but with a boundary-defined weight, defined by balance_w 3: as 1, but with a cell-defined weight, defined by balance_w |
[in] | interpolate | interpolation option: 0: values are simply based on matching cell or face center values 1: values are based on matching cell or face center values, corrected by gradient interpolation |
[in] | n_faces | number of selected boundary faces |
[in] | faces | list of selected boundary faces (0 to n-1), or nullptr if no indirection is needed |
[in] | balance_w | optional balance weight, or nullptr |
cs_boundary_conditions_open_t * cs_boundary_conditions_open_find | ( | const cs_zone_t * | zone | ) |
Get an open boundary context structure for a given zone.
[in] | zone | pointer to associated zone |
cs_boundary_conditions_open_t * cs_boundary_conditions_open_find_or_add | ( | const cs_zone_t * | zone | ) |
Find or add an open boundary context for a given zone.
[in] | zone | pointer to associated zone |
Return the volume flow rate to an inlet or outlet.
The flow direction may be specified by also calling cs_boundary_conditions_open_set_velocity_by_value, or cs_boundary_conditions_open_set_velocity_by_func. In that case, the velocity vector is rescaled so as to obtain the required volume flow rate.
[in] | z | pointer to associated zone |
cs_time_control_t * cs_boundary_conditions_open_get_time_control | ( | const cs_zone_t * | zone | ) |
Acess the time control structure of an open (inlet/outlet) boundary.
This allows modifying that structure, for example updating the inlet velocity values only in a certain time range, and avoiding uneeded recomputations outside that range.
[in] | zone | pointer to associated zone |
void cs_boundary_conditions_open_set_mass_flow_rate_by_func | ( | const cs_zone_t * | z, |
cs_eval_at_location_t * | func, | ||
void * | input | ||
) |
Assign a mass flow rate to an inlet or outlet based on provided function.
The flow direction may be specified by also calling cs_boundary_conditions_open_set_velocity_by_value, cs_boundary_conditions_open_set_velocity_by_normal_value, or cs_boundary_conditions_open_set_velocity_by_func. In that case, the velocity vector is rescaled so as to obtain the required mass flow rate.
Since the flow rate is a global value, the provided function should be associated with the CS_MESH_LOCATION_NONE location.
Note also that during updates, this function will be called before the velocity vector update, so in complex cases where flow rate computation would require feedback from the velocity at this boundary, the user must be aware that values from the previous time step or update will be used, handle this in another manner.
Reminder: if the input pointer is non-null, it must point to valid data when the selection function is called, so either:
[in] | z | pointer to associated zone |
[in] | func | associated scalar (mass flow rate) evaluation function |
[in] | input | optional function evaluation input, or nullptr |
Assign a constant mass flow rate to an inlet or outlet.
By default, the flow direction is considered normal to the boundary. The flow direction may be specified by calling cs_boundary_conditions_open_set_velocity_by_value, or cs_boundary_conditions_open_set_velocity_by_func for the appropriate zone before calling this function. In that case, the velocity vector is rescaled so as to obtain the required mass flow rate.
[in] | z | pointer to associated zone |
[in] | q | associated constant mass flow rate |
void cs_boundary_conditions_open_set_velocity_by_func | ( | const cs_zone_t * | z, |
cs_eval_at_location_t * | func, | ||
void * | input | ||
) |
Assign a normal velocity to an inlet using a provided function.
Reminder: if the input pointer is non-null, it must point to valid data when the selection function is called, so either:
[in] | z | pointer to associated zone |
[in] | func | associated velocity vector evaluation function at zone faces |
[in] | input | optional function evaluation input, or nullptr |
void cs_boundary_conditions_open_set_velocity_by_normal_value | ( | const cs_zone_t * | z, |
cs_real_t | u_norm | ||
) |
Assign a constant velocity normal to an inlet.
[in] | z | pointer to associated zone |
[in] | u_norm | associated constant normal |
void cs_boundary_conditions_open_set_velocity_by_value | ( | const cs_zone_t * | z, |
const cs_real_t | u[3] | ||
) |
Assign a constant velocity to an open (inlet/outlet) boundary.
This function may also be used to define the flow direction if called before one of the cs_boundary_conditions_open_set_mass_flow_rate
or cs_boundary_conditions_open_set_volume_flow_rate
functions.
[in] | z | pointer to associated zone |
[in] | u | associated velocity value |
void cs_boundary_conditions_open_set_volume_flow_rate_by_func | ( | const cs_zone_t * | z, |
cs_eval_at_location_t * | func, | ||
void * | input | ||
) |
Assign a volume flow rate to an inlet or outlet based on provided function.
The flow direction may be specified by also calling cs_boundary_conditions_open_set_velocity_by_value, cs_boundary_conditions_open_set_velocity_by_normal_value, or cs_boundary_conditions_open_set_velocity_by_func. In that case, the velocity vector is rescaled so as to obtain the required volume flow rate.
Since the flow rate is a global value, the provided function should be associated with the CS_MESH_LOCATION_NONE location.
Note also that during updates, this function will be called before the velocity vector update, so in complex cases where flow rate computation would require feedback from the velocity at this boundary, the user must be aware that values from the previous time step or update will be used, handle this in another manner.
Reminder: if the input pointer is non-null, it must point to valid data when the selection function is called, so either:
[in] | z | pointer to associated zone |
[in] | func | associated scalar (volume flow rate) evaluation function |
[in] | input | optional function evaluation input, or nullptr |
Assign a constant volume flow rate to an inlet or outlet.
The flow direction may be specified by also calling cs_boundary_conditions_open_set_velocity_by_value, or cs_boundary_conditions_open_set_velocity_by_func. In that case, the velocity vector is rescaled so as to obtain the required volume flow rate.
[in] | z | pointer to associated zone |
[in] | q | associated constant volume flow rate |
void cs_boundary_conditions_open_turb | ( | void | ) |
void cs_boundary_conditions_reset | ( | void | ) |
Prepare (reset) condition coefficients for all variable fields.