Nalu
Nalu: a generalized unstructured massively parallel low Mach flow code designed to support a variety of energy applications of interest (most notably Wind ECP) built on the Sierra Toolkit and Trilinos solver Tpetra/Epetra stack. The open source BSD, clause 3 license model has been chosen for the code base. See LICENSE for more information. http://NaluCFD.org
H5IO.h
Go to the documentation of this file.
1 #ifndef H5IO_H
2 #define H5IO_H
3 
4 #include <hdf5.h>
5 
6 #include <string>
7 #include <vector>
8 
9 namespace sierra {
10 namespace nalu {
11 
12 //============================================================================
57 class H5IO {
58 
59  public:
60  H5IO();
61  ~H5IO();
62 
63  void create_file( const std::string & name, int version = 1 );
64  void open_file( const std::string & name );
65  void close_file();
66 
67  H5IO create_group( const std::string & name );
68  H5IO open_group( const std::string & name );
69 
70  unsigned int num_attributes();
71  int file_version() const { return fileVersion_; }
72 
73  void write_attribute( const std::string & name, int value );
74  void write_attribute( const std::string & name, unsigned int value );
75  void write_attribute( const std::string & name, double value );
76  void write_attribute( const std::string & name, const std::string & value );
77 
78  void write_attribute( const std::string & name,
79  const std::vector<int> & value );
80  void write_attribute( const std::string & name,
81  const std::vector<unsigned int> & value );
82  void write_attribute( const std::string & name,
83  const std::vector<double> & value );
84  void write_attribute( const std::string & name,
85  const std::vector<std::string> & value );
86 
87  bool has_attribute( const std::string & name );
88 
89  void read_attribute( const std::string & name, int & value );
90  void read_attribute( const std::string & name, unsigned int & value );
91  void read_attribute( const std::string & name, double & value );
92  void read_attribute( const std::string & name, std::string & value );
93  void read_attribute( unsigned int index, std::string & name,
94  std::string & value );
95 
96  void read_attribute( const std::string & name,
97  std::vector<int> & value );
98  void read_attribute( const std::string & name,
99  std::vector<unsigned int> & value );
100  void read_attribute( const std::string & name,
101  std::vector<double> & value );
102  void read_attribute( const std::string & name,
103  std::vector<std::string> & value );
104 
105  void write_dataset( const std::string & name,
106  const std::vector<double> & value );
107 
108  void read_dataset( const std::string & name, std::vector<double> & value );
109 
110  private:
111  void h5io_create_group( const std::string & name );
112  void h5io_open_group( const std::string & name );
113  void h5io_open_group();
114  void h5io_close_group();
115  hid_t h5io_create_scalar();
116  hid_t h5io_create_1D_array( unsigned int size );
117  hid_t h5io_create_attribute( const std::string & name,
118  hid_t type,
119  hid_t space );
120  hid_t h5io_create_dataset( const std::string & name,
121  hid_t type,
122  hid_t space );
123 
124  std::string fileName_;
125  std::string groupName_;
126  hid_t file_;
127  hid_t group_;
129 
130 };
131 
132 } // end nalu namespace
133 } // end sierra namespace
134 
135 #endif
H5IO open_group(const std::string &name)
Definition: H5IO.C:132
hid_t h5io_create_scalar()
Definition: H5IO.C:237
void read_dataset(const std::string &name, std::vector< double > &value)
Definition: H5IO.C:689
Definition: ABLForcingAlgorithm.C:26
int file_version() const
Definition: H5IO.h:71
Simple wrapper around the HDF5 library to make usage easier.
Definition: H5IO.h:57
hid_t group_
Definition: H5IO.h:127
std::string fileName_
Definition: H5IO.h:124
hid_t h5io_create_dataset(const std::string &name, hid_t type, hid_t space)
Definition: H5IO.C:281
void open_file(const std::string &name)
Definition: H5IO.C:62
void h5io_open_group()
Definition: H5IO.C:208
std::string groupName_
Definition: H5IO.h:125
int fileVersion_
Definition: H5IO.h:128
void h5io_create_group(const std::string &name)
Definition: H5IO.C:166
unsigned int num_attributes()
Definition: H5IO.C:148
H5IO()
Definition: H5IO.C:15
void write_attribute(const std::string &name, int value)
Definition: H5IO.C:296
void read_attribute(const std::string &name, int &value)
Definition: H5IO.C:509
bool has_attribute(const std::string &name)
Definition: H5IO.C:485
void create_file(const std::string &name, int version=1)
Definition: H5IO.C:25
void write_dataset(const std::string &name, const std::vector< double > &value)
Definition: H5IO.C:665
hid_t file_
Definition: H5IO.h:126
hid_t h5io_create_1D_array(unsigned int size)
Definition: H5IO.C:251
void h5io_close_group()
Definition: H5IO.C:222
hid_t h5io_create_attribute(const std::string &name, hid_t type, hid_t space)
Definition: H5IO.C:267
void close_file()
Definition: H5IO.C:94
~H5IO()
Definition: H5IO.C:21
H5IO create_group(const std::string &name)
Definition: H5IO.C:116