My Project
programmer's documentation
Functions | Variables
cs_time_moment.c File Reference

Temporal moments management. More...

#include "cs_defs.h"
#include <assert.h>
#include <stdarg.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bft_error.h"
#include "bft_mem.h"
#include "bft_printf.h"
#include "cs_array_reduce.h"
#include "cs_base.h"
#include "cs_field.h"
#include "cs_field_pointer.h"
#include "cs_log.h"
#include "cs_mesh.h"
#include "cs_mesh_location.h"
#include "cs_parall.h"
#include "cs_restart.h"
#include "cs_restart_default.h"
#include "cs_prototypes.h"
#include "cs_time_step.h"
#include "cs_time_moment.h"
Include dependency graph for cs_time_moment.c:

Functions

void cs_time_moment_destroy_all (void)
 Destroy all moments management metadata. More...
 
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. More...
 
int cs_time_moment_define_by_func (const char *name, int location_id, int dim, 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. More...
 
int cs_time_moment_n_moments (void)
 Return the number of defined time moments. More...
 
int cs_time_moment_n_moments_restart (void)
 Return the number of time moments in the restart file, if any. More...
 
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. More...
 
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). More...
 
cs_field_tcs_time_moment_get_field (int moment_id)
 Return pointer to field associated with a given moment. More...
 
int cs_time_moment_is_active (int moment_id)
 Return 1 if moment is active, 0 if it is not active yet. More...
 
void cs_time_moment_reset (int moment_id)
 Reset a time moment. More...
 
void cs_time_moment_map_cell_dt (const cs_real_t *dt)
 Map time step values array for temporal moments. More...
 
void cs_time_moment_update_all (void)
 Update all moment accumulators. More...
 
void cs_time_moment_log_setup (void)
 Log moment definition setup information. More...
 
void cs_time_moment_log_iteration (void)
 Log moment definition information for a given iteration. More...
 
void cs_time_moment_restart_use_main (int use_main)
 Indicate if restart API should use "main" instead of "auxiliary" file. More...
 
void cs_time_moment_restart_read (cs_restart_t *restart)
 Read restart moment data. More...
 
void cs_time_moment_restart_write (cs_restart_t *restart)
 Checkpoint moment data. More...
 

Variables

const char * cs_time_moment_type_name []
 

Detailed Description

Temporal moments management.

Function Documentation

◆ cs_time_moment_define_by_field_ids()

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.

Define a moment of a product of existing field 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.

Parameters
[in]namename of associated moment
[in]n_fieldsnumber of associated fields
[in]field_idids of associated fields
[in]component_idids of matching field components (-1 for all)
[in]typemoment type
[in]nt_startstarting time step (or -1 to use t_start)
[in]t_startstarting time
[in]restart_modebehavior in case of restart (reset, automatic, or strict)
[in]restart_nameif not NULL, previous name in case of restart
Returns
id of new moment in case of success, -1 in case of error.

◆ cs_time_moment_define_by_func()

int cs_time_moment_define_by_func ( const char *  name,
int  location_id,
int  dim,
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.

Parameters
[in]namename of associated moment
[in]location_idid of associated mesh location
[in]dimdimension associated with element data
[in]data_funcfunction used to define data values
[in]data_inputpointer to optional (untyped) value or structure to be used by data_func
[in]w_data_funcfunction used to define weight values
[in]w_data_inputpointer to optional (untyped) value or structure to be used by w_data_func
[in]typemoment type
[in]nt_startstarting time step (or -1 to use t_start)
[in]t_startstarting time
[in]restart_modebehavior in case of restart (reset, automatic, or strict)
[in]restart_nameif not NULL, previous name in case of restart
Returns
id of new moment in case of success, -1 in case of error.

◆ cs_time_moment_destroy_all()

void cs_time_moment_destroy_all ( void  )

Destroy all moments management metadata.

◆ cs_time_moment_get_field()

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, NULL is returned.

Parameters
[in]moment_idid of associated moment
Returns
pointer to field associated with given moment, or NULL

◆ cs_time_moment_is_active()

int cs_time_moment_is_active ( int  moment_id)

Return 1 if moment is active, 0 if it is not active yet.

Parameters
[in]moment_idid of associated moment
Returns
1 if moment is active, 0 if it is not active yet

◆ cs_time_moment_log_iteration()

void cs_time_moment_log_iteration ( void  )

Log moment definition information for a given iteration.

◆ cs_time_moment_log_setup()

void cs_time_moment_log_setup ( void  )

Log moment definition setup information.

◆ cs_time_moment_map_cell_dt()

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.

Parameters
[in]dtpointer to time step values array

◆ cs_time_moment_n_moments()

int cs_time_moment_n_moments ( void  )

Return the number of defined time moments.

Returns
number of defined time moments

◆ cs_time_moment_n_moments_restart()

int cs_time_moment_n_moments_restart ( void  )

Return the number of time moments in the restart file, if any.

Returns
number of defined moments in restart file, or 0

◆ cs_time_moment_reset()

void cs_time_moment_reset ( int  moment_id)

Reset a time moment.

Parameters
[in]moment_idid of associated moment

◆ cs_time_moment_restart_name()

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).

Parameters
[in]restart_idid of time moment in restart data
Returns
name of defined moment in restart file, or NULL

◆ cs_time_moment_restart_options_by_id()

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).

Parameters
[in]restart_id-2: automatic, -1: reset, >= 0: id of matching moment in restart data
[out]restart_modematching restart mode
[out]restart_namematching restart name

◆ cs_time_moment_restart_read()

void cs_time_moment_restart_read ( cs_restart_t restart)

Read restart moment data.

Parameters
[in]restartassociated restart file pointer

◆ cs_time_moment_restart_use_main()

void cs_time_moment_restart_use_main ( int  use_main)

Indicate if restart API should use "main" instead of "auxiliary" file.

Parameters
[in]use_mainuse "main" restart if nonzero, "auxiliary" otherwise

◆ cs_time_moment_restart_write()

void cs_time_moment_restart_write ( cs_restart_t restart)

Checkpoint moment data.

Parameters
[in]restartassociated restart file pointer

◆ cs_time_moment_update_all()

void cs_time_moment_update_all ( void  )

Update all moment accumulators.

Variable Documentation

◆ cs_time_moment_type_name

const char* cs_time_moment_type_name[]
Initial value:
= {N_("mean"),
N_("variance")}
N_
#define N_(String)
Definition: cs_defs.h:56