Proto
Proto_VisitWriter.H
1 #ifndef _VISIT_WRITER_H_
2 #define _VISIT_WRITER_H_
3 
4 
5 
6 /*****************************************************************************
7 *
8 * Copyright (c) 2000 - 2008, Lawrence Livermore National Security, LLC
9 * Produced at the Lawrence Livermore National Laboratory
10 * LLNL-CODE-400142
11 * All rights reserved.
12 *
13 * This file is part of VisIt. For details, see https://visit.llnl.gov/. The
14 * full copyright notice is contained in the file COPYRIGHT located at the root
15 * of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are met:
19 *
20 * - Redistributions of source code must retain the above copyright notice,
21 * this list of conditions and the disclaimer below.
22 * - Redistributions in binary form must reproduce the above copyright notice,
23 * this list of conditions and the disclaimer (as noted below) in the
24 * documentation and/or other materials provided with the distribution.
25 * - Neither the name of the LLNS/LLNL nor the names of its contributors may
26 * be used to endorse or promote products derived from this software without
27 * specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
33 * LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
34 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
36 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
40 * DAMAGE.
41 *
42 *****************************************************************************/
43 
44 /* ************************************************************************* //
45 // visit_writer.h //
46 // ************************************************************************* */
47 
48 /*
49 // This file contains function prototypes for writing out point meshes,
50 // unstructured meshes, rectilinear meshes, regular meshes, and
51 // structured/curvilinear meshes into files that can later be read by VisIt.
52 //
53 // Each routine assumes that the data being written is three-dimensional.
54 // If the data is two-dimensional, you must still write out the data
55 // as three-dimensional (ie pad arrays so that they are the correct size, etc).
56 // However: the VisIt reader will determine that the data is truly two-
57 // dimensional and visualize it as a two-dimensional dataset.
58 //
59 // All writers have an ASCII vs Binary decision. The tradeoffs are the
60 // standard ones: ASCII is human readable, but slow. The
61 // binary is much faster, but not human readable. Note: the binary format
62 // is portable, since it converts all data to be big-endian (this was a
63 // design decision for the format the visit_writer writes to -- the VTK
64 // format).
65 //
66 // If you have multiple grids, you can write out one file for each grid.
67 // There are potential pitfalls in doing this, where extra geometry and
68 // interpolation problems appear along grid boundaries. For additional
69 // help with this issue, e-mail [email protected]
70 */
71 
72 #ifndef VISIT_USE_BINARY
73 #define VISIT_USE_BINARY 1
74 #endif
75 
76 FILE * vtk_open_file(const char* a_filename);
77 void vtk_close_file(FILE* fp, int& numInColumn);
78 
79 /* ****************************************************************************
80 // Function: write_point_mesh
81 //
82 // Purpose:
83 // Writes out a point mesh.
84 //
85 // Arguments:
86 // filename The name of the file to write. If the extension ".vtk" is
87 // not present, it will be added.
88 // useBinary '0' to write ASCII, !0 to write binary
89 // npts The number of points in the mesh.
90 // pts The spatial locations of the points. This array should
91 // be size 3*npts. The points should be encoded as:
92 // <x1, y1, z1, x2, y2, z2, ..., xn, yn, zn>
93 // nvars The number of variables.
94 // vardim The dimension of each variable. The size of vardim should
95 // be nvars. If var i is a scalar, then vardim[i] = 1.
96 // If var i is a vector, then vardim[i] = 3.
97 // vars An array of variables. The size of vars should be nvars.
98 // The size of vars[i] should be npts*vardim[i].
99 //
100 // Programmer: Hank Childs
101 // Creation: September 2, 2004
102 //
103 // ***************************************************************************/
104 
105 void write_point_mesh(const char *filename, int npts,
106  double *pts, int nvars, int *vardim,
107  const char * const *varnames, double **vars);
108 /*
109 void write_point_mesh(FILE* file, int useBinary, int npts,
110  double *pts, int nvars, int *vardim,
111  const char * const *varnames, double **vars);
112 */
113 
114 
115 /* ****************************************************************************
116 // Function: write_unstructured_mesh
117 //
118 // Purpose:
119 // Writes out a unstructured mesh.
120 //
121 //
122 // Arguments:
123 // filename The name of the file to write. If the extension ".vtk" is
124 // not present, it will be added.
125 // useBinary '0' to write ASCII, !0 to write binary
126 // npts The number of points in the mesh.
127 // pts The spatial locations of the points. This array should
128 // be size 3*npts. The points should be encoded as:
129 // <x1, y1, z1, x2, y2, z2, ..., xn, yn, zn>
130 // ncells The number of cells.
131 // celltypes The type of each cell.
132 // conn The connectivity array.
133 // nvars The number of variables.
134 // vardim The dimension of each variable. The size of vardim should
135 // be nvars. If var i is a scalar, then vardim[i] = 1.
136 // If var i is a vector, then vardim[i] = 3.
137 // centering The centering of each variable. The size of centering
138 // should be nvars. If centering[i] == 0, then the variable
139 // is cell-based. If centering[i] != 0, then the variable
140 // is point-based.
141 // vars An array of variables. The size of vars should be nvars.
142 // The size of vars[i] should be npts*vardim[i].
143 //
144 // Example:
145 // You have two triangles. The first has points (0,0,0), (0,1,0), and
146 // (1,1,0). The second has points (0,0,0), (1,1,0), and (1,0,0).
147 //
148 // There are four unique points.
149 //
150 // double pts[12] = { 0,0,0, 0,1,0, 1,1,0, 1,0,0 };
151 //
152 // It is important the points list contain only unique points,
153 // because VisIt is not able to correctly determine the connectivity of a
154 // dataset when points are duplicated.
155 //
156 // There are two triangles.
157 // int ncells = 2;
158 //
159 // The cells are both triangles.
160 // int celltypes[2] = { VISIT_TRIANGLE, VISIT_TRIANGLE };
161 //
162 // The connectivity contains indices into the points list. The indexing
163 // assumes that each point has size 3 (x,y,z).
164 //
165 // int conn[6] = { 0, 1, 2, 0, 2, 3 };
166 //
167 // Hint:
168 // When writing an unstructured mesh, it is easy to get the orientation
169 // of a cell backwards. VisIt typically does okay with this, but it
170 // can cause problems. To test if this is happening, bring up VisIt on
171 // your newly outputted dataset and make a Pseudocolor plot of
172 // "mesh_quality/volume" for 3D datasets or "mesh_quality/area" for 2D
173 // datasets. If the cells are inside-out, the volumes or areas will be
174 // negative.
175 //
176 //
177 // Programmer: Hank Childs
178 // Creation: September 2, 2004
179 //
180 // ***************************************************************************/
181 
182 #define VISIT_VERTEX 1
183 #define VISIT_LINE 3
184 #define VISIT_TRIANGLE 5
185 #define VISIT_QUAD 9
186 #define VISIT_TETRA 10
187 #define VISIT_HEXAHEDRON 12
188 #define VISIT_WEDGE 13
189 #define VISIT_PYRAMID 14
190 
191 void write_unstructured_mesh(const char *filename, int npts,
192  double *pts, int ncells, int *celltypes, int *conn,
193  int nvars, int *vardim, int *centering,
194  const char * const *varnames, double **vars);
195 
196 
197 
198 /* ****************************************************************************
199 // Function: write_regular_mesh
200 //
201 // Purpose:
202 // Writes out a regular mesh. A regular mesh is one where the data lies
203 // along regular intervals. "Brick of bytes/doubles",
204 // "Block of bytes/doubles", and MRI data all are examples of data that
205 // lie on regular meshes.
206 //
207 //
208 // Arguments:
209 // filename The name of the file to write. If the extension ".vtk" is
210 // not present, it will be added.
211 // useBinary '0' to write ASCII, !0 to write binary
212 // dims An array of size 3 = { nX, nY, nZ }, where nX is the
213 // number of points in the X-dimension, etc.
214 // nvars The number of variables.
215 // vardim The dimension of each variable. The size of vardim should
216 // be nvars. If var i is a scalar, then vardim[i] = 1.
217 // If var i is a vector, then vardim[i] = 3.
218 // centering The centering of each variable. The size of centering
219 // should be nvars. If centering[i] == 0, then the variable
220 // is cell-based. If centering[i] != 0, then the variable
221 // is point-based.
222 // vars An array of variables. The size of vars should be nvars.
223 // The size of vars[i] should be npts*vardim[i].
224 //
225 //
226 // Programmer: Hank Childs
227 // Creation: September 2, 2004
228 //
229 // ***************************************************************************/
230 
231 void write_regular_mesh(const char *filename, int *dims,
232  int nvars, int *vardim, int *centering,
233  const char * const *varnames, double **vars);
234 
235 
236 /* ****************************************************************************
237 // Function: write_rectilinear_mesh
238 //
239 // Purpose:
240 // Writes out a rectilinear mesh.
241 //
242 //
243 // Arguments:
244 // filename The name of the file to write. If the extension ".vtk" is
245 // not present, it will be added.
246 // useBinary '0' to write ASCII, !0 to write binary
247 // dims An array of size 3 = { nX, nY, nZ }, where nX is the
248 // number of points in the X-dimension, etc.
249 // x An array of size dims[0] that contains the x-coordinates.
250 // y An array of size dims[1] that contains the x-coordinates.
251 // z An array of size dims[2] that contains the x-coordinates.
252 // nvars The number of variables.
253 // vardim The dimension of each variable. The size of vardim should
254 // be nvars. If var i is a scalar, then vardim[i] = 1.
255 // If var i is a vector, then vardim[i] = 3.
256 // centering The centering of each variable. The size of centering
257 // should be nvars. If centering[i] == 0, then the variable
258 // is cell-based. If centering[i] != 0, then the variable
259 // is point-based.
260 // vars An array of variables. The size of vars should be nvars.
261 // The size of vars[i] should be npts*vardim[i].
262 //
263 //
264 // Example:
265 // You have a rectilinear mesh with x = { 0, 1, 2}, y = { 1, 1.5, 2, 3 },
266 // and z = { 2.5, 3.5 }.
267 //
268 // Then dims = { 3, 4, 2 }.
269 //
270 // Programmer: Hank Childs
271 // Creation: September 2, 2004
272 //
273 // ***************************************************************************/
274 
275 void write_rectilinear_mesh(const char *filename,
276  int *dims, double *x, double *y, double *z,
277  int nvars, int *vardim, int *centering,
278  const char * const *varnames, double **vars);
279 
280 /*
281 void write_rectilinear_mesh(FILE* file, int useBinary,
282  int *dims, double *x, double *y, double *z,
283  int nvars, int *vardim, int *centering,
284  const char * const *varnames, double **vars);
285 */
286 
287 
288 
289 /* ****************************************************************************
290 // Function: write_curvilinear_mesh
291 //
292 // Purpose:
293 // Writes out a curvilinear mesh.
294 //
295 //
296 // Arguments:
297 // filename The name of the file to write. If the extension ".vtk" is
298 // not present, it will be added.
299 // useBinary '0' to write ASCII, !0 to write binary
300 // dims An array of size 3 = { nI, nJ, nK }, where nI is the
301 // number of points in the logical I dimension, etc.
302 // pts An array of size nI*nJ*nK*3. The array should be layed
303 // out as (pt(i=0,j=0,k=0), pt(i=1,j=0,k=0), ...
304 // pt(i=nI-1,j=0,k=0), pt(i=0,j=1,k=0), ...).
305 // nvars The number of variables.
306 // vardim The dimension of each variable. The size of vardim should
307 // be nvars. If var i is a scalar, then vardim[i] = 1.
308 // If var i is a vector, then vardim[i] = 3.
309 // centering The centering of each variable. The size of centering
310 // should be nvars. If centering[i] == 0, then the variable
311 // is cell-based. If centering[i] != 0, then the variable
312 // is point-based.
313 // vars An array of variables. The size of vars should be nvars.
314 // The size of vars[i] should be npts*vardim[i].
315 //
316 //
317 // Programmer: Hank Childs
318 // Creation: September 2, 2004
319 //
320 // ***************************************************************************/
321 
322 void write_curvilinear_mesh(const char *filename,
323  int *dims, double *pts,
324  int nvars, int *vardim, int *centering,
325  const char * const *varnames, double **vars);
326 
327 #include "implem/Proto_VisitWriterImplem.H"
328 #endif
329