My Project
programmer's documentation
|
#include "cs_defs.h"
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <mpi.h>
#include "bft_mem.h"
#include "bft_error.h"
#include "bft_printf.h"
#include "fvm_io_num.h"
#include "cs_base.h"
#include "cs_block_dist.h"
#include "cs_block_to_part.h"
#include "cs_file.h"
#include "cs_io.h"
#include "cs_mesh.h"
#include "cs_mesh_save.h"
#include "cs_mesh_location.h"
#include "cs_part_to_block.h"
#include "cs_parall.h"
#include "cs_timer.h"
#include "cs_time_step.h"
#include "cs_restart.h"
Functions | |
void | CS_PROCF (dflsui, DFLSUI) |
void | CS_PROCF (reqsui, REQSUI) |
void | CS_PROCF (stusui, STUSUI) |
void | CS_PROCF (trbsui, TRBSUI) |
void | CS_PROCF (indsui, INDSUI) |
void | cs_restart_checkpoint_set_defaults (int nt_interval, double t_interval, double wt_interval) |
Define default checkpoint interval. More... | |
void | cs_restart_checkpoint_set_mesh_mode (int mode) |
Define checkpoint behavior for mesh. More... | |
void | cs_restart_checkpoint_set_last_ts (int nt_last) |
Define last forced checkpoint time step. More... | |
void | cs_restart_checkpoint_set_next_ts (int nt_next) |
Define next forced checkpoint time step. More... | |
void | cs_restart_checkpoint_set_next_tv (double t_next) |
Define next forced checkpoint time value. More... | |
void | cs_restart_checkpoint_set_next_wt (double wt_next) |
Define next forced checkpoint wall-clock time value. More... | |
bool | cs_restart_checkpoint_required (const cs_time_step_t *ts) |
Check if checkpointing is recommended at a given time. More... | |
void | cs_restart_checkpoint_done (const cs_time_step_t *ts) |
Indicate checkpointing has been done at a given time. More... | |
int | cs_restart_present (void) |
Check if we have a restart directory. More... | |
cs_restart_t * | cs_restart_create (const char *name, const char *path, cs_restart_mode_t mode) |
Initialize a restart file. More... | |
void | cs_restart_destroy (cs_restart_t **restart) |
Destroy structure associated with a restart file (and close the file). More... | |
void | cs_restart_check_base_location (const cs_restart_t *restart, bool *match_cell, bool *match_i_face, bool *match_b_face, bool *match_vertex) |
Check the locations associated with a restart file. More... | |
int | cs_restart_add_location (cs_restart_t *restart, const char *location_name, cs_gnum_t n_glob_ents, cs_lnum_t n_ents, const cs_gnum_t *ent_global_num) |
Add a location definition. More... | |
void | cs_restart_add_location_ref (const char *location_name, cs_gnum_t n_glob_ents, cs_lnum_t n_ents, const cs_gnum_t *ent_global_num) |
Add a reference location definition with a private copy. More... | |
void | cs_restart_clear_locations_ref (void) |
Clear reference location definitions with a private copy. More... | |
void | cs_restart_set_context (void *context) |
Associate a context to restart section check operations. More... | |
cs_restart_check_section_t * | cs_restart_set_check_section_func (cs_restart_check_section_t *func) |
Associate a function to restart section check operations. More... | |
cs_restart_read_section_t * | cs_restart_set_read_section_func (cs_restart_read_section_t *func) |
Associate a function and its input to all restart section read operations. More... | |
cs_restart_write_section_t * | cs_restart_set_write_section_func (cs_restart_write_section_t *func) |
Associate a function and its input to all restart section write operations. More... | |
const char * | cs_restart_get_name (const cs_restart_t *restart) |
Return name of restart file. More... | |
cs_lnum_t | cs_restart_get_n_location_elts (const cs_restart_t *restart, int location_id) |
Return local number of elements associated with a given restart location. More... | |
void | cs_restart_dump_index (const cs_restart_t *restart) |
Print the index associated with a restart file in read mode. More... | |
int | cs_restart_check_section (cs_restart_t *restart, const char *sec_name, int location_id, int n_location_vals, cs_restart_val_type_t val_type) |
Check the presence of a given section in a restart file. More... | |
int | cs_restart_read_section (cs_restart_t *restart, const char *sec_name, int location_id, int n_location_vals, cs_restart_val_type_t val_type, void *val) |
Read a section from a restart file. More... | |
void | cs_restart_write_section (cs_restart_t *restart, const char *sec_name, int location_id, int n_location_vals, cs_restart_val_type_t val_type, const void *val) |
Write a section to a restart file. More... | |
int | cs_restart_read_particles_info (cs_restart_t *restart, const char *name, cs_lnum_t *n_particles) |
Read basic particles information from a restart file. More... | |
int | cs_restart_read_particles (cs_restart_t *restart, int particles_location_id, cs_lnum_t *particle_cell_id, cs_real_t *particle_coords) |
Read basic particles information from a restart file. More... | |
int | cs_restart_write_particles (cs_restart_t *restart, const char *name, bool number_by_coords, cs_lnum_t n_particles, const cs_lnum_t *particle_cell_id, const cs_real_t *particle_coords) |
Write basic particles information to a restart file. More... | |
int | cs_restart_read_ids (cs_restart_t *restart, const char *sec_name, int location_id, int ref_location_id, cs_lnum_t ref_id_base, cs_lnum_t *ref_id) |
Read a referenced location id section from a restart file. More... | |
void | cs_restart_write_ids (cs_restart_t *restart, const char *sec_name, int location_id, int ref_location_id, cs_lnum_t ref_id_base, const cs_lnum_t *ref_id) |
Write a referenced location id section to a restart file. More... | |
int | cs_restart_read_section_compat (cs_restart_t *restart, const char *sec_name, const char *old_name, int location_id, int n_location_vals, cs_restart_val_type_t val_type, void *val) |
Read a section from a restart file, when that section may have used a different name in a previous version. More... | |
int | cs_restart_read_real_3_t_compat (cs_restart_t *restart, const char *sec_name, const char *old_name_x, const char *old_name_y, const char *old_name_z, int location_id, cs_real_3_t *val) |
Read a cs_real_3_t vector section from a restart file, when that section may have used a different name and been non-interleaved in a previous version. More... | |
int | cs_restart_read_real_6_t_compat (cs_restart_t *restart, const char *sec_name, const char *old_name_xx, const char *old_name_yy, const char *old_name_zz, const char *old_name_xy, const char *old_name_yz, const char *old_name_xz, int location_id, cs_real_6_t *val) |
Read a cs_real_6_t tensor section from a restart file, when that section may have used a different name and been non-interleaved in a previous version. More... | |
int | cs_restart_read_real_66_t_compat (cs_restart_t *restart, const char *sec_name, const char *old_name_xx, const char *old_name_yy, const char *old_name_zz, const char *old_name_xy, const char *old_name_yz, const char *old_name_xz, int location_id, cs_real_66_t *val) |
Read a cs_real_66_t tensor section from a restart file, when that section may have used a different name and been non-interleaved in a previous version. More... | |
void | cs_restart_print_stats (void) |
Print statistics associated with restart files. More... | |
Manage checkpoint / restart files.
void CS_PROCF | ( | dflsui | , |
DFLSUI | |||
) |
void CS_PROCF | ( | indsui | , |
INDSUI | |||
) |
void CS_PROCF | ( | reqsui | , |
REQSUI | |||
) |
void CS_PROCF | ( | stusui | , |
STUSUI | |||
) |
void CS_PROCF | ( | trbsui | , |
TRBSUI | |||
) |
int cs_restart_add_location | ( | cs_restart_t * | restart, |
const char * | location_name, | ||
cs_gnum_t | n_glob_ents, | ||
cs_lnum_t | n_ents, | ||
const cs_gnum_t * | ent_global_num | ||
) |
Add a location definition.
[in] | restart | associated restart file pointer |
[in] | location_name | name associated with the location |
[in] | n_glob_ents | global number of entities |
[in] | n_ents | local number of entities |
[in] | ent_global_num | global entity numbers, or NULL |
void cs_restart_add_location_ref | ( | const char * | location_name, |
cs_gnum_t | n_glob_ents, | ||
cs_lnum_t | n_ents, | ||
const cs_gnum_t * | ent_global_num | ||
) |
Add a reference location definition with a private copy.
[in] | location_name | name associated with the location |
[in] | n_glob_ents | global number of entities |
[in] | n_ents | local number of entities |
[in] | ent_global_num | global entity numbers, or NULL |
void cs_restart_check_base_location | ( | const cs_restart_t * | restart, |
bool * | match_cell, | ||
bool * | match_i_face, | ||
bool * | match_b_face, | ||
bool * | match_vertex | ||
) |
Check the locations associated with a restart file.
For each type of entity, the corresponding flag is set to true if the associated number of entities matches the current value (and so that we consider the mesh locations are the same), false otherwise.
[out] | restart | associated restart file pointer |
[out] | match_cell | matching cells flag |
[out] | match_i_face | matching interior faces flag |
[out] | match_b_face | matching boundary faces flag |
[out] | match_vertex | matching vertices flag |
int cs_restart_check_section | ( | cs_restart_t * | restart, |
const char * | sec_name, | ||
int | location_id, | ||
int | n_location_vals, | ||
cs_restart_val_type_t | val_type | ||
) |
Check the presence of a given section in a restart file.
[in] | restart | associated restart file pointer |
[in] | sec_name | section name |
[in] | location_id | id of corresponding location |
[in] | n_location_vals | number of values per location (interlaced) |
[in] | val_type | value type |
void cs_restart_checkpoint_done | ( | const cs_time_step_t * | ts | ) |
Indicate checkpointing has been done at a given time.
This updates the status for future checks to determine if checkpointing is recommended at a given time.
[in] | ts | time step status structure |
bool cs_restart_checkpoint_required | ( | const cs_time_step_t * | ts | ) |
Check if checkpointing is recommended at a given time.
[in] | ts | time step status structure |
void cs_restart_checkpoint_set_defaults | ( | int | nt_interval, |
double | t_interval, | ||
double | wt_interval | ||
) |
Define default checkpoint interval.
[in] | nt_interval | if > 0 time step interval for checkpoint if 0, default of 4 checkpoints per run if -1, checkpoint at end if -2, no checkpointing |
[in] | t_interval | if > 0, time value interval for checkpoint |
[in] | wt_interval | if > 0, wall-clock interval for checkpoints |
void cs_restart_checkpoint_set_last_ts | ( | int | nt_last | ) |
Define last forced checkpoint time step.
[in] | nt_last | last time step for forced checkpoint |
void cs_restart_checkpoint_set_mesh_mode | ( | int | mode | ) |
Define checkpoint behavior for mesh.
If mesh checkpointing is active (default), upon writing the first checkpoint file of a computation, a mesh_output file is moved to checkpoint/mesh_input if present. If not present but a mesh_input file (or link to file) is present, a hard link to that file is added as checkpoint/mesh_input.
A mesh_input directory is ignored, as it is normally only created when multiple input files are appended, which leads to the output and thus presence of a mesh_output file, unless explicitely deactivated by the user.
[in] | mode | if 0, do not checkpoint mesh if 1, checkpoint mesh_output or mesh_input file |
void cs_restart_checkpoint_set_next_ts | ( | int | nt_next | ) |
Define next forced checkpoint time step.
[in] | nt_next | next time step for forced checkpoint |
void cs_restart_checkpoint_set_next_tv | ( | double | t_next | ) |
Define next forced checkpoint time value.
[in] | t_next | next time value for forced checkpoint |
void cs_restart_checkpoint_set_next_wt | ( | double | wt_next | ) |
Define next forced checkpoint wall-clock time value.
[in] | wt_next | next wall-clock time value for forced checkpoint |
void cs_restart_clear_locations_ref | ( | void | ) |
Clear reference location definitions with a private copy.
cs_restart_t* cs_restart_create | ( | const char * | name, |
const char * | path, | ||
cs_restart_mode_t | mode | ||
) |
Initialize a restart file.
[in] | name | file name |
[in] | path | optional directory name for output, or NULL for default (directory automatically created if necessary) |
[in] | mode | read or write |
void cs_restart_destroy | ( | cs_restart_t ** | restart | ) |
Destroy structure associated with a restart file (and close the file).
[in,out] | restart | pointer to restart file structure pointer |
void cs_restart_dump_index | ( | const cs_restart_t * | restart | ) |
Print the index associated with a restart file in read mode.
[in] | restart | associated restart file pointer |
cs_lnum_t cs_restart_get_n_location_elts | ( | const cs_restart_t * | restart, |
int | location_id | ||
) |
Return local number of elements associated with a given restart location.
[in] | restart | associated restart file pointer |
[in] | location_id | id of corresponding location |
const char* cs_restart_get_name | ( | const cs_restart_t * | restart | ) |
Return name of restart file.
[in] | restart | associated restart file pointer |
int cs_restart_present | ( | void | ) |
Check if we have a restart directory.
void cs_restart_print_stats | ( | void | ) |
Print statistics associated with restart files.
int cs_restart_read_ids | ( | cs_restart_t * | restart, |
const char * | sec_name, | ||
int | location_id, | ||
int | ref_location_id, | ||
cs_lnum_t | ref_id_base, | ||
cs_lnum_t * | ref_id | ||
) |
Read a referenced location id section from a restart file.
The section read from file contains the global ids matching the local element ids of a given location. Global id's are transformed to local ids by this function.
In case global referenced ids read do not match those of local elements, id_base - 1 is assigned to the corresponding local ids.
[in] | restart | associated restart file pointer |
[in] | sec_name | section name |
[in] | location_id | id of location on which id_ref is defined |
[in] | ref_location_id | id of referenced location |
[in] | ref_id_base | base of location entity id numbers (usually 0 or 1) |
[out] | ref_id | array of location entity ids |
int cs_restart_read_particles | ( | cs_restart_t * | restart, |
int | particles_location_id, | ||
cs_lnum_t * | particle_cell_id, | ||
cs_real_t * | particle_coords | ||
) |
Read basic particles information from a restart file.
[in] | restart | associated restart file pointer |
[in] | particles_location_id | location id of particles set |
[out] | particle_cell_id | local cell id to which particles belong |
[out] | particle_coords | local particle coordinates (interleaved) |
int cs_restart_read_particles_info | ( | cs_restart_t * | restart, |
const char * | name, | ||
cs_lnum_t * | n_particles | ||
) |
Read basic particles information from a restart file.
This includes building a matching location and associated global numbering.
[in] | restart | associated restart file pointer |
[in] | name | name of particles set |
[out] | n_particles | number of particles, or NULL |
int cs_restart_read_real_3_t_compat | ( | cs_restart_t * | restart, |
const char * | sec_name, | ||
const char * | old_name_x, | ||
const char * | old_name_y, | ||
const char * | old_name_z, | ||
int | location_id, | ||
cs_real_3_t * | val | ||
) |
Read a cs_real_3_t vector section from a restart file, when that section may have used a different name and been non-interleaved in a previous version.
This function assumes a mesh-base location (i.e. location_id > 0)
[in] | restart | associated restart file pointer |
[in] | sec_name | section name |
[in] | old_name_x | old name, x component |
[in] | old_name_y | old name, y component |
[in] | old_name_y | old name, z component |
[in] | location_id | id of corresponding location |
[out] | val | array of values |
int cs_restart_read_real_66_t_compat | ( | cs_restart_t * | restart, |
const char * | sec_name, | ||
const char * | old_name_xx, | ||
const char * | old_name_yy, | ||
const char * | old_name_zz, | ||
const char * | old_name_xy, | ||
const char * | old_name_yz, | ||
const char * | old_name_xz, | ||
int | location_id, | ||
cs_real_66_t * | val | ||
) |
Read a cs_real_66_t tensor section from a restart file, when that section may have used a different name and been non-interleaved in a previous version.
This function assumes a mesh-base location (i.e. location_id > 0)
[in] | restart | associated restart file pointer |
[in] | sec_name | section name |
[in] | old_name_xx | old name, xx component |
[in] | old_name_yy | old name, yy component |
[in] | old_name_zz | old name, zz component |
[in] | old_name_xy | old name, xy component |
[in] | old_name_yz | old name, yz component |
[in] | old_name_xz | old name, xz component |
[in] | location_id | id of corresponding location |
[out] | val | array of values |
int cs_restart_read_real_6_t_compat | ( | cs_restart_t * | restart, |
const char * | sec_name, | ||
const char * | old_name_xx, | ||
const char * | old_name_yy, | ||
const char * | old_name_zz, | ||
const char * | old_name_xy, | ||
const char * | old_name_yz, | ||
const char * | old_name_xz, | ||
int | location_id, | ||
cs_real_6_t * | val | ||
) |
Read a cs_real_6_t tensor section from a restart file, when that section may have used a different name and been non-interleaved in a previous version.
This function assumes a mesh-base location (i.e. location_id > 0)
[in] | restart | associated restart file pointer |
[in] | sec_name | section name |
[in] | old_name_xx | old name, xx component |
[in] | old_name_yy | old name, yy component |
[in] | old_name_zz | old name, zz component |
[in] | old_name_xy | old name, xy component |
[in] | old_name_yz | old name, yz component |
[in] | old_name_xz | old name, xz component |
[in] | location_id | id of corresponding location |
[out] | val | array of values |
int cs_restart_read_section | ( | cs_restart_t * | restart, |
const char * | sec_name, | ||
int | location_id, | ||
int | n_location_vals, | ||
cs_restart_val_type_t | val_type, | ||
void * | val | ||
) |
Read a section from a restart file.
[in] | restart | associated restart file pointer |
[in] | sec_name | section name |
[in] | location_id | id of corresponding location |
[in] | n_location_vals | number of values per location (interlaced) |
[in] | val_type | value type |
[out] | val | array of values |
int cs_restart_read_section_compat | ( | cs_restart_t * | restart, |
const char * | sec_name, | ||
const char * | old_name, | ||
int | location_id, | ||
int | n_location_vals, | ||
cs_restart_val_type_t | val_type, | ||
void * | val | ||
) |
Read a section from a restart file, when that section may have used a different name in a previous version.
[in] | restart | associated restart file pointer |
[in] | sec_name | section name |
[in] | location_id | id of corresponding location |
[in] | n_location_vals | number of values per location (interlaced) |
[in] | val_type | value type |
[out] | val | array of values |
cs_restart_check_section_t* cs_restart_set_check_section_func | ( | cs_restart_check_section_t * | func | ) |
Associate a function to restart section check operations.
This allows defining alternate operations when checking restart sections.
[in] | func | associated function |
void cs_restart_set_context | ( | void * | context | ) |
Associate a context to restart section check operations.
This context may be used by the cs_restart_check_section_t, cs_restart_read_section_t, and cs_restart_write_section_t type functions.
Note that the lifecycle of the data pointed to must be handled separately (and the pointer must remain valid until the matching restart structure is destroyed.
[in] | context | pointer to associated data, or NULL |
cs_restart_read_section_t* cs_restart_set_read_section_func | ( | cs_restart_read_section_t * | func | ) |
Associate a function and its input to all restart section read operations.
This allows defining alternate operations when reading restart sections.
[in] | func | associated function |
cs_restart_write_section_t* cs_restart_set_write_section_func | ( | cs_restart_write_section_t * | func | ) |
Associate a function and its input to all restart section write operations.
This allows defining alternate operations when writing restart sections.
[in] | func | associated hook function |
void cs_restart_write_ids | ( | cs_restart_t * | restart, |
const char * | sec_name, | ||
int | location_id, | ||
int | ref_location_id, | ||
cs_lnum_t | ref_id_base, | ||
const cs_lnum_t * | ref_id | ||
) |
Write a referenced location id section to a restart file.
The section written to file contains the global ids matching the local element ids of a given location.
[in] | restart | associated restart file pointer |
[in] | sec_name | section name |
[in] | location_id | id of location on which id_ref is defined |
[in] | ref_location_id | id of referenced location |
[in] | ref_id_base | base of location entity id numbers (usually 0 or 1) |
[in] | ref_id | array of location entity ids |
int cs_restart_write_particles | ( | cs_restart_t * | restart, |
const char * | name, | ||
bool | number_by_coords, | ||
cs_lnum_t | n_particles, | ||
const cs_lnum_t * | particle_cell_id, | ||
const cs_real_t * | particle_coords | ||
) |
Write basic particles information to a restart file.
This includes defining a matching location and associated global numbering, then writing particle coordinates and cell ids.
[in] | restart | associated restart file pointer |
[in] | name | name of particles set |
[in] | number_by_coords | if true, numbering is based on current coordinates; otherwise, it is simply based on local numbers, plus the sum of particles on lower MPI ranks |
[in] | n_particles | local number of particles |
[in] | particle_cell_id | local cell id (0 to n-1) to which particles belong |
[in] | particle_coords | local particle coordinates (interleaved) |
void cs_restart_write_section | ( | cs_restart_t * | restart, |
const char * | sec_name, | ||
int | location_id, | ||
int | n_location_vals, | ||
cs_restart_val_type_t | val_type, | ||
const void * | val | ||
) |
Write a section to a restart file.
[in] | restart | associated restart file pointer |
[in] | sec_name | section name |
[in] | location_id | id of corresponding location |
[in] | n_location_vals | number of values per location (interlaced) |
[in] | val_type | value type |
[in] | val | array of values |