My Project
programmer's documentation
fvm_to_cgns.h
Go to the documentation of this file.
1 #ifndef __FVM_TO_CGNS_H__
2 #define __FVM_TO_CGNS_H__
3 
4 #if defined(HAVE_CGNS)
5 
6 /*============================================================================
7  * Write a nodal representation associated with a mesh and associated
8  * variables to CGNS 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 CGNS format.
61  *
62  * returns:
63  * number of library version strings associated with the CGNS format.
64  *----------------------------------------------------------------------------*/
65 
66 int
67 fvm_to_cgns_n_version_strings(void);
68 
69 /*----------------------------------------------------------------------------
70  * Returns a library version string associated with the CGNS format.
71  *
72  * In certain cases, when using dynamic libraries, fvm may be compiled
73  * with one library version, and linked with another. If both run-time
74  * and compile-time version information is available, this function
75  * will return the run-time version string by default.
76  *
77  * Setting the compile_time flag to 1, the compile-time version string
78  * will be returned if this is different from the run-time version.
79  * If the version is the same, or only one of the 2 version strings are
80  * available, a NULL character string will be returned with this flag set.
81  *
82  * parameters:
83  * string_index <-- index in format's version string list (0 to n-1)
84  * compile_time <-- 0 by default, 1 if we want the compile-time version
85  * string, if different from the run-time version.
86  *
87  * returns:
88  * pointer to constant string containing the library's version.
89  *----------------------------------------------------------------------------*/
90 
91 const char *
92 fvm_to_cgns_version_string(int string_index,
93  int compile_time_version);
94 
95 /*----------------------------------------------------------------------------
96  * Initialize FVM to CGNS file writer.
97  *
98  * Options are:
99  * discard_polygons do not output polygons or related values
100  * discard_polyhedra do not output polyhedra or related values
101  * divide_polygons tesselate polygons with triangles
102  * adf use ADF file type
103  * hdf5 use HDF5 file type (default if available)
104  * links split output to separate files using links
105  *
106  * As CGNS does not handle polyhedral elements in a simple manner,
107  * polyhedra are automatically tesselated with tetrahedra and pyramids
108  * (adding a vertex near each polyhedron's center) unless discarded.
109  *
110  * parameters:
111  * name <-- base output case name.
112  * options <-- whitespace separated, lowercase options list
113  * time_dependecy <-- indicates if and how meshes will change with time
114  * comm <-- associated MPI communicator.
115  *
116  * returns:
117  * pointer to opaque CGNS writer structure.
118  *----------------------------------------------------------------------------*/
119 
120 #if defined(HAVE_MPI)
121 
122 void *
123 fvm_to_cgns_init_writer(const char *name,
124  const char *path,
125  const char *options,
126  fvm_writer_time_dep_t time_dependency,
127  MPI_Comm comm);
128 
129 #else
130 
131 void *
132 fvm_to_cgns_init_writer(const char *name,
133  const char *path,
134  const char *options,
135  fvm_writer_time_dep_t time_dependency);
136 
137 #endif
138 
139 /*----------------------------------------------------------------------------
140  * Finalize FVM to CGNS file writer.
141  *
142  * parameters:
143  * this_writer_p <-- pointer to opaque CGNS writer structure.
144  *
145  * returns:
146  * NULL pointer.
147  *----------------------------------------------------------------------------*/
148 
149 void *
150 fvm_to_cgns_finalize_writer(void *this_writer_p);
151 
152 /*----------------------------------------------------------------------------
153  * Associate new time step with a CGNS geometry.
154  *
155  * parameters:
156  * this_writer_p <-- pointer to associated writer
157  * time_step <-- time step number
158  * time_value <-- time_value number
159  *----------------------------------------------------------------------------*/
160 
161 void
162 fvm_to_cgns_set_mesh_time(void *this_writer_p,
163  int time_step,
164  double time_value);
165 
166 /*----------------------------------------------------------------------------
167  * Indicate if elements of a given type in a mesh associated with a given
168  * CGNS file writer need to be tesselated.
169  *
170  * parameters:
171  * this_writer_p <-- pointer to associated writer
172  * mesh <-- pointer to nodal mesh structure that should be written
173  * element_type <-- element type we are interested in
174  *
175  * returns:
176  * 1 if tesselation of the given element type is needed, 0 otherwise
177  *----------------------------------------------------------------------------*/
178 
179 int
180 fvm_to_cgns_needs_tesselation(void *this_writer_p,
181  const fvm_nodal_t *mesh,
182  fvm_element_t element_type);
183 
184 /*----------------------------------------------------------------------------
185  * Write nodal mesh to a CGNS file
186  *
187  * parameters:
188  * this_writer_p <-- pointer to associated writer.
189  * mesh <-- pointer to nodal mesh structure that should be written.
190  *----------------------------------------------------------------------------*/
191 
192 void
193 fvm_to_cgns_export_nodal(void *this_writer_p,
194  const fvm_nodal_t *mesh);
195 
196 /*----------------------------------------------------------------------------
197  * Write field associated with a nodal mesh to a CGNS file.
198  *
199  * Assigning a negative value to the time step indicates a time-independent
200  * field (in which case the time_value argument is unused).
201  *
202  * parameters:
203  * this_writer_p <-- pointer to associated writer
204  * mesh <-- pointer to associated nodal mesh structure
205  * name <-- variable name
206  * location <-- variable definition location (nodes or elements)
207  * dimension <-- variable dimension (0: constant, 1: scalar,
208  * 3: vector, 6: sym. tensor, 9: asym. tensor)
209  * interlace <-- indicates if variable in memory is interlaced
210  * n_parent_lists <-- indicates if variable values are to be obtained
211  * directly through the local entity index (when 0) or
212  * through the parent entity numbers (when 1 or more)
213  * parent_num_shift <-- parent number to value array index shifts;
214  * size: n_parent_lists
215  * datatype <-- indicates the data type of (source) field values
216  * time_step <-- number of the current time step
217  * time_value <-- associated time value
218  * field_values <-- array of associated field value arrays
219  *----------------------------------------------------------------------------*/
220 
221 void
222 fvm_to_cgns_export_field(void *this_writer_p,
223  const fvm_nodal_t *mesh,
224  const char *name,
225  fvm_writer_var_loc_t location,
226  int dimension,
227  cs_interlace_t interlace,
228  int n_parent_lists,
229  const cs_lnum_t parent_num_shift[],
230  cs_datatype_t datatype,
231  int time_step,
232  double time_value,
233  const void *const field_values[]);
234 
235 /*----------------------------------------------------------------------------
236  * Flush files associated with a given writer.
237  *
238  * parameters:
239  * this_writer_p <-- pointer to associated writer
240  *----------------------------------------------------------------------------*/
241 
242 void
243 fvm_to_cgns_flush(void *this_writer_p);
244 
245 /*----------------------------------------------------------------------------*/
246 
248 
249 #endif /* HAVE_CGNS */
250 
251 #endif /* __FVM_TO_CGNS_H__ */
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