My Project
programmer's documentation
Data Structures | Typedefs | Enumerations | Functions | Variables
cs_lagr_stat.h File Reference
#include "cs_defs.h"
#include "assert.h"
#include "cs_base.h"
#include "cs_field.h"
#include "cs_restart.h"
#include "cs_lagr.h"
#include "cs_lagr_event.h"
#include "cs_lagr_particle.h"
Include dependency graph for cs_lagr_stat.h:

Go to the source code of this file.

Data Structures

struct  cs_lagr_stat_options_t
 

Typedefs

typedef void() cs_lagr_moment_p_data_t(const void *input, const void *particle, const cs_lagr_attribute_map_t *p_am, cs_real_t vals[])
 
typedef void() cs_lagr_moment_e_data_t(const void *input, const cs_lagr_event_set_t *events, cs_lnum_t id_range[2], cs_real_t vals[])
 
typedef void() cs_lagr_moment_m_data_t(const void *input, const cs_lagr_event_set_t *events, int location_id, int class_id, cs_real_t vals[])
 

Enumerations

enum  cs_lagr_stat_moment_t { CS_LAGR_MOMENT_MEAN, CS_LAGR_MOMENT_VARIANCE }
 
enum  cs_lagr_stat_group_t { CS_LAGR_STAT_GROUP_PARTICLE, CS_LAGR_STAT_GROUP_TRACKING_EVENT, CS_LAGR_STAT_GROUP_N_GROUPS }
 
enum  cs_lagr_stat_restart_t { CS_LAGR_MOMENT_RESTART_RESET, CS_LAGR_MOMENT_RESTART_AUTO, CS_LAGR_MOMENT_RESTART_EXACT }
 
enum  cs_lagr_stat_type_t {
  CS_LAGR_STAT_CUMULATIVE_WEIGHT, CS_LAGR_STAT_VOLUME_FRACTION, CS_LAGR_STAT_E_CUMULATIVE_WEIGHT, CS_LAGR_STAT_RESUSPENSION_CUMULATIVE_WEIGHT,
  CS_LAGR_STAT_FOULING_CUMULATIVE_WEIGHT, CS_LAGR_STAT_MASS_FLUX, CS_LAGR_STAT_RESUSPENSION_MASS_FLUX, CS_LAGR_STAT_FOULING_MASS_FLUX,
  CS_LAGR_STAT_IMPACT_ANGLE, CS_LAGR_STAT_IMPACT_VELOCITY, CS_LAGR_STAT_FOULING_DIAMETER, CS_LAGR_STAT_FOULING_COKE_FRACTION,
  CS_LAGR_STAT_ATTR
}
 

Functions

int cs_lagr_stat_particle_define (const char *name, int location_id, int stat_type, cs_lagr_stat_moment_t m_type, int class_id, int dim, int component_id, cs_lagr_moment_p_data_t *data_func, void *data_input, cs_lagr_moment_p_data_t *w_data_func, void *w_data_input, int nt_start, double t_start, cs_lagr_stat_restart_t restart_mode)
 Define a particle-based statistic. More...
 
int cs_lagr_stat_event_define (const char *name, int location_id, int stat_type, cs_lagr_stat_group_t stat_group, cs_lagr_stat_moment_t m_type, int class_id, int dim, int component_id, cs_lagr_moment_e_data_t *data_func, void *data_input, cs_lagr_moment_e_data_t *w_data_func, void *w_data_input, int nt_start, double t_start, cs_lagr_stat_restart_t restart_mode)
 Define an event-based statistic. More...
 
int cs_lagr_stat_accumulator_define (const char *name, int location_id, cs_lagr_stat_group_t stat_group, int class_id, cs_lagr_moment_p_data_t *p_data_func, cs_lagr_moment_e_data_t *e_data_func, void *data_input, int nt_start, double t_start, cs_lagr_stat_restart_t restart_mode)
 Define a particle weight type statistic. More...
 
int cs_lagr_stat_mesh_define (const char *name, int location_id, cs_lagr_stat_group_t stat_group, int class_id, int dim, cs_lagr_moment_m_data_t *data_func, void *data_input, int nt_start, double t_start)
 Define mesh-based statistic based on particles or particle events. More...
 
