9.2
general 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-2026 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 "base/cs_defs.h"
34
35/*----------------------------------------------------------------------------
36 * Local headers
37 *----------------------------------------------------------------------------*/
38
39#include "fvm/fvm_defs.h"
40#include "fvm/fvm_nodal.h"
41#include "fvm/fvm_writer.h"
42
43/*=============================================================================
44 * Macro definitions
45 *============================================================================*/
46
47/*============================================================================
48 * Type definitions
49 *============================================================================*/
50
51/*=============================================================================
52 * Public function prototypes
53 *============================================================================*/
54
55/*----------------------------------------------------------------------------
56 * Returns number of library version strings associated with the CGNS format.
57 *
58 * returns:
59 * number of library version strings associated with the CGNS format.
60 *----------------------------------------------------------------------------*/
61
62extern "C" int
63fvm_to_cgns_n_version_strings(void);
64
65/*----------------------------------------------------------------------------
66 * Returns a library version string associated with the CGNS format.
67 *
68 * In certain cases, when using dynamic libraries, fvm may be compiled
69 * with one library version, and linked with another. If both run-time
70 * and compile-time version information is available, this function
71 * will return the run-time version string by default.
72 *
73 * Setting the compile_time flag to 1, the compile-time version string
74 * will be returned if this is different from the run-time version.
75 * If the version is the same, or only one of the 2 version strings are
76 * available, a NULL character string will be returned with this flag set.
77 *
78 * parameters:
79 * string_index <-- index in format's version string list (0 to n-1)
80 * compile_time <-- 0 by default, 1 if we want the compile-time version
81 * string, if different from the run-time version.
82 *
83 * returns:
84 * pointer to constant string containing the library's version.
85 *----------------------------------------------------------------------------*/
86
87extern "C" const char *
88fvm_to_cgns_version_string(int string_index,
89 int compile_time_version);
90
91/*----------------------------------------------------------------------------
92 * Initialize FVM to CGNS file writer.
93 *
94 * Options are:
95 * discard_bcs do not output boundary conditions
96 * discard_steady discard steady solution data
97 * (to avoid issues with some tools when both steady
98 * and unsteady data is present)
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 * preserve_precision do not convert double precision to single
103 * precision types (leads to larger files)
104 * adf use ADF file type
105 * hdf5 use HDF5 file type (default if available)
106 * links split output to separate files using links
107 *
108 * As CGNS does not handle polyhedral elements in a simple manner,
109 * polyhedra are automatically tesselated with tetrahedra and pyramids
110 * (adding a vertex near each 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
124extern "C" void *
125fvm_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
133extern "C" void *
134fvm_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
151extern "C" void *
152fvm_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
163extern "C" void
164fvm_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
181extern "C" int
182fvm_to_cgns_needs_tesselation(void *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
194extern "C" void
195fvm_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
223extern "C" void
224fvm_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 * Flush files associated with a given writer.
239 *
240 * parameters:
241 * this_writer_p <-- pointer to associated writer
242 *----------------------------------------------------------------------------*/
243
244extern "C" void
245fvm_to_cgns_flush(void *this_writer_p);
246
247/*----------------------------------------------------------------------------*/
248
249#endif /* HAVE_CGNS */
250
251#endif /* FVM_TO_CGNS_H */
cs_datatype_t
Definition: cs_defs.h:290
cs_interlace_t
Definition: cs_defs.h:504
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
fvm_element_t
Definition: fvm_defs.h:44
fvm_writer_time_dep_t
Definition: fvm_writer.h:57
fvm_writer_var_loc_t
Definition: fvm_writer.h:69
Definition: mesh.f90:26