8.3
general documentation
cs_boundary_conditions.cpp File Reference
#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"
+ Include dependency graph for cs_boundary_conditions.cpp:

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_tcs_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_tcs_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...
 

Detailed Description

Boundary condition handling.

Function Documentation

◆ cs_boundary_conditions_add_map()

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.

Note
This function is currently restricted to mapping of boundary face locations (usually from boundary zones) to cell of boundary face locations, but could be extended to other location types in the future.
Parameters
[in]bc_location_idid of selected boundary mesh location; currently restricted to subsets of boundary faces (i.e. boundary zone location ids).
[in]source_location_idid 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_shiftcoordinates shift relative to selected boundary faces
[in]tolerancerelative tolerance for point location.
Returns
id of added map

◆ cs_boundary_conditions_assign_model_inlet()

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.

Parameters
[in]zonepointer to associated zone
[in]s_ptrpointer to associated structure
[in]s_deldestructor for associated structure, or nullptr

◆ cs_boundary_conditions_complete()

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.

Parameters
[in]bc_typetype of boundary for each face

◆ cs_boundary_conditions_compute()

void cs_boundary_conditions_compute ( int  bc_type[])

Update per variable boundary condition codes.

Parameters
[in]bc_typetype of boundary for each face

◆ cs_boundary_conditions_create()

void cs_boundary_conditions_create ( void  )

Create the legacy boundary conditions face type and face zone arrays.

◆ cs_boundary_conditions_create_legacy_zone_data()

void cs_boundary_conditions_create_legacy_zone_data ( void  )

Create the legacy boundary conditions zone data arrays.

◆ cs_boundary_conditions_error()

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.

Parameters
[in]bc_flagarray of BC type ids
[in]type_namename of attribute in error, or nullptr

◆ cs_boundary_conditions_free()

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_boundary_conditions_get_b_head_loss()

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.

Parameters
[in]alloc_if_nulldo we need to allocate this if not present ?
Returns
b_head_loss pointer to boundary head losses array, or nullptr

◆ cs_boundary_conditions_get_bc_type()

int * cs_boundary_conditions_get_bc_type ( void  )

Return pointer to boundary conditions BC type array.

◆ cs_boundary_conditions_get_legacy_zone_num()

int cs_boundary_conditions_get_legacy_zone_num ( const cs_zone_t z)

◆ cs_boundary_conditions_get_model_inlet()

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.

Parameters
[in]zonepointer to associated zone
Returns
: pointer to structure associated with zone

◆ cs_boundary_conditions_inlet_set_turbulence_hyd_diam()

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).

Parameters
[in]zonepointer to associated zone
[in]hdassociated hydraulic diameter

◆ cs_boundary_conditions_inlet_set_turbulence_intensity()

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).

Parameters
[in]zonepointer to associated zone
[in]tiassociated turbulence intensity

◆ cs_boundary_conditions_legacy_turbulence()

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, ...).

Deprecated:
Code should migrate to the "per zone" open boundary condition definitions.
Parameters
[in]bc_typetype of boundary for each face

◆ cs_boundary_conditions_map()

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.

Parameters
[in]location_typematching values location (CS_MESH_LOCATION_CELLS or CS_MESH_LOCATION_BOUNDARY_FACES)
[in]n_location_eltsnumber of selected location elements
[in]n_facesnumber of selected boundary faces
[in]location_eltslist of selected location elements (0 to n-1), or nullptr if no indirection is needed
[in]faceslist of selected boundary faces (0 to n-1), or nullptr if no indirection is needed
[in]coord_shiftarray of coordinates shift relative to selected boundary faces
[in]coord_strideaccess stride in coord_shift: 0 for uniform shift, 1 for "per face" shift.
[in]tolerancerelative tolerance for point location.
Returns
associated locator structure

◆ cs_boundary_conditions_mapped_set()

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.

Parameters
[in]ffield whose boundary conditions are set
[in]locatorassociated mapping locator, as returned by cs_boundary_conditions_map.
[in]location_typematching values location (CS_MESH_LOCATION_CELLS or CS_MESH_LOCATION_BOUNDARY_FACES)
[in]normalizenormalization 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]interpolateinterpolation 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_facesnumber of selected boundary faces
[in]faceslist of selected boundary faces (0 to n-1), or nullptr if no indirection is needed
[in]balance_woptional balance weight, or nullptr

◆ cs_boundary_conditions_open_find()

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.

Parameters
[in]zonepointer to associated zone
Returns
: pointer to structure associated with zone, or nullptr if not found.

◆ cs_boundary_conditions_open_find_or_add()

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.

Parameters
[in]zonepointer to associated zone
Returns
: pointer to structure associated with zone

◆ cs_boundary_conditions_open_get_mass_flow_rate()

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.

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.

Parameters
[in]zpointer to associated zone
Returns
volume flow rate associated with open boundary

◆ cs_boundary_conditions_open_get_time_control()

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.

Parameters
[in]zonepointer to associated zone

◆ cs_boundary_conditions_open_set_mass_flow_rate_by_func()

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:

  • that value or structure should not be temporary (i.e. local);
  • when a single integer identifier is needed, the input pointer can be set to that value instead of an actual address;
Parameters
[in]zpointer to associated zone
[in]funcassociated scalar (mass flow rate) evaluation function
[in]inputoptional function evaluation input, or nullptr

◆ cs_boundary_conditions_open_set_mass_flow_rate_by_value()

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.

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.

Parameters
[in]zpointer to associated zone
[in]qassociated constant mass flow rate

◆ cs_boundary_conditions_open_set_velocity_by_func()

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:

  • that value or structure should not be temporary (i.e. local);
  • when a single integer identifier is needed, the input pointer can be set to that value instead of an actual address;
Parameters
[in]zpointer to associated zone
[in]funcassociated velocity vector evaluation function at zone faces
[in]inputoptional function evaluation input, or nullptr

◆ cs_boundary_conditions_open_set_velocity_by_normal_value()

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.

Parameters
[in]zpointer to associated zone
[in]u_normassociated constant normal

◆ cs_boundary_conditions_open_set_velocity_by_value()

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.

Parameters
[in]zpointer to associated zone
[in]uassociated velocity value

◆ cs_boundary_conditions_open_set_volume_flow_rate_by_func()

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:

  • that value or structure should not be temporary (i.e. local);
  • when a single integer identifier is needed, the input pointer can be set to that value instead of an actual address;
Parameters
[in]zpointer to associated zone
[in]funcassociated scalar (volume flow rate) evaluation function
[in]inputoptional function evaluation input, or nullptr

◆ cs_boundary_conditions_open_set_volume_flow_rate_by_value()

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.

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.

Parameters
[in]zpointer to associated zone
[in]qassociated constant volume flow rate

◆ cs_boundary_conditions_open_turb()

void cs_boundary_conditions_open_turb ( void  )

◆ cs_boundary_conditions_reset()

void cs_boundary_conditions_reset ( void  )

Prepare (reset) condition coefficients for all variable fields.