avtVsFileFormat.h 8.46 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/**
 *
 * @file        avtVsFileFormat.h
 *
 * @brief       Base class for VizSchema visit plugins
 *
 * @version $Id: avtVsFileFormat.h 27 2008-03-26 22:04:41Z sveta $
 *
 * Copyright © 2007, Tech-X Corporation
 * See LICENSE file for conditions of use.
 *
 */

// ************************************************************************* //
//                            avtVsFileFormat.h                                 //
// ************************************************************************* //

#ifndef VS_FILE_FORMAT_H
#define VS_FILE_FORMAT_H

21 22
#include <vtkUnsignedCharArray.h>
#include <vtkPoints.h>
apletzer's avatar
apletzer committed
23 24
#include <VsDataset.h>
//#include <VsReader.h>
25 26 27
#include <avtSTMDFileFormat.h>
#include <hdf5.h>
#include <visit-hdf5.h>
28
#include "HighOrderUnstructuredData.h"
29

30 31 32
#include <string>
#include <vector>

33
// Forward references to minimize compilation
34 35
class vtkPoints;
class vtkUnsignedCharArray;
36 37 38 39
class vtkDataSet;
class vtkDataArray;
class avtDatabaseMetaData;
class avtMeshMetaData;
40 41 42 43 44 45
class VsVariableWithMesh;
class VsUnstructuredMesh;
class VsUniformMesh;
class VsStructuredMesh;
class VsRectilinearMesh;
class VsRegistry;
apletzer's avatar
apletzer committed
46
class VsReader;
47 48 49 50 51 52 53 54 55

/**
 * avtSTMDFileFormat is a base class for multi-domain, single-time
 * VisIt plugins.  It provides mesh, scalar, and vector data.  It
 * assumes an ordering of component minor in the data file.  This is
 * reversed to get Fortran ordering.
 *
 * No ability to account for tensors at the present time.
 */
56 57
class avtVsFileFormat: public avtSTMDFileFormat {
#if HDF5_VERSION_GE(1, 8, 1)
58 59
  public:

60 61 62 63 64
  /**
   * Construct a file reader from a data file.
   *
   * @param dfnm the name of the data file
   */
65
  avtVsFileFormat(const char*, DBOptionsAttributes *);
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80

  /**
   * Destructor
   */
  virtual ~avtVsFileFormat();

  /**
   * Get plugin type
   *
   * @return plugin type name
   */
  virtual const char* GetType(void) {
    return "Vs";
  };

allens's avatar
allens committed
81
  virtual std::string CreateCacheNameIncludingSelections(std::string s);
82

allens's avatar
allens committed
83 84 85 86
  /**
   * Get the data selections
   *
   */
87 88
  virtual void RegisterDataSelections( const std::vector<avtDataSelection_p> &sels,
                                       std::vector<bool> *selectionsApplied );
allens's avatar
allens committed
89 90 91 92 93 94 95

  /**
   * Process the data selections
   *
   */
  bool ProcessDataSelections(int *mins, int *maxs, int *strides);

96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
  /**
   * Get a mesh by name
   *
   * @param domain the number of the domain in this mesh
   * @param meshname the name of the mesh
   *
   * @return a pointer to the mesh. Caller assumes ownership (must delete when done)
   */
  virtual vtkDataSet* GetMesh(int domain, const char* meshname);

  /**
   * get a scalar variable by name
   *
   * @param domain the number of the domain in this mesh
   * @param varname the name of the variable
   *
   * @return a pointer to the variable. Caller assumes ownership (must delete when done)
   */
  virtual vtkDataArray* GetVar(int domain, const char* varname);

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
  /**
   * Get variable in the case when it is stored on a node by node basis per cell.  This
   * is needed for discontinuous Galerkin data.
   * @param meta is the variable of interest
   * @param component is the component of interest
   */
  virtual vtkDataArray* NodalVar(VsVariable* meta, std::string requestedName, int component);

  /**
   * Get a variable that is "standard".  A standard variable is a variable that
   * is stored on cell centers, cell vertices or edges.  It does not include
   * discontinuous Galerkin type data (or likely other high order data).
   */
  virtual vtkDataArray* StandardVar(int domain, const char* requestedName);

  /**
   * Determine if the name is a component of a larger vector
   * @param name is the name of the variable
   * @param componentIndex is the index of that variable (returned).
   */
  virtual bool nameIsComponent(std::string& name, int& componentIndex);

  /**
   * Check to see if the name has been transformed to a different name for
   * display
   * @param name is the name of the variable
   */
  virtual bool isTransformedName(std::string& name);

145 146 147 148
  /**
   * Free up any resources created by this object.
   */
  virtual void FreeUpResources(void);
149

150 151 152 153 154 155 156
  /**
   * Called to alert the database reader that VisIt is about to ask for data
   * at this timestep.  Since this reader is single-time, this is 
   * only provided for reference and does nothing.
   */
  virtual void ActivateTimestep(void);
  
157 158 159 160 161
  /**
   * Updates cycles and times in the given database metadata object
   * Deprecated 06.02.2011 in favor of GetCycle and GetTime
   * Marc Durant
   */
162
  virtual void UpdateCyclesAndTimes(avtDatabaseMetaData* md);
163
  
164
  protected:
165 166 167 168 169 170 171 172 173 174 175 176
  /**
   * Get the cycle for the associated file
   * @return the cycle, or INVALID_CYCLE if none is available
   */
  virtual int GetCycle();

