My Project
programmer's documentation
Lagrangian module

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:

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.

{
const cs_zone_t *z;
int n_zones = cs_boundary_zone_n_zones();
/* default: rebound for all types */
for (int z_id = 0; z_id < n_zones; z_id++) {
lagr_bcs->zone_type[z_id] = CS_LAGR_REBOUND;
}
/* inlet and outlet for specified zones */
lagr_bcs->zone_type[z->id] = CS_LAGR_INLET;
z = cs_boundary_zone_by_name("outlet");
lagr_bcs->zone_type[z->id] = CS_LAGR_OUTLET;
}

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.

{
const cs_zone_t *z = cs_boundary_zone_by_name("inlet");
int set_id = 0;
= cs_lagr_get_injection_set(lagr_bcs, z->id, set_id);
/* Now define parameters for this class and set */
zis->n_inject = 100;
/* Assign other attributes (could be done through the GUI) */
zis->cluster = set_id + 1;
zis->velocity_profile = 0;
zis->velocity_magnitude = 1.1;
zis->stat_weight = 1.0;
zis->flow_rate = 0.0;
/* Mean value and standard deviation of the diameter */
zis->diameter = 5e-05;
zis->diameter_variance = 0.0;
/* Density */
zis->density = 2500.0;
zis->fouling_index = 100.0;
/* Temperature and Cp */
zis->temperature = 20.0;
zis->cp = 1400.;
zis->emissivity = 0.7;
}
}

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(int zone_id,
int location_id,
const void *input,
cs_lnum_t n_elts,
const cs_lnum_t elt_ids[],
cs_real_t profile[])
{
const cs_real_3_t *b_face_coords
const int itmx = 8;
/* Data initializations with experimental measurements
--------------------------------------------------- */
/* transverse coordinate */
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};
/* particle volume fraction */
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};
/* vertical mean velocity of the particles */
cs_real_t ui[] = {5.544, 8.827, 9.068, 9.169, 8.923, 8.295, 7.151, 6.048,
4.785, 5.544};
/* Loop en elements
---------------- */
for (cs_lnum_t ei = 0; ei < n_elts; ei++) {
/* Face center */
const cs_lnum_t face_id = elt_ids[ei];
const cs_real_t z = b_face_coords[face_id][2];
/* Interpolation */
int i = 0;
if (z > zi[0]) {
for (i = 0; i < itmx; i++) {
if (z >= zi[i] && z < zi[i+1])
break;
}
}
/* Compute volume fraction and statistical weight */
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]);
/* number of particles in the cell */
profile[ei] = lvfp * up;
}
}

Assigning the profile to the injection set simply requires assigning the function to the pointer in the injection set structure:

