My Project
programmer's documentation
fvm_to_histogram.h
Go to the documentation of this file.
1 #ifndef __FVM_TO_HISTOGRAM_H__
2 #define __FVM_TO_HISTOGRAM_H__
3 
4 /*============================================================================
5  * Write a nodal representation associated with a mesh and associated
6  * variables to histogram (whitepace-separated or csv) files
7  *============================================================================*/
8 
9 /*
10  This file is part of Code_Saturne, a general-purpose CFD tool.
11 
12  Copyright (C) 1998-2019 EDF S.A.
13 
14  This program is free software; you can redistribute it and/or modify it under
15  the terms of the GNU General Public License as published by the Free Software
16  Foundation; either version 2 of the License, or (at your option) any later
17  version.
18 
19  This program is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22  details.
23 
24  You should have received a copy of the GNU General Public License along with
25  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
26  Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 */
28 
29 /*----------------------------------------------------------------------------*/
30 
31 #include "cs_defs.h"
32 
33 /*----------------------------------------------------------------------------
34  * Local headers
35  *----------------------------------------------------------------------------*/
36 
37 #include "fvm_defs.h"
38 #include "fvm_nodal.h"
39 #include "fvm_writer.h"
40 
41 /*----------------------------------------------------------------------------*/
42 
44 
45 /*=============================================================================
46  * Macro definitions
47  *============================================================================*/
48 
49 /*============================================================================
50  * Type definitions
51  *============================================================================*/
52 
53 /* Type of histogram file format */
54 
55 typedef enum {
56  CS_HISTOGRAM_TXT, /* .txt file */
57  CS_HISTOGRAM_TEX, /* .tex file */
58  CS_HISTOGRAM_PNG /* .png file */
60 
61 /*----------------------------------------------------------------------------
62  * Histogram writer structure
63  *----------------------------------------------------------------------------*/
64 
65 typedef struct {
66 
67  char *name; /* Writer name */
68  char *path; /* Path prefix */
69 
70  int rank; /* Rank of current process in communicator */
71  int n_ranks; /* Number of processes in communicator */
72 
73  cs_histogram_format_t format; /* Histogram format */
74 
75  int nt; /* Time step */
76  double t; /* Time value */
77 
78  cs_real_t *buffer; /* Values buffer */
79 
80  char *file_name; /* File name */
81  FILE *f; /* Associated histograms */
82 
83  int n_sub; /* Number of subdivisions */
84 
85 #if defined(HAVE_MPI)
86  MPI_Comm comm; /* Associated MPI communicator */
87 #endif
88 
90 
91 /*----------------------------------------------------------------------------*/
101 /*----------------------------------------------------------------------------*/
102 
103 typedef void
105  cs_real_t var_max,
106  cs_gnum_t count[],
108  char *var_name);
109 
110 /*=============================================================================
111  * Public function prototypes
112  *============================================================================*/
113 
114 /*----------------------------------------------------------------------------
115  * Initialize FVM to histogram file writer.
116  *
117  * Options are:
118  * txt output txt (space-separated) files
119  * tex output TeX (TixZ) files
120  * png output PNG files
121  * [n_sub] number of subdivisions
122  *
123  * parameters:
124  * name <-- base output case name.
125  * options <-- whitespace separated, lowercase options list
126  * time_dependecy <-- indicates if and how meshes will change with time
127  * comm <-- associated MPI communicator.
128  *
129  * returns:
130  * pointer to opaque histogram writer structure.
131  *----------------------------------------------------------------------------*/
132 
133 #if defined(HAVE_MPI)
134 
135 void *
136 fvm_to_histogram_init_writer(const char *name,
137  const char *path,
138  const char *options,
139  fvm_writer_time_dep_t time_dependency,
140  MPI_Comm comm);
141 
142 #else
143 
144 void *
145 fvm_to_histogram_init_writer(const char *name,
146  const char *path,
147  const char *options,
148  fvm_writer_time_dep_t time_dependency);
149 
150 #endif
151 
152 /*----------------------------------------------------------------------------
153  * Finalize FVM to histogram file writer.
154  *
155  * parameters:
156  * writer <-- pointer to opaque histogram writer structure.
157  *
158  * returns:
159  * NULL pointer.
160  *----------------------------------------------------------------------------*/
161 
162 void *
164 
165 /*----------------------------------------------------------------------------
166  * Associate new time step with a histogram geometry.
167  *
168  * parameters:
169  * writer <-- pointer to associated writer
170  * time_step <-- time step number
171  * time_value <-- time_value number
172  *----------------------------------------------------------------------------*/
173 
174 void
175 fvm_to_histogram_set_mesh_time(void *writer,
176  const int time_step,
177  const double time_value);
178 
179 /*----------------------------------------------------------------------------
180  * Write field associated with a nodal mesh to a histogram file.
181  *
182  * Assigning a negative value to the time step indicates a time-independent
183  * field (in which case the time_value argument is unused).
184  *
185  * parameters:
186  * writer <-- pointer to associated writer
187  * mesh <-- pointer to associated nodal mesh structure
188  * name <-- variable name
189  * location <-- variable definition location (nodes or elements)
190  * dimension <-- variable dimension (0: constant, 1: scalar,
191  * 3: vector, 6: sym. tensor, 9: asym. tensor)
192  * interlace <-- indicates if variable in memory is interlaced
193  * n_parent_lists <-- indicates if variable values are to be obtained
194  * directly through the local entity index (when 0) or
195  * through the parent entity numbers (when 1 or more)
196  * parent_num_shift <-- parent number to value array index shifts;
197  * size: n_parent_lists
198  * datatype <-- indicates the data type of (source) field values
199  * time_step <-- number of the current time step
200  * time_value <-- associated time value
201  * field_values <-- array of associated field value arrays
202  *----------------------------------------------------------------------------*/
203 
204 void
205 fvm_to_histogram_export_field(void *writer,
206  const fvm_nodal_t *mesh,
207  const char *name,
208  fvm_writer_var_loc_t location,
209  int dimension,
210  cs_interlace_t interlace,
211  int n_parent_lists,
212  const cs_lnum_t parent_num_shift[],
213  cs_datatype_t datatype,
214  int time_step,
215  double time_value,
216  const void *const field_values[]);
217 
218 /*----------------------------------------------------------------------------
219  * Flush files associated with a given writer.
220  *
221  * In this case, the effective writing to file is done.
222  *
223  * parameters:
224  * writer <-- pointer to associated writer
225  *----------------------------------------------------------------------------*/
226 
227 void
228 fvm_to_histogram_flush(void *writer);
229 
230 /*----------------------------------------------------------------------------*/
231 
233 
234 #endif /* __FVM_TO_HISTOGRAM_H__ */
fvm_writer_var_loc_t
fvm_writer_var_loc_t
Definition: fvm_writer.h:69
cs_defs.h
fvm_to_histogram_writer_t::path
char * path
Definition: fvm_to_histogram.h:68
fvm_to_histogram_set_mesh_time
void fvm_to_histogram_set_mesh_time(void *writer, const int time_step, const double time_value)
Definition: fvm_to_histogram.c:695
fvm_to_histogram_finalize_writer
void * fvm_to_histogram_finalize_writer(void *writer)
Definition: fvm_to_histogram.c:662
fvm_to_histogram_writer_t::rank
int rank
Definition: fvm_to_histogram.h:70
fvm_to_histogram_writer_t::name
char * name
Definition: fvm_to_histogram.h:67
CS_HISTOGRAM_TEX
Definition: fvm_to_histogram.h:57
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
fvm_to_histogram_init_writer
void * fvm_to_histogram_init_writer(const char *name, const char *path, const char *options, fvm_writer_time_dep_t time_dependency)
Definition: fvm_to_histogram.c:546
fvm_to_histogram_writer_t::t
double t
Definition: fvm_to_histogram.h:76
fvm_to_histogram_writer_t::n_ranks
int n_ranks
Definition: fvm_to_histogram.h:71
cs_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
fvm_writer.h
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_histogram_format_t
cs_histogram_format_t
Definition: fvm_to_histogram.h:55
mesh
Definition: mesh.f90:26
fvm_to_histogram_writer_t::n_sub
int n_sub
Definition: fvm_to_histogram.h:83
cs_datatype_t
cs_datatype_t
Definition: cs_defs.h:260
fvm_to_histogram_flush
void fvm_to_histogram_flush(void *writer)
Definition: fvm_to_histogram.c:819
cs_gnum_t
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:286
fvm_writer_time_dep_t
fvm_writer_time_dep_t
Definition: fvm_writer.h:57
fvm_to_histogram_writer_t::format
cs_histogram_format_t format
Definition: fvm_to_histogram.h:73
fvm_to_histogram_writer_t::f
FILE * f
Definition: fvm_to_histogram.h:81
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_interlace_t
cs_interlace_t
Definition: cs_defs.h:439
fvm_to_histogram_writer_t::file_name
char * file_name
Definition: fvm_to_histogram.h:80
fvm_nodal.h
CS_HISTOGRAM_TXT
Definition: fvm_to_histogram.h:56
CS_HISTOGRAM_PNG
Definition: fvm_to_histogram.h:58
fvm_to_histogram_writer_t::buffer
cs_real_t * buffer
Definition: fvm_to_histogram.h:78
fvm_defs.h
fvm_to_histogram_writer_t
Definition: fvm_to_histogram.h:65
fvm_to_histogram_writer_t::nt
int nt
Definition: fvm_to_histogram.h:75
fvm_to_histogram_display_t
void() fvm_to_histogram_display_t(cs_real_t var_min, cs_real_t var_max, cs_gnum_t count[], fvm_to_histogram_writer_t *w, char *var_name)
Definition: fvm_to_histogram.h:104
fvm_to_histogram_export_field
void fvm_to_histogram_export_field(void *writer, const fvm_nodal_t *mesh, const char *name, fvm_writer_var_loc_t location, int dimension, cs_interlace_t interlace, int n_parent_lists, const cs_lnum_t parent_num_shift[], cs_datatype_t datatype, int time_step, double time_value, const void *const field_values[])
Definition: fvm_to_histogram.c:733