  /**
   * Get the time for the associated file
   * @return the time, or INVALID_TIME if none is available
   */
  virtual double GetTime();

177 178
  /** Populate the meta data */
  virtual void PopulateDatabaseMetaData(avtDatabaseMetaData* md);
179

180 181
  /** The file containing the data */
  std::string dataFileName;
182

183
  /** Pointer to the reader */
apletzer's avatar
apletzer committed
184
  VsReader* reader;
185

186 187 188
  /** Ensure data has been read **/
  void LoadData();

189 190 191 192 193 194 195
  /**
   * This is not the best way to do this.  In fact every type of mesh should
   * have a separate class and then there would be a pointer to the type selected.
   * Since I only have one class that uses this approach I'm doing it this way.
   */
  HighOrderUnstructuredData thisData;

196
  private:
197 198 199 200 201 202 203 204 205

  /**
   * Get the meta data for a variable given a name.
   * @domain is the domain of interest
   * @requestedName is the full name of the variable
   * @componentIndex is the component we are requesting
   */
  VsVariable* getVariableMeta(int domain, std::string requestedName, int &componentIndex);

206 207 208 209 210
  /**
   * A counter to track the number of avtVsFileFormat objects in existence
   */
  static int instanceCounter;

211 212 213
  /**
   * A registry of all objects found in the data file
   */
214
  VsRegistry* registry;
215

216 217 218 219
  /** Some stuff to keep track of data selections */
  std::vector<avtDataSelection_p> selList;
  std::vector<bool>              *selsApplied;

allens's avatar
allens committed
220 221
  bool processDataSelections;

222 223 224 225
  /**
   * Maintain a list of curve names so we can classify expressions better
   */
  std::vector<std::string> curveNames;
allens's avatar
allens committed
226

227 228 229 230 231 232 233 234 235 236
  /**
   * Set the axis labels for a mesh.
   *
   * @param mmd a pointer to the object that needs the axis labels.
   */
  void setAxisLabels(avtMeshMetaData* mmd);

  /**
   * Create various meshes.
   */
237
  vtkDataSet* getUniformMesh(VsUniformMesh*, bool, int*, int*, int*);
238
  vtkDataSet* getRectilinearMesh(VsRectilinearMesh*, bool, int*, int*, int*, bool);
239
  vtkDataSet* getStructuredMesh(VsStructuredMesh*, bool, int*, int*, int*);
240
  vtkDataSet* getUnstructuredMesh(VsUnstructuredMesh*, bool, int*, int*, int*);
241
  vtkDataSet* getPointMesh(VsVariableWithMesh*, bool, int*, int*, int*, bool);
242
  vtkDataSet* getHighOrderUnstructuredMesh(VsUnstructuredMesh*, bool, int*, int*, int*);
243 244
  vtkDataSet* getCurve(int domain, const std::string& name);

245

246 247 248 249 250 251 252 253 254 255
  /**
   * Each type of object is added to the database with a separate method
   * for neatness.
   */
  void RegisterMeshes(avtDatabaseMetaData* md);
  void RegisterMdMeshes(avtDatabaseMetaData* md);
  void RegisterVarsWithMesh(avtDatabaseMetaData* md);
  void RegisterVars(avtDatabaseMetaData* md);
  void RegisterMdVars(avtDatabaseMetaData* md);
  void RegisterExpressions(avtDatabaseMetaData* md);
256

allens's avatar
allens committed
257
  void GetSelectionBounds( int numTopologicalDims,
258 259
                           std::vector<int> &numCells,
                           std::vector<int> &gdims,
allens's avatar
allens committed
260 261 262 263
                           int *mins,
                           int *maxs,
                           int *strides,
                           bool haveDataSelections,
264
                           bool isNodal = true );
allens's avatar
allens committed
265

266
  bool GetParallelDecomp( int numTopologicalDims,
267
                          std::vector<int> &dims,
268 269 270
                          int *mins,
                          int *maxs,
                          int *strides,
271
                          bool isNodal = true );
272 273 274
  
  template <typename TYPE>
  void fillInMaskNodeArray(const std::vector<int>& gdims,
apletzer's avatar
apletzer committed
275
                           VsDataset *mask, bool maskIsFortranOrder,
276 277 278 279 280 281 282 283
                           vtkUnsignedCharArray *maskedNodes);

  template <typename TYPE>
    void setStructuredMeshCoords(const std::vector<int>& gdims,
                                 const TYPE* dataPtr,
                                 bool isFortranOrder,
                                 vtkPoints* vpoints);

284

285
#else
286
  avtVsFileFormat(const char* dfnm) : avtSTMDFileFormat(&dfnm, 1) {;};
287 288 289 290
#endif
};

#endif