My Project
programmer's documentation
fvm_to_med.h
Go to the documentation of this file.
1 #ifndef __FVM_TO_MED_H__
2 #define __FVM_TO_MED_H__
3 
4 #if defined(HAVE_MED)
5 
6 /*============================================================================
7  * Write a nodal representation associated with a mesh and associated
8  * variables to MED files
9  *============================================================================*/
10 
11 /*
12  This file is part of Code_Saturne, a general-purpose CFD tool.
13 
14  Copyright (C) 1998-2019 EDF S.A.
15 
16  This program is free software; you can redistribute it and/or modify it under
17  the terms of the GNU General Public License as published by the Free Software
18  Foundation; either version 2 of the License, or (at your option) any later
19  version.
20 
21  This program is distributed in the hope that it will be useful, but WITHOUT
22  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
23  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
24  details.
25 
26  You should have received a copy of the GNU General Public License along with
27  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
28  Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 */
30 
31 /*----------------------------------------------------------------------------*/
32 
33 #include "cs_defs.h"
34 
35 /*----------------------------------------------------------------------------
36  * Local headers
37  *----------------------------------------------------------------------------*/
38 
39 #include "fvm_defs.h"
40 #include "fvm_nodal.h"
41 #include "fvm_writer.h"
42 
43 /*----------------------------------------------------------------------------*/
44 
46 
47 /*=============================================================================
48  * Macro definitions
49  *============================================================================*/
50 
51 /*============================================================================
52  * Type definitions
53  *============================================================================*/
54 
55 /*=============================================================================
56  * Public function prototypes
57  *============================================================================*/
58 
59 /*----------------------------------------------------------------------------
60  * Returns number of library version strings associated with the MED format.
61  *
62  * The first associated version string should corresponds to the MED library,
63  * The second to the HDF5 library.
64  *
65  * returns:
66  * number of library version strings associated with the MED format.
67  *----------------------------------------------------------------------------*/
68 
69 int
70 fvm_to_med_n_version_strings(void);
71 
72 /*----------------------------------------------------------------------------
73  * Returns a library version string associated with the MED format.
74  *
75  * The first associated version string should corresponds to the MED library,
76  * The second to the HDF5 library.
77  *
78  * In certain cases, when using dynamic libraries, fvm may be compiled
79  * with one library version, and linked with another. If both run-time
80  * and compile-time version information is available, this function
81  * will return the run-time version string by default.
82  *
83  * Setting the compile_time flag to 1, the compile-time version string
84  * will be returned if this is different from the run-time version.
85  * If the version is the same, or only one of the 2 version strings are
86  * available, a NULL character string will be returned with this flag set.
87  *
88  * parameters:
89  * string_index <-- index in format's version string list (0 to n-1)
90  * compile_time <-- 0 by default, 1 if we want the compile-time version
91  * string, if different from the run-time version.
92  *
93  * returns:
94  * pointer to constant string containing the library's version.
95  *----------------------------------------------------------------------------*/
96 
97 const char *
98 fvm_to_med_version_string(int string_index,
99  int compile_time_version);
100 
101 /*----------------------------------------------------------------------------
102  * Initialize FVM to MED file writer.
103  *
104  * Options are:
105  * discard_polygons do not output polygons or related values
106  * discard_polyhedra do not output polyhedra or related values
107  * divide_polygons tesselate polygons with triangles
108  * divide_polyhedra tesselate polyhedra with tetrahedra and pyramids
109  * (adding a vertex near each polyhedron's center)
110  * serial_io force serial IO even when parallel IO is available
111  *
112  * parameters:
113  * name <-- base output case name.
114  * options <-- whitespace separated, lowercase options list
115  * time_dependecy <-- indicates if and how meshes will change with time
116  * comm <-- associated MPI communicator.
117  *
118  * returns:
119  * pointer to opaque MED writer structure.
120  *----------------------------------------------------------------------------*/
121 
122 #if defined(HAVE_MPI)
123 
124 void *
125 fvm_to_med_init_writer(const char *const name,
126  const char *const path,
127  const char *const options,
128  const fvm_writer_time_dep_t time_dependency,
129  const MPI_Comm comm);
130 
131 #else
132 
133 void *
134 fvm_to_med_init_writer(const char *const name,
135  const char *const path,
136  const char *const options,
137  const fvm_writer_time_dep_t time_dependency);
138 
139 #endif
140 
141 /*----------------------------------------------------------------------------
142  * Finalize FVM to MED file writer.
143  *
144  * parameters:
145  * this_writer_p <-- pointer to opaque MED writer structure.
146  *
147  * returns:
148  * NULL pointer.
149  *----------------------------------------------------------------------------*/
150 
151 void *
152 fvm_to_med_finalize_writer(void *this_writer_p);
153 
154 /*----------------------------------------------------------------------------
155  * Indicate if a elements of a given type in a mesh associated to a given
156  * MED file writer need to be tesselated.
157  *
158  * parameters:
159  * this_writer <-- pointer to associated writer
160  * mesh <-- pointer to nodal mesh structure that should be written
161  * element_type <-- element type we are interested in
162  *
163  * returns:
164  * 1 if tesselation of the given element type is needed, 0 otherwise
165  *----------------------------------------------------------------------------*/
166 
167 int
168 fvm_to_med_needs_tesselation(void *this_writer,
169  const fvm_nodal_t *mesh,
170  fvm_element_t element_type);
171 
172 /*----------------------------------------------------------------------------
173  * Associate new time step with a MED mesh.
174  *
175  * parameters:
176  * this_writer <-- pointer to associated writer
177  * time_step <-- time step number
178  * time_value <-- time_value number
179  *----------------------------------------------------------------------------*/
180 
181 void
182 fvm_to_med_set_mesh_time(void *const this_writer,
183  const int time_step,
184  const double time_value);
185 
186 /*----------------------------------------------------------------------------
187  * Indicate a given mesh is present in a MED file.
188  *
189  * This does not do any verification that the mesh is indeed present,
190  * so this should be ensured before. The writer info is simply updated
191  * so that additional fields may be output or updated in an existing file.
192  *
193  * parameters:
194  * this_writer <-- pointer to associated writer.
195  * mesh <-- pointer to nodal mesh structure that should be written.
196  *----------------------------------------------------------------------------*/
197 
198 void
199 fvm_to_med_map_nodal(void *this_writer,
200  const fvm_nodal_t *mesh);
201 
202 /*----------------------------------------------------------------------------
203  * Write nodal mesh to a MED file
204  *
205  * parameters:
206  * this_writer_p <-- pointer to associated writer.
207  * mesh <-- pointer to nodal mesh structure that should be written.
208  *----------------------------------------------------------------------------*/
209 
210 void
211 fvm_to_med_export_nodal(void *const this_writer_p,
212  const fvm_nodal_t *const mesh);
213 
214 /*----------------------------------------------------------------------------
215  * Write field associated with a nodal mesh to a MED file.
216  *
217  * Assigning a negative value to the time step indicates a time-independent
218  * field (in which case the time_value argument is unused).
219  *
220  * parameters:
221  * this_writer_p <-- pointer to associated writer
222  * mesh <-- pointer to associated nodal mesh structure
223  * name <-- variable name
224  * location <-- variable definition location (nodes or elements)
225  * dimension <-- variable dimension (0: constant, 1: scalar,
226  * 3: vector, 6: sym. tensor, 9: asym. tensor)
227  * interlace <-- indicates if variable in memory is interlaced
228  * n_parent_lists <-- indicates if variable values are to be obtained
229  * directly through the local entity index (when 0) or
230  * through the parent entity numbers (when 1 or more)
231  * parent_num_shift <-- parent number to value array index shifts;
232  * size: n_parent_lists
233  * datatype <-- indicates the data type of (source) field values
234  * time_step <-- number of the current time step
235  * time_value <-- associated time value
236  * field_values <-- array of associated field value arrays
237  *----------------------------------------------------------------------------*/
238 
239 void
240 fvm_to_med_export_field(void *const this_writer,
241  const fvm_nodal_t *const mesh,
242  const char *const name,
243  const fvm_writer_var_loc_t location,
244  const int dimension,
245  const cs_interlace_t interlace,
246  const int n_parent_lists,
247  const cs_lnum_t parent_num_shift[],
248  const cs_datatype_t datatype,
249  const int time_step,
250  const double time_value,
251  const void *const field_values[]);
252 
253 /*----------------------------------------------------------------------------*/
254 
256 
257 #endif /* __FVM_TO_MED_H__ */
258 
259 #endif /* HAVE_MED */
fvm_writer_var_loc_t
fvm_writer_var_loc_t
Definition: fvm_writer.h:69
cs_defs.h
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
fvm_writer.h
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
mesh
Definition: mesh.f90:26
cs_datatype_t
cs_datatype_t
Definition: cs_defs.h:260
fvm_element_t
fvm_element_t
Definition: fvm_defs.h:48
fvm_writer_time_dep_t
fvm_writer_time_dep_t
Definition: fvm_writer.h:57
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_nodal.h
fvm_defs.h