programmer's 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-2016 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 probe-type data.
71  *
72  * This subroutine should only be called by one rank for a given data series.
73  *
74  * subroutine tppini (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 nprb : <-- : number of probes
85  * integer lstprb : <-- : list of probes (1 to n)
86  * double precision xyzprb : <-- : probe coordinates
87  * integer lnam : <-- : name length
88  * integer lpre : <-- : prefix length
89  *----------------------------------------------------------------------------*/
90 
91 void CS_PROCF (tppini, TPPINI)
92 (
93  const cs_int_t *tplnum,
94  const char *tplnam,
95  const char *tplpre,
96  const cs_int_t *tplfmt,
97  const cs_int_t *idtvar,
98  const cs_int_t *nprb,
99  const cs_int_t *lstprb,
100  const cs_real_t *xyzprb,
101  const cs_int_t *lnam,
102  const cs_int_t *lpre
103  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
104  by many Fortran compilers) */
105 );
106 
107 /*----------------------------------------------------------------------------
108  * Create a writer for time plot structure-type data.
109  *
110  * This subroutine should only be called by one rank for a given data series.
111  *
112  * subroutine tpsini (tplnum, tplnam, tplpre, tplfmt, idtvar,
113  * *****************
114  * nprb, lstprb, xyzprb, lnam, lpre)
115  *
116  * integer tplnum : <-- : number of plot to create (> 0)
117  * character tplnam : <-- : name of associated plot
118  * character tplpre : <-- : prefix for associated file
119  * integer tplfmt : <-- : associated format
120  * (1: dat, 2: csv, 3: both)
121  * integer idtvar : <-- : calculation time dependency
122  * integer nstru : <-- : number of structures
123  * double precision xmstru : <-- : mass matrixes
124  * double precision xcstru : <-- : damping matrixes
125  * double precision xkstru : <-- : stiffness matrixes
126  * integer lnam : <-- : name length
127  * integer lpre : <-- : prefix length
128  *----------------------------------------------------------------------------*/
129 
130 void CS_PROCF (tpsini, TPPINI)
131 (
132  const cs_int_t *tplnum,
133  const char *tplnam,
134  const char *tplpre,
135  const cs_int_t *tplfmt,
136  const cs_int_t *idtvar,
137  const cs_int_t *nstru,
138  const cs_real_t *xmstru,
139  const cs_real_t *xcstru,
140  const cs_real_t *xkstru,
141  const cs_int_t *lnam,
142  const cs_int_t *lpre
143  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
144  by many Fortran compilers) */
145 );
146 
147 /*----------------------------------------------------------------------------
148  * Finalize a writer for time plot data.
149  *
150  * This subroutine should only be called by one rank for a given data series.
151  *
152  * subroutine tplend (tplnum)
153  * *****************
154  *
155  * integer tplnum : <-- : number of plot to create (> 0)
156  * integer tplfmt : <-- : associated format
157  * (1: dat, 2: csv, 3: both)
158  *----------------------------------------------------------------------------*/
159 
160 void CS_PROCF (tplend, TPLEND)
161 (
162  const cs_int_t *tplnum,
163  const cs_int_t *tplfmt
164 );
165 
166 /*----------------------------------------------------------------------------
167  * Write time plot values.
168  *
169  * subroutine tplwri (tplnum, tplfmt, nprb, ntcabs, ttcabs, valprb)
170  * *****************
171  *
172  * integer tplnum : <-- : number of associated plot (> 0)
173  * integer tplfmt : <-- : associated format
174  * (1: dat, 2: csv, 3: both)
175  * integer nprb : <-- : number of probes
176  * integer ntcabs : <-- : current time step number
177  * double precision ttcabs : <-- : current time value
178  * double precision valprb : <-- : probe values
179  *----------------------------------------------------------------------------*/
180 
181 void CS_PROCF (tplwri, TPLWRI)
182 (
183  const cs_int_t *tplnum,
184  const cs_int_t *tplfmt,
185  const cs_int_t *nprb,
186  const cs_int_t *ntcabs,
187  const cs_real_t *ttcabs,
188  const cs_real_t *valprb
189 );
190 
191 /*----------------------------------------------------------------------------
192  * Return the number of time plots accessible through the Fortran API
193  *
194  * This subroutine will only return the number of time plots defined by the
195  * local rank
196  *
197  * subroutine tplnbr (ntpl)
198  * *****************
199  *
200  * integer ntpl : --> : number of time plots defined
201  *----------------------------------------------------------------------------*/
202 
203 void CS_PROCF (tplnbr, TPLNBR)
204 (
205  cs_int_t *ntpl
206 );
207 
208 /*=============================================================================
209  * Public function prototypes
210  *============================================================================*/
211 
212 /*----------------------------------------------------------------------------
213  * Initialize a plot file writer for probe-type plots
214  *
215  * This function should only be called by one rank for a given data series.
216  *
217  * parameters:
218  * plot_name <-- plot (variable) name
219  * file_prefix <-- file name prefix
220  * format <-- associated file format
221  * use_iteration <-- should we use the iteration number instead of the
222  * physical time ?
223  * flush_wtime <-- elapsed time interval between file flushes
224  * (if < 0, no forced flush)
225  * n_buffer_steps <-- number of time steps in output buffer if
226  * file is not to be kept open
227  * n_probes <-- number of probes associated with this plot
228  * probe_list <-- numbers (1 to n) of probes if filtered, or NULL
229  * probe_coords <-- probe coordinates, or NULL
230  * probe_names <-- probe names, or NULL
231  *
232  * returns:
233  * pointer to new time plot writer
234  *----------------------------------------------------------------------------*/
235 
237 cs_time_plot_init_probe(const char *plot_name,
238  const char *file_prefix,
239  cs_time_plot_format_t format,
240  bool use_iteration,
241  double flush_wtime,
242  int n_buffer_steps,
243  int n_probes,
244  const int *probe_list,
245  const cs_real_t probe_coords[],
246  const char *probe_names[]);
247 
248 /*----------------------------------------------------------------------------
249  * Initialize a plot file writer for structure-type plots
250  *
251  * This function should only be called by one rank for a given data series.
252  *
253  * parameters:
254  * plot_name <-- plot (variable) name
255  * file_prefix <-- file name prefix
256  * format <-- associated file format
257  * use_iteration <-- should we use the iteration number instead of the
258  * physical time ?
259  * flush_wtime <-- elapsed time interval between file flushes
260  * (if < 0, no forced flush)
261  * n_buffer_steps <-- number of time steps in output buffer if
262  * file is not to be kept open
263  * n_structures <-- number of structures associated with this plot
264  * mass_matrixes <-- mass matrix coefficients (3x3 blocks)
265  * damping_matrixes <-- damping matrix coefficients (3x3 blocks)
266  * stiffness_matrixes <-- stiffness matrix coefficients (3x3 blocks)
267  *
268  * returns:
269  * pointer to new time plot writer
270  *----------------------------------------------------------------------------*/
271 
273 cs_time_plot_init_struct(const char *plot_name,
274  const char *file_prefix,
275  cs_time_plot_format_t format,
276  bool use_iteration,
277  double flush_wtime,
278  int n_buffer_steps,
279  int n_structures,
280  const cs_real_t mass_matrixes[],
281  const cs_real_t damping_matrixes[],
282  const cs_real_t stiffness_matrixes[]);
283 
284 /*----------------------------------------------------------------------------
285  * Finalize time plot writer for a given variable
286  *
287  * This function should only be called by one rank for a given data series.
288  *
289  * parameters:
290  * p <-> time plot values file handler
291  *----------------------------------------------------------------------------*/
292 
293 void
295 
296 /*----------------------------------------------------------------------------
297  * Write time plot values
298  *
299  * This function should only be called by one rank for a given data series.
300  *
301  * parameters:
302  * p <-- pointer to associated plot structure
303  * tn <-- associated time step number
304  * t <-- associated time value
305  * n_vals <-- number of associated time values
306  * vals <-- associated time values
307  *----------------------------------------------------------------------------*/
308 
309 void
311  int tn,
312  double t,
313  int n_vals,
314  const cs_real_t vals[]);
315 
316 /*----------------------------------------------------------------------------
317  * Flush buffered values to file if applicable
318  *
319  * parameters:
320  * p <-> time plot values file handler
321  *----------------------------------------------------------------------------*/
322 
323 void
325 
326 /*----------------------------------------------------------------------------
327  * flush all time plots
328  *----------------------------------------------------------------------------*/
329 
330 void
332 
333 /*----------------------------------------------------------------------------
334  * Set time plot file writer flush behavior defaults.
335  *
336  * parameters:
337  * flush_wtime <-- elapsed time interval between file flushes;
338  * if < 0, no forced flush
339  * n_buffer_steps <-- number of time steps in output buffer if
340  * file is not to be kept open
341  *----------------------------------------------------------------------------*/
342 
343 void
344 cs_time_plot_set_flush_default(float flush_wtime,
345  int n_buffer_steps);
346 
347 /*----------------------------------------------------------------------------
348  * Return time plot file writer flush behavior defaults.
349  *
350  * parameters:
351  * flush_wtime --> elapsed time interval between file flushes;
352  * if < 0, no forced flush (NULL if not queried)
353  * n_buffer_steps <-- number of time steps in output buffer if
354  * file is not to be kept open (NULL if not queried)
355  *----------------------------------------------------------------------------*/
356 
357 void
358 cs_time_plot_get_flush_default(float *flush_wtime,
359  int *n_buffer_steps);
360 
361 /*----------------------------------------------------------------------------*/
362 
364 
365 #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:1320
void tplwri(const cs_int_t *tplnum, const cs_int_t *tplfmt, const cs_int_t *nprb, const cs_int_t *ntcabs, const cs_real_t *ttcabs, const cs_real_t *valprb)
Definition: cs_time_plot.c:999
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
int cs_int_t
Fortran-compatible integer.
Definition: cs_defs.h:295
void tplend(const cs_int_t *tplnum, const cs_int_t *tplfmt)
Definition: cs_time_plot.c:947
integer(c_int), pointer, save idtvar
option for a variable time step
Definition: optcal.f90:431
double precision, dimension(3, 3, nstrmx), save xmstru
Definition: alstru.f90:48
Definition: cs_field_pointer.h:66
#define CS_ARGF_SUPP_CHAINE
Definition: cs_defs.h:487
double cs_real_t
Floating-point value.
Definition: cs_defs.h:296
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. In case of restart, this is equal to ttpabs + additional computed time...
Definition: optcal.f90:405
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:1146
void tplnbr(cs_int_t *ntpl)
Definition: cs_time_plot.c:1041
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:1230
void tpsini(const cs_int_t *tplnum, const char *tplnam, const char *tplpre, const cs_int_t *tplfmt, const cs_int_t *idtvar, const cs_int_t *nstru, const cs_real_t *xmstru, const cs_real_t *xcstru, const cs_real_t *xkstru, const cs_int_t *lnam, const cs_int_t *lpre CS_ARGF_SUPP_CHAINE)
Definition: cs_time_plot.c:877
void cs_time_plot_finalize(cs_time_plot_t **p)
Definition: cs_time_plot.c:1189
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:1355
integer, save tplfmt
time plot format (1: .dat, 2: .csv, 3: both)
Definition: entsor.f90:168
#define END_C_DECLS
Definition: cs_defs.h:449
void cs_time_plot_set_flush_default(float flush_wtime, int n_buffer_steps)
Definition: cs_time_plot.c:1337
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:392
#define CS_PROCF(x, y)
Definition: cs_defs.h:472
void cs_time_plot_flush(cs_time_plot_t *p)
Definition: cs_time_plot.c:1298
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:1084
Definition: cs_field_pointer.h:93
void tppini(const cs_int_t *tplnum, const char *tplnam, const char *tplpre, const cs_int_t *tplfmt, const cs_int_t *idtvar, const cs_int_t *nprb, const cs_int_t *lstprb, const cs_real_t *xyzprb, const cs_int_t *lnam, const cs_int_t *lpre CS_ARGF_SUPP_CHAINE)
Definition: cs_time_plot.c:798
Definition: cs_time_plot.h:57