Boundary conditions
Lagrangian boundary conditions are based on boundary zone (cs_boundary_zone_t) definitions. Additional information may be provided for Lagrangian boundary types and injections.
As usual, definitions may be created using the GUI and extended with user functions.
Access to the Lagrangian boundary conditions structure, which is necessary to most of the following examples, may be done as follows:
cs_lagr_zone_data_t * cs_lagr_get_boundary_conditions(void)
Return pointer to the main boundary conditions structure.
Definition: cs_lagr.cpp:1544
Definition: cs_lagr.h:773
Boundary zones
In this example, we assign rebound conditions to all boundary zones, except for an inlet and outlet type to specified zones. The type assigned is an integer based on the cs_lagr_bc_type_t enumerator type.
{
for (int z_id = 0; z_id < n_zones; z_id++) {
}
}
const cs_zone_t * cs_boundary_zone_by_name(const char *name)
Return a pointer to a boundary zone based on its name if present.
Definition: cs_boundary_zone.cpp:708
int cs_boundary_zone_n_zones(void)
Return number of boundary zones defined.
Definition: cs_boundary_zone.cpp:423
@ CS_LAGR_OUTLET
Definition: cs_lagr.h:88
@ CS_LAGR_INLET
Definition: cs_lagr.h:87
@ CS_LAGR_REBOUND
Definition: cs_lagr.h:89
int * zone_type
Definition: cs_lagr.h:778
int id
Definition: cs_zone.h:55
Injection sets
In the following example, a first injection set for an inlet zone is defined. Note that newly injected particles may also be modified using the cs_user_lagr_in function.
{
int set_id = 0;
}
}
cs_lagr_injection_set_t * cs_lagr_get_injection_set(cs_lagr_zone_data_t *zone_data, int zone_id, int set_id)
Provide access to injection set structure.
Definition: cs_lagr.cpp:1185
cs_lagr_model_t * cs_glob_lagr_model
cs_lagr_specific_physics_t * cs_glob_lagr_specific_physics
Definition: cs_lagr.h:615
cs_real_t diameter_variance
Definition: cs_lagr.h:659
cs_real_t density
Definition: cs_lagr.h:675
int injection_frequency
Definition: cs_lagr.h:624
int temperature_profile
Definition: cs_lagr.h:642
cs_real_t velocity_magnitude
Definition: cs_lagr.h:653
int velocity_profile
Definition: cs_lagr.h:637
cs_real_t cp
Definition: cs_lagr.h:679
cs_real_t diameter
Definition: cs_lagr.h:658
cs_gnum_t n_inject
Definition: cs_lagr.h:621
int cluster
Definition: cs_lagr.h:648
cs_real_t fouling_index
Definition: cs_lagr.h:677
cs_real_t flow_rate
Definition: cs_lagr.h:683
cs_real_t emissivity
Definition: cs_lagr.h:685
cs_real_t stat_weight
Definition: cs_lagr.h:681
cs_real_t temperature
Definition: cs_lagr.h:656
int n_stat_classes
Definition: cs_lagr.h:354
int solve_temperature
Definition: cs_lagr.h:460
In the next example, a profile is assigned to the second injection set of an inlet zone (it is assumed this et was previously defined either through the GUI or user function).
This requires first defining a profile definition function, matching the profile of cs_lagr_injection_profile_compute_t. An example based on experimental profiles is given here:
static void
_injection_profile([[maybe_unused]] int zone_id,
[[maybe_unused]] int location_id,
[[maybe_unused]] const void *input,
{
const int itmx = 8;
cs_real_t zi[] = {0.e-3, 1.e-3, 1.5e-3, 2.0e-3, 2.5e-3, 3.0e-3, 3.5e-3,
4.0e-3, 4.5e-3, 5.0e-3};
cs_real_t lvf[] = {0.377e-4, 2.236e-4, 3.014e-4, 4.306e-4, 5.689e-4,
8.567e-4, 7.099e-4, 4.520e-4, 2.184e-4, 0.377e-4};
cs_real_t ui[] = {5.544, 8.827, 9.068, 9.169, 8.923, 8.295, 7.151, 6.048,
4.785, 5.544};
const cs_real_t z = b_face_coords[face_id][2];
int i = 0;
if (z > zi[0]) {
for (i = 0; i < itmx; i++) {
if (z >= zi[i] && z < zi[i+1])
break;
}
}
cs_real_t up = ui[i] +(z-zi[i])*(ui[i+1]-ui[i])/(zi[i+1]-zi[i]);
cs_real_t lvfp = lvf[i] + (z-zi[i])*(lvf[i+1]-lvf[i])/(zi[i+1]-zi[i]);
profile[ei] = lvfp * up;
}
}
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:349
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
cs_mesh_quantities_t * cs_glob_mesh_quantities
cs_real_3_t * b_face_cog
Definition: cs_mesh_quantities.h:102
Assigning the profile to the injection set simply requires assigning the function to the pointer in the injection set structure:
{
int set_id = 1;
}
cs_lagr_injection_profile_compute_t * injection_profile_func
Definition: cs_lagr.h:628
void * injection_profile_input
Definition: cs_lagr.h:631
An optional user-defined input function may also be associated.
Boundary-particle interactions
It is also possible to decide of the behavior of particle when they encounter a boundary (this boundary has to be of type CS_LAGR_BC_USER).
In the following example, the particle is simply deposited and marked for elimination:
# pragma omp atomic
p_set.n_part_dep += 1;
# pragma omp atomic
p_set.weight_dep += p_set.attr_real(
p_id,
for (
int k = 0;
k < 3;
k++)
particle_coord[
k] = c_intersect[
k];
@ k
Definition: cs_field_pointer.h:68
#define CS_EVENT_OUTFLOW
Definition: cs_lagr_event.h:56
#define CS_EVENT_DEPOSITION
Definition: cs_lagr_event.h:62
@ CS_LAGR_STAT_WEIGHT
Definition: cs_lagr_particle.h:87
@ CS_LAGR_COORDS
Definition: cs_lagr_particle.h:92
#define CS_LAGR_PART_DEPOSITED
Definition: cs_lagr_particle.h:54
@ CS_LAGR_PART_OUT
Definition: cs_lagr_tracking.h:56
Volume conditions
Lagrangian volume conditions are based on volume zone (cs_volume_zone_t) definitions. Additional information may be provided for Lagrangian injections.
As usual, definitions may be created using the GUI and extended with user functions.
Access to the Lagrangian volume conditions structure, which is necessary to most of the following examples, may be done as follows:
cs_lagr_zone_data_t * cs_lagr_get_volume_conditions(void)
Return pointer to the main volume conditions structure.
Definition: cs_lagr.cpp:1568
Injection sets
In the following example, we inject 1 particle set at each time step:
{
int set_id = 0;
}
}
cs_lagr_agglomeration_model_t * cs_glob_lagr_agglomeration_model
const cs_zone_t * cs_volume_zone_by_name(const char *name)
Return a pointer to a volume zone based on its name if present.
Definition: cs_volume_zone.cpp:665
cs_real_t base_diameter
Definition: cs_lagr.h:572
int aggregat_class_id
Definition: cs_lagr.h:650
cs_real_t aggregat_fractal_dim
Definition: cs_lagr.h:651
int fragmentation
Definition: cs_lagr.h:352
int agglomeration
Definition: cs_lagr.h:348
{
for (int set_id = 0; set_id < 2; set_id++) {
}
}
unsigned cs_gnum_t
global mesh entity number
Definition: cs_defs.h:317
const cs_zone_t * cs_volume_zone_by_id(int id)
Return a pointer to a volume zone based on its id.
Definition: cs_volume_zone.cpp:641
In the following example, we inject 2 particle sets at computation initialization (i.e. at the first time step of a computation sequence in which the Lagrangian module is activated). Note that newly injected particles may also be modified using the cs_user_lagr_in function.
{
for (int set_id = 0; set_id < 2; set_id++) {
}
}
In the followin example, we define an injection for rain zone for cooling towers module:
{
int set_id = 0;
if (f_lagr_injection_profile != nullptr) {
auto lagr_injection_profile = f_lagr_injection_profile->
get_val_s();
flow_rate += lagr_injection_profile[cell_id];
}
else
"while field \"lagr_injection_profile\" does not "
"exist.\n"), __func__);
}
Field descriptor.
Definition: cs_field.h:275
cs_span< cs_real_t > get_val_s(const int time_id=0) const
Return a 1D span view of field values. If the field is not a scalar a fatal error is provoked.
Definition: cs_field.cpp:5080
#define _(String)
Definition: cs_defs.h:61
cs_field_t * cs_field_try(int id)
Return a pointer to a field based on its id. If no field of the given name is defined,...
Definition: cs_field.cpp:4371
int cs_log_warning(const char *format,...)
Print a warning message to the warnings.log file and a copy to the default log file.
Definition: cs_log.cpp:697
static void sum(const cs_mpi_wrapper &mpi_w, T &first, Vals &... values)
Sum values of a given datatype over a given communicator.
Definition: cs_parall.h:893
cs_lnum_t n_cells
Definition: cs_mesh.h:97
This requires in preambule the definition of the function pointer:
static void
_injection_profile([[maybe_unused]] int zone_id,
[[maybe_unused]] int location_id,
[[maybe_unused]] const void *input,
{
if (f != nullptr) {
auto lagr_injection_profile = f->
get_val_s();
profile[ei] = lagr_injection_profile[cell_id];
assert(profile[ei] >= 0.);
}
}
else
"%s: Called while field \"lagr_injection_profile\" doesn't exist.\n",
__func__);
}
void bft_error(const char *const file_name, const int line_num, const int sys_error_code, const char *const format,...)
Calls the error handler (set by bft_error_handler_set() or default).
Definition: bft_error.cpp:187
External force
User definition of an external force field acting on the particles.
It must be prescribed in every cell and be homogeneous to gravity (m/s^2) By default gravity and drag force are the only forces acting on the particles (the gravity components gx gy gz are assigned in the GUI or in cs_user_parameters)
void
{
fextla[0] = 0;
fextla[1] = 0;
fextla[2] = 0;
}
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:358
void cs_user_lagr_ef(cs_real_t dt_p, const cs_lnum_t p_id, const cs_real_t *taup, const cs_real_3_t *tlag, const cs_real_3_t *piil, const cs_real_33_t *bx, const cs_real_t tsfext, const cs_real_3_t gradpr, const cs_real_33_t gradvf, cs_real_t rho_p, cs_real_3_t fextla)
User definition of an external force field acting on the particles.
Definition: cs_user_lagr_particle.cpp:84
Impose motion on a particle
Impose the motion of a particle flagged CS_LAGR_PART_IMPOSED_MOTION by modifying the particle position and its velocity.
#pragma weak cs_user_lagr_imposed_motion
void
(
)
{
disp[0] = 0.;
disp[1] = rcost * (cos(omega*
dt) - 1.0 ) - rsint * sin(omega*
dt);
disp[2] = rsint * (cos(omega*
dt) - 1.0 ) + rcost * sin(omega*
dt);
for ( int i = 0; i < 3; i++)
disp[i] *= -2;
}
}
}
@ dt
Definition: cs_field_pointer.h:61
@ CS_LAGR_STAT_CLASS
Definition: cs_lagr_particle.h:168
void cs_user_lagr_imposed_motion(cs_lagr_particle_set_t &p_set, cs_lnum_t p_id, const cs_real_t coords[3], const cs_real_t dt, cs_real_t disp[3])
Impose the motion of a particle flagged CS_LAGR_PART_IMPOSED_MOTION.
Definition: cs_user_lagr_particle.cpp:134
Definition: cs_lagr_particle.h:324
Modification of newly injected particles
User modification of newly injected particles.
This function is called after the initialization of the new particles in order to modify them according to new particle profiles (injection profiles, position of the injection point, statistical weights, correction of the diameter if the standard-deviation option is activated).
- Warning
- The modification of particles position must be made in cs_user_lagr_in_force_pos to get an initialization of particle properties coherent with the local fields.
This function is called for each injection zone and set. Particles with ids between pset->n_particles and n_elts are initialized but may be modified by this function.
void
(
[[maybe_unused]]
const cs_lnum_t particle_range[2],
[[maybe_unused]]
const cs_lnum_t particle_face_id[],
[[maybe_unused]]
const cs_real_t visc_length[]
)
{
for (
cs_lnum_t p_id = particle_range[0]; p_id < particle_range[1]; p_id++) {
part_vel[0] = 1.0;
part_vel[1] = 0.0;
part_vel[2] = 0.0;
attr_id++) {
*user_var = 0.;
}
}
if (particle_range[1] <= particle_range[0])
return;
for (
cs_lnum_t p_id = particle_range[0]; p_id < particle_range[1]; p_id++) {
_inlet2(p_set, p_id);
}
}
}
int nt_cur
Definition: cs_time_step.h:72
cs_lagr_source_terms_t * cs_glob_lagr_source_terms
cs_lagr_time_scheme_t * cs_glob_lagr_time_scheme
cs_lagr_attribute_t
Definition: cs_lagr_particle.h:76
@ CS_LAGR_USER
Definition: cs_lagr_particle.h:177
@ CS_LAGR_VELOCITY
Definition: cs_lagr_particle.h:93
@ CS_LAGR_TEMPERATURE
Definition: cs_lagr_particle.h:146
@ CS_LAGR_DIAMETER
Definition: cs_lagr_particle.h:90
void cs_user_lagr_in(cs_lagr_particle_set_t &p_set, const cs_lagr_injection_set_t *zis, const cs_lnum_t particle_range[2], const cs_lnum_t particle_face_id[], const cs_real_t visc_length[])
User modification of newly injected particles.
Definition: cs_user_lagr_particle.cpp:209
cs_lagr_stat_options_t * cs_glob_lagr_stat_options
const cs_time_step_t * cs_glob_time_step
int n_user_variables
Definition: cs_lagr.h:356
int nstits
Definition: cs_lagr.h:726
int nstist
Definition: cs_lagr_stat.h:211
int isttio
Definition: cs_lagr.h:210
To modify the particle position use:
#pragma weak cs_user_lagr_in_force_coords
void
(
[[maybe_unused]]
const cs_lnum_t particle_range[2],
[[maybe_unused]]
const cs_lnum_t particle_face_id[],
[[maybe_unused]]
const cs_real_t visc_length[]
)
{
for (
cs_lnum_t p_id = particle_range[0]; p_id < particle_range[1]; p_id++) {
for (int i = 0; i < 3; i++) {
part_coord[i] = dest[i];
}
}
}
void cs_user_lagr_in_force_coords(cs_lagr_particle_set_t &p_set, const cs_lagr_injection_set_t *zis, const cs_lnum_t particle_range[2], const cs_lnum_t particle_face_id[], const cs_real_t visc_length[])
User modification of newly injected particle location and cell_id.
Definition: cs_user_lagr_particle.cpp:170
Here is another example of the modification of newly injected particles:
constexpr int n_max_layers = 5;
assert(n_layers <= n_max_layers);
int coal_id = 0;
cs_real_t initial_diameter = 0, shrinking_diameter = 0;
for (int l_id = 0; l_id < n_layers; l_id++) {
temperature[l_id] = 0;
coal_mass_fraction[l_id] = 0;
coke_density[l_id] = 0;
coke_mass_fraction[l_id] = 0;
}
if (zis->zone_id == 1 && zis->set_id == 0) {
coal_id = 0;
density
* (1.0 - (cm->
y1ch[coal_id] + cm->
y2ch[coal_id]) / 2.0);
water_mass_f = 0.0;
for (int l_id = 0; l_id < n_layers; l_id++) {
temperature[l_id] = 800 - 273.15;
coal_mass_fraction[l_id] = 0.;
coke_density[l_id]
* (1.0 - (cm->
y1ch[coal_id] + cm->
y2ch[coal_id]) / 2.0);
coke_mass_fraction[l_id] = coke_density[l_id] / density;
}
shrinking_diameter = zis->diameter;
initial_diameter = zis->diameter;
}
for (
cs_lnum_t p_id = particle_range[0]; p_id < particle_range[1]; p_id++) {
for (int l_id = 0; l_id < n_layers; l_id++) {
particle_temperature[l_id] = temperature[l_id];
particle_coal_mass[l_id] = coal_mass_fraction[l_id] * mass / n_layers;
particle_coke_mass[l_id] = coke_mass_fraction[l_id] * mass / n_layers;
particle_coal_density[l_id] = coke_density[l_id];
}
}
cs_coal_model_t * cs_glob_coal_model
Definition: cs_coal.cpp:95
@ cp
Definition: cs_field_pointer.h:99
@ CS_LAGR_COAL_DENSITY
Definition: cs_lagr_particle.h:160
@ CS_LAGR_MASS
Definition: cs_lagr_particle.h:89
@ CS_LAGR_COAL_MASS
Definition: cs_lagr_particle.h:153
@ CS_LAGR_COKE_MASS
Definition: cs_lagr_particle.h:154
@ CS_LAGR_CP
Definition: cs_lagr_particle.h:148
@ CS_LAGR_INITIAL_DIAMETER
Definition: cs_lagr_particle.h:157
@ CS_LAGR_SHRINKING_DIAMETER
Definition: cs_lagr_particle.h:156
@ CS_LAGR_WATER_MASS
Definition: cs_lagr_particle.h:152
static constexpr cs_real_t cs_math_pi
Definition: cs_math.h:111
double y2ch[CS_COMBUSTION_MAX_COALS]
Definition: cs_coal.h:296
double y1ch[CS_COMBUSTION_MAX_COALS]
Definition: cs_coal.h:287
double cp2ch[CS_COMBUSTION_MAX_COALS]
Definition: cs_coal.h:254
double xwatch[CS_COMBUSTION_MAX_COALS]
Definition: cs_coal.h:263
double xashch[CS_COMBUSTION_MAX_COALS]
Definition: cs_coal.h:260
double rho0ch[CS_COMBUSTION_MAX_COALS]
Definition: cs_coal.h:212
int n_temperature_layers
Definition: cs_lagr.h:288