VAPoR  0.1
AMRIO.h
Go to the documentation of this file.
1 //
2 // $Id$
3 //
4 //***********************************************************************
5 // *
6 // Copyright (C) 2006 *
7 // University Corporation for Atmospheric Research *
8 // All Rights Reserved *
9 // *
10 //***********************************************************************
11 //
12 // File: AMRIO.h
13 //
14 // Author: John Clyne
15 // National Center for Atmospheric Research
16 // PO 3000, Boulder, Colorado
17 //
18 // Date: Thu Jan 5 16:57:43 MST 2006
19 //
20 // Description:
21 //
22 //
23 #ifndef _AMRIO_h_
24 #define _AMRIO_h_
25 
26 #include <cstdio>
27 #include <vapor/MyBase.h>
28 #include <vapor/AMRTree.h>
29 #include <vapor/AMRData.h>
30 #include <vapor/VDFIOBase.h>
31 
32 namespace VAPoR {
33 
34 
35 //
44 //
45 class VDF_API AMRIO : public VAPoR::VDFIOBase {
46 
47 public:
48 
60  //
61  AMRIO(
62  const MetadataVDC &metadata
63  );
64 
74  //
75  AMRIO(
76  const string &metafile
77  );
78 
79  virtual ~AMRIO();
80 
92  //
93  int VariableExists(
94  size_t ts,
95  const char *varname,
96  int reflevel = 0,
97  int lod = 0
98  ) const ;
99 
113  //
114  int OpenTreeWrite(
115  size_t timestep
116  );
117 
130  //
131  int OpenTreeRead(
132  size_t timestep
133  );
134 
138  //
139  int CloseTree();
140 
150  //
151  int TreeRead(AMRTree *tree);
152 
153 
161  int TreeWrite(const AMRTree *tree);
162 
163 
185  int OpenVariableWrite(
186  size_t timestep,
187  const char *varname,
188  int reflevel = -1,
189  int lod = -1
190  );
191 
192  virtual int BlockWriteRegion(
193  const float *region, const size_t bmin[3], const size_t bmax[3],
194  bool block=true
195  ) { SetErrMsg("Not implemented"); return(-1); }
196 
197  virtual int WriteRegion(
198  const float *region, const size_t min[3], const size_t max[3]
199  ) { SetErrMsg("Not implemented"); return(-1); }
200 
201  virtual int WriteRegion(
202  const float *region
203  ) { SetErrMsg("Not implemented"); return(-1); }
204 
205  virtual int WriteSlice(const float *slice)
206  { SetErrMsg("Not implemented"); return(-1); }
207 
208 
233  int OpenVariableRead(
234  size_t timestep,
235  const char *varname,
236  int reflevel = 0,
237  int lod = 0
238  );
239 
240  virtual int BlockReadRegion(
241  const size_t bmin[3], const size_t bmax[3], float *region, bool unblock=true
242  ) { SetErrMsg("Not implemented"); return(-1); }
243 
244  virtual int ReadRegion(
245  const size_t min[3], const size_t max[3], float *region
246  ) { SetErrMsg("Not implemented"); return(-1); }
247 
248  virtual int ReadRegion(
249  float *region
250  ) { SetErrMsg("Not implemented"); return(-1); }
251 
252  virtual int ReadSlice(float *slice) {
253  SetErrMsg("Not implemented"); return(-1);
254  }
255 
259  //
260  virtual int CloseVariable();
261 
271  //
272  int VariableRead(AMRData *data);
273 
281  int VariableWrite(AMRData *data);
282 
283 
300  int GetBlockMins(const float **mins, int reflevel) const;
301 
304  int GetBlockMaxs(const float **maxs, int reflevel) const;
305 
306  const float *GetDataRange() const {return (_dataRange);}
307 
308  void GetValidRegion(
309  size_t min[3], size_t max[3], int reflevel
310  ) const;
311 
312 
313 private:
314  typedef int int32_t;
315 
316  static const int MAX_LEVELS = 32; // Max # of refinement leveles permitted
317 
318  int _reflevel; // refinement level of currently opened file.
319 
320  string _varName; // Currently opened variable
321  string _treeFileName; // Currenly opened tree file name
322  string _dataFileName; // Currenly opened amr data file name
323 
324  int _treeIsOpen; // true if an AMR tree file is open
325  int _dataIsOpen; // true if an AMR data file is open
326  int _treeWriteMode; // true if file opened for writing
327  int _dataWriteMode; // true if file opened for writing
328  float _dataRange[2];
329  size_t _validRegMin[3];
330  size_t _validRegMax[3];
331 
332 
333  int _AMRIO();
334  int mkpath(size_t timestep, string *path) const;
335  int mkpath(size_t timestep, const char *varname, string *path) const;
336 
337 };
338 
339 }
340 
341 #endif // _WavletBlock3d_h_
virtual int BlockWriteRegion(const float *region, const size_t bmin[3], const size_t bmax[3], bool block=true)
Definition: AMRIO.h:192
#define VDF_API
Definition: common.h:61
This class manages an Adaptive Mesh Refinement grid.
Definition: AMRData.h:62
const float * GetDataRange() const
Definition: AMRIO.h:306
virtual int ReadRegion(const size_t min[3], const size_t max[3], float *region)
Definition: AMRIO.h:244
virtual int WriteRegion(const float *region)
Definition: AMRIO.h:201
Performs data IO to VDF files.
Definition: AMRIO.h:45
A class for managing data set metadata.
Definition: MetadataVDC.h:92
virtual int BlockReadRegion(const size_t bmin[3], const size_t bmax[3], float *region, bool unblock=true)
Definition: AMRIO.h:240
virtual int WriteSlice(const float *slice)
Definition: AMRIO.h:205
virtual int WriteRegion(const float *region, const size_t min[3], const size_t max[3])
Definition: AMRIO.h:197
Abstract base class for performing data IO to a VDC.
Definition: VDFIOBase.h:27
virtual int ReadRegion(float *region)
Definition: AMRIO.h:248
This class manages an AMR tree data structure.
Definition: AMRTree.h:62
virtual int ReadSlice(float *slice)
Definition: AMRIO.h:252