int cs_lagr_stat_time_moment_define (const char *name, int location_id, int stat_type, cs_lagr_stat_moment_t m_type, int class_id, int dim, int component_id, cs_lagr_moment_m_data_t *data_func, void *data_input, int nt_start, double t_start, cs_lagr_stat_restart_t restart_mode)
 Define a time moment associated to particle statistics. More...
 
void cs_lagr_stat_activate (int stat_type)
 Activate Lagrangian statistics for a given statistics type. More...
 
void cs_lagr_stat_activate_time_moment (int stat_type, cs_lagr_stat_moment_t moment)
 Activate time moment for some predefined Lagrangian statistics types. More...
 
void cs_lagr_stat_deactivate (int stat_type)
 Deactivate Lagrangian statistics for a given statistics type. More...
 
void cs_lagr_stat_activate_attr (int attr_id)
 Activate Lagrangian statistics for a given particle attribute. More...
 
void cs_lagr_stat_deactivate_attr (int attr_id)
 Deactivate Lagrangian statistics for a given particle attribute. More...
 
int cs_lagr_stat_type_from_attr_id (int attr_id)
 Return statistics type associated with a given particle attribute id. More...
 
int cs_lagr_stat_type_to_attr_id (int stat_type)
 Return attribute id associated with a given statistics type. More...
 
int cs_lagr_stat_type_by_name (const char *name)
 Determine a basic statistic type by its base name. More...
 
void cs_lagr_stat_map_cell_dt (const cs_real_t *dt)
 Map time step values array for Lagrangian statistics. More...
 
void cs_lagr_stat_initialize (void)
 Lagrangian statistics initialization. More...
 
bool cs_lagr_stat_is_active (cs_lagr_stat_group_t group)
 Indicate if a given statistics type has active statistics. More...
 
void cs_lagr_stat_restart_read (void)
 Read particle statistics restart info if needed. More...
 
void cs_lagr_stat_prepare (void)
 Prepare particle statistics for a given time step. More...
 
void cs_lagr_stat_update (void)
 Update particle statistics for a given time step. More...
 
void cs_lagr_stat_update_event (cs_lagr_event_set_t *events, cs_lagr_stat_group_t group)
 Update event-based moment accumulators. More...
 
void cs_lagr_stat_finalize (void)
 Destroy all moments management metadata. More...
 
void cs_lagr_stat_log_setup (void)
 Log moment definition setup information. More...
 
void cs_lagr_stat_log_iteration (void)
 Log moment definition information for a given iteration. More...
 
void cs_lagr_stat_restart_write (cs_restart_t *restart)
 Checkpoint moment data. More...
 
cs_field_tcs_lagr_stat_get_moment (int stat_type, cs_lagr_stat_group_t stat_group, cs_lagr_stat_moment_t m_type, int class_id, int component_id)
 Return field associated with a given Lagrangian statistic, given a statistics type (i.e. variable), group (particles or event), moment order, statistical class, and component id. More...
 
cs_field_tcs_lagr_stat_get_stat_weight (int class_id)
 Return statistical weight. More...
 
cs_real_t cs_lagr_stat_get_age (void)
 Return global volume statistics age. More...
 
cs_real_t cs_lagr_stat_get_moment_age (cs_field_t *f)
 Return statistics age for a given moment. More...
 

Variables

cs_lagr_stat_options_tcs_glob_lagr_stat_options
 

Typedef Documentation

◆ cs_lagr_moment_e_data_t

typedef void() cs_lagr_moment_e_data_t(const void *input, const cs_lagr_event_set_t *events, cs_lnum_t id_range[2], cs_real_t vals[])

◆ cs_lagr_moment_m_data_t

typedef void() cs_lagr_moment_m_data_t(const void *input, const cs_lagr_event_set_t *events, int location_id, int class_id, cs_real_t vals[])

◆ cs_lagr_moment_p_data_t

typedef void() cs_lagr_moment_p_data_t(const void *input, const void *particle, const cs_lagr_attribute_map_t *p_am, cs_real_t vals[])

