programmer's documentation
cs_post.h
Go to the documentation of this file.
1 #ifndef __CS_POST_H__
2 #define __CS_POST_H__
3 
4 /*============================================================================
5  * Post-processing management
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  * Standard C library headers
32  *----------------------------------------------------------------------------*/
33 
34 /*----------------------------------------------------------------------------
35  * Local headers
36  *----------------------------------------------------------------------------*/
37 
38 #include "fvm_nodal.h"
39 #include "fvm_writer.h"
40 
41 #include "cs_base.h"
42 #include "cs_probe.h"
43 #include "cs_time_step.h"
44 
45 /*----------------------------------------------------------------------------*/
46 
48 
49 /*============================================================================
50  * Macro definitions
51  *============================================================================*/
52 
53 /*
54  * Output type masks
55  */
56 
57 #define CS_POST_ON_LOCATION (1 << 0) /* postprocess variables
58  on their base location
59  (volume for variables) */
60 #define CS_POST_BOUNDARY_NR (1 << 1) /* postprocess boundary
61  without reconstruction */
62 
63 /*============================================================================
64  * Local type definitions
65  *============================================================================*/
66 
67 /* Datatype enumeration */
68 
69 typedef enum {
76 
77 /*----------------------------------------------------------------------------
78  * Function pointer to elements selection definition.
79  *
80  * Each function of this sort may be used to select a given type of element,
81  * usually cells, interior faces, boundary faces, or particles.
82  *
83  * If non-empty and not containing all elements, a list of elements of the
84  * main mesh should be allocated (using BFT_MALLOC) and defined by this
85  * function when called. This list's lifecycle is then managed by the
86  * postprocessing subsystem.
87  *
88  * Note: if the input pointer is non-NULL, it must point to valid data
89  * when the selection function is called, so either:
90  * - that value or structure should not be temporary (i.e. local);
91  * - post-processing output must be ensured using cs_post_write_meshes()
92  * with a fixed-mesh writer before the data pointed to goes out of scope;
93  *
94  * parameters:
95  * input <-> pointer to optional (untyped) value or structure.
96  * n_elts --> number of selected elements.
97  * elt_list --> list of selected elements (0 to n-1 numbering).
98  *----------------------------------------------------------------------------*/
99 
100 typedef void
102  cs_lnum_t *n_elts,
103  cs_lnum_t **elt_list);
104 
105 /*----------------------------------------------------------------------------
106  * Function pointer associated with a specific post-processing output.
107  *
108  * Such functions are registered using the cs_post_add_time_dep_vars(),
109  * and all registered functions are automatically called by
110  * cs_post_write_vars().
111  *
112  * Note: if the input pointer is non-NULL, it must point to valid data
113  * when the output function is called, so either:
114  * - that value or structure should not be temporary (i.e. local);
115  * - post-processing output must be ensured using cs_post_write_var()
116  * or similar before the data pointed to goes out of scope.
117  *
118  * parameters:
119  * input <-> pointer to optional (untyped) value or structure.
120  * ts <-- time step status structure, or NULL
121  *----------------------------------------------------------------------------*/
122 
123 typedef void
125  const cs_time_step_t *ts);
126 
127 /*----------------------------------------------------------------------------
128  * Function pointer associated with a specific post-processing output
129  * on multiple meshes.
130  *
131  * Such functions are registered using the cs_post_add_time_mesh_dep_vars(),
132  * and all registered functions are automatically called by
133  * cs_post_write_vars().
134  *
135  * Note: if the input pointer is non-NULL, it must point to valid data
136  * when the output function is called, so either:
137  * - that value or structure should not be temporary (i.e. local);
138  * - post-processing output must be ensured using cs_post_write_var()
139  * or similar before the data pointed to goes out of scope.
140  *
141  * parameters:
142  * input <-> pointer to optional (untyped) value or structure.
143  * mesh_id <-- id of the output mesh for the current call
144  * cat_id <-- category id of the output mesh for the current call
145  * ent_flag <-- indicate global presence of cells (ent_flag[0]), interior
146  * faces (ent_flag[1]), boundary faces (ent_flag[2]),
147  * particles (ent_flag[3]) or probes (ent_flag[4])
148  * n_cells <-- local number of cells of post_mesh
149  * n_i_faces <-- local number of interior faces of post_mesh
150  * n_b_faces <-- local number of boundary faces of post_mesh
151  * cell_list <-- list of cells (1 to n) of post-processing mesh
152  * i_face_list <-- list of interior faces (1 to n) of post-processing mesh
153  * b_face_list <-- list of boundary faces (1 to n) of post-processing mesh
154  * ts <-- time step status structure, or NULL
155  *----------------------------------------------------------------------------*/
156 
157 typedef void
159  int mesh_id,
160  int cat_id,
161  int ent_flag[5],
162  cs_lnum_t n_cells,
163  cs_lnum_t n_i_faces,
164  cs_lnum_t n_b_faces,
165  const cs_lnum_t cell_list[],
166  const cs_lnum_t i_face_list[],
167  const cs_lnum_t b_face_list[],
168  const cs_time_step_t *ts);
169 
170 /*=============================================================================
171  * Global variables
172  *============================================================================*/
173 
174 /*============================================================================
175  * Public function prototypes
176  *============================================================================*/
177 
178 /*----------------------------------------------------------------------------
179  * Configure the post-processing output so that a mesh displacement field
180  * may be output automatically for meshes based on the global volume mesh/
181  *----------------------------------------------------------------------------*/
182 
183 void
185 
186 /*----------------------------------------------------------------------------
187  * Configure the post-processing output so that mesh connectivity
188  * may be automatically updated.
189  *
190  * This is done for meshes defined using selection criteria or functions.
191  * The behavior of Lagrangian meshes is unchanged.
192  *
193  * To be effective, this function should be called before defining
194  * postprocessing meshes.
195  *----------------------------------------------------------------------------*/
196 
197 void
199 
200 /*----------------------------------------------------------------------------
201  * Define a writer; this objects manages a case's name, directory, and format,
202  * as well as associated mesh's time dependency, and the default output
203  * frequency for associated variables.
204  *
205  * This function must be called before the time loop. If a writer with a
206  * given id is defined multiple times, the last definition supercedes the
207  * previous ones.
208  *
209  * parameters:
210  * writer_id <-- number of writer to create (< 0 reserved, > 0 for user)
211  * case_name <-- associated case name
212  * dir_name <-- associated directory name
213  * fmt_name <-- associated format name
214  * fmt_opts <-- associated format options string
215  * time_dep <-- FVM_WRITER_FIXED_MESH if mesh definitions are fixed,
216  * FVM_WRITER_TRANSIENT_COORDS if coordinates change,
217  * FVM_WRITER_TRANSIENT_CONNECT if connectivity changes
218  * output_at_end <-- force output at calculation end if not 0
219  * frequency_n <-- default output frequency in time-steps, or < 0
220  * frequency_t <-- default output frequency in seconds, or < 0
221  * (has priority over frequency_n)
222  *----------------------------------------------------------------------------*/
223 
224 void
225 cs_post_define_writer(int writer_id,
226  const char *case_name,
227  const char *dir_name,
228  const char *fmt_name,
229  const char *fmt_opts,
230  fvm_writer_time_dep_t time_dep,
231  bool output_at_end,
232  int frequency_n,
233  double frequency_t);
234 
235 /*----------------------------------------------------------------------------
236  * Define a volume post-processing mesh.
237  *
238  * parameters:
239  * mesh_id <-- id of mesh to define (< 0 reserved, > 0 for user)
240  * mesh_name <-- associated mesh name
241  * cell_criteria <-- selection criteria for cells
242  * add_groups <-- if true, add group information if present
243  * auto_variables <-- if true, automatic output of main variables
244  * n_writers <-- number of associated writers
245  * writer_ids <-- ids of associated writers
246  *----------------------------------------------------------------------------*/
247 
248 void
249 cs_post_define_volume_mesh(int mesh_id,
250  const char *mesh_name,
251  const char *cell_criteria,
252  bool add_groups,
253  bool auto_variables,
254  int n_writers,
255  const int writer_ids[]);
256 
257 /*----------------------------------------------------------------------------
258  * Define a volume post-processing mesh using a selection function.
259  *
260  * The selection may be updated over time steps if both the time_varying
261  * flag is set to true and the mesh is only associated with writers defined
262  * with the FVM_WRITER_TRANSIENT_CONNECT option.
263  *
264  * Note: if the cell_select_input pointer is non-NULL, it must point
265  * to valid data when the selection function is called, so either:
266  * - that value or structure should not be temporary (i.e. local);
267  * - post-processing output must be ensured using cs_post_write_meshes()
268  * with a fixed-mesh writer before the data pointed to goes out of scope;
269  *
270  * parameters:
271  * mesh_id <-- id of mesh to define (< 0 reserved, > 0 for user)
272  * mesh_name <-- associated mesh name
273  * cell_select_func <-- pointer to cells selection function
274  * cell_select_input <-> pointer to optional input data for the cell
275  * selection function, or NULL
276  * time_varying <-- if true, try to redefine mesh at each output time
277  * add_groups <-- if true, add group information if present
278  * auto_variables <-- if true, automatic output of main variables
279  * n_writers <-- number of associated writers
280  * writer_ids <-- ids of associated writers
281  *----------------------------------------------------------------------------*/
282 
283 void
285  const char *mesh_name,
286  cs_post_elt_select_t *cell_select_func,
287  void *cell_select_input,
288  bool time_varying,
289  bool add_groups,
290  bool auto_variables,
291  int n_writers,
292  const int writer_ids[]);
293 
294 /*----------------------------------------------------------------------------
295  * Define a surface post-processing mesh.
296  *
297  * parameters:
298  * mesh_id <-- id of mesh to define (< 0 reserved, > 0 for user)
299  * mesh_name <-- associated mesh name
300  * i_face_criteria <-- selection criteria for interior faces
301  * b_face_criteria <-- selection criteria for boundary faces
302  * add_groups <-- if true, add group information if present
303  * auto_variables <-- if true, automatic output of main variables
304  * n_writers <-- number of associated writers
305  * writer_ids <-- ids of associated writers
306  *----------------------------------------------------------------------------*/
307 
308 void
309 cs_post_define_surface_mesh(int mesh_id,
310  const char *mesh_name,
311  const char *i_face_criteria,
312  const char *b_face_criteria,
313  bool add_groups,
314  bool auto_variables,
315  int n_writers,
316  const int writer_ids[]);
317 
318 /*----------------------------------------------------------------------------
319  * Define a surface post-processing mesh using selection functions.
320  *
321  * The selection may be updated over time steps if both the time_varying
322  * flag is set to true and the mesh is only associated with writers defined
323  * with the FVM_WRITER_TRANSIENT_CONNECT option.
324  *
325  * Note: if i_face_select_input or b_face_select_input pointer is non-NULL,
326  * it must point to valid data when the selection function is called,
327  * so either:
328  * - that value or structure should not be temporary (i.e. local);
329  * - post-processing output must be ensured using cs_post_write_meshes()
330  * with a fixed-mesh writer before the data pointed to goes out of scope;
331  *
332  * parameters:
333  * mesh_id <-- id of mesh to define (< 0 reserved, > 0 for user)
334  * mesh_name <-- associated mesh name
335  * i_face_select_func <-- pointer to interior faces selection function
336  * b_face_select_func <-- pointer to boundary faces selection function
337  * i_face_select_input <-> pointer to optional input data for the interior
338  * faces selection function, or NULL
339  * b_face_select_input <-> pointer to optional input data for the boundary
340  * faces selection function, or NULL
341  * time_varying <-- if true, try to redefine mesh at each output time
342  * add_groups <-- if true, add group information if present
343  * auto_variables <-- if true, automatic output of main variables
344  * n_writers <-- number of associated writers
345  * writer_ids <-- ids of associated writers
346  *----------------------------------------------------------------------------*/
347 
348 void
350  const char *mesh_name,
351  cs_post_elt_select_t *i_face_select_func,
352  cs_post_elt_select_t *b_face_select_func,
353  void *i_face_select_input,
354  void *b_face_select_input,
355  bool time_varying,
356  bool add_groups,
357  bool auto_variables,
358  int n_writers,
359  const int writer_ids[]);
360 
361 /*----------------------------------------------------------------------------
362  * Define a particles post-processing mesh.
363  *
364  * Such a mesh is always time-varying, and will only be output by writers
365  * defined with the FVM_WRITER_TRANSIENT_CONNECT option.
366  *
367  * If the trajectory_mode argument is set to true, this logic is reversed,
368  * and output will only occur for writers defined with the
369  * FVM_WRITER_FIXED_MESH option. In this case, a submesh consisting of
370  * trajectory segments for the current time step will be added to
371  * the output at each output time step.
372  *
373  * parameters:
374  * mesh_id <-- id of mesh to define (< 0 reserved, > 0 for user)
375  * mesh_name <-- associated mesh name
376  * cell_criteria <-- selection criteria for cells containing particles,
377  * or NULL.
378  * density <-- fraction of the particles in the selected area
379  * which should be output (0 < density <= 1)
380  * trajectory <-- if true, activate trajectory mode
381  * auto_variables <-- if true, automatic output of main variables
382  * n_writers <-- number of associated writers
383  * writer_ids <-- ids of associated writers
384  *----------------------------------------------------------------------------*/
385 
386 void
388  const char *mesh_name,
389  const char *cell_criteria,
390  double density,
391  bool trajectory,
392  bool auto_variables,
393  int n_writers,
394  const int writer_ids[]);
395 
396 /*----------------------------------------------------------------------------
397  * Define a particles post-processing mesh using a selection function.
398  *
399  * The selection may be updated over time steps.
400  *
401  * Such a mesh is always time-varying, and will only be output by writers
402  * defined with the FVM_WRITER_TRANSIENT_CONNECT option.
403  *
404  * If the trajectory_mode argument is set to true, this logic is reversed,
405  * and output will only occur for writers defined with the
406  * FVM_WRITER_FIXED_MESH option. In this case, a submesh consisting of
407  * trajectory segments for the current time step will be added to
408  * the output at each output time step.
409  *
410  * Note: if the p_select_input pointer is non-NULL, it must point
411  * to valid data when the selection function is called, so
412  * that value or structure should not be temporary (i.e. local);
413  *
414  * parameters:
415  * mesh_id <-- id of mesh to define (< 0 reserved, > 0 for user)
416  * mesh_name <-- associated mesh name
417  * p_select_func <-- pointer to particles selection function
418  * p_select_input <-> pointer to optional input data for the particles
419  * selection function, or NULL
420  * density <-- fraction of the particles in the selected area
421  * which should be output (0 < density <= 1)
422  * trajectory <-- if true, activate trajectory mode
423  * auto_variables <-- if true, automatic output of main variables
424  * n_writers <-- number of associated writers
425  * writer_ids <-- ids of associated writers
426  *----------------------------------------------------------------------------*/
427 
428 void
430  const char *mesh_name,
431  cs_post_elt_select_t *p_select_func,
432  void *p_select_input,
433  bool trajectory,
434  bool auto_variables,
435  int n_writers,
436  const int writer_ids[]);
437 
438 /*----------------------------------------------------------------------------*/
452 /*----------------------------------------------------------------------------*/
453 
454 void
455 cs_post_define_probe_mesh(int mesh_id,
456  cs_probe_set_t *pset,
457  bool time_varying,
458  bool is_profile,
459  bool on_boundary,
460  bool auto_variable,
461  int n_writers,
462  const int writer_ids[]);
463 
464 /*----------------------------------------------------------------------------
465  * Create an alias to a post-processing mesh.
466  *
467  * An alias allows association of an extra identifier (id) to an
468  * existing post-processing mesh, and thus to associate different writers
469  * than those associated with the existing mesh. For example, this allows
470  * outputting a set of main variables every n1 time steps with one writer,
471  * and outputting a specific set of variables every n2 time time steps to
472  * another post-processing set using another writer, without the overhead
473  * that would be incurred by duplication of the post-processing mesh.
474  *
475  * An alias is thus treated in all points like its associated mesh;
476  * if the definition of either one is modified, that of the other is
477  * modified also.
478  *
479  * It is forbidden to associate an alias to another alias (as there is no
480  * identified use for this, and it would make consistency checking more
481  * difficult), but multiple aliases may be associated with a given mesh.
482  *
483  * parameters:
484  * mesh_id <-- id of mesh to define (< 0 reserved, > 0 for user)
485  * aliased_mesh_id <-- id of aliased mesh
486  * auto_variables <-- if true, automatic output of main variables
487  * n_writers <-- number of associated writers
488  * writer_ids <-- ids of associated writers
489  *----------------------------------------------------------------------------*/
490 
491 void
492 cs_post_define_alias_mesh(int mesh_id,
493  int aliased_mesh_id,
494  bool auto_variables,
495  int n_writers,
496  const int writer_ids[]);
497 
498 /*----------------------------------------------------------------------------
499  * Create a post-processing mesh associated with an existing exportable mesh
500  * representation.
501  *
502  * If the exportable mesh is not intended to be used elsewhere, one can choose
503  * to transfer its property to the post-processing mesh, which will then
504  * manage its lifecycle based on its own requirements.
505  *
506  * If the exportable mesh must still be shared, one must be careful to
507  * maintain consistency between this mesh and the post-processing output.
508  *
509  * The mesh in exportable dimension may be of a lower dimension than
510  * its parent mesh, if it has been projected. In this case, a
511  * dim_shift value of 1 indicates that parent cells are mapped to
512  * exportable faces, and faces to edges, while a dim_shift value of 2
513  * would indicate that parent cells are mapped to edges.
514  * This is important when variables values are exported.
515  *
516  * parameters:
517  * mesh_id <-- number of mesh to create (< 0 reserved, > 0 for user)
518  * exp_mesh <-- mesh in exportable representation (i.e. fvm_nodal_t)
519  * dim_shift <-- nonzero if exp_mesh has been projected
520  * transfer <-- if true, ownership of exp_mesh is transferred to
521  * the post-processing mesh
522  * auto_variables <-- if true, automatic output of main variables
523  * n_writers <-- number of associated writers
524  * writer_ids <-- ids of associated writers
525  *----------------------------------------------------------------------------*/
526 
527 void
528 cs_post_define_existing_mesh(int mesh_id,
529  fvm_nodal_t *exp_mesh,
530  int dim_shift,
531  bool transfer,
532  bool auto_variables,
533  int n_writers,
534  const int writer_ids[]);
535 
536 /*----------------------------------------------------------------------------
537  * Create a mesh based upon the extraction of edges from an existing mesh.
538  *
539  * The newly created edges have no link to their parent elements, so
540  * no variable referencing parent elements may be output to this mesh,
541  * whose main use is to visualize "true" face edges when polygonal faces
542  * are subdivided by the writer. In this way, even highly non-convex
543  * faces may be visualized correctly if their edges are overlaid on
544  * the surface mesh with subdivided polygons.
545  *
546  * parameters:
547  * mesh_id <-- id of edges mesh to create (< 0 reserved, > 0 for user)
548  * base_mesh_id <-- id of existing mesh (< 0 reserved, > 0 for user)
549  * n_writers <-- number of associated writers
550  * writer_ids <-- ids of associated writers
551  *----------------------------------------------------------------------------*/
552 
553 void
554 cs_post_define_edges_mesh(int mesh_id,
555  int base_mesh_id,
556  int n_writers,
557  const int writer_ids[]);
558 
559 /*----------------------------------------------------------------------------
560  * Get a postprocessing meshes entity presence flag.
561  *
562  * This flag is an array of 3 integers, indicating the presence of elements
563  * of given types on at least one subdomain (i.e. rank):
564  * 0: presence of cells
565  * 1: presence of interior faces
566  * 2: presence of boundary faces
567  *
568  * parameters:
569  * mesh_id <-- postprocessing mesh id
570  *
571  * returns:
572  * pointer to entity presence flag
573  *----------------------------------------------------------------------------*/
574 
575 const int *
576 cs_post_mesh_get_ent_flag(int mesh_id);
577 
578 /*----------------------------------------------------------------------------
579  * Get a postprocessing mesh's number of cells.
580  *
581  * parameters:
582  * mesh_id <-- postprocessing mesh id
583  *
584  * returns:
585  * number of cells of postprocessing mesh.
586  *----------------------------------------------------------------------------*/
587 
588 cs_lnum_t
589 cs_post_mesh_get_n_cells(int mesh_id);
590 
591 /*----------------------------------------------------------------------------
592  * Get a postprocessing mesh's list of cells.
593  *
594  * The array of cell ids must be of at least size
595  * cs_post_mesh_get_n_cells(mesh_id).
596  *
597  * parameters:
598  * mesh_id <-- postprocessing mesh id
599  * cell_ids --> array of associated cell ids (0 to n-1 numbering,
600  * relative to main mesh)
601  *----------------------------------------------------------------------------*/
602 
603 void
604 cs_post_mesh_get_cell_ids(int mesh_id,
605  cs_lnum_t *cell_ids);
606 
607 /*----------------------------------------------------------------------------
608  * Get a postprocessing mesh's number of interior faces.
609  *
610  * parameters:
611  * mesh_id <-- postprocessing mesh id
612  *
613  * returns:
614  * number of cells of postprocessing mesh.
615  *----------------------------------------------------------------------------*/
616 
617 cs_lnum_t
618 cs_post_mesh_get_n_i_faces(int mesh_id);
619 
620 /*----------------------------------------------------------------------------
621  * Get a postprocessing mesh's list of boundary faces.
622  *
623  * The array of boundary face ids must be of at least size
624  * cs_post_mesh_get_n_b_faces(mesh_id).
625  *
626  * parameters:
627  * mesh_id <-- postprocessing mesh id
628  * i_face_ids --> array of associated interior faces ids
629  * (0 to n-1 numbering, relative to main mesh)
630  *----------------------------------------------------------------------------*/
631 
632 void
633 cs_post_mesh_get_i_face_ids(int mesh_id,
634  cs_lnum_t i_face_ids[]);
635 
636 /*----------------------------------------------------------------------------
637  * Get a postprocessing mesh's number of boundary faces
638  *
639  * parameters:
640  * mesh_id <-- postprocessing mesh id
641  *
642  * returns:
643  * number of cells of postprocessing mesh.
644  *----------------------------------------------------------------------------*/
645 
646 cs_lnum_t
647 cs_post_mesh_get_n_b_faces(int mesh_id);
648 
649 /*----------------------------------------------------------------------------
650  * Get a postprocessing mesh's list of boundary faces.
651  *
652  * The array of boundary face ids must be of at least size
653  * cs_post_mesh_get_n_b_faces(mesh_id).
654  *
655  * parameters:
656  * mesh_id <-- postprocessing mesh id
657  * b_face_ids --> array of associated boundary faces ids
658  * (0 to n-1 numbering, relative to main mesh)
659  *----------------------------------------------------------------------------*/
660 
661 void
662 cs_post_mesh_get_b_face_ids(int mesh_id,
663  cs_lnum_t b_face_ids[]);
664 
665 /*----------------------------------------------------------------------------
666  * Set whether postprocessing mesh's parallel domain should be output.
667  *
668  * parameters:
669  * mesh_id <-- id of mesh to remove
670  * post_domain <- true if parallel domain should be output,
671  * false otherwise.
672  *----------------------------------------------------------------------------*/
673 
674 void
675 cs_post_mesh_set_post_domain(int mesh_id,
676  bool post_domain);
677 
678 /*----------------------------------------------------------------------------
679  * Remove a post-processing mesh.
680  *
681  * No further post-processing output will be allowed on this mesh,
682  * so the associated structures may be freed.
683  *
684  * A post-processing mesh that has been associated with a time-varying
685  * writer or that is referenced by an alias may not be removed.
686  *
687  * parameters:
688  * mesh_id <-- id of mesh to remove
689  *----------------------------------------------------------------------------*/
690 
691 void
692 cs_post_free_mesh(int mesh_id);
693 
694 /*----------------------------------------------------------------------------
695  * Check for the existence of a writer of the given id.
696  *
697  * parameters:
698  * writer_id <-- writer id to check
699  *
700  * returns:
701  * true if writer with this id exists, false otherwise
702  *----------------------------------------------------------------------------*/
703 
704 bool
705 cs_post_writer_exists(int writer_id);
706 
707 /*----------------------------------------------------------------------------
708  * Return a pointer to the FVM writer associated to a writer_id.
709  *
710  * parameters:
711  * writer_id <-- associated writer id
712  *
713  * returns:
714  * a pointer to a fvm_writer_t structure
715  *----------------------------------------------------------------------------*/
716 
717 fvm_writer_t *
718 cs_post_get_writer(int writer_id);
719 
720 /*----------------------------------------------------------------------------
721  * Return time dependency associated to a writer_id.
722  *
723  * parameters:
724  * writer_id <-- associated writer id
725  *
726  * returns:
727  * associated writer's time dependency
728  *----------------------------------------------------------------------------*/
729 
731 cs_post_get_writer_time_dep(int writer_id);
732 
733 /*----------------------------------------------------------------------------
734  * Add an activation time step for a specific writer or for all writers.
735  *
736  * If a negative value is provided, a previously added activation time
737  * step matching that absolute value will be removed, if present.
738  *
739  * parameters:
740  * writer_id <-- writer id, or 0 for all writers
741  * nt <-- time step value to add (or remove)
742  *----------------------------------------------------------------------------*/
743 
744 void
745 cs_post_add_writer_t_step(int writer_id,
746  int nt);
747 
748 /*----------------------------------------------------------------------------
749  * Add an activation time value for a specific writer or for all writers.
750  *
751  * If a negative value is provided, a previously added activation time
752  * step matching that absolute value will be removed, if present.
753  *
754  * parameters:
755  * writer_id <-- writer id, or 0 for all writers
756  * t <-- time value to add (or remove)
757  *----------------------------------------------------------------------------*/
758 
759 void
760 cs_post_add_writer_t_value(int writer_id,
761  double t);
762 
763 /*----------------------------------------------------------------------------
764  * Check for the existence of a post-processing mesh of the given id.
765  *
766  * parameters:
767  * mesh_id <-- mesh id to check
768  *
769  * returns:
770  * true if mesh with this id exists, false otherwise
771  *----------------------------------------------------------------------------*/
772 
773 bool
774 cs_post_mesh_exists(int mesh_id);
775 
776 /*----------------------------------------------------------------------------
777  * Modify an existing post-processing mesh.
778  *
779  * The lists of cells or faces are redefined, for example to update an
780  * extracted mesh based in "interesting" zones.
781  *
782  * It is not necessary to use this function if a mesh is simply deformed.
783  *
784  * parameters:
785  * mesh_id <-- id of mesh to modify (< 0 reserved, > 0 for user)
786  * n_cells <-- number of associated cells
787  * n_i_faces <-- number of associated interior faces
788  * n_b_faces <-- number of associated boundary faces
789  * cell_list <-> list of associated cells
790  * i_face_list <-> list of associated interior faces
791  * b_face_list <-> list of associated boundary faces
792  *
793  *----------------------------------------------------------------------------*/
794 
795 void
796 cs_post_modify_mesh(int mesh_id,
797  cs_lnum_t n_cells,
798  cs_lnum_t n_i_faces,
799  cs_lnum_t n_b_faces,
800  cs_lnum_t cell_list[],
801  cs_lnum_t i_face_list[],
802  cs_lnum_t b_face_list[]);
803 
804 /*----------------------------------------------------------------------------
805  * Return the default writer format name
806  *
807  * Returns:
808  * name of the default writer format
809  *----------------------------------------------------------------------------*/
810 
811 const char *
813 
814 /*----------------------------------------------------------------------------
815  * Return the default writer format options
816  *
817  * Returns:
818  * default writer format options string
819  *----------------------------------------------------------------------------*/
820 
821 const char *
823 
824 /*----------------------------------------------------------------------------
825  * Return the next "reservable" (i.e. non-user) writer id available.
826  *
827  * Returns:
828  * the smallest negative integer present, -1
829  *----------------------------------------------------------------------------*/
830 
831 int
833 
834 /*----------------------------------------------------------------------------
835  * Return the next "reservable" (i.e. non-user) mesh id available.
836  *
837  * Returns:
838  * the smallest negative integer present, -1
839  *----------------------------------------------------------------------------*/
840 
841 int
843 
844 /*----------------------------------------------------------------------------
845  * Update "active" or "inactive" flag of writers based on the time step.
846  *
847  * Writers are activated if their output frequency is a divisor of the
848  * current time step, or if their optional time step and value output lists
849  * contain matches for the current time step.
850  *
851  * parameters:
852  * ts <-- time step status structure
853  *----------------------------------------------------------------------------*/
854 
855 void
857 
858 /*----------------------------------------------------------------------------
859  * Force the "active" or "inactive" flag for a specific writer or for all
860  * writers for the current time step.
861  *
862  * parameters:
863  * writer_id <-- writer id, or 0 for all writers
864  * activate <-- false to deactivate, true to activate
865  *----------------------------------------------------------------------------*/
866 
867 void
868 cs_post_activate_writer(int writer_id,
869  bool activate);
870 
871 /*----------------------------------------------------------------------------
872  * Output post-processing meshes using associated writers.
873  *
874  * parameters:
875  * ts <-- time step status structure
876  *----------------------------------------------------------------------------*/
877 
878 void
880 
881 /*----------------------------------------------------------------------------
882  * Output a variable defined at cells or faces of a post-processing mesh
883  * using associated writers.
884  *
885  * parameters:
886  * mesh_id <-- id of associated mesh
887  * var_name <-- name of variable to output
888  * var_dim <-- 1 for scalar, 3 for vector
889  * interlace <-- if a vector, true for interlaced values, false otherwise
890  * use_parent <-- true if values are defined on "parent" mesh,
891  * false if values are defined on post-processing mesh
892  * var_type <-- variable's data type
893  * cel_vals <-- cell values
894  * i_face_vals <-- interior face values
895  * b_face_vals <-- boundary face values
896  * ts <-- time step status structure, or NULL
897  *----------------------------------------------------------------------------*/
898 
899 void
900 cs_post_write_var(int mesh_id,
901  const char *var_name,
902  int var_dim,
903  bool interlace,
904  bool use_parent,
905  cs_post_type_t var_type,
906  const void *cel_vals,
907  const void *i_face_vals,
908  const void *b_face_vals,
909  const cs_time_step_t *ts);
910 
911 /*----------------------------------------------------------------------------
912  * Output a variable defined at vertices of a post-processing mesh using
913  * associated writers.
914  *
915  * parameters:
916  * mesh_id <-- id of associated mesh
917  * var_name <-- name of variable to output
918  * var_dim <-- 1 for scalar, 3 for vector
919  * interlace <-- if a vector, true for interlaced values, false otherwise
920  * use_parent <-- true if values are defined on "parent" mesh,
921  * false if values are defined on post-processing mesh
922  * var_type <-- variable's data type
923  * vtx_vals <-- vertex values
924  * ts <-- time step status structure, or NULL
925  *----------------------------------------------------------------------------*/
926 
927 void
928 cs_post_write_vertex_var(int mesh_id,
929  const char *var_name,
930  int var_dim,
931  bool interlace,
932  bool use_parent,
933  cs_post_type_t var_type,
934  const void *vtx_vals,
935  const cs_time_step_t *ts);
936 
937 /*----------------------------------------------------------------------------
938  * Output an existing lagrangian particle attribute at particle
939  * positions or trajectory endpoints of a particle mesh using
940  * associated writers.
941  *
942  * parameters:
943  * mesh_id <-- id of associated mesh
944  * attr <-- associated particle attribute id
945  * var_name <-- name of variable to output
946  * component_id <-- if -1 : extract the whole attribute
947  * if >0 : id of the component to extract
948  * ts <-- time step status structure, or NULL
949  *----------------------------------------------------------------------------*/
950 
951 void
953  int attr_id,
954  const char *var_name,
955  int component_id,
956  const cs_time_step_t *ts);
957 
958 /*----------------------------------------------------------------------------
959  * Update references to parent mesh of post-processing meshes in case of
960  * computational mesh cell renumbering.
961  *
962  * This function may be called only once, after possible renumbering of cells,
963  * to update existing post-processing meshes. Post-processing meshes defined
964  * after renumbering will automatically be based upon the new numbering,
965  * so this function will not need to be called again.
966  *
967  * parameters:
968  * init_cell_num <-- initial cell numbering (new -> old)
969  *----------------------------------------------------------------------------*/
970 
971 void
972 cs_post_renum_cells(const cs_lnum_t init_cell_num[]);
973 
974 /*----------------------------------------------------------------------------
975  * Update references to parent mesh of post-processing meshes in case of
976  * computational mesh interior and/or boundary faces renumbering.
977  *
978  * This function may be called only once, after possible renumbering of faces,
979  * to update existing post-processing meshes. Post-processing meshes defined
980  * after renumbering will automatically be based upon the new numbering,
981  * so this function will not need to be called again.
982  *
983  * parameters:
984  * init_i_face_num <-- initial interior numbering (new -> old)
985  * init_b_face_num <-- initial boundary numbering (new -> old)
986  *----------------------------------------------------------------------------*/
987 
988 void
989 cs_post_renum_faces(const cs_lnum_t init_i_face_num[],
990  const cs_lnum_t init_b_face_num[]);
991 
992 /*----------------------------------------------------------------------------
993  * Initialize post-processing writers
994  *----------------------------------------------------------------------------*/
995 
996 void
998 
999 /*----------------------------------------------------------------------------
1000  * Initialize main post-processing meshes
1001  *
1002  * The check_flag variable is a mask, used for additionnal post-processing:
1003  *
1004  * - If (check_flag & 1), volume submeshes are output by groups if more
1005  * than one group is present and the default writer uses the EnSight format.
1006  *
1007  * - If (check_flag & 2), boundary submeshes are output by groups if more
1008  * than one group is present and the default writer uses the EnSight format.
1009  *
1010  * Note that all alias-type post-processing meshes and the meshes they
1011  * relate to should have been defined before calling this function, so it is
1012  * recommended that user-defined post-processing meshes be defined before
1013  * calling this function, though specific "automatic" meshes (for example
1014  * those related to couplings) may be defined between this call and a
1015  * time loop.
1016  *
1017  * parameters:
1018  * check_flag <-- mask used for additional output
1019  *----------------------------------------------------------------------------*/
1020 
1021 void
1022 cs_post_init_meshes(int check_mask);
1023 
1024 /*----------------------------------------------------------------------------
1025  * Loop on post-processing meshes to output variables.
1026  *
1027  * This handles all default fields output, as well as all
1028  * registred output functions.
1029  *
1030  * parameters:
1031  * ts <-- time step status structure, or NULL
1032  *----------------------------------------------------------------------------*/
1033 
1034 void
1036 
1037 /*----------------------------------------------------------------------------
1038  * Destroy all structures associated with post-processing
1039  *----------------------------------------------------------------------------*/
1040 
1041 void
1042 cs_post_finalize(void);
1043 
1044 /*----------------------------------------------------------------------------
1045  * Postprocess free (isolated) faces of the current global mesh
1046  *----------------------------------------------------------------------------*/
1047 
1048 void
1050 
1051 /*----------------------------------------------------------------------------
1052  * Initialize post-processing writer with same format and associated
1053  * options as default writer, but no time dependency, intended to
1054  * troubleshoot errors.
1055  *----------------------------------------------------------------------------*/
1056 
1057 void
1059 
1060 /*----------------------------------------------------------------------------
1061  * Initialize post-processing writer with same format and associated
1062  * options as default writer, but no time dependency, and associate
1063  * and output global volume mesh.
1064  *
1065  * This is intended to help troubleshoot errors using fields based
1066  * on cells.
1067  *
1068  * returns:
1069  * id of error output mesh (< 0), or 0 if all writers are deactivated
1070  *----------------------------------------------------------------------------*/
1071 
1072 int
1074 
1075 /*----------------------------------------------------------------------------
1076  * Register a processing of time-dependent variables to the call to
1077  * cs_post_write_vars().
1078  *
1079  * Note: if the input pointer is non-NULL, it must point to valid data
1080  * when the output function is called, so either:
1081  * - that value or structure should not be temporary (i.e. local);
1082  * - post-processing output must be ensured using cs_post_write_var()
1083  * or similar before the data pointed to goes out of scope.
1084  *
1085  * parameters:
1086  * function <-- function to register
1087  * input <-> pointer to optional (untyped) value or structure.
1088  *----------------------------------------------------------------------------*/
1089 
1090 void
1092  void *input);
1093 
1094 /*----------------------------------------------------------------------------
1095  * Register a processing of time-dependent variables than can be output
1096  * on different meshes to the call to cs_post_write_vars().
1097  *
1098  * Note: if the input pointer is non-NULL, it must point to valid data
1099  * when the output function is called, so either:
1100  * - that value or structure should not be temporary (i.e. local);
1101  * - post-processing output must be ensured using cs_post_write_var()
1102  * or similar before the data pointed to goes out of scope.
1103  *
1104  * parameters:
1105  * function <-- function to register
1106  * input <-> pointer to optional (untyped) value or structure.
1107  *----------------------------------------------------------------------------*/
1108 
1109 void
1111  void *input);
1112 
1113 /*----------------------------------------------------------------------------*/
1114 
1116 
1117 #endif /* __CS_POST_H__ */
void cs_post_write_vars(const cs_time_step_t *ts)
Loop on post-processing meshes to output variables.
Definition: cs_post.c:5452
Definition: cs_post.h:74
const char * cs_post_get_default_format(void)
Return the default writer format name.
Definition: cs_post.c:4146
time step descriptor
Definition: cs_time_step.h:51
void cs_post_mesh_get_i_face_ids(int mesh_id, cs_lnum_t i_face_ids[])
Get a postprocessing mesh&#39;s list of boundary faces.
Definition: cs_post.c:3888
void cs_post_init_error_writer(void)
Initialize post-processing writer with same format and associated options as default writer...
Definition: cs_post.c:6047
cs_post_type_t
Postprocessing input variable type.
Definition: cs_post.h:69
void cs_post_write_var(int mesh_id, const char *var_name, int var_dim, bool interlace, bool use_parent, cs_post_type_t var_type, const void *cel_vals, const void *i_face_vals, const void *b_face_vals, const cs_time_step_t *ts)
Output a variable defined at cells or faces of a post-processing mesh using associated writers...
Definition: cs_post.c:4471
Definition: cs_post.h:73
void cs_post_define_surface_mesh_by_func(int mesh_id, const char *mesh_name, cs_post_elt_select_t *i_face_select_func, cs_post_elt_select_t *b_face_select_func, void *i_face_select_input, void *b_face_select_input, bool time_varying, bool add_groups, bool auto_variables, int n_writers, const int writer_ids[])
Define a surface post-processing mesh using selection functions.
Definition: cs_post.c:3295
void cs_post_write_vertex_var(int mesh_id, const char *var_name, int var_dim, bool interlace, bool use_parent, cs_post_type_t var_type, const void *vtx_vals, const cs_time_step_t *ts)
Output a variable defined at vertices of a post-processing mesh using associated writers.
Definition: cs_post.c:4711
void cs_post_free_mesh(int mesh_id)
Remove a post-processing mesh.
Definition: cs_post.c:4026
void cs_post_init_writers(void)
Initialize post-processing writers.
Definition: cs_post.c:5178
void( cs_post_time_dep_output_t)(void *input, const cs_time_step_t *ts)
Definition: cs_post.h:124
void cs_post_activate_by_time_step(const cs_time_step_t *ts)
Update "active" or "inactive" flag of writers based on the time step.
Definition: cs_post.c:4206
#define BEGIN_C_DECLS
Definition: cs_defs.h:448
const int * cs_post_mesh_get_ent_flag(int mesh_id)
Get a postprocessing meshes entity presence flag.
Definition: cs_post.c:3781
void cs_post_define_particles_mesh_by_func(int mesh_id, const char *mesh_name, cs_post_elt_select_t *p_select_func, void *p_select_input, bool trajectory, bool auto_variables, int n_writers, const int writer_ids[])
Define a particles post-processing mesh using a selection function.
Definition: cs_post.c:3425
int cs_post_get_free_writer_id(void)
Return the next "reservable" (i.e. non-user) writer id available.
Definition: cs_post.c:4174
void( cs_post_time_mesh_dep_output_t)(void *input, int mesh_id, int cat_id, int ent_flag[5], cs_lnum_t n_cells, cs_lnum_t n_i_faces, cs_lnum_t n_b_faces, const cs_lnum_t cell_list[], const cs_lnum_t i_face_list[], const cs_lnum_t b_face_list[], const cs_time_step_t *ts)
Definition: cs_post.h:158
int cs_post_init_error_writer_cells(void)
Initialize post-processing writer with same format and associated options as default writer...
Definition: cs_post.c:6097
void cs_post_define_existing_mesh(int mesh_id, fvm_nodal_t *exp_mesh, int dim_shift, bool transfer, bool auto_variables, int n_writers, const int writer_ids[])
Create a post-processing mesh associated with an existing exportable mesh representation.
Definition: cs_post.c:3617
void cs_post_mesh_set_post_domain(int mesh_id, bool post_domain)
Set whether postprocessing mesh&#39;s parallel domain should be output.
Definition: cs_post.c:4003
fvm_writer_time_dep_t
Definition: fvm_writer.h:57
fvm_writer_t * cs_post_get_writer(int writer_id)
Return a pointer to the FVM writer associated to a writer_id.
Definition: cs_post.c:4311
Definition: cs_post.h:70
void cs_post_renum_faces(const cs_lnum_t init_i_face_num[], const cs_lnum_t init_b_face_num[])
Update references to parent mesh of post-processing meshes in case of computational mesh interior and...
Definition: cs_post.c:5057
void cs_post_init_meshes(int check_mask)
Initialize main post-processing meshes.
Definition: cs_post.c:5265
void cs_post_define_probe_mesh(int mesh_id, cs_probe_set_t *pset, bool time_varying, bool is_profile, bool on_boundary, bool auto_variable, int n_writers, const int writer_ids[])
Define a post-processing mesh for probes (set of probes should have been already defined) ...
Definition: cs_post.c:3475
void cs_post_mesh_get_b_face_ids(int mesh_id, cs_lnum_t b_face_ids[])
Get a postprocessing mesh&#39;s list of boundary faces.
Definition: cs_post.c:3961
cs_lnum_t cs_post_mesh_get_n_b_faces(int mesh_id)
Get a postprocessing mesh&#39;s number of boundary faces.
Definition: cs_post.c:3931
cs_lnum_t cs_post_mesh_get_n_i_faces(int mesh_id)
Get a postprocessing mesh&#39;s number of interior faces.
Definition: cs_post.c:3858
const char * cs_post_get_default_format_options(void)
Return the default writer format options.
Definition: cs_post.c:4160
void cs_post_define_particles_mesh(int mesh_id, const char *mesh_name, const char *cell_criteria, double density, bool trajectory, bool auto_variables, int n_writers, const int writer_ids[])
Define a particles post-processing mesh.
Definition: cs_post.c:3357
void cs_post_add_time_mesh_dep_output(cs_post_time_mesh_dep_output_t *function, void *input)
Register a processing of time-dependent variables than can be output on different meshes to the call ...
Definition: cs_post.c:6199
void cs_post_write_meshes(const cs_time_step_t *ts)
Output post-processing meshes using associated writers.
Definition: cs_post.c:4422
fvm_writer_time_dep_t cs_post_get_writer_time_dep(int writer_id)
Return time dependency associated to a writer_id.
Definition: cs_post.c:4336
void cs_post_define_volume_mesh(int mesh_id, const char *mesh_name, const char *cell_criteria, bool add_groups, bool auto_variables, int n_writers, const int writer_ids[])
Define a volume post-processing mesh.
Definition: cs_post.c:3121
Definition: cs_post.h:72
void cs_post_finalize(void)
Destroy all structures associated with post-processing.
Definition: cs_post.c:5731
void cs_post_define_writer(int writer_id, const char *case_name, const char *dir_name, const char *fmt_name, const char *fmt_opts, fvm_writer_time_dep_t time_dep, bool output_at_end, int frequency_n, double frequency_t)
Define a writer; this objects manages a case&#39;s name, directory, and format, as well as associated mes...
Definition: cs_post.c:2991
static int input(void)
void cs_post_define_surface_mesh(int mesh_id, const char *mesh_name, const char *i_face_criteria, const char *b_face_criteria, bool add_groups, bool auto_variables, int n_writers, const int writer_ids[])
Define a surface post-processing mesh.
Definition: cs_post.c:3226
void cs_post_set_changing_connectivity(void)
Configure the post-processing output so that mesh connectivity may be automatically updated...
Definition: cs_post.c:5166
double precision, dimension(:,:,:), allocatable density
Definition: atimbr.f90:124
void cs_post_modify_mesh(int mesh_id, cs_lnum_t n_cells, cs_lnum_t n_i_faces, cs_lnum_t n_b_faces, cs_lnum_t cell_list[], cs_lnum_t i_face_list[], cs_lnum_t b_face_list[])
void( cs_post_elt_select_t)(void *input, cs_lnum_t *n_elts, cs_lnum_t **elt_list)
Function pointer to elements selection definition.
Definition: cs_post.h:101
int cs_post_get_free_mesh_id(void)
Return the next "reservable" (i.e. non-user) mesh id available.
Definition: cs_post.c:4188
void cs_post_set_deformable(void)
Configure the post-processing output so that a mesh displacement field may be output automatically fo...
Definition: cs_post.c:5147
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
cs_lnum_t cs_post_mesh_get_n_cells(int mesh_id)
Get a postprocessing mesh&#39;s number of cells.
Definition: cs_post.c:3799
void cs_post_mesh_get_cell_ids(int mesh_id, cs_lnum_t *cell_ids)
Get a postprocessing mesh&#39;s list of cells.
Definition: cs_post.c:3829
void cs_post_activate_writer(int writer_id, bool activate)
Force the "active" or "inactive" flag for a specific writer or for all writers for the current time s...
Definition: cs_post.c:4281
void cs_post_add_free_faces(void)
Postprocess free (isolated) faces of the current global mesh.
Definition: cs_post.c:5836
#define END_C_DECLS
Definition: cs_defs.h:449
void cs_post_add_writer_t_value(int writer_id, double t)
Add an activation time value for a specific writer or for all writers.
Definition: cs_post.c:4395
struct _cs_probe_set_t cs_probe_set_t
Definition: cs_probe.h:48
void cs_post_add_time_dep_output(cs_post_time_dep_output_t *function, void *input)
Register a processing of time-dependent variables to the call to cs_post_write_vars().
Definition: cs_post.c:6158
Definition: cs_post.h:71
void cs_post_define_edges_mesh(int mesh_id, int base_mesh_id, int n_writers, const int writer_ids[])
Create a mesh based upon the extraction of edges from an existing mesh.
Definition: cs_post.c:3741
Definition: cs_field_pointer.h:93
void cs_post_write_particle_values(int mesh_id, int attr_id, const char *var_name, int component_id, const cs_time_step_t *ts)
Output an existing lagrangian particle attribute at particle positions or trajectory endpoints of a p...
Definition: cs_post.c:4825
void cs_post_define_alias_mesh(int mesh_id, int aliased_mesh_id, bool auto_variables, int n_writers, const int writer_ids[])
Create an alias to a post-processing mesh.
Definition: cs_post.c:3545
bool cs_post_mesh_exists(int mesh_id)
Check for the existence of a post-processing mesh of the given id.
Definition: cs_post.c:4121
void cs_post_add_writer_t_step(int writer_id, int nt)
Add an activation time step for a specific writer or for all writers.
Definition: cs_post.c:4367
bool cs_post_writer_exists(int writer_id)
Check for the existence of a writer of the given id.
Definition: cs_post.c:4092
void cs_post_define_volume_mesh_by_func(int mesh_id, const char *mesh_name, cs_post_elt_select_t *cell_select_func, void *cell_select_input, bool time_varying, bool add_groups, bool auto_variables, int n_writers, const int writer_ids[])
Define a volume post-processing mesh using a selection function.
Definition: cs_post.c:3180
void cs_post_renum_cells(const cs_lnum_t init_cell_num[])
Update references to parent mesh of post-processing meshes in case of computational mesh cell renumbe...
Definition: cs_post.c:4981