7.2
general documentation
cs_time_plot.h
Go to the documentation of this file.
1 #ifndef __CS_TIME_PLOT_H__
2 #define __CS_TIME_PLOT_H__
3 
4 /*============================================================================
5  * Time_Plot helper structures
6  *============================================================================*/
7 
8 /*
9  This file is part of code_saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2022 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_base.h"
35 
36 /*----------------------------------------------------------------------------*/
37 
39 
40 /*============================================================================
41  * Macro definitions
42  *============================================================================*/
43 
44 /*============================================================================
45  * Type definitions
46  *============================================================================*/
47 
48 typedef struct _cs_time_plot_t cs_time_plot_t;
49 
50 /*============================================================================
51  * Local type definitions
52  *============================================================================*/
53 
54 /* Type of 1D plot file format */
55 
56 typedef enum {
57  CS_TIME_PLOT_DAT, /* .dat file (usable by Qtplot or Grace) */
58  CS_TIME_PLOT_CSV /* .csv file (readable by ParaView or spreadsheat) */
60 
61 /*============================================================================
62  * Global variables
63  *============================================================================*/
64 
65 /*=============================================================================
66  * Public function prototypes for Fortran API
67  *============================================================================*/
68 
69 /*----------------------------------------------------------------------------
70  * Create a writer for time plot structure-type data.
71  *
72  * This subroutine should only be called by one rank for a given data series.
73  *
74  * subroutine tpsini (tplnum, tplnam, tplpre, tplfmt, idtvar,
75  * *****************
76  * nprb, lstprb, xyzprb, lnam, lpre)
77  *
78  * integer tplnum : <-- : number of plot to create (> 0)
79  * character tplnam : <-- : name of associated plot
80  * character tplpre : <-- : prefix for associated file
81  * integer tplfmt : <-- : associated format
82  * (1: dat, 2: csv, 3: both)
83  * integer idtvar : <-- : calculation time dependency
84  * integer nstru : <-- : number of structures
85  * double precision xmstru : <-- : mass matrixes
86  * double precision xcstru : <-- : damping matrixes
87  * double precision xkstru : <-- : stiffness matrixes
88  *----------------------------------------------------------------------------*/
89 
90 void CS_PROCF (tpsini, TPSINI)
91 (
92  const int *tplnum,
93  const char *tplnam,
94  const char *tplpre,
95  const int *tplfmt,
96  const int *idtvar,
97  const int *nstru,
98  const cs_real_t *xmstru,
99  const cs_real_t *xcstru,
100  const cs_real_t *xkstru
101 );
102 
103 /*----------------------------------------------------------------------------
104  * Finalize a writer for time plot data.
105  *
106  * This subroutine should only be called by one rank for a given data series.
107  *
108  * subroutine tplend (tplnum)
109  * *****************
110  *
111  * integer tplnum : <-- : number of plot to create (> 0)
112  * integer tplfmt : <-- : associated format
113  * (1: dat, 2: csv, 3: both)
114  *----------------------------------------------------------------------------*/
115 
116 void CS_PROCF (tplend, TPLEND)
117 (
118  const int *tplnum,
119  const int *tplfmt
120 );
121 
122 /*----------------------------------------------------------------------------
123  * Write time plot values.
124  *
125  * subroutine tplwri (tplnum, tplfmt, nprb, ntcabs, ttcabs, valprb)
126  * *****************
127  *
128  * integer tplnum : <-- : number of associated plot (> 0)
129  * integer tplfmt : <-- : associated format
130  * (1: dat, 2: csv, 3: both)
131  * integer nprb : <-- : number of probes
132  * integer ntcabs : <-- : current time step number
133  * double precision ttcabs : <-- : current time value
134  * double precision valprb : <-- : probe values
135  *----------------------------------------------------------------------------*/
136 
137 void CS_PROCF (tplwri, TPLWRI)
138 (
139  const int *tplnum,
140  const int *tplfmt,
141  const int *nprb,
142  const int *ntcabs,
143  const cs_real_t *ttcabs,
144  const cs_real_t *valprb
145 );
146 
147 /*----------------------------------------------------------------------------
148  * Return the number of time plots accessible through the Fortran API
149  *
150  * This subroutine will only return the number of time plots defined by the
151  * local rank
152  *
153  * subroutine tplnbr (ntpl)
154  * *****************
155  *
156  * integer ntpl : --> : number of time plots defined
157  *----------------------------------------------------------------------------*/
158 
159 void CS_PROCF (tplnbr, TPLNBR)
160 (
161  int *ntpl
162 );
163 
164 /*=============================================================================
165  * Public function prototypes
166  *============================================================================*/
167 
168 /*----------------------------------------------------------------------------
169  * Initialize a plot file writer for probe-type plots
170  *
171  * This function should only be called by one rank for a given data series.
172  *
173  * parameters:
174  * plot_name <-- plot (variable) name
175  * file_prefix <-- file name prefix
176  * format <-- associated file format
177  * use_iteration <-- should we use the iteration number instead of the
178  * physical time ?
179  * flush_wtime <-- elapsed time interval between file flushes
180  * (if < 0, no forced flush)
181  * n_buffer_steps <-- number of time steps in output buffer if
182  * file is not to be kept open
183  * n_probes <-- number of probes associated with this plot
184  * probe_list <-- numbers (1 to n) of probes if filtered, or NULL
185  * probe_coords <-- probe coordinates, or NULL
186  * probe_names <-- probe names, or NULL
187  *
188  * returns:
189  * pointer to new time plot writer
190  *----------------------------------------------------------------------------*/
191 
193 cs_time_plot_init_probe(const char *plot_name,
194  const char *file_prefix,
195  cs_time_plot_format_t format,
196  bool use_iteration,
197  double flush_wtime,
198  int n_buffer_steps,
199  int n_probes,
200  const int *probe_list,
201  const cs_real_t probe_coords[],
202  const char *probe_names[]);
203 
204 /*----------------------------------------------------------------------------
205  * Initialize a plot file writer for structure-type plots
206  *
207  * This function should only be called by one rank for a given data series.
208  *
209  * parameters:
210  * plot_name <-- plot (variable) name
211  * file_prefix <-- file name prefix
212  * format <-- associated file format
213  * use_iteration <-- should we use the iteration number instead of the
214  * physical time ?
215  * flush_wtime <-- elapsed time interval between file flushes
216  * (if < 0, no forced flush)
217  * n_buffer_steps <-- number of time steps in output buffer if
218  * file is not to be kept open
219  * n_structures <-- number of structures associated with this plot
220  * mass_matrixes <-- mass matrix coefficients (3x3 blocks)
221  * damping_matrixes <-- damping matrix coefficients (3x3 blocks)
222  * stiffness_matrixes <-- stiffness matrix coefficients (3x3 blocks)
223  *
224  * returns:
225  * pointer to new time plot writer
226  *----------------------------------------------------------------------------*/
227 
229 cs_time_plot_init_struct(const char *plot_name,
230  const char *file_prefix,
231  cs_time_plot_format_t format,
232  bool use_iteration,
233  double flush_wtime,
234  int n_buffer_steps,
235  int n_structures,
236  const cs_real_t mass_matrixes[],
237  const cs_real_t damping_matrixes[],
238  const cs_real_t stiffness_matrixes[]);
239 
240 /*----------------------------------------------------------------------------
241  * Finalize time plot writer for a given variable
242  *
243  * This function should only be called by one rank for a given data series.
244  *
245  * parameters:
246  * p <-> time plot values file handler
247  *----------------------------------------------------------------------------*/
248 
249 void
251 
252 /*----------------------------------------------------------------------------
253  * Write time plot values
254  *
255  * This function should only be called by one rank for a given data series.
256  *
257  * parameters:
258  * p <-- pointer to associated plot structure
259  * tn <-- associated time step number
260  * t <-- associated time value
261  * n_vals <-- number of associated time values
262  * vals <-- associated time values
263  *----------------------------------------------------------------------------*/
264 
265 void
267  int tn,
268  double t,
269  int n_vals,
270  const cs_real_t vals[]);
271 
272 /*----------------------------------------------------------------------------
273  * Flush buffered values to file if applicable
274  *
275  * parameters:
276  * p <-> time plot values file handler
277  *----------------------------------------------------------------------------*/
278 
279 void
281 
282 /*----------------------------------------------------------------------------
283  * flush all time plots
284  *----------------------------------------------------------------------------*/
285 
286 void
288 
289 /*----------------------------------------------------------------------------
290  * Set time plot file writer flush behavior defaults.
291  *
292  * parameters:
293  * flush_wtime <-- elapsed time interval between file flushes;
294  * if < 0, no forced flush
295  * n_buffer_steps <-- number of time steps in output buffer if
296  * file is not to be kept open
297  *----------------------------------------------------------------------------*/
298 
299 void
300 cs_time_plot_set_flush_default(float flush_wtime,
301  int n_buffer_steps);
302 
303 /*----------------------------------------------------------------------------
304  * Return time plot file writer flush behavior defaults.
305  *
306  * parameters:
307  * flush_wtime --> elapsed time interval between file flushes;
308  * if < 0, no forced flush (NULL if not queried)
309  * n_buffer_steps <-- number of time steps in output buffer if
310  * file is not to be kept open (NULL if not queried)
311  *----------------------------------------------------------------------------*/
312 
313 void
314 cs_time_plot_get_flush_default(float *flush_wtime,
315  int *n_buffer_steps);
316 
317 /*----------------------------------------------------------------------------*/
318 
320 
321 #endif /* __CS_PROBE_H__ */
double precision, dimension(3, 3, nstrmx), save xcstru
Definition: alstru.f90:51
void cs_time_plot_flush_all(void)
Definition: cs_time_plot.c:1246
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
void tpsini(const int *tplnum, const char *tplnam, const char *tplpre, const int *tplfmt, const int *idtvar, const int *nstru, const cs_real_t *xmstru, const cs_real_t *xcstru, const cs_real_t *xkstru)
Definition: cs_time_plot.c:811
integer(c_int), pointer, save idtvar
option for a variable time step
Definition: optcal.f90:383
double precision, dimension(3, 3, nstrmx), save xmstru
Definition: alstru.f90:48
Definition: cs_field_pointer.h:67
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
struct _cs_time_plot_t cs_time_plot_t
Definition: cs_time_plot.h:48
Definition: cs_time_plot.h:58
double precision, dimension(3, 3, nstrmx), save xkstru
Definition: alstru.f90:54
real(c_double), pointer, save ttcabs
Current absolute time.
Definition: optcal.f90:353
cs_time_plot_t * cs_time_plot_init_struct(const char *plot_name, const char *file_prefix, cs_time_plot_format_t format, bool use_iteration, double flush_wtime, int n_buffer_steps, int n_structures, const cs_real_t mass_matrixes[], const cs_real_t damping_matrixes[], const cs_real_t stiffness_matrixes[])
Definition: cs_time_plot.c:1072
void cs_time_plot_vals_write(cs_time_plot_t *p, int tn, double t, int n_vals, const cs_real_t vals[])
Definition: cs_time_plot.c:1156
void cs_time_plot_finalize(cs_time_plot_t **p)
Definition: cs_time_plot.c:1115
cs_time_plot_format_t
Definition: cs_time_plot.h:56
void cs_time_plot_get_flush_default(float *flush_wtime, int *n_buffer_steps)
Definition: cs_time_plot.c:1281
integer, save tplfmt
time plot format (1: .dat, 2: .csv, 3: both)
Definition: entsor.f90:106
#define END_C_DECLS
Definition: cs_defs.h:511
void cs_time_plot_set_flush_default(float flush_wtime, int n_buffer_steps)
Definition: cs_time_plot.c:1263
integer(c_int), pointer, save ntcabs
Current absolute time step number. In case of restart, this is equal to ntpabs + number of new iterat...
Definition: optcal.f90:319
#define CS_PROCF(x, y)
Definition: cs_defs.h:524
void cs_time_plot_flush(cs_time_plot_t *p)
Definition: cs_time_plot.c:1224
void tplend(const int *tplnum, const int *tplfmt)
Definition: cs_time_plot.c:869
cs_time_plot_t * cs_time_plot_init_probe(const char *plot_name, const char *file_prefix, cs_time_plot_format_t format, bool use_iteration, double flush_wtime, int n_buffer_steps, int n_probes, const int *probe_list, const cs_real_t probe_coords[], const char *probe_names[])
Definition: cs_time_plot.c:1006
void tplwri(const int *tplnum, const int *tplfmt, const int *nprb, const int *ntcabs, const cs_real_t *ttcabs, const cs_real_t *valprb)
Definition: cs_time_plot.c:921
Definition: cs_field_pointer.h:92
void tplnbr(int *ntpl)
Definition: cs_time_plot.c:963
Definition: cs_time_plot.h:57