Enumeration Type Documentation

◆ cs_lagr_stat_group_t

Particle statistics moment data type

Enumerator
CS_LAGR_STAT_GROUP_PARTICLE 
CS_LAGR_STAT_GROUP_TRACKING_EVENT 
CS_LAGR_STAT_GROUP_N_GROUPS 

◆ cs_lagr_stat_moment_t

Particle statistics moment type

Enumerator
CS_LAGR_MOMENT_MEAN 
CS_LAGR_MOMENT_VARIANCE 

◆ cs_lagr_stat_restart_t

Moment restart behavior

Enumerator
CS_LAGR_MOMENT_RESTART_RESET 
CS_LAGR_MOMENT_RESTART_AUTO 
CS_LAGR_MOMENT_RESTART_EXACT 

◆ cs_lagr_stat_type_t

Predefined particle and event statistics

Enumerator
CS_LAGR_STAT_CUMULATIVE_WEIGHT 

cumulative particle statistical weight (active if any particle attribute statistics are active, may be activated separately)

CS_LAGR_STAT_VOLUME_FRACTION 

particle volume fraction

CS_LAGR_STAT_E_CUMULATIVE_WEIGHT 

cumulative particle event statistical weight

CS_LAGR_STAT_RESUSPENSION_CUMULATIVE_WEIGHT 

cumulative fouling event statistical weight

CS_LAGR_STAT_FOULING_CUMULATIVE_WEIGHT 

cumulative fouling event statistical weight

CS_LAGR_STAT_MASS_FLUX 

particle mass flux

CS_LAGR_STAT_RESUSPENSION_MASS_FLUX 

particle resuspension mass flux

CS_LAGR_STAT_FOULING_MASS_FLUX 

particle fouling mass flux

CS_LAGR_STAT_IMPACT_ANGLE 

particle impact angle (in radians)

CS_LAGR_STAT_IMPACT_VELOCITY 

particle impact velocity

CS_LAGR_STAT_FOULING_DIAMETER 

fouled particle diameter

CS_LAGR_STAT_FOULING_COKE_FRACTION 

fouled particle coke fraction

CS_LAGR_STAT_ATTR 

particle or event attribute; add attribute id for given attribute

Function Documentation

◆ cs_lagr_stat_accumulator_define()

int cs_lagr_stat_accumulator_define ( const char *  name,
int  location_id,
cs_lagr_stat_group_t  stat_group,
int  class_id,
cs_lagr_moment_p_data_t p_data_func,
cs_lagr_moment_e_data_t e_data_func,
void *  data_input,
int  nt_start,
double  t_start,
cs_lagr_stat_restart_t  restart_mode 
)

Define a particle weight type statistic.

Weights are automatically associated to general statitistics, but defining them explicitely allows activation of standard logging and postprocessing for those weights, as well as defining specific weights.

Parameters
[in]namestatistics base name
[in]location_idid of associated mesh location
[in]stat_groupstatistics group (particle or event)
[in]class_idparticle class id, or 0 for all
[in]p_data_funcpointer to function to compute particle weight (if NULL, statistic weight assumed)
[in]e_data_funcpointer to function to compute event weight (if NULL, statistic weight assumed)
[in]data_inputassociated input for data_func
[in]nt_startstarting time step (or -1 to use t_start, 0 to use idstnt)
[in]t_startstarting time
[in]restart_modebehavior in case of restart (reset, automatic, or strict)
Returns
id of new moment in case of success, -1 in case of error.

◆ cs_lagr_stat_activate()

void cs_lagr_stat_activate ( int  stat_type)

Activate Lagrangian statistics for a given statistics type.

This function is ignored if called after cs_lagr_stat_initialize.

Parameters
[in]stat_typeparticle statistics type

◆ cs_lagr_stat_activate_attr()

void cs_lagr_stat_activate_attr ( int  attr_id)

Activate Lagrangian statistics for a given particle attribute.

This function is ignored if called after cs_lagr_stat_initialize.

Parameters
[in]attr_idparticle attribute id

◆ cs_lagr_stat_activate_time_moment()

