![]() |
programmer's documentation
|
#include "cs_defs.h"
#include <assert.h>
#include <ctype.h>
#include <stdarg.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bft_printf.h"
#include "bft_error.h"
#include "bft_mem.h"
#include "cs_base.h"
#include "cs_file.h"
#include "cs_math.h"
#include "cs_mesh.h"
#include "cs_mesh_location.h"
#include "cs_mesh_quantities.h"
#include "cs_order.h"
#include "cs_parall.h"
#include "cs_restart_default.h"
#include "cs_timer_stats.h"
#include "cs_log.h"
#include "cs_array_reduce.h"
#include "cs_field.h"
#include "cs_field_pointer.h"
#include "cs_lagr_tracking.h"
#include "cs_lagr.h"
#include "cs_lagr_stat.h"
Functions | |
static void | _unit_value_m_cells (const void *input, int location_id, int class_id, cs_real_t vals[]) |
static void | _vol_fraction (const void *input, int location_id, int class_id, cs_real_t vals[]) |
static void | _check_moment_type (int type) |
Check statistics type is in possible range. More... | |
static int | _n_stat_types (void) |
Return number of possible statistics types. More... | |
static void | _statistical_weight_name (int class, char name[64]) |
Create statistical weight. More... | |
static void | _stat_name (int stat_type, int component_id, int class_id, cs_lagr_stat_moment_t moment_type, char name[64]) |
Create statistics name. More... | |
static cs_real_t * | _mwa_val (cs_lagr_moment_wa_t *mwa) |
Return pointer to weight accumulator values. More... | |
static const cs_real_t * | _mwa_const_val (const cs_lagr_moment_wa_t *mwa) |
Return pointer to weight accumulator values. More... | |
static const cs_real_t * | _dt_val (void) |
Return pointer to time step values. More... | |
static void | _assert_restart_success (int retcode) |
static int | _check_restart (const char *name, const cs_time_step_t *ts, cs_lagr_moment_restart_info_t *ri, int location_id, int wa_location_id, int dim, cs_lagr_stat_moment_t moment_type, int stat_type, int class_id, int *nt_start, double *t_start, cs_lagr_stat_restart_t restart_mode) |
static void | _restart_info_read_auxiliary (cs_restart_t *r) |
static void | _restart_info_read (void) |
static void | _restart_info_free (void) |
static void | _cs_lagr_moment_restart_read (void) |
Read restart moment data. More... | |
static void | _init_vars_attribute (void) |
static int | _find_or_add_wa (cs_lagr_moment_p_data_t *p_data_func, cs_lagr_moment_m_data_t *m_data_func, const void *data_input, int class_id, int location_id, int nt_start, double t_start, int prev_wa_id) |
Add or find moment weight and time accumulator. More... | |
static cs_field_t * | _cs_lagr_moment_associate_field (const char *name, int location_id, int dim) |
Create and associate a field to a moment. More... | |
static int | _find_or_add_moment (int location_id, int component_id, int class_id, int stat_type, int dim, cs_lagr_moment_p_data_t *p_data_func, cs_lagr_moment_m_data_t *m_data_func, const void *data_input, cs_lagr_stat_moment_t m_type, int wa_id, int prev_id) |
Add or find moment structure. . More... | |
static void | _cs_lagr_moment_reset (cs_lagr_moment_t *mt) |
Statistics initialization. More... | |
static cs_lnum_t | _n_w_elts (const cs_lagr_moment_wa_t *mwa) |
Return number of elements associated with a weight accumulator. More... | |
static void | _ensure_init_wa (cs_lagr_moment_wa_t *mwa) |
Initialize weight accumulator if required and reset to 0. More... | |
static void | _update_wa_m (cs_lagr_moment_wa_t *mwa, cs_real_t *restrict w) |
Update weight accumulator for a mesh-based weight array. More... | |
static void | _ensure_init_moment (cs_lagr_moment_t *mt) |
Initialize moment value if required. More... | |
static void | _vv_mesh_location_cells (int location_id_y, const cs_real_t x[], cs_real_t y[]) |
Vector-vector multiplication, where the multiplying vector is defined on cells, and the multiplied vector defined on a given mesh location. More... | |
static cs_real_t * | _compute_current_weight_m (cs_lagr_moment_wa_t *mwa, const cs_real_t *restrict dt, cs_real_t w0[1]) |
Compute current weight if weight is based on a mesh (not particle) based function. More... | |
static void | _cs_lagr_moment_reset_unsteady_stats (void) |
Reset unsteady stats. More... | |
static void | _cs_lagr_stat_update_mesh_moment (cs_lagr_moment_t *mt, const cs_lagr_moment_wa_t *mwa, const cs_real_t *restrict w, int nt_cur) |
Update a given mesh based date function moment. More... | |
static void | _cs_lagr_stat_update_all (void) |
Update all moment accumulators. More... | |
static void | _free_all_moments (void) |
static void | _free_all_wa (void) |
Free all moment weight and time accumulators. More... | |
static int | _stat_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 *p_data_func, cs_lagr_moment_m_data_t *m_data_func, void *data_input, cs_lagr_moment_p_data_t *w_p_data_func, cs_lagr_moment_m_data_t *w_m_data_func, void *w_data_input, int nt_start, double t_start, cs_lagr_stat_restart_t restart_mode) |
Define a particle statistic. More... | |
int | cs_lagr_stat_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 statistic. More... | |
int | cs_lagr_stat_accumulator_define (const char *name, int location_id, int class_id, 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 weight type statistic. 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, cs_lagr_moment_m_data_t *w_data_func, void *w_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_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... | |
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... | |
void | cs_lagr_stat_update (void) |
Update particle statistics for a given time step. More... | |
void | cs_lagr_stat_finalize (void) |
Destroy all moments management metadata. 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_t * | cs_lagr_stat_get_moment (int stat_type, 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), moment order, and given a statistics type (i.e. variable), moment order, statistical class, and component id. More... | |
cs_field_t * | cs_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 | |
static bool * | _vol_stat_activate = NULL |
static bool | _restart_info_checked = false |
static cs_lagr_moment_restart_info_t * | _restart_info = NULL |
static cs_lagr_moment_wa_t * | _lagr_stats_wa = NULL |
static cs_lagr_moment_t * | _lagr_stats = NULL |
static int | _n_lagr_stats_wa = 0 |
static int | _n_lagr_stats_wa_max = 0 |
static int | _n_lagr_stats = 0 |
static int | _n_lagr_stats_max = 0 |
static double | _t_prev_iter = 0. |
static const cs_real_t * | _p_dt = NULL |
const char * | cs_lagr_moment_type_name [] |
static cs_lagr_stat_options_t | _lagr_stat_options |
cs_lagr_stat_options_t * | cs_glob_lagr_stat_options = &_lagr_stat_options |
|
static |
|
static |
Check statistics type is in possible range.
[in] | type | moment type |
|
static |
|
static |
Compute current weight if weight is based on a mesh (not particle) based function.
When applicable, this function either returns a pointer to an allocated array, or to w0. If the returned value is different from w0 (i.e. allocated), the caller is responsible for freeing it.
When not applicable (i.e. when no mesh-based weight computation function is defined), NULL is returned.
[in, out] mwa moment weight accumulator [in] dt cell time step values [in, out] w0 pointer to buffer in case weight values is of size 1
|
static |
Create and associate a field to a moment.
[in] | name | field name |
[in] | location_id | mesh location id |
[in] | dim | field dimension |
|
static |
Statistics initialization.
Reset moment to zero Called once for stationnary moments, at every step for non-stationnary statistics
|
static |
Reset unsteady stats.
|
static |
Read restart moment data.
|
static |
Update all moment accumulators.
|
static |
Update a given mesh based date function moment.
[in,out] | mt | pointer to associated moment |
[in] | mwa | pointer to associated weight accumulator |
[in] | w | weight values for current time step |
[in] | nt_cur |
|
static |
Return pointer to time step values.
|
static |
Initialize moment value if required.
[in,out] | mt | moment |
|
static |
Initialize weight accumulator if required and reset to 0.
[in,out] | mwa | moment weight accumulator |
|
static |
Add or find moment structure. .
[in] | location_id | id of associated mesh location |
[in] | component_id | attribute component id, or < 0 for all |
[in] | class_id | statistical class |
[in] | stat_type | statistics type id, or -1 |
[in] | dim | dimension associated with element data |
[in] | p_data_func | particle-based function used to define data values, or NULL |
[in] | m_data_func | mesh-based function used to define data values, or NULL |
[in] | data_input | pointer to optional value or structure to be used by data_func |
[in] | m_type | moment type, mean or variance |
[in] | wa_id | weight accumulator id |
[in] | prev_id | restart moment id |
|
static |
Add or find moment weight and time accumulator.
If no data function is provided, a constant weight of 1 is assumed (this weight will be multiplied by the time step).
Note that if the data_input associated with a data_func pointer is not NULL, the lifecycle of the data pointed to must be handled separately (and the pointer must remain valid throughout the time moment updates).
[in] | m_type | associated moment type |
[in] | p_data_func | particle-based function used to define data values, or NULL |
[in] | m_data_func | mesh-based function used to define data values, or NULL |
[in] | data_input | pointer to optional (untyped) value or structure |
[in] | class_id | statistical class number |
[in] | location_id | associated mesh location id |
[in] | nt_start | starting time step |
[in] | t_start | starting time |
[in] | prev_wa_id | previous weight accumulator id, or -1 |
|
static |
|
static |
Free all moment weight and time accumulators.
|
static |
|
static |
Return pointer to weight accumulator values.
[in] | mwa | pointer to weight accumulator structure |
|
static |
Return pointer to weight accumulator values.
[in] | mwa | pointer to weight accumulator structure |
|
inlinestatic |
Return number of possible statistics types.
|
static |
Return number of elements associated with a weight accumulator.
|
static |
|
static |
|
static |
|
static |
Define a particle statistic.
If dimension > 1, the val array is interleaved
[in] | name | statistics base name |
[in] | location_id | id of associated mesh location |
[in] | stat_type | predefined statistics type, or -1 |
[in] | m_type | moment type |
[in] | class_id | particle class id, or 0 for all |
[in] | dim | dimension associated with element data |
[in] | component_id | attribute component id, or < 0 for all |
[in] | p_data_func | pointer to particle function to compute statistics (if stat_type < 0) |
[in] | m_data_func | pointer to mesh location function to compute statistics (if stat_type < 0) |
[in] | data_input | associated input |
[in] | w_p_data_func | pointer to particle function to compute weight (if NULL, statistic weight assumed) |
[in] | w_m_data_func | pointer to mesh location function to compute weight (if stat_type < 0) |
[in] | w_data_input | associated input for w_data_func |
[in] | nt_start | starting time step (or -1 to use t_start, 0 to use idstnt) |
[in] | t_start | starting time |
[in] | restart_mode | behavior in case of restart (reset, automatic, or strict) |
|
static |
Create statistics name.
[in] | stat_type | particle statistics type |
[in] | component_id | component id, or -1 |
[in] | class_id | statistical class id, or 0 |
[in] | moment_type | moment type |
[out] | name | resulting name |
|
static |
Create statistical weight.
[in] | class | statistical class id, or 0 |
[out] | name | resulting name |
|
static |
Update weight accumulator for a mesh-based weight array.
[in,out] | mwa | moment weight accumulator |
[in] | pointer | to current weight values |
|
static |
|
static |
Vector-vector multiplication, where the multiplying vector is defined on cells, and the multiplied vector defined on a given mesh location.
[in] | location_id_y | location id for y |
[in] | x | multiplier array |
[in,out] | y | multiplied array |
int cs_lagr_stat_accumulator_define | ( | const char * | name, |
int | location_id, | ||
int | class_id, | ||
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 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.
[in] | name | statistics base name |
[in] | location_id | id of associated mesh location |
[in] | class_id | particle class id, or 0 for all |
[in] | w_data_func | pointer to function to compute particle weight (if NULL, statistic weight assumed) |
[in] | w_data_input | associated input for w_data_func |
[in] | nt_start | starting time step (or -1 to use t_start, 0 to use idstnt) |
[in] | t_start | starting time |
[in] | restart_mode | behavior in case of restart (reset, automatic, or strict) |
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.
[in] | stat_type_id | particle statistics type |
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.
[in] | attr_id | particle attribute id |
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.
[in] | stat_type | particle statistics type |
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.
[in] | attr_id | particle attribute id |
int cs_lagr_stat_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 statistic.
(DOXYGEN_SHOULD_SKIP_THIS)
If dimension > 1, the val array is interleaved
[in] | name | statistics base name |
[in] | location_id | id of associated mesh location |
[in] | stat_type | predefined statistics type, or -1 |
[in] | m_type | moment type |
[in] | class | particle class id, or 0 for all |
[in] | dim | dimension associated with element data |
[in] | component_id | attribute component id, or < 0 for all |
[in] | data_func | pointer to function to compute statistics (if stat_type < 0) |
[in] | data_input | associated input |
[in] | w_data_func | pointer to function to compute weight (if NULL, statistic weight assumed) |
[in] | w_data_input | associated input for w_data_func |
[in] | nt_start | starting time step (or -1 to use t_start, 0 to use idstnt) |
[in] | t_start | starting time |
[in] | restart_mode | behavior in case of restart (reset, automatic, or strict) |
void cs_lagr_stat_finalize | ( | void | ) |
Destroy all moments management metadata.
cs_real_t cs_lagr_stat_get_age | ( | void | ) |
Return global volume statistics age.
cs_field_t* cs_lagr_stat_get_moment | ( | int | stat_type, |
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), moment order, and given a statistics type (i.e. variable), moment order, statistical class, and component id.
Return field associated with a given Lagrangian statistic, given a statistics type (i.e. variable), moment order, statistical class, and component id.
[in] | stat_type | statistics type |
[in] | m_type | moment type (mean or variance) |
[in] | class_id | particle statistical class |
[in] | component_id | component id, or -1 for all |
cs_real_t cs_lagr_stat_get_moment_age | ( | cs_field_t * | f | ) |
Return statistics age for a given moment.
[in] | f | field associated with given statistic |
cs_field_t* cs_lagr_stat_get_stat_weight | ( | int | class_id | ) |
Return statistical weight.
[in] | class_id | particle statistical class |
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
void cs_lagr_stat_log_iteration | ( | void | ) |
Log moment definition information for a given iteration.
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.
[in] | dt | pointer to time step values array |
void cs_lagr_stat_restart_write | ( | cs_restart_t * | restart | ) |
Checkpoint moment data.
[in] | restart | associated restart file pointer |
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, | ||
cs_lagr_moment_m_data_t * | w_data_func, | ||
void * | w_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 similar to other particle statistics.
If dimension > 1, the val array is interleaved
[in] | name | statistics base name |
[in] | location_id | id of associated mesh location |
[in] | stat_type | predefined statistics type, or -1 |
[in] | m_type | moment type |
[in] | class_id | particle class id, or 0 for all |
[in] | dim | dimension associated with element data |
[in] | component_id | attribute component id, or < 0 for all |
[in] | data_func | pointer to function to compute statistics (if stat_type < 0) |
[in] | data_input | associated input |
[in] | w_data_func | pointer to function to compute weight (if NULL, statistic weight assumed) |
[in] | w_data_input | associated input for w_data_func |
[in] | nt_start | starting time step (or -1 to use t_start, 0 to use idstnt) |
[in] | t_start | starting time |
[in] | restart_mode | behavior in case of restart (reset, automatic, or strict) |
int cs_lagr_stat_type_from_attr_id | ( | int | attr_id | ) |
Return statistics type associated with a given particle attribute id.
[in] | attr_id | particle attribute id |
int cs_lagr_stat_type_to_attr_id | ( | int | stat_type | ) |
Return attribute id associated with a given statistics type.
[in] | stat_type | particle statistics type |
void cs_lagr_stat_update | ( | void | ) |
Update particle statistics for a given time step.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
cs_lagr_stat_options_t* cs_glob_lagr_stat_options = &_lagr_stat_options |