Temporal moments management. More...
#include "base/cs_defs.h"
#include <assert.h>
#include <stdarg.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bft/bft_error.h"
#include "bft/bft_printf.h"
#include "base/cs_array.h"
#include "base/cs_array_reduce.h"
#include "base/cs_base.h"
#include "base/cs_field.h"
#include "base/cs_field_pointer.h"
#include "base/cs_log.h"
#include "base/cs_halo.h"
#include "base/cs_halo_perio.h"
#include "base/cs_mem.h"
#include "mesh/cs_mesh.h"
#include "mesh/cs_mesh_location.h"
#include "base/cs_parall.h"
#include "base/cs_restart.h"
#include "base/cs_restart_default.h"
#include "base/cs_prototypes.h"
#include "base/cs_time_step.h"
#include "base/cs_function.h"
#include "base/cs_time_moment.h"
Functions | |
void | cs_time_moment_destroy_all (void) |
Destroy all moments management metadata. | |
int | cs_time_moment_define_by_field_ids (const char *name, int n_fields, const int field_id[], const int component_id[], cs_time_moment_type_t type, int nt_start, double t_start, cs_time_moment_restart_t restart_mode, const char *restart_name) |
Define a moment of a product of existing fields components. | |
int | cs_time_moment_define_by_field (const char *name, const cs_field_t *f, cs_time_moment_type_t type, int nt_start, double t_start, cs_time_moment_restart_t restart_mode, const char *restart_name) |
Define a time moment of an existing field. | |
int | cs_time_moment_define_by_function (const char *name, cs_function_t *f, cs_time_moment_type_t type, int nt_start, double t_start, cs_time_moment_restart_t restart_mode, const char *restart_name) |
Define a time moment based on an evaluation function. | |
int | cs_time_moment_define_by_func (const char *name, int location_id, int dim, bool is_intensive, cs_time_moment_data_t *data_func, const void *data_input, cs_time_moment_data_t *w_data_func, void *w_data_input, cs_time_moment_type_t type, int nt_start, double t_start, cs_time_moment_restart_t restart_mode, const char *restart_name) |
Define a moment whose data values will be computed using a specified function. | |
int | cs_time_moment_n_moments (void) |
Return the number of defined time moments. | |
int | cs_time_moment_n_moments_restart (void) |
Return the number of time moments in the restart file, if any. | |
void | cs_time_moment_restart_options_by_id (int restart_id, cs_time_moment_restart_t *restart_mode, const char **restart_name) |
Define a moment restart mode and name by an id. | |
const char * | cs_time_moment_restart_name (int restart_id) |
Return name of a given time moments in the restart file, if any (check also cs_time_moment_n_moments_restart). | |
cs_field_t * | cs_time_moment_get_field (int moment_id) |
Return pointer to field associated with a given moment. | |
void | cs_time_moment_set_start_time (int moment_id, int nt_start) |
Reset selected time step for starting time step of selected moment. | |
void | cs_time_moment_set_start_time (int moment_id, double t_start) |
Reset selected time step for starting time step of selected moment. | |
int | cs_time_moment_is_active (int moment_id) |
Return 1 if moment is active, 0 if it is not active yet. | |
void | cs_time_moment_reset (int moment_id) |
Set current iteration as starting time step of selected moment. | |
void | cs_time_moment_map_cell_dt (const cs_real_t *dt) |
Map time step values array for temporal moments. | |
void | cs_time_moment_update_all (void) |
Update all moment accumulators. | |
void | cs_time_moment_log_setup (void) |
Log moment definition setup information. | |
void | cs_time_moment_log_iteration (void) |
Log moment definition information for a given iteration. | |
void | cs_time_moment_restart_use_main (int use_main) |
Indicate if restart API should use "main" instead of "auxiliary" file. | |
void | cs_time_moment_restart_read (cs_restart_t *restart) |
Read restart moment data. | |
void | cs_time_moment_restart_write (cs_restart_t *restart) |
Checkpoint moment data. |
Variables | |
const char * | cs_time_moment_type_name [] |
Temporal moments management.
int cs_time_moment_define_by_field | ( | const char * | name, |
const cs_field_t * | f, | ||
cs_time_moment_type_t | type, | ||
int | nt_start, | ||
double | t_start, | ||
cs_time_moment_restart_t | restart_mode, | ||
const char * | restart_name ) |
Define a time moment of an existing field.
Moments will involve the tensor products of their component fields, and only scalar, vector, or rank-2 tensors are handled (for post-processing output reasons), so a 1st-order moment (i.e. mean) may involve a scalar, vector, or tensor, while a second-order moment (i.e. variance) may only involve a scalar or vector.
[in] | name | name of associated moment |
[in] | f | pointer to associated field |
[in] | type | moment type |
[in] | nt_start | starting time step (or -1 to use t_start) |
[in] | t_start | starting time |
[in] | restart_mode | behavior in case of restart (reset, automatic, or strict) |
[in] | restart_name | if non-null, previous name in case of restart |
int cs_time_moment_define_by_field_ids | ( | const char * | name, |
int | n_fields, | ||
const int | field_id[], | ||
const int | component_id[], | ||
cs_time_moment_type_t | type, | ||
int | nt_start, | ||
double | t_start, | ||
cs_time_moment_restart_t | restart_mode, | ||
const char * | restart_name ) |
Define a moment of a product of existing fields components.
Moments will involve the tensor products of their component fields, and only scalar, vector, or rank-2 tensors are handled (for post-processing output reasons), so a moment may not involve more than 2 vectors or 1 tensor, unless single components are specified.
[in] | name | name of associated moment |
[in] | n_fields | number of associated fields |
[in] | field_id | ids of associated fields |
[in] | component_id | ids of matching field components (-1 for all) |
[in] | type | moment type |
[in] | nt_start | starting time step (or -1 to use t_start) |
[in] | t_start | starting time |
[in] | restart_mode | behavior in case of restart (reset, automatic, or strict) |
[in] | restart_name | if non-null, previous name in case of restart |
int cs_time_moment_define_by_func | ( | const char * | name, |
int | location_id, | ||
int | dim, | ||
bool | is_intensive, | ||
cs_time_moment_data_t * | data_func, | ||
const void * | data_input, | ||
cs_time_moment_data_t * | w_data_func, | ||
void * | w_data_input, | ||
cs_time_moment_type_t | type, | ||
int | nt_start, | ||
double | t_start, | ||
cs_time_moment_restart_t | restart_mode, | ||
const char * | restart_name ) |
Define a moment whose data values will be computed using a specified function.
[in] | name | name of associated moment |
[in] | location_id | id of associated mesh location |
[in] | dim | dimension associated with element data |
[in] | is_intensive | is the time moment intensive? |
[in] | data_func | function used to define data values |
[in] | data_input | pointer to optional (untyped) value or structure to be used by data_func |
[in] | w_data_func | function used to define weight values |
[in] | w_data_input | pointer to optional (untyped) value or structure to be used by w_data_func |
[in] | type | moment type |
[in] | nt_start | starting time step (or -1 to use t_start) |
[in] | t_start | starting time |
[in] | restart_mode | behavior in case of restart (reset, automatic, or strict) |
[in] | restart_name | if non-null, previous name in case of restart |
int cs_time_moment_define_by_function | ( | const char * | name, |
cs_function_t * | f, | ||
cs_time_moment_type_t | type, | ||
int | nt_start, | ||
double | t_start, | ||
cs_time_moment_restart_t | restart_mode, | ||
const char * | restart_name ) |
Define a time moment based on an evaluation function.
Moments will involve the tensor products of their component fields, and only scalar, vector, or rank-2 tensors are handled (for post-processing output reasons), so a 1st-order moment (i.e. mean) may involve a scalar, vector, or tensor, while a second-order moment (i.e. variance) may only involve a scalar or vector.
[in] | name | name of associated moment |
[in] | f | pointer to function object |
[in] | type | moment type |
[in] | nt_start | starting time step (or -1 to use t_start) |
[in] | t_start | starting time |
[in] | restart_mode | behavior in case of restart (reset, automatic, or strict) |
[in] | restart_name | if non-null, previous name in case of restart |
void cs_time_moment_destroy_all | ( | void | ) |
Destroy all moments management metadata.
cs_field_t * cs_time_moment_get_field | ( | int | moment_id | ) |
Return pointer to field associated with a given moment.
For moments defined automatically to assist computation of higher order moments, which do not have an associated field, a null pointer is returned.
[in] | moment_id | id of associated moment |
int cs_time_moment_is_active | ( | int | moment_id | ) |
Return 1 if moment is active, 0 if it is not active yet.
[in] | moment_id | id of associated moment |
void cs_time_moment_log_iteration | ( | void | ) |
Log moment definition information for a given iteration.
void cs_time_moment_log_setup | ( | void | ) |
Log moment definition setup information.
void cs_time_moment_map_cell_dt | ( | const cs_real_t * | dt | ) |
Map time step values array for temporal moments.
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 |
int cs_time_moment_n_moments | ( | void | ) |
Return the number of defined time moments.
int cs_time_moment_n_moments_restart | ( | void | ) |
Return the number of time moments in the restart file, if any.
void cs_time_moment_reset | ( | int | moment_id | ) |
Set current iteration as starting time step of selected moment.
All other time moments sharing the same start time should also be reset.
[in] | moment_id | id of associated moment |
const char * cs_time_moment_restart_name | ( | int | restart_id | ) |
Return name of a given time moments in the restart file, if any (check also cs_time_moment_n_moments_restart).
[in] | restart_id | id of time moment in restart data |
void cs_time_moment_restart_options_by_id | ( | int | restart_id, |
cs_time_moment_restart_t * | restart_mode, | ||
const char ** | restart_name ) |
Define a moment restart mode and name by an id.
This is a utility function, to allow simplification of automatic setups. It must be called just before defining a moment to work properly if restart_id < -1 (automatic mode).
[in] | restart_id | -2: automatic, -1: reset, >= 0: id of matching moment in restart data |
[out] | restart_mode | matching restart mode |
[out] | restart_name | matching restart name |
void cs_time_moment_restart_read | ( | cs_restart_t * | restart | ) |
Read restart moment data.
[in] | restart | associated restart file pointer |
void cs_time_moment_restart_use_main | ( | int | use_main | ) |
Indicate if restart API should use "main" instead of "auxiliary" file.
[in] | use_main | use "main" restart if nonzero, "auxiliary" otherwise |
void cs_time_moment_restart_write | ( | cs_restart_t * | restart | ) |
Checkpoint moment data.
[in] | restart | associated restart file pointer |
void cs_time_moment_set_start_time | ( | int | moment_id, |
double | t_start ) |
Reset selected time step for starting time step of selected moment.
All other time moments sharing the same start time will also start at the same time step.
[in] | moment_id | id of associated moment, or -1 for all |
[in] | nt_start | starting time value |
void cs_time_moment_set_start_time | ( | int | moment_id, |
int | nt_start ) |
Reset selected time step for starting time step of selected moment.
All other time moments sharing the same start time will also start at the same time step.
[in] | moment_id | id of associated moment, or -1 for all |
[in] | nt_start | starting time step |
void cs_time_moment_update_all | ( | void | ) |
Update all moment accumulators.