void cs_lagr_stat_activate_time_moment ( int  stat_type,
cs_lagr_stat_moment_t  moment 
)

Activate time moment for some predefined Lagrangian statistics types.

By default, statistics such as mass flows are based on a current time step, and time moments are not computed by default. This function allows forcing the associated moment level so that it is computed also.

Note that requesting a higher order moment will automatically include lower order moments, so activating the variance also activates the mean.

Parameters
[in]stat_typeparticle statistics type
[in]momentassociated time moment level

◆ cs_lagr_stat_deactivate()

void cs_lagr_stat_deactivate ( int  stat_type)

Deactivate Lagrangian statistics for a given statistics type.

This function is ignored if called after cs_lagr_stat_initialize.

Parameters
[in]stat_typeparticle statistics type

◆ cs_lagr_stat_deactivate_attr()

void cs_lagr_stat_deactivate_attr ( int  attr_id)

Deactivate Lagrangian statistics for a given particle attribute.

This function is ignored if called after cs_lagr_stat_initialize.

Parameters
[in]attr_idparticle attribute id

◆ cs_lagr_stat_event_define()

int cs_lagr_stat_event_define ( const char *  name,
int  location_id,
int  stat_type,
cs_lagr_stat_group_t  stat_group,
cs_lagr_stat_moment_t  m_type,
int  class_id,
int  dim,
int  component_id,
cs_lagr_moment_e_data_t data_func,
void *  data_input,
cs_lagr_moment_e_data_t w_data_func,
void *  w_data_input,
int  nt_start,
double  t_start,
cs_lagr_stat_restart_t  restart_mode 
)

Define an event-based statistic.

If dimension > 1, the val array is interleaved

Parameters
[in]namestatistics base name
[in]location_idid of associated mesh location
[in]stat_typepredefined statistics type, or -1
[in]stat_groupstatistics group (event type)
[in]m_typemoment type
[in]class_idparticle class id, or 0 for all
[in]dimdimension associated with element data
[in]component_idattribute component id, or < 0 for all
[in]data_funcpointer to function to compute statistics (if stat_type < 0)
[in]data_inputassociated input
[in]w_data_funcpointer to function to compute weight (if NULL, statistic weight assumed)
[in]w_data_inputassociated input for w_data_func
[in]nt_startstarting time step (or -1 to use t_start, 0 to use idstnt)
[in]t_startstarting time
[in]restart_modebehavior in case of restart (reset, automatic, or strict)
Returns
id of new moment in case of success, -1 in case of error.

◆ cs_lagr_stat_finalize()

void cs_lagr_stat_finalize ( void  )

Destroy all moments management metadata.

◆ cs_lagr_stat_get_age()

cs_real_t cs_lagr_stat_get_age ( void  )

Return global volume statistics age.

Returns
age of volume statistics, or -1 if statistics not active yet

◆ cs_lagr_stat_get_moment()

cs_field_t* cs_lagr_stat_get_moment ( int  stat_type,
cs_lagr_stat_group_t  stat_group,
cs_lagr_stat_moment_t  m_type,
int  class_id,
int  component_id 
)

Return field associated with a given Lagrangian statistic, given a statistics type (i.e. variable), group (particles or event), moment order, statistical class, and component id.

Parameters
[in]stat_typestatistics type
[in]stat_groupstatistics group (particle or event)
[in]m_typemoment type (mean or variance)
[in]class_idparticle statistical class
[in]component_idcomponent id, or -1 for all
Returns
pointer to the field associated to the corresponding moment

◆ cs_lagr_stat_get_moment_age()

cs_real_t cs_lagr_stat_get_moment_age ( cs_field_t f)

Return statistics age for a given moment.

Parameters
[in]ffield associated with given statistic
Returns
age of given statistic, or -1 if not active yet

◆ cs_lagr_stat_get_stat_weight()

cs_field_t* cs_lagr_stat_get_stat_weight ( int  class_id)

Return statistical weight.

Parameters
[in]class_idparticle statistical class
Returns
pointer to the field associated to the corresponding weight

◆ cs_lagr_stat_initialize()

