00001 #ifndef _VISIT_WRITER_H_ 00002 #define _VISIT_WRITER_H_ 00003 00004 /***************************************************************************** 00005 * 00006 * Copyright (c) 2000 - 2008, Lawrence Livermore National Security, LLC 00007 * Produced at the Lawrence Livermore National Laboratory 00008 * LLNL-CODE-400142 00009 * All rights reserved. 00010 * 00011 * This file is part of VisIt. For details, see https://visit.llnl.gov/. The 00012 * full copyright notice is contained in the file COPYRIGHT located at the root 00013 * of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html. 00014 * 00015 * Redistribution and use in source and binary forms, with or without 00016 * modification, are permitted provided that the following conditions are met: 00017 * 00018 * - Redistributions of source code must retain the above copyright notice, 00019 * this list of conditions and the disclaimer below. 00020 * - Redistributions in binary form must reproduce the above copyright notice, 00021 * this list of conditions and the disclaimer (as noted below) in the 00022 * documentation and/or other materials provided with the distribution. 00023 * - Neither the name of the LLNS/LLNL nor the names of its contributors may 00024 * be used to endorse or promote products derived from this software without 00025 * specific prior written permission. 00026 * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00028 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00029 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00030 * ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, 00031 * LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY 00032 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00033 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00034 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00035 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00036 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00037 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00038 * DAMAGE. 00039 * 00040 *****************************************************************************/ 00041 00042 /* ************************************************************************* // 00043 // visit_writer.h // 00044 // ************************************************************************* */ 00045 00046 /* 00047 // This file contains function prototypes for writing out point meshes, 00048 // unstructured meshes, rectilinear meshes, regular meshes, and 00049 // structured/curvilinear meshes into files that can later be read by VisIt. 00050 // 00051 // Each routine assumes that the data being written is three-dimensional. 00052 // If the data is two-dimensional, you must still write out the data 00053 // as three-dimensional (ie pad arrays so that they are the correct size, etc). 00054 // However: the VisIt reader will determine that the data is truly two- 00055 // dimensional and visualize it as a two-dimensional dataset. 00056 // 00057 // All writers have an ASCII vs Binary decision. The tradeoffs are the 00058 // standard ones: ASCII is human readable, but slow. The 00059 // binary is much faster, but not human readable. Note: the binary format 00060 // is portable, since it converts all data to be big-endian (this was a 00061 // design decision for the format the visit_writer writes to -- the VTK 00062 // format). 00063 // 00064 // If you have multiple grids, you can write out one file for each grid. 00065 // There are potential pitfalls in doing this, where extra geometry and 00066 // interpolation problems appear along grid boundaries. For additional 00067 // help with this issue, e-mail [email protected] 00068 */ 00069 00070 00071 /* **************************************************************************** 00072 // Function: write_point_mesh 00073 // 00074 // Purpose: 00075 // Writes out a point mesh. 00076 // 00077 // Arguments: 00078 // filename The name of the file to write. If the extension ".vtk" is 00079 // not present, it will be added. 00080 // useBinary '0' to write ASCII, !0 to write binary 00081 // npts The number of points in the mesh. 00082 // pts The spatial locations of the points. This array should 00083 // be size 3*npts. The points should be encoded as: 00084 // <x1, y1, z1, x2, y2, z2, ..., xn, yn, zn> 00085 // nvars The number of variables. 00086 // vardim The dimension of each variable. The size of vardim should 00087 // be nvars. If var i is a scalar, then vardim[i] = 1. 00088 // If var i is a vector, then vardim[i] = 3. 00089 // vars An array of variables. The size of vars should be nvars. 00090 // The size of vars[i] should be npts*vardim[i]. 00091 // 00092 // Programmer: Hank Childs 00093 // Creation: September 2, 2004 00094 // 00095 // ***************************************************************************/ 00096 00097 void write_point_mesh(const char *filename, int useBinary, int npts, 00098 float *pts, int nvars, int *vardim, 00099 const char * const *varnames, float **vars); 00100 00101 00102 00103 /* **************************************************************************** 00104 // Function: write_unstructured_mesh 00105 // 00106 // Purpose: 00107 // Writes out a unstructured mesh. 00108 // 00109 // 00110 // Arguments: 00111 // filename The name of the file to write. If the extension ".vtk" is 00112 // not present, it will be added. 00113 // useBinary '0' to write ASCII, !0 to write binary 00114 // npts The number of points in the mesh. 00115 // pts The spatial locations of the points. This array should 00116 // be size 3*npts. The points should be encoded as: 00117 // <x1, y1, z1, x2, y2, z2, ..., xn, yn, zn> 00118 // ncells The number of cells. 00119 // celltypes The type of each cell. 00120 // conn The connectivity array. 00121 // nvars The number of variables. 00122 // vardim The dimension of each variable. The size of vardim should 00123 // be nvars. If var i is a scalar, then vardim[i] = 1. 00124 // If var i is a vector, then vardim[i] = 3. 00125 // centering The centering of each variable. The size of centering 00126 // should be nvars. If centering[i] == 0, then the variable 00127 // is cell-based. If centering[i] != 0, then the variable 00128 // is point-based. 00129 // vars An array of variables. The size of vars should be nvars. 00130 // The size of vars[i] should be npts*vardim[i]. 00131 // 00132 // Example: 00133 // You have two triangles. The first has points (0,0,0), (0,1,0), and 00134 // (1,1,0). The second has points (0,0,0), (1,1,0), and (1,0,0). 00135 // 00136 // There are four unique points. 00137 // 00138 // float pts[12] = { 0,0,0, 0,1,0, 1,1,0, 1,0,0 }; 00139 // 00140 // It is important the points list contain only unique points, 00141 // because VisIt is not able to correctly determine the connectivity of a 00142 // dataset when points are duplicated. 00143 // 00144 // There are two triangles. 00145 // int ncells = 2; 00146 // 00147 // The cells are both triangles. 00148 // int celltypes[2] = { VISIT_TRIANGLE, VISIT_TRIANGLE }; 00149 // 00150 // The connectivity contains indices into the points list. The indexing 00151 // assumes that each point has size 3 (x,y,z). 00152 // 00153 // int conn[6] = { 0, 1, 2, 0, 2, 3 }; 00154 // 00155 // Hint: 00156 // When writing an unstructured mesh, it is easy to get the orientation 00157 // of a cell backwards. VisIt typically does okay with this, but it 00158 // can cause problems. To test if this is happening, bring up VisIt on 00159 // your newly outputted dataset and make a Pseudocolor plot of 00160 // "mesh_quality/volume" for 3D datasets or "mesh_quality/area" for 2D 00161 // datasets. If the cells are inside-out, the volumes or areas will be 00162 // negative. 00163 // 00164 // 00165 // Programmer: Hank Childs 00166 // Creation: September 2, 2004 00167 // 00168 // ***************************************************************************/ 00169 00170 #define VISIT_VERTEX 1 00171 #define VISIT_LINE 3 00172 #define VISIT_TRIANGLE 5 00173 #define VISIT_QUAD 9 00174 #define VISIT_TETRA 10 00175 #define VISIT_HEXAHEDRON 12 00176 #define VISIT_WEDGE 13 00177 #define VISIT_PYRAMID 14 00178 00179 void write_unstructured_mesh(const char *filename, int useBinary, int npts, 00180 float *pts, int ncells, int *celltypes, int *conn, 00181 int nvars, int *vardim, int *centering, 00182 const char * const *varnames, float **vars); 00183 00184 00185 00186 /* **************************************************************************** 00187 // Function: write_regular_mesh 00188 // 00189 // Purpose: 00190 // Writes out a regular mesh. A regular mesh is one where the data lies 00191 // along regular intervals. "Brick of bytes/floats", 00192 // "Block of bytes/floats", and MRI data all are examples of data that 00193 // lie on regular meshes. 00194 // 00195 // 00196 // Arguments: 00197 // filename The name of the file to write. If the extension ".vtk" is 00198 // not present, it will be added. 00199 // useBinary '0' to write ASCII, !0 to write binary 00200 // dims An array of size 3 = { nX, nY, nZ }, where nX is the 00201 // number of points in the X-dimension, etc. 00202 // nvars The number of variables. 00203 // vardim The dimension of each variable. The size of vardim should 00204 // be nvars. If var i is a scalar, then vardim[i] = 1. 00205 // If var i is a vector, then vardim[i] = 3. 00206 // centering The centering of each variable. The size of centering 00207 // should be nvars. If centering[i] == 0, then the variable 00208 // is cell-based. If centering[i] != 0, then the variable 00209 // is point-based. 00210 // vars An array of variables. The size of vars should be nvars. 00211 // The size of vars[i] should be npts*vardim[i]. 00212 // 00213 // 00214 // Programmer: Hank Childs 00215 // Creation: September 2, 2004 00216 // 00217 // ***************************************************************************/ 00218 00219 void write_regular_mesh(const char *filename, int useBinary, int *dims, 00220 int nvars, int *vardim, int *centering, 00221 const char * const *varnames, float **vars); 00222 00223 00224 00225 00226 /* **************************************************************************** 00227 // Function: write_rectilinear_mesh 00228 // 00229 // Purpose: 00230 // Writes out a rectilinear mesh. 00231 // 00232 // 00233 // Arguments: 00234 // filename The name of the file to write. If the extension ".vtk" is 00235 // not present, it will be added. 00236 // useBinary '0' to write ASCII, !0 to write binary 00237 // dims An array of size 3 = { nX, nY, nZ }, where nX is the 00238 // number of points in the X-dimension, etc. 00239 // x An array of size dims[0] that contains the x-coordinates. 00240 // y An array of size dims[1] that contains the x-coordinates. 00241 // z An array of size dims[2] that contains the x-coordinates. 00242 // nvars The number of variables. 00243 // vardim The dimension of each variable. The size of vardim should 00244 // be nvars. If var i is a scalar, then vardim[i] = 1. 00245 // If var i is a vector, then vardim[i] = 3. 00246 // centering The centering of each variable. The size of centering 00247 // should be nvars. If centering[i] == 0, then the variable 00248 // is cell-based. If centering[i] != 0, then the variable 00249 // is point-based. 00250 // vars An array of variables. The size of vars should be nvars. 00251 // The size of vars[i] should be npts*vardim[i]. 00252 // 00253 // 00254 // Example: 00255 // You have a rectilinear mesh with x = { 0, 1, 2}, y = { 1, 1.5, 2, 3 }, 00256 // and z = { 2.5, 3.5 }. 00257 // 00258 // Then dims = { 3, 4, 2 }. 00259 // 00260 // Programmer: Hank Childs 00261 // Creation: September 2, 2004 00262 // 00263 // ***************************************************************************/ 00264 00265 void write_rectilinear_mesh(const char *filename, int useBinary, 00266 int *dims, float *x, float *y, float *z, 00267 int nvars, int *vardim, int *centering, 00268 const char * const *varnames, float **vars); 00269 00270 00271 00272 00273 /* **************************************************************************** 00274 // Function: write_curvilinear_mesh 00275 // 00276 // Purpose: 00277 // Writes out a curvilinear mesh. 00278 // 00279 // 00280 // Arguments: 00281 // filename The name of the file to write. If the extension ".vtk" is 00282 // not present, it will be added. 00283 // useBinary '0' to write ASCII, !0 to write binary 00284 // dims An array of size 3 = { nI, nJ, nK }, where nI is the 00285 // number of points in the logical I dimension, etc. 00286 // pts An array of size nI*nJ*nK*3. The array should be layed 00287 // out as (pt(i=0,j=0,k=0), pt(i=1,j=0,k=0), ... 00288 // pt(i=nI-1,j=0,k=0), pt(i=0,j=1,k=0), ...). 00289 // nvars The number of variables. 00290 // vardim The dimension of each variable. The size of vardim should 00291 // be nvars. If var i is a scalar, then vardim[i] = 1. 00292 // If var i is a vector, then vardim[i] = 3. 00293 // centering The centering of each variable. The size of centering 00294 // should be nvars. If centering[i] == 0, then the variable 00295 // is cell-based. If centering[i] != 0, then the variable 00296 // is point-based. 00297 // vars An array of variables. The size of vars should be nvars. 00298 // The size of vars[i] should be npts*vardim[i]. 00299 // 00300 // 00301 // Programmer: Hank Childs 00302 // Creation: September 2, 2004 00303 // 00304 // ***************************************************************************/ 00305 00306 void write_curvilinear_mesh(const char *filename, int useBinary, 00307 int *dims, float *pts, 00308 int nvars, int *vardim, int *centering, 00309 const char * const *varnames, float **vars); 00310 #endif 00311