#include "mbs_buffer.h"
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "set_output.h"
#include "mbs_message.h"
#include "useful_functions.h"
#include "mbs_errors_names.h"
Macros | |
#define | TIME_ID(i) ((i)*(b->nx+1)) |
Macro to get the id in tx array corresponding to index (assuming b->nx exist) More... | |
Functions | |
MbsBuffer * | mbs_new_buffer (char *filename, char *anim_name, int nx, int size, int id, char *buf_format, int save_anim, int save_visu, double anim_period) |
Allocate and initialize a MbsBuffer structure. More... | |
MbsGrowingBuffer * | mbs_new_growing_buffer (int max_nx, int size, const char *respath) |
create a new growing buffer for the user inputs to save More... | |
void | mbs_delete_buffer (MbsBuffer *b) |
Free memory of the specified MbsBuffer. More... | |
void | mbs_delete_growing_buffer (MbsGrowingBuffer *b) |
release memory for growing buffer More... | |
int | mbs_buffer_save (MbsBuffer *b, double t, double *x) |
Save the given array to the specified buffer with the specified time. More... | |
int | mbs_growing_buffer_save (MbsGrowingBuffer *b, double t) |
Save the given values of auto_output to the specified buffer with the specified time. More... | |
int | mbs_buffer_write (MbsBuffer *b) |
Write the content of the buffer to disk. More... | |
int | mbs_anim_write (MbsBuffer *b) |
Write the content of the q buffer as anim file to the disk. More... | |
int | mbs_growing_buffer_write (MbsGrowingBuffer *b) |
write the content of the growing buffer to disk More... | |
Implements function defined in mbs_buffer.h
(c) Universite catholique de Louvain
#define TIME_ID | ( | i | ) | ((i)*(b->nx+1)) |
Macro to get the id in tx array corresponding to index (assuming b->nx exist)
int mbs_anim_write | ( | MbsBuffer * | b | ) |
Write the content of the q buffer as anim file to the disk.
int mbs_buffer_save | ( | MbsBuffer * | b, |
double | t, | ||
double * | x | ||
) |
Save the given array to the specified buffer with the specified time.
The content of the buffer is automatically written to the associated file when the buffer is full. The buffer index is then reset to 0.
b | the buffer in which to store |
t | the corresponding time [s] |
x | the array to save (value are copied) |
int mbs_buffer_write | ( | MbsBuffer * | b | ) |
Write the content of the buffer to disk.
Values contained in the buffer for line 0 to line index-1 are appended to the file associated with this buffer.
void mbs_delete_growing_buffer | ( | MbsGrowingBuffer * | b | ) |
release memory for growing buffer
[out] | b | growing buffer to release |
int mbs_growing_buffer_save | ( | MbsGrowingBuffer * | b, |
double | t | ||
) |
Save the given values of auto_output to the specified buffer with the specified time.
[in,out] | b | the growing buffer in which to store |
[in] | t | the corresponding time [s] |
The content of the buffer is automatically written to the associated file when the buffer is full. The buffer index is then reset to 0.
int mbs_growing_buffer_write | ( | MbsGrowingBuffer * | b | ) |
write the content of the growing buffer to disk
[in] | b | growing buffer |
MbsBuffer* mbs_new_buffer | ( | char * | filename, |
char * | anim_name, | ||
int | nx, | ||
int | size, | ||
int | id, | ||
char * | buf_format, | ||
int | save_anim, | ||
int | save_visu, | ||
double | anim_period | ||
) |
Allocate and initialize a MbsBuffer structure.
The associated text file defined by filename is (re-)initialized
[in] | filename | the name of the file associated to this buffer |
[in] | anim_name | the name of the file associated to the animation file (only used for BUFFER_Q) |
[in] | nx | the size of the array to be tracked by this buffer |
[in] | size | the size of the buffer |
[in] | id | the buffer ID, see BUFFER_Q, BUFFER_QD ... |
[in] | format | of the buffer (if NULL, "%e" is used) |
[in] | save_anim | 1 to save the anim file, 0 otherwise |
[in] | save_visu | 1 to save the visualization file (as it appears in 'user_realtime_visu.c'), 0 otherwise (for real-time simulation) |
[in] | anim_period | time interval between two recorded values in the animation file |
MbsGrowingBuffer* mbs_new_growing_buffer | ( | int | max_nx, |
int | size, | ||
const char * | respath | ||
) |
create a new growing buffer for the user inputs to save
[in] | max_nx | maximum number of user inputs to save |
[in] | size | size of the buffer |
[in] | respath | path to the file for the results |