void cs_lagr_stat_initialize ( void  )

Lagrangian statistics initialization.

Statistics activated or deactivated by previous calls to cs_lagr_stat_activate, cs_lagr_stat_deactivate, cs_lagr_stat_activate_attr, and cs_lagr_stat_deactivate_attr will be initialized here.

Restart info will be used after to fill in the moments structure

◆ cs_lagr_stat_is_active()

bool cs_lagr_stat_is_active ( cs_lagr_stat_group_t  group)

Indicate if a given statistics type has active statistics.

Parameters
[in]groupevent group to update
Returns
true if statistics are active for the given group

◆ cs_lagr_stat_log_iteration()

void cs_lagr_stat_log_iteration ( void  )

Log moment definition information for a given iteration.

◆ cs_lagr_stat_log_setup()

void cs_lagr_stat_log_setup ( void  )

Log moment definition setup information.

◆ cs_lagr_stat_map_cell_dt()

void cs_lagr_stat_map_cell_dt ( const cs_real_t dt)

Map time step values array for Lagrangian statistics.

If this function is not called, the field referenced by field pointer CS_F_(dt) will be used instead.

Parameters
[in]dtpointer to time step values array

◆ cs_lagr_stat_mesh_define()

int cs_lagr_stat_mesh_define ( const char *  name,
int  location_id,
cs_lagr_stat_group_t  stat_group,
int  class_id,
int  dim,
cs_lagr_moment_m_data_t data_func,
void *  data_input,
int  nt_start,
double  t_start 
)

Define mesh-based statistic based on particles or particle events.

This type of statistic is reinitialized and evaluated during each time step, but may be computed incrementally when based on particle events, so the associated data function must uptate the statistics without reinitializing them at each call.

As this type of statistic does not need to keep state between time steps, it is ignored by the lagragian statistics checkpoint/restart mechanism.

If dimension > 1, the val array is interleaved

Parameters
[in]namestatistics base name
[in]location_idid of associated mesh location
[in]stat_groupstatistics group (particle or event)
[in]class_idparticle class id, or 0 for all
[in]dimdimension associated with element data
[in]data_funcpointer to function to compute statistics
[in]data_inputassociated input
[in]nt_startstarting time step (or -1 to use t_start, 0 to use idstnt)
[in]t_startstarting time
Returns
id of new moment in case of success, -1 in case of error.

◆ cs_lagr_stat_particle_define()

int cs_lagr_stat_particle_define ( const char *  name,
int  location_id,
int  stat_type,
cs_lagr_stat_moment_t  m_type,
int  class_id,
int  dim,
int  component_id,
cs_lagr_moment_p_data_t data_func,
void *  data_input,
cs_lagr_moment_p_data_t w_data_func,
void *  w_data_input,
int  nt_start,
double  t_start,
cs_lagr_stat_restart_t  restart_mode 
)

Define a particle-based statistic.

If dimension > 1, the val array is interleaved

Parameters
[in]namestatistics base name
[in]location_idid of associated mesh location
[in]stat_typepredefined statistics type, or -1
[in]stat_groupstatistics group (particle or event)
[in]m_typemoment type
[in]class_idparticle class id, or 0 for all
[in]dimdimension associated with element data
[in]component_idattribute component id, or < 0 for all
[in]data_funcpointer to function to compute statistics (if stat_type < 0)
[in]data_inputassociated input
[in]w_data_funcpointer to function to compute weight (if NULL, statistic weight assumed)
[in]w_data_inputassociated input for w_data_func
[in]nt_startstarting time step (or -1 to use t_start, 0 to use idstnt)
[in]t_startstarting time
[in]restart_modebehavior in case of restart (reset, automatic, or strict)
Returns
id of new moment in case of success, -1 in case of error.

(DOXYGEN_SHOULD_SKIP_THIS)

If dimension > 1, the val array is interleaved

