1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
/*****************************************************************************
*
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-400124
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ************************************************************************* //
// avtSiloWriter.h //
// ************************************************************************* //
#ifndef AVT_SILO_WRITER_H
#define AVT_SILO_WRITER_H
#include <avtDatabaseWriter.h>
#include <map>
#include <string>
#include <vector>
#include <silo.h>
using std::map;
using std::string;
using std::vector;
class vtkCellData;
class vtkDataSetAttributes;
class vtkPointData;
class vtkPolyData;
class vtkRectilinearGrid;
class vtkStructuredGrid;
class vtkUnstructuredGrid;
class avtMeshMetaData;
class DBOptionsAttributes;
// ****************************************************************************
// Class: avtSiloWriter
//
// Purpose:
// A module that writes out Silo files.
//
// Programmer: Hank Childs
// Creation: September 11, 2003
//
// Modifications
// Mark C. Miller, Tue Mar 9 07:03:56 PST 2004
// Added data members to hold args passed in WriteHeaders to facilitate
// writing extents on multi-objects in CloseFile()
//
// Hank Childs, Tue Sep 27 10:21:36 PDT 2005
// Use virtual inheritance.
//
// Jeremy Meredith, Tue Mar 27 11:39:24 EDT 2007
// Added numblocks to the OpenFile method, and save off the actual
// encountered mesh types, because we cannot trust the metadata.
//
// Cyrus Harrison, Thu Aug 16 20:50:24 PDT 2007
// Added dir to hold output directory.
//
// Cyrus Harrison, Wed Feb 27 07:57:35 PST 2008
// Added VTKZoneTypeToSiloZoneType helper method to help with
// DBPutZoneList2 migration.
//
// Mark C. Miller, Wed Jul 23 17:49:39 PDT 2008
// Added bool to WriteUcdvars to handle point vars
//
// Mark C. Miller, Thu Jul 31 18:06:08 PDT 2008
// Added option to write all data to a single file
//
// Brad Whitlock, Fri Mar 6 15:30:16 PST 2009
// I added helper functions so we can share code when writing variables.
// I also added code to export expressions.
//
// Brad Whitlock, Tue May 19 12:22:38 PDT 2009
// I added an argument to WriteUcdvars.
//
// Eric Brugger, Mon Jun 22 16:35:47 PDT 2009
// I modified the writer to handle the case where the meshes in a
// multimesh or multivar were not all of the same type.
//
// ****************************************************************************
class
avtSiloWriter : public virtual avtDatabaseWriter
{
public:
avtSiloWriter(DBOptionsAttributes *);
virtual ~avtSiloWriter();
protected:
string stem;
string dir;
string meshname;
string matname;
int nblocks;
int driver;
int nmeshes;
int *meshtypes;
DBoptlist *optlist;
bool singleFile;
bool checkSums;
string compressionParams;
// places to hold args passed in WriteHeaders
const avtDatabaseMetaData *headerDbMd;
vector<string> headerScalars;
vector<string> headerVectors;
vector<string> headerMaterials;
// storage for per-block info to be written in DBPutMulti... calls
vector<double> spatialMins;
vector<double> spatialMaxs;
vector<int> zoneCounts;
map<string,vector<double> > dataMins;
map<string,vector<double> > dataMaxs;
virtual bool CanHandleMaterials(void) { return true; };
virtual void OpenFile(const string &, int);
virtual void WriteHeaders(const avtDatabaseMetaData *,
vector<string> &,
vector<string> &,
vector<string> &);
virtual void WriteChunk(vtkDataSet *, int);
virtual void CloseFile(void);
void ConstructMultimesh(DBfile *dbfile, const avtMeshMetaData *,
int *);
void ConstructMultivar(DBfile *dbfile, const string &,
const avtMeshMetaData *, int *);
void ConstructMultimat(DBfile *dbfile, const string &,
const avtMeshMetaData *);
void ConstructChunkOptlist(const avtDatabaseMetaData *);
void WriteCurvilinearMesh(DBfile *, vtkStructuredGrid *, int);
void WritePolygonalMesh(DBfile *, vtkPolyData *, int);
void WriteRectilinearMesh(DBfile *, vtkRectilinearGrid *, int);
void WriteUnstructuredMesh(DBfile *, vtkUnstructuredGrid *, int);
void WriteUcdvars(DBfile *, vtkPointData *, vtkCellData *, bool,
const unsigned char *);
void WriteQuadvars(DBfile *, vtkPointData *, vtkCellData *,
int, int *);
void WriteMaterials(DBfile *, vtkCellData *, int);
int VTKZoneTypeToSiloZoneType(int);
void WriteUcdvarsHelper(DBfile *dbfile, vtkDataSetAttributes *ds,
bool isPointMesh, int centering,
const unsigned char *gz);
void WriteQuadvarsHelper(DBfile *dbfile, vtkDataSetAttributes *ds,
int ndims, int *dims, int centering);
void WriteExpressions(DBfile *dbfile);
};
#endif
|