9.2
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-2026 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 "base/cs_defs.h"
35#include "base/cs_time_step.h"
36
37/*============================================================================
38 * Type definitions
39 *============================================================================*/
40
41typedef struct _cs_time_table_t cs_time_table_t;
42
43/*=============================================================================
44 * Public function prototypes
45 *============================================================================*/
46
47/*----------------------------------------------------------------------------*/
56/*----------------------------------------------------------------------------*/
57
58int
59cs_time_table_column_id_by_name(const cs_time_table_t *table,
60 const char *name);
61
62/*----------------------------------------------------------------------------*/
70/*----------------------------------------------------------------------------*/
71
72cs_time_table_t *
73cs_time_table_by_name_try(const char *name);
74
75/*----------------------------------------------------------------------------*/
83/*----------------------------------------------------------------------------*/
84
85cs_time_table_t *
86cs_time_table_by_name(const char *name);
87
88/*----------------------------------------------------------------------------*/
95/*----------------------------------------------------------------------------*/
96
97void
98cs_time_table_set_offset(cs_time_table_t *table,
99 cs_real_t time_offset);
100
101/*----------------------------------------------------------------------------*/
110/*----------------------------------------------------------------------------*/
111
112void
113cs_time_table_set_headers(cs_time_table_t *table,
114 const int n_headers,
115 const char **headers);
116
117/*----------------------------------------------------------------------------*/
131/*----------------------------------------------------------------------------*/
132
133cs_time_table_t *
134cs_time_table_from_csv_file(const char *name,
135 const char *file_name,
136 const char *separator,
137 const int n_headers,
138 const int n_columns,
139 const int *col_idx,
140 const bool ignore_missing_tokens);
141
142/*----------------------------------------------------------------------------*/
153/*----------------------------------------------------------------------------*/
154
155cs_time_table_t *
157 const char *file_name,
158 const char *separator);
159
160/*----------------------------------------------------------------------------*/
172/*----------------------------------------------------------------------------*/
173
174cs_time_table_t *
176 const char *file_name,
177 const char *separator,
178 const int n_headers);
179
180/*----------------------------------------------------------------------------*/
187/*----------------------------------------------------------------------------*/
188
189void
190cs_time_table_set_time_col_id(cs_time_table_t *table,
191 const int col_id);
192
193/*----------------------------------------------------------------------------*/
200/*----------------------------------------------------------------------------*/
201
202void
203cs_time_table_set_time_from_label(cs_time_table_t *table,
204 const char *time_label);
205
206/*----------------------------------------------------------------------------*/
213/*----------------------------------------------------------------------------*/
214
215void
216cs_time_table_set_time_from_label_try(cs_time_table_t *table,
217 const char *time_label);
218
219/*----------------------------------------------------------------------------*/
226/*----------------------------------------------------------------------------*/
227
228void
229cs_time_table_reset_position(cs_time_table_t *table);
230
231/*----------------------------------------------------------------------------*/
240/*----------------------------------------------------------------------------*/
241
242void
243cs_time_table_update_position(cs_time_table_t *table,
244 cs_real_t time,
245 bool reset_time_value);
246
247/*----------------------------------------------------------------------------*/
258/*----------------------------------------------------------------------------*/
259
261cs_time_table_compute_time_value(const char *name,
262 cs_real_t t,
263 const int col,
264 bool overwrite_prev);
265
266/*----------------------------------------------------------------------------*/
277/*----------------------------------------------------------------------------*/
278
281 cs_real_t t,
282 const char *label,
283 bool overwrite_prev);
284
285/*----------------------------------------------------------------------------*/
297/*----------------------------------------------------------------------------*/
298
299void
301 cs_real_t t,
302 const int n_cols,
303 const int cols[],
304 bool overwrite_prev,
305 cs_real_t *retvals);
306
307/*----------------------------------------------------------------------------*/
319/*----------------------------------------------------------------------------*/
320
321void
323 cs_real_t t,
324 const int n_cols,
325 const char *labels[],
326 bool overwrite_prev,
327 cs_real_t *retvals);
328
329/*----------------------------------------------------------------------------*/
339/*----------------------------------------------------------------------------*/
340
341static inline cs_real_t
342CS_TIME_TABLE(const char *name,
343 const char *label)
344{
347 label,
348 false);
349}
350
351/*----------------------------------------------------------------------------*/
357/*----------------------------------------------------------------------------*/
358
359int
360cs_time_table_get_n_rows(const char *name);
361
362/*----------------------------------------------------------------------------*/
368/*----------------------------------------------------------------------------*/
369
370int
371cs_time_table_get_n_cols(const char *name);
372
373/*----------------------------------------------------------------------------*/
380/*----------------------------------------------------------------------------*/
381
382const cs_real_t **
383cs_time_table_get_data(const char *name);
384
385/*----------------------------------------------------------------------------*/
389/*----------------------------------------------------------------------------*/
390
391void
393
394/*----------------------------------------------------------------------------*/
395
396#endif /* CS_TIME_TABLE_H */
double t_cur
Definition: cs_time_step.h:78
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
@ t
Definition: cs_field_pointer.h:91
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.cpp:518
const cs_real_t ** cs_time_table_get_data(const char *name)
Return pointer to table data.
Definition: cs_time_table.cpp:811
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.cpp:753
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.cpp:607
void cs_time_table_destroy_all(void)
Free all data structures related to datasets.
Definition: cs_time_table.cpp:825
int cs_time_table_get_n_cols(const char *name)
Extract n_cols from cs_time_table_t structure.
Definition: cs_time_table.cpp:794
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.cpp:351
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.cpp:492
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.cpp:392
void cs_time_table_set_time_from_label_try(cs_time_table_t *table, const char *time_label)
Define the column id for time based on a label (if it exists)
Definition: cs_time_table.cpp: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.cpp:291
int cs_time_table_column_id_by_name(const cs_time_table_t *table, const char *name)
Get column id corresponding to a given header/label.
Definition: cs_time_table.cpp:258
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.cpp:462
cs_time_table_t * cs_time_table_by_name(const char *name)
Get time table based on name.
Definition: cs_time_table.cpp:309
int cs_time_table_get_n_rows(const char *name)
Extract n_rows from cs_time_table_t structure.
Definition: cs_time_table.cpp:778
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.cpp: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:342
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.cpp:665
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.cpp:723
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.cpp:331
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.cpp:585
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.cpp:691
char * label
Definition: keywords.h:58