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-2021 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 38 BEGIN_C_DECLS 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) */ 59 } cs_time_plot_format_t; 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 * integer lnam : <-- : name length 89 * integer lpre : <-- : prefix length 90 *----------------------------------------------------------------------------*/ 91 92 void CS_PROCF (tpsini, TPSINI) 93 ( 94 const int *tplnum, 95 const char *tplnam, 96 const char *tplpre, 97 const int *tplfmt, 98 const int *idtvar, 99 const int *nstru, 100 const cs_real_t *xmstru, 101 const cs_real_t *xcstru, 102 const cs_real_t *xkstru, 103 const int *lnam, 104 const int *lpre 105 CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added 106 by many Fortran compilers) */ 107 ); 108 109 /*---------------------------------------------------------------------------- 110 * Finalize a writer for time plot data. 111 * 112 * This subroutine should only be called by one rank for a given data series. 113 * 114 * subroutine tplend (tplnum) 115 * ***************** 116 * 117 * integer tplnum : <-- : number of plot to create (> 0) 118 * integer tplfmt : <-- : associated format 119 * (1: dat, 2: csv, 3: both) 120 *----------------------------------------------------------------------------*/ 121 122 void CS_PROCF (tplend, TPLEND) 123 ( 124 const int *tplnum, 125 const int *tplfmt 126 ); 127 128 /*---------------------------------------------------------------------------- 129 * Write time plot values. 130 * 131 * subroutine tplwri (tplnum, tplfmt, nprb, ntcabs, ttcabs, valprb) 132 * ***************** 133 * 134 * integer tplnum : <-- : number of associated plot (> 0) 135 * integer tplfmt : <-- : associated format 136 * (1: dat, 2: csv, 3: both) 137 * integer nprb : <-- : number of probes 138 * integer ntcabs : <-- : current time step number 139 * double precision ttcabs : <-- : current time value 140 * double precision valprb : <-- : probe values 141 *----------------------------------------------------------------------------*/ 142 143 void CS_PROCF (tplwri, TPLWRI) 144 ( 145 const int *tplnum, 146 const int *tplfmt, 147 const int *nprb, 148 const int *ntcabs, 149 const cs_real_t *ttcabs, 150 const cs_real_t *valprb 151 ); 152 153 /*---------------------------------------------------------------------------- 154 * Return the number of time plots accessible through the Fortran API 155 * 156 * This subroutine will only return the number of time plots defined by the 157 * local rank 158 * 159 * subroutine tplnbr (ntpl) 160 * ***************** 161 * 162 * integer ntpl : --> : number of time plots defined 163 *----------------------------------------------------------------------------*/ 164 165 void CS_PROCF (tplnbr, TPLNBR) 166 ( 167 int *ntpl 168 ); 169 170 /*============================================================================= 171 * Public function prototypes 172 *============================================================================*/ 173 174 /*---------------------------------------------------------------------------- 175 * Initialize a plot file writer for probe-type plots 176 * 177 * This function should only be called by one rank for a given data series. 178 * 179 * parameters: 180 * plot_name <-- plot (variable) name 181 * file_prefix <-- file name prefix 182 * format <-- associated file format 183 * use_iteration <-- should we use the iteration number instead of the 184 * physical time ? 185 * flush_wtime <-- elapsed time interval between file flushes 186 * (if < 0, no forced flush) 187 * n_buffer_steps <-- number of time steps in output buffer if 188 * file is not to be kept open 189 * n_probes <-- number of probes associated with this plot 190 * probe_list <-- numbers (1 to n) of probes if filtered, or NULL 191 * probe_coords <-- probe coordinates, or NULL 192 * probe_names <-- probe names, or NULL 193 * 194 * returns: 195 * pointer to new time plot writer 196 *----------------------------------------------------------------------------*/ 197 198 cs_time_plot_t * 199 cs_time_plot_init_probe(const char *plot_name, 200 const char *file_prefix, 201 cs_time_plot_format_t format, 202 bool use_iteration, 203 double flush_wtime, 204 int n_buffer_steps, 205 int n_probes, 206 const int *probe_list, 207 const cs_real_t probe_coords[], 208 const char *probe_names[]); 209 210 /*---------------------------------------------------------------------------- 211 * Initialize a plot file writer for structure-type plots 212 * 213 * This function should only be called by one rank for a given data series. 214 * 215 * parameters: 216 * plot_name <-- plot (variable) name 217 * file_prefix <-- file name prefix 218 * format <-- associated file format 219 * use_iteration <-- should we use the iteration number instead of the 220 * physical time ? 221 * flush_wtime <-- elapsed time interval between file flushes 222 * (if < 0, no forced flush) 223 * n_buffer_steps <-- number of time steps in output buffer if 224 * file is not to be kept open 225 * n_structures <-- number of structures associated with this plot 226 * mass_matrixes <-- mass matrix coefficients (3x3 blocks) 227 * damping_matrixes <-- damping matrix coefficients (3x3 blocks) 228 * stiffness_matrixes <-- stiffness matrix coefficients (3x3 blocks) 229 * 230 * returns: 231 * pointer to new time plot writer 232 *----------------------------------------------------------------------------*/ 233 234 cs_time_plot_t * 235 cs_time_plot_init_struct(const char *plot_name, 236 const char *file_prefix, 237 cs_time_plot_format_t format, 238 bool use_iteration, 239 double flush_wtime, 240 int n_buffer_steps, 241 int n_structures, 242 const cs_real_t mass_matrixes[], 243 const cs_real_t damping_matrixes[], 244 const cs_real_t stiffness_matrixes[]); 245 246 /*---------------------------------------------------------------------------- 247 * Finalize time plot writer for a given variable 248 * 249 * This function should only be called by one rank for a given data series. 250 * 251 * parameters: 252 * p <-> time plot values file handler 253 *----------------------------------------------------------------------------*/ 254 255 void 256 cs_time_plot_finalize(cs_time_plot_t **p); 257 258 /*---------------------------------------------------------------------------- 259 * Write time plot values 260 * 261 * This function should only be called by one rank for a given data series. 262 * 263 * parameters: 264 * p <-- pointer to associated plot structure 265 * tn <-- associated time step number 266 * t <-- associated time value 267 * n_vals <-- number of associated time values 268 * vals <-- associated time values 269 *----------------------------------------------------------------------------*/ 270 271 void 272 cs_time_plot_vals_write(cs_time_plot_t *p, 273 int tn, 274 double t, 275 int n_vals, 276 const cs_real_t vals[]); 277 278 /*---------------------------------------------------------------------------- 279 * Flush buffered values to file if applicable 280 * 281 * parameters: 282 * p <-> time plot values file handler 283 *----------------------------------------------------------------------------*/ 284 285 void 286 cs_time_plot_flush(cs_time_plot_t *p); 287 288 /*---------------------------------------------------------------------------- 289 * flush all time plots 290 *----------------------------------------------------------------------------*/ 291 292 void 293 cs_time_plot_flush_all(void); 294 295 /*---------------------------------------------------------------------------- 296 * Set time plot file writer flush behavior defaults. 297 * 298 * parameters: 299 * flush_wtime <-- elapsed time interval between file flushes; 300 * if < 0, no forced flush 301 * n_buffer_steps <-- number of time steps in output buffer if 302 * file is not to be kept open 303 *----------------------------------------------------------------------------*/ 304 305 void 306 cs_time_plot_set_flush_default(float flush_wtime, 307 int n_buffer_steps); 308 309 /*---------------------------------------------------------------------------- 310 * Return time plot file writer flush behavior defaults. 311 * 312 * parameters: 313 * flush_wtime --> elapsed time interval between file flushes; 314 * if < 0, no forced flush (NULL if not queried) 315 * n_buffer_steps <-- number of time steps in output buffer if 316 * file is not to be kept open (NULL if not queried) 317 *----------------------------------------------------------------------------*/ 318 319 void 320 cs_time_plot_get_flush_default(float *flush_wtime, 321 int *n_buffer_steps); 322 323 /*----------------------------------------------------------------------------*/ 324 325 END_C_DECLS 326 327 #endif /* __CS_PROBE_H__ */ 328