Code_Saturne
CFD tool
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-2012 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 /*----------------------------------------------------------------------------
34  * Local headers
35  *----------------------------------------------------------------------------*/
36 
37 #include "fvm_defs.h"
38 #include "fvm_nodal.h"
39 #include "fvm_writer.h"
40 
41 /*----------------------------------------------------------------------------*/
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #if 0
46 } /* Fake brace to force back Emacs auto-indentation back to column 0 */
47 #endif
48 #endif /* __cplusplus */
49 
50 /*=============================================================================
51  * Macro definitions
52  *============================================================================*/
53 
54 /*============================================================================
55  * Type definitions
56  *============================================================================*/
57 
58 /*=============================================================================
59  * Public function prototypes
60  *============================================================================*/
61 
62 /*----------------------------------------------------------------------------
63  * Returns number of library version strings associated with the CGNS format.
64  *
65  * returns:
66  * number of library version strings associated with the CGNS format.
67  *----------------------------------------------------------------------------*/
68 
69 int
70 fvm_to_cgns_n_version_strings(void);
71 
72 /*----------------------------------------------------------------------------
73  * Returns a library version string associated with the CGNS format.
74  *
75  * In certain cases, when using dynamic libraries, fvm may be compiled
76  * with one library version, and linked with another. If both run-time
77  * and compile-time version information is available, this function
78  * will return the run-time version string by default.
79  *
80  * Setting the compile_time flag to 1, the compile-time version string
81  * will be returned if this is different from the run-time version.
82  * If the version is the same, or only one of the 2 version strings are
83  * available, a NULL character string will be returned with this flag set.
84  *
85  * parameters:
86  * string_index <-- index in format's version string list (0 to n-1)
87  * compile_time <-- 0 by default, 1 if we want the compile-time version
88  * string, if different from the run-time version.
89  *
90  * returns:
91  * pointer to constant string containing the library's version.
92  *----------------------------------------------------------------------------*/
93 
94 const char *
95 fvm_to_cgns_version_string(int string_index,
96  int compile_time_version);
97 
98 /*----------------------------------------------------------------------------
99  * Initialize FVM to CGNS file writer.
100  *
101  * Options are:
102  * discard_polygons do not output polygons or related values
103  * discard_polyhedra do not output polyhedra or related values
104  * divide_polygons tesselate polygons with triangles
105  * adf use ADF file type
106  * hdf5 use HDF5 file type (default if available)
107  *
108  * As CGNS does not handle polyhedral elements, polyhedra are automatically
109  * tesselated with tetrahedra and pyramids (adding a vertex near each
110  * polyhedron's center) unless discarded.
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 CGNS writer structure.
120  *----------------------------------------------------------------------------*/
121 
122 #if defined(HAVE_MPI)
123 
124 void *
125 fvm_to_cgns_init_writer(const char *name,
126  const char *path,
127  const char *options,
128  fvm_writer_time_dep_t time_dependency,
129  MPI_Comm comm);
130 
131 #else
132 
133 void *
134 fvm_to_cgns_init_writer(const char *name,
135  const char *path,
136  const char *options,
137  fvm_writer_time_dep_t time_dependency);
138 
139 #endif
140 
141 /*----------------------------------------------------------------------------
142  * Finalize FVM to CGNS file writer.
143  *
144  * parameters:
145  * this_writer_p <-- pointer to opaque CGNS writer structure.
146  *
147  * returns:
148  * NULL pointer.
149  *----------------------------------------------------------------------------*/
150 
151 void *
152 fvm_to_cgns_finalize_writer(void *this_writer_p);
153 
154 /*----------------------------------------------------------------------------
155  * Associate new time step with a CGNS geometry.
156  *
157  * parameters:
158  * this_writer_p <-- pointer to associated writer
159  * time_step <-- time step number
160  * time_value <-- time_value number
161  *----------------------------------------------------------------------------*/
162 
163 void
164 fvm_to_cgns_set_mesh_time(void *this_writer_p,
165  int time_step,
166  double time_value);
167 
168 /*----------------------------------------------------------------------------
169  * Indicate if elements of a given type in a mesh associated with a given
170  * CGNS file writer need to be tesselated.
171  *
172  * parameters:
173  * this_writer_p <-- pointer to associated writer
174  * mesh <-- pointer to nodal mesh structure that should be written
175  * element_type <-- element type we are interested in
176  *
177  * returns:
178  * 1 if tesselation of the given element type is needed, 0 otherwise
179  *----------------------------------------------------------------------------*/
180 
181 int
182 fvm_to_cgns_needs_tesselation(fvm_writer_t *this_writer_p,
183  const fvm_nodal_t *mesh,
184  fvm_element_t element_type);
185 
186 /*----------------------------------------------------------------------------
187  * Write nodal mesh to a CGNS file
188  *
189  * parameters:
190  * this_writer_p <-- pointer to associated writer.
191  * mesh <-- pointer to nodal mesh structure that should be written.
192  *----------------------------------------------------------------------------*/
193 
194 void
195 fvm_to_cgns_export_nodal(void *this_writer_p,
196  const fvm_nodal_t *mesh);
197 
198 /*----------------------------------------------------------------------------
199  * Write field associated with a nodal mesh to a CGNS file.
200  *
201  * Assigning a negative value to the time step indicates a time-independent
202  * field (in which case the time_value argument is unused).
203  *
204  * parameters:
205  * this_writer_p <-- pointer to associated writer
206  * mesh <-- pointer to associated nodal mesh structure
207  * name <-- variable name
208  * location <-- variable definition location (nodes or elements)
209  * dimension <-- variable dimension (0: constant, 1: scalar,
210  * 3: vector, 6: sym. tensor, 9: asym. tensor)
211  * interlace <-- indicates if variable in memory is interlaced
212  * n_parent_lists <-- indicates if variable values are to be obtained
213  * directly through the local entity index (when 0) or
214  * through the parent entity numbers (when 1 or more)
215  * parent_num_shift <-- parent number to value array index shifts;
216  * size: n_parent_lists
217  * datatype <-- indicates the data type of (source) field values
218  * time_step <-- number of the current time step
219  * time_value <-- associated time value
220  * field_values <-- array of associated field value arrays
221  *----------------------------------------------------------------------------*/
222 
223 void
224 fvm_to_cgns_export_field(void *this_writer_p,
225  const fvm_nodal_t *mesh,
226  const char *name,
227  fvm_writer_var_loc_t location,
228  int dimension,
229  cs_interlace_t interlace,
230  int n_parent_lists,
231  const cs_lnum_t parent_num_shift[],
232  cs_datatype_t datatype,
233  int time_step,
234  double time_value,
235  const void *const field_values[]);
236 
237 /*----------------------------------------------------------------------------*/
238 
239 #ifdef __cplusplus
240 }
241 #endif /* __cplusplus */
242 
243 #endif /* HAVE_CGNS */
244 
245 #endif /* __FVM_TO_CGNS_H__ */
cs_datatype_t
Definition: cs_defs.h:223
fvm_writer_var_loc_t
Definition: fvm_writer.h:70
cs_interlace_t
Definition: cs_defs.h:347
Definition: fvm_nodal_priv.h:152
Definition: fvm_writer_priv.h:171
fvm_writer_time_dep_t
Definition: fvm_writer.h:58
fvm_element_t
Definition: fvm_defs.h:49
int cs_lnum_t
Definition: cs_defs.h:260
Definition: mesh.f90:25