{
const cs_zone_t *z = cs_boundary_zone_by_name("inlet");
int set_id = 1;
= cs_lagr_get_injection_set(lagr_bcs, z->id, set_id);
/* Assign injection profile function */
zis->injection_profile_func = _injection_profile;
zis->injection_profile_input = NULL; /* default */
}

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
particles->n_part_dep += 1;
# pragma omp atomic
particles->weight_dep += cs_lagr_particle_get_real(particles,
p_id,
/* Mark particle as deposited and update its coordinates */
cs_real_t *particle_coord
for (int k = 0; k < 3; k++)
particle_coord[k] = c_intersect[k];
/* Update event and particle state */
*event_flag = *event_flag | (CS_EVENT_OUTFLOW | CS_EVENT_DEPOSITION);
*tracking_state = CS_LAGR_PART_OUT;

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:

Injection sets

In the following example, we inject 1 particle set at each time step:

{
/* The volume zone named "particle_injection" is created in the GUI */
const cs_zone_t *z = cs_volume_zone_by_name("particle_injection");
/* Inject 1 particle set every time step */
int set_id = 0;
= cs_lagr_get_injection_set(lagr_vol_conds, z->id, set_id);
zis->n_inject = 1000;
zis->injection_frequency = 1; /* if <= 0, injection at
initialization only */
zis->velocity_profile = -1; /* fluid velocity */
zis->stat_weight = 1.0;
zis->diameter = 5e-6;
zis->diameter_variance = 1e-6;
zis->density = 2475.;
zis->fouling_index = 100.0;
}
{
/* The volume zone containing all cells always has id 0;
a given zone may otherwise be selected using cs_volume_zone_by_name() */
/* Inject 2 particle sets of different diameters */
cs_gnum_t n_inject[] = {500, 500};
cs_real_t diam[] = {1e-3, 1e-2};
cs_real_t diam_dev[] = {1e-6, 1e-5};
cs_real_t density[] = {2500., 1500.};
for (int set_id = 0; set_id < 2; set_id++) {
= cs_lagr_get_injection_set(lagr_vol_conds, z->id, set_id);
zis->n_inject = n_inject[set_id];
zis->injection_frequency = 0; /* if <= 0, injection at
initialization only */
zis->cluster = set_id + 1;
zis->velocity_profile = -1; /* fluid velocity */
zis->stat_weight = 1.0;
zis->flow_rate = 0;
zis->diameter = diam[set_id];
zis->diameter_variance = diam_dev[set_id];
zis->density = density[set_id];
zis->fouling_index = 100.0;
zis->temperature_profile = 0; /* fluid temperature */
zis->cp = 1400.0;
zis->emissivity = 0.7;
}
}

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.

{
/* The volume zone containing all cells always has id 0;
a given zone may otherwise be selected using cs_volume_zone_by_name() */
/* Inject 2 particle sets of different diameters */
cs_gnum_t n_inject[] = {500, 500};
cs_real_t diam[] = {1e-3, 1e-2};
cs_real_t diam_dev[] = {1e-6, 1e-5};
cs_real_t density[] = {2500., 1500.};
for (int set_id = 0; set_id < 2; set_id++) {
= cs_lagr_get_injection_set(lagr_vol_conds, z->id, set_id);
zis->n_inject = n_inject[set_id];
zis->injection_frequency = 0; /* if <= 0, injection at
initialization only */
zis->cluster = set_id + 1;
zis->velocity_profile = -1; /* fluid velocity */
zis->stat_weight = 1.0;
zis->flow_rate = 0;
zis->diameter = diam[set_id];
zis->diameter_variance = diam_dev[set_id];
zis->density = density[set_id];
zis->fouling_index = 100.0;
zis->temperature_profile = 0; /* fluid temperature */
zis->cp = 1400.0;
zis->emissivity = 0.7;
}
}
cs_lagr_specific_physics_t::itpvar
int itpvar
Definition: cs_lagr.h:369
cs_lagr_injection_set_t::velocity_magnitude
cs_real_t velocity_magnitude
Definition: cs_lagr.h:543
input
static int input(void)
cs_lagr_injection_set_t::injection_frequency
int injection_frequency
Definition: cs_lagr.h:516
cs_lagr_get_volume_conditions
cs_lagr_zone_data_t * cs_lagr_get_volume_conditions(void)
Return pointer to the main volume conditions structure.
Definition: cs_lagr.c:1503
cs_lagr_get_boundary_conditions
cs_lagr_zone_data_t * cs_lagr_get_boundary_conditions(void)
Return pointer to the main boundary conditions structure.
Definition: cs_lagr.c:1479
cs_lagr_injection_set_t::cluster
int cluster
Definition: cs_lagr.h:539
cs_lagr_injection_set_t::injection_profile_func
cs_lagr_injection_profile_compute_t * injection_profile_func
Definition: cs_lagr.h:520
cs_boundary_zone_n_zones
int cs_boundary_zone_n_zones(void)
Return number of boundary zones defined.
Definition: cs_boundary_zone.c:421
cs_zone_t
Definition: cs_zone.h:55
cs_glob_mesh_quantities
cs_mesh_quantities_t * cs_glob_mesh_quantities
cs_real_3_t
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:315
cs_volume_zone_by_id
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.c:652
cs_mesh_quantities_t::b_face_cog
cs_real_t * b_face_cog
Definition: cs_mesh_quantities.h:105
cs_lagr_injection_set_t::velocity_profile
int velocity_profile
Definition: cs_lagr.h:529
cs_lagr_injection_set_t::density
cs_real_t density
Definition: cs_lagr.h:551
cs_glob_lagr_model
cs_lagr_model_t * cs_glob_lagr_model
cs_lagr_model_t::n_stat_classes
int n_stat_classes
Definition: cs_lagr.h:290
cs_lagr_injection_set_t::diameter
cs_real_t diameter
Definition: cs_lagr.h:548
cs_volume_zone_by_name
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.c:676
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
cs_lagr_particles_set_flag
static void cs_lagr_particles_set_flag(const cs_lagr_particle_set_t *particle_set, cs_lnum_t particle_id, int mask)
Set flag value with a selected mask for a given particle in a set.
Definition: cs_lagr_particle.h:526
cs_lagr_get_injection_set
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.c:1177
cs_lagr_injection_set_t::temperature_profile
int temperature_profile
Definition: cs_lagr.h:534
cs_lagr_injection_set_t
Definition: cs_lagr.h:507
cs_lagr_injection_set_t::emissivity
cs_real_t emissivity
Definition: cs_lagr.h:561
CS_LAGR_INLET
Definition: cs_lagr.h:87
atimbr::density
double precision, dimension(:,:,:), allocatable density
Definition: atimbr.f90:124
cs_lagr_particles_attr
static void * cs_lagr_particles_attr(cs_lagr_particle_set_t *particle_set, cs_lnum_t particle_id, cs_lagr_attribute_t attr)
Get pointer to a current attribute of a given particle in a set.
Definition: cs_lagr_particle.h:400
cs_lagr_particle_get_real
static cs_real_t cs_lagr_particle_get_real(const void *particle, const cs_lagr_attribute_map_t *attr_map, cs_lagr_attribute_t attr)
Get attribute value of type cs_real_t of a given particle in a set.
Definition: cs_lagr_particle.h:1229
cs_lagr_injection_set_t::diameter_variance
cs_real_t diameter_variance
Definition: cs_lagr.h:549
cs_gnum_t
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:286
CS_LAGR_PART_OUT
Definition: cs_lagr_tracking.h:60
cs_lagr_injection_set_t::fouling_index
cs_real_t fouling_index
Definition: cs_lagr.h:553
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_lagr_injection_set_t::temperature
cs_real_t temperature
Definition: cs_lagr.h:546
CS_LAGR_REBOUND
Definition: cs_lagr.h:89
cs_zone_t::id
int id
Definition: cs_zone.h:59
cs_boundary_zone_by_name
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.c:706
cs_lagr_injection_set_t::cp
cs_real_t cp
Definition: cs_lagr.h:555
cs_glob_lagr_specific_physics
cs_lagr_specific_physics_t * cs_glob_lagr_specific_physics
CS_EVENT_DEPOSITION
#define CS_EVENT_DEPOSITION
Definition: cs_lagr_event.h:62
CS_EVENT_OUTFLOW
#define CS_EVENT_OUTFLOW
Definition: cs_lagr_event.h:56
CS_LAGR_COORDS
Definition: cs_lagr_particle.h:95
CS_LAGR_STAT_WEIGHT
Definition: cs_lagr_particle.h:90
cs_lagr_zone_data_t
Definition: cs_lagr.h:654
cs_lagr_injection_set_t::stat_weight
cs_real_t stat_weight
Definition: cs_lagr.h:557
CS_LAGR_PART_DEPOSITED
#define CS_LAGR_PART_DEPOSITED
Definition: cs_lagr_particle.h:57
cs_lagr_injection_set_t::injection_profile_input
void * injection_profile_input
Definition: cs_lagr.h:523
cs_lagr_injection_set_t::n_inject
cs_gnum_t n_inject
Definition: cs_lagr.h:513
cs_lagr_zone_data_t::zone_type
int * zone_type
Definition: cs_lagr.h:659
cs_lagr_injection_set_t::flow_rate
cs_real_t flow_rate
Definition: cs_lagr.h:559
CS_LAGR_OUTLET
Definition: cs_lagr.h:88
k
Definition: cs_field_pointer.h:70