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
HDF5Table.h
Go to the documentation of this file.
1 #ifndef HDF5TABLE_H
2 #define HDF5TABLE_H
3 
4 #include <vector>
5 #include <set>
6 #include <string>
7 #include <map>
8 
9 #include "tabular_props/H5IO.h"
10 
11 namespace sierra {
12 namespace nalu {
13 
14 // Forward declarations
15 //class Realm;
16 class Converter;
17 class H5IO;
18 class BSpline;
19 
20 struct ClipEvent {
21  double severity;
22  std::vector<double> values;
23 };
24 
25 template <class T>
27  public:
28  bool operator() ( const T & v1,
29  const T & v2 ) const {
30  // Sort based on the severity only, in decreasing order
31  return v1.severity > v2.severity;
32  }
33 };
34 
35 typedef std::set<ClipEvent, ClipEventSortCriterion<ClipEvent> > ClipEventLog;
36 
49 class HDF5Table
50 {
51 
52  public:
53 
54  typedef std::map<std::string, std::string> Attributes;
55 
59  HDF5Table();
64  HDF5Table(
65  H5IO *fileIO,
66  std::string tablePropName,
67  std::vector<std::string> &indVarNameVec,
68  std::vector<std::string> &indVarTableNameVec);
69 
70  virtual ~HDF5Table();
71 
76  void add_converter( const Converter * converter );
77 
79  const std::string & name() const { return name_; }
80 
83  const std::vector<std::string> & input_names() const { return inputNames_; }
84 
85  /* Get the number of inputs required by the query() function */
86  unsigned int dimension() const { return dimension_; }
87 
96  double query( const std::vector<double> &inputs ) const;
97 
107  double raw_query( const std::vector<double> &inputs ) const;
108 
110  void set_clipping_log_size( unsigned int size ) ;
111 
113  unsigned int num_clipping_events() const;
114 
118  const ClipEventLog & clipping_event_log() const;
119 
124  const std::vector<std::string> & clipping_event_input_names() const { return inputNames_; }
125 
127  const std::vector<double> & clipping_event_min_bounds() const;
128 
130  const std::vector<double> & clipping_event_max_bounds() const;
131 
133  void clear_clipping_log() ;
134 
139  unsigned int num_converters() const { return converters_.size(); }
140 
142  bool has_attribute( const std::string & name ) const;
143 
145  const std::string & attribute( const std::string & name ) const;
146 
148  void read_hdf5_property( );
149 
151  void read_hdf5_table( H5IO & io );
152 
153  private:
154 
155  // Add the current values to the clipping event log
156  void log_clip_event( const std::vector<double> & values ) const;
157 
161  void update_input_mapping();
162 
164  int findix( const std::vector<std::string> & nameVector,
165  const std::string & name );
166 
167  //HDF5 file pointer
169 
170  // name of dependent variable as given in the table
171  std::string tablePropName_;
172 
173  // names of independent variables as given in the table
174  std::vector<std::string> indVarTableNameVec_;
175 
176  // number of independent variables
177  const size_t indVarSize_;
178 
179  // Number of inputs required by the query() function
180  unsigned int dimension_;
181 
182  // Name of the variable returned by calls to query()
183  std::string name_;
184 
185  // Names of the inputs required by the query() function
186  std::vector<std::string> inputNames_;
187 
188  // List of optional input converters for the table
189  std::vector<const Converter *> converters_;
190 
191  // Table and Converter input and output index mapping data
192  std::vector<unsigned int> directInputIndex_;
193  std::vector<unsigned int> convTableIndex_;
194  std::vector<std::vector<unsigned int> > convInputIndex_;
195  // used to map between input ordered by indVarTableNameVec_
196  // and input required by ordering of inputNames_
197  std::vector<unsigned int> indexIndVar_;
198 
199 
200 
202  // FROM Atab_Table.h
204 
205  // Status of internal log scale use for each independent variable
206  std::vector<unsigned int> inputLogScale_;
207 
208  // Minimum and maximum values for the independent variables
209  std::vector<double> meshMin_;
210  std::vector<double> meshMax_;
211 
212  // Minimum and maximum clipping values and clipping status for the
213  // independent variables
214  std::vector<double> inputMin_;
215  std::vector<double> inputMax_;
216 
217 
218  // Independent variable mesh points used to build the interpolator
219  std::vector<std::vector<double> > mesh_;
220 
221  // Minimum and maximum interpolated variable value
222  double valueMin_;
223  double valueMax_;
224 
225  // Arbitrary metadata
226  Attributes attributes_;
227 
228  // Internal interpolator used to perform table lookups
230 
231  // Buffers for storing clipping diagnostic information
232  mutable unsigned int clipEventLogSize_;
233  mutable unsigned int numClipped_;
234  mutable ClipEventLog clipEventLog_;
235 
236  // delete this and use lookupBuf_ instead
237  // double * tableBuf_;
238  // Scratch space for conversions
239  mutable std::vector<double> converterBuf_;
240 
241  // Scratch space for doing log scale conversions, etc. on the input variables
242  mutable std::vector<double> lookupBuffer_;
243  // Scratch space for doing bounds clipping on lookupBuffer_
244  mutable std::vector<double> lookupBufferChecked_;
245 
246 };
247 
248 //typedef SharedPtr<const HDF5Table> ConstHDF5TablePtr;
249 
250 } // end nalu namespace
251 } // end sierra namespace
252 
253 #endif
unsigned int dimension() const
Definition: HDF5Table.h:86
std::string tablePropName_
Definition: HDF5Table.h:171
Definition: ABLForcingAlgorithm.C:26
unsigned int dimension_
Definition: HDF5Table.h:180
Simple wrapper around the HDF5 library to make usage easier.
Definition: H5IO.h:57
std::vector< double > lookupBuffer_
Definition: HDF5Table.h:242
double severity
Definition: HDF5Table.h:21
BSpline * spline_
Definition: HDF5Table.h:229
std::vector< const Converter * > converters_
Definition: HDF5Table.h:189
double valueMin_
Definition: HDF5Table.h:222
const std::string & name() const
Get the name of the variable returned by a query to this HDF5Table.
Definition: HDF5Table.h:79
Attributes attributes_
Definition: HDF5Table.h:226
std::vector< std::string > indVarTableNameVec_
Definition: HDF5Table.h:174
std::vector< unsigned int > directInputIndex_
Definition: HDF5Table.h:192
std::vector< std::vector< double > > mesh_
Definition: HDF5Table.h:219
Definition: HDF5Table.h:26
std::vector< double > meshMin_
Definition: HDF5Table.h:209
std::vector< unsigned int > convTableIndex_
Definition: HDF5Table.h:193
std::vector< std::string > inputNames_
Definition: HDF5Table.h:186
H5IO * fileIO_
Definition: HDF5Table.h:168
std::vector< unsigned int > inputLogScale_
Definition: HDF5Table.h:206
std::vector< double > inputMax_
Definition: HDF5Table.h:215
std::vector< double > lookupBufferChecked_
Definition: HDF5Table.h:244
std::vector< double > inputMin_
Definition: HDF5Table.h:214
std::vector< double > converterBuf_
Definition: HDF5Table.h:239
std::map< std::string, std::string > Attributes
Definition: HDF5Table.h:54
const std::vector< std::string > & input_names() const
Get the list of input variables required by calls to query(), in the order that they are to be provid...
Definition: HDF5Table.h:83
std::vector< double > meshMax_
Definition: HDF5Table.h:210
double valueMax_
Definition: HDF5Table.h:223
Provides arbitrary processing of input data before handing off values to a Table for interpolation...
Definition: Converter.h:41
unsigned int clipEventLogSize_
Definition: HDF5Table.h:232
std::set< ClipEvent, ClipEventSortCriterion< ClipEvent > > ClipEventLog
Definition: HDF5Table.h:35
std::string name_
Definition: HDF5Table.h:183
const size_t indVarSize_
Definition: HDF5Table.h:177
Object to manage property evaluation as a function of a set of input chemical state variables...
Definition: HDF5Table.h:49
const std::vector< std::string > & clipping_event_input_names() const
Return the list of input variables corresponding to the values in the clipping event log...
Definition: HDF5Table.h:124
unsigned int numClipped_
Definition: HDF5Table.h:233
std::vector< unsigned int > indexIndVar_
Definition: HDF5Table.h:197
Base class for B-Splines.
Definition: BSpline.h:26
unsigned int num_converters() const
Return the number of Converters.
Definition: HDF5Table.h:139
std::vector< std::vector< unsigned int > > convInputIndex_
Definition: HDF5Table.h:194
std::vector< double > values
Definition: HDF5Table.h:22
Definition: HDF5Table.h:20
ClipEventLog clipEventLog_
Definition: HDF5Table.h:234