Parameters
[in]namestatistics base name
[in]location_idid of associated mesh location
[in]stat_typepredefined statistics type, or -1
[in]m_typemoment type
[in]class_idparticle class id, or 0 for all
[in]dimdimension associated with element data
[in]component_idattribute component id, or < 0 for all
[in]data_funcpointer to function to compute statistics (if stat_type < 0)
[in]data_inputassociated input
[in]w_data_funcpointer to function to compute weight (if NULL, statistic weight assumed)
[in]w_data_inputassociated input for w_data_func
[in]nt_startstarting time step (or -1 to use t_start, 0 to use idstnt)
[in]t_startstarting time
[in]restart_modebehavior in case of restart (reset, automatic, or strict)
Returns
id of new moment in case of success, -1 in case of error.

◆ cs_lagr_stat_prepare()

void cs_lagr_stat_prepare ( void  )

Prepare particle statistics for a given time step.

◆ cs_lagr_stat_restart_read()

void cs_lagr_stat_restart_read ( void  )

Read particle statistics restart info if needed.

◆ cs_lagr_stat_restart_write()

void cs_lagr_stat_restart_write ( cs_restart_t restart)

Checkpoint moment data.

Parameters
[in]restartassociated restart file pointer

◆ cs_lagr_stat_time_moment_define()

int cs_lagr_stat_time_moment_define ( const char *  name,
int  location_id,
int  stat_type,
cs_lagr_stat_moment_t  m_type,
int  class_id,
int  dim,
int  component_id,
cs_lagr_moment_m_data_t data_func,
void *  data_input,
int  nt_start,
double  t_start,
cs_lagr_stat_restart_t  restart_mode 
)

Define a time moment associated to particle statistics.

This is similar to general time moments (see cs_time_moment.c), with restart, logging, and unsteady reinitialization behavior aligned with other particle statistics.

Time moments must be based on values available at the end of each time step, so they cannot be based directly on events (though they can be based on fields defined through cs_lagr_stat_mesh_define, as the matching event-based fields will be updated first).

If dimension > 1, the val array is interleaved

Parameters
[in]namestatistics base name
[in]location_idid of associated mesh location
[in]stat_typepredefined statistics type, or -1
[in]m_typemoment type
[in]class_idparticle class id, or 0 for all
[in]dimdimension associated with element data
[in]component_idattribute component id, or < 0 for all
[in]data_funcpointer to function to compute statistics (if stat_type < 0)
[in]data_inputassociated input
[in]nt_startstarting time step (or -1 to use t_start, 0 to use idstnt)
[in]t_startstarting time
[in]restart_modebehavior in case of restart (reset, automatic, or strict)
Returns
id of new moment in case of success, -1 in case of error.

◆ cs_lagr_stat_type_by_name()

int cs_lagr_stat_type_by_name ( const char *  name)

Determine a basic statistic type by its base name.

Parameters
[in]nameparticle statistics base name (without class id)
Returns
matching stat type id, or -1 if not found

◆ cs_lagr_stat_type_from_attr_id()

int cs_lagr_stat_type_from_attr_id ( int  attr_id)

Return statistics type associated with a given particle attribute id.

Parameters
[in]attr_idparticle attribute id
Returns
associated particle statistics type id

◆ cs_lagr_stat_type_to_attr_id()

int cs_lagr_stat_type_to_attr_id ( int  stat_type)

Return attribute id associated with a given statistics type.

Parameters
[in]stat_typeparticle statistics type
Returns
attribute id, or -1 if not applicable

◆ cs_lagr_stat_update()

void cs_lagr_stat_update ( void  )

Update particle statistics for a given time step.

◆ cs_lagr_stat_update_event()

void cs_lagr_stat_update_event ( cs_lagr_event_set_t events,
cs_lagr_stat_group_t  group 
)

Update event-based moment accumulators.

Partial updates are allowed, so as to balance memory cost for storing events and repetition of mesh-location-based weight updates.

Parameters
[in]eventspointer to event set
[in]groupevent group to update

Partial updates are allowed, so as to balance memory cost for storing events and repetition of mesh-location-based weigh updates.

Parameters
[in]eventspointer to event set
[in]groupevent group to update

Variable Documentation

◆ cs_glob_lagr_stat_options

cs_lagr_stat_options_t* cs_glob_lagr_stat_options