8.0
general documentation
cs_time_table.h
Go to the documentation of this file.
1 #ifndef __CS_TIME_TABLE_H__
2 #define __CS_TIME_TABLE_H__
3 
4 /*============================================================================
5  * Tabulation handling for code_saturne
6  *============================================================================*/
7 
8 /*
9  This file is part of code_saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2023 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_defs.h"
35 #include "cs_time_step.h"
36 
37 /*----------------------------------------------------------------------------*/
38 
40 
41 /*============================================================================
42  * Type definitions
43  *============================================================================*/
44 
45 typedef struct _cs_time_table_t cs_time_table_t;
46 
47 /*=============================================================================
48  * Public function prototypes
49  *============================================================================*/
50 
51 /*----------------------------------------------------------------------------*/
59 /*----------------------------------------------------------------------------*/
60 
61 cs_time_table_t *
62 cs_time_table_by_name_try(const char *name);
63 
64 /*----------------------------------------------------------------------------*/
72 /*----------------------------------------------------------------------------*/
73 
74 cs_time_table_t *
75 cs_time_table_by_name(const char *name);
76 
77 /*----------------------------------------------------------------------------*/
84 /*----------------------------------------------------------------------------*/
85 
86 void
87 cs_time_table_set_offset(cs_time_table_t *table,
88  cs_real_t time_offset);
89 
90 /*----------------------------------------------------------------------------*/
99 /*----------------------------------------------------------------------------*/
100 
101 void
102 cs_time_table_set_headers(cs_time_table_t *table,
103  const int n_headers,
104  const char **headers);
105 
106 /*----------------------------------------------------------------------------*/
120 /*----------------------------------------------------------------------------*/
121 
122 cs_time_table_t *
123 cs_time_table_from_csv_file(const char *name,
124  const char *file_name,
125  const char *separator,
126  const int n_headers,
127  const int n_columns,
128  const int *col_idx,
129  const bool ignore_missing_tokens);
130 
131 /*----------------------------------------------------------------------------*/
142 /*----------------------------------------------------------------------------*/
143 
144 cs_time_table_t *
145 cs_time_table_from_csv_file_simple(const char *name,
146  const char *file_name,
147  const char *separator);
148 
149 /*----------------------------------------------------------------------------*/
161 /*----------------------------------------------------------------------------*/
162 
163 cs_time_table_t *
165  const char *file_name,
166  const char *separator,
167  const int n_headers);
168 
169 /*----------------------------------------------------------------------------*/
176 /*----------------------------------------------------------------------------*/
177 void
178 cs_time_table_set_time_col_id(cs_time_table_t *table,
179  const int col_id);
180 
181 /*----------------------------------------------------------------------------*/
188 /*----------------------------------------------------------------------------*/
189 void
190 cs_time_table_set_time_from_label(cs_time_table_t *table,
191  const char *time_label);
192 
193 /*----------------------------------------------------------------------------*/
200 /*----------------------------------------------------------------------------*/
201 
202 void
203 cs_time_table_reset_position(cs_time_table_t *table);
204 
205 /*----------------------------------------------------------------------------*/
214 /*----------------------------------------------------------------------------*/
215 
216 void
217 cs_time_table_update_position(cs_time_table_t *table,
218  cs_real_t time,
219  bool reset_time_value);
220 
221 /*----------------------------------------------------------------------------*/
232 /*----------------------------------------------------------------------------*/
233 
234 cs_real_t
235 cs_time_table_compute_time_value(const char *name,
236  cs_real_t t,
237  const int col,
238  bool overwrite_prev);
239 
240 /*----------------------------------------------------------------------------*/
251 /*----------------------------------------------------------------------------*/
252 
253 cs_real_t
255  cs_real_t t,
256  const char *label,
257  bool overwrite_prev);
258 
259 /*----------------------------------------------------------------------------*/
271 /*----------------------------------------------------------------------------*/
272 
273 void
274 cs_time_table_compute_n_time_values(const char *name,
275  cs_real_t t,
276  const int n_cols,
277  const int cols[],
278  bool overwrite_prev,
279  cs_real_t *retvals);
280 
281 /*----------------------------------------------------------------------------*/
293 /*----------------------------------------------------------------------------*/
294 
295 void
297  cs_real_t t,
298  const int n_cols,
299  const char *labels[],
300  bool overwrite_prev,
301  cs_real_t *retvals);
302 
303 /*----------------------------------------------------------------------------*/
313 /*----------------------------------------------------------------------------*/
314 
315 static inline cs_real_t
316 CS_TIME_TABLE(const char *name,
317  const char *label)
318 {
321  label,
322  false);
323 }
324 /*----------------------------------------------------------------------------*/
328 /*----------------------------------------------------------------------------*/
329 
330 void
332 
333 /*----------------------------------------------------------------------------*/
334 
336 
337 #endif /* __CS_TIME_TABLE_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:509
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
#define END_C_DECLS
Definition: cs_defs.h:510
@ t
Definition: cs_field_pointer.h:92
const cs_time_step_t * cs_glob_time_step
void cs_time_table_set_time_col_id(cs_time_table_t *table, const int col_id)
Define the column id for time based on an index.
Definition: cs_time_table.c:519
void cs_time_table_compute_n_time_values_by_label(const char *name, cs_real_t t, const int n_cols, const char *labels[], bool overwrite_prev, cs_real_t *retvals)
Compute values for several columns of a time table for a given abscissa.
Definition: cs_time_table.c:730
void cs_time_table_update_position(cs_time_table_t *table, cs_real_t time, bool reset_time_value)
Update time coefficients used for data interpolation.
Definition: cs_time_table.c:584
void cs_time_table_destroy_all(void)
Free all data structures related to datasets.
Definition: cs_time_table.c:753
void cs_time_table_set_headers(cs_time_table_t *table, const int n_headers, const char **headers)
Set headers labels for a time table. Number of headers needs to be equal to the number of columns,...
Definition: cs_time_table.c:349
cs_time_table_t * cs_time_table_from_csv_file_simple_headers(const char *name, const char *file_name, const char *separator, const int n_headers)
Define a time table from a CSV file. We suppose that all columns are to be read and that missing toke...
Definition: cs_time_table.c:492
cs_time_table_t * cs_time_table_from_csv_file_simple(const char *name, const char *file_name, const char *separator)
Define a time table from a CSV file. We suppose that all columns are to be read, no headers line to s...
Definition: cs_time_table.c:461
cs_time_table_t * cs_time_table_from_csv_file(const char *name, const char *file_name, const char *separator, const int n_headers, const int n_columns, const int *col_idx, const bool ignore_missing_tokens)
Define a time table from a CSV file.
Definition: cs_time_table.c:391
cs_time_table_t * cs_time_table_by_name(const char *name)
Get time table based on name.
Definition: cs_time_table.c:307
void cs_time_table_set_time_from_label(cs_time_table_t *table, const char *time_label)
Define the column id for time based on a label.
Definition: cs_time_table.c:536
static cs_real_t CS_TIME_TABLE(const char *name, const char *label)
Compute value from time table based on label and current time. Positions are not updated for the tabl...
Definition: cs_time_table.h:316
cs_real_t cs_time_table_compute_time_value(const char *name, cs_real_t t, const int col, bool overwrite_prev)
Compute value using a given abscissa and a specific column.
Definition: cs_time_table.c:640
void cs_time_table_compute_n_time_values(const char *name, cs_real_t t, const int n_cols, const int cols[], bool overwrite_prev, cs_real_t *retvals)
Compute values for several columns of a time table for a given abscissa.
Definition: cs_time_table.c:699
void cs_time_table_set_offset(cs_time_table_t *table, cs_real_t time_offset)
Set time offset value for a time table.
Definition: cs_time_table.c:329
void cs_time_table_reset_position(cs_time_table_t *table)
Reset time table time value (force search from beginning of table).
Definition: cs_time_table.c:561
cs_time_table_t * cs_time_table_by_name_try(const char *name)
Try to get time table based on name.
Definition: cs_time_table.c:289
cs_real_t cs_time_table_compute_time_value_by_label(const char *name, cs_real_t t, const char *label, bool overwrite_prev)
Compute value using a given abscissa and a label.
Definition: cs_time_table.c:666
char * label
Definition: keywords.h:71
double t_cur
Definition: cs_time_step.h:80