MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
NSDFWriter.h
Go to the documentation of this file.
1 /* NSDFWriter.h ---
2  *
3  * Filename: NSDFWriter.h
4  * Description:
5  * Author: subha
6  * Maintainer:
7  * Created: Thu Jun 18 23:06:59 2015 (-0400)
8  * Version:
9  * Last-Updated: Sun Dec 20 23:17:32 2015 (-0500)
10  * By: subha
11  * Update #: 2
12  * URL:
13  * Keywords:
14  * Compatibility:
15  *
16  */
17 
18 /* Commentary:
19  *
20  *
21  *
22  */
23 
24 /* Change log:
25  *
26  *
27  */
28 
29 /* This program is free software; you can redistribute it and/or
30  * modify it under the terms of the GNU General Public License as
31  * published by the Free Software Foundation; either version 3, or
32  * (at your option) any later version.
33  *
34  * This program is distributed in the hope that it will be useful,
35  * but WITHOUT ANY WARRANTY; without even the implied warranty of
36  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
37  * General Public License for more details.
38  *
39  * You should have received a copy of the GNU General Public License
40  * along with this program; see the file COPYING. If not, write to
41  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth
42  * Floor, Boston, MA 02110-1301, USA.
43  */
44 
45 /* Code: */
46 
47 #ifdef USE_HDF5
48 #ifndef _NSDFWRITER_H
49 #define _NSDFWRITER_H
50 
51 #include "HDF5DataWriter.h"
52 
53 class InputVariable;
54 
58 typedef struct {
59  const char * source;
60  hobj_ref_t data;
61 } map_type;
62 
77 class NSDFWriter: public HDF5DataWriter
78 {
79  public:
80  NSDFWriter();
81  ~NSDFWriter();
82  virtual void flush();
83  // set the environment specs like title, author, tstart etc.
84  void setEnvironment(string key, string value);
85  // the model tree rooted here is to be copied to NSDF file
86  void setModelRoot(string root);
87  string getModelRoot() const;
88  InputVariable *getEventInput(unsigned int index);
89  void setNumEventInputs(unsigned int num);
90  unsigned int getNumEventInputs() const;
91  void setInput(unsigned int index, double value);
92  void openUniformData(const Eref &eref);
93  void closeUniformData();
94  void openEventData(const Eref &eref);
95  void closeEventData();
96  virtual void close();
97  void createUniformMap();
98  void createEventMap();
99  void writeModelTree();
100  // Sort the incoming data lines according to source object/field.
101  void process(const Eref &e, ProcPtr p);
102  void reinit(const Eref &e, ProcPtr p);
103  NSDFWriter& operator=(const NSDFWriter&other);
104 
105  static const Cinfo *initCinfo();
106 
107  protected:
108  hid_t getEventDataset(string srcPath, string srcField);
109  void sortOutUniformSources(const Eref& eref);
110  /* hid_t getUniformDataset(string srcPath, string srcField); */
111  map <string, string> env_; // environment attributes
112  vector < hid_t > eventDatasets_;
113  // event times data_ and datasets_ inherited from HDF5DataWriter
114  // are still attached to requestOut message
115  vector < vector < double > > events_;
116  vector < InputVariable > eventInputs_;
117  vector < string > eventSrcFields_;
118  vector < string > eventSrc_;
119  map < string, hid_t > eventSrcDataset_;
120  hid_t eventGroup_; // handle for event container
121  hid_t uniformGroup_; // handle for uniform container
122  hid_t dataGroup_; // handle for data container.
123  hid_t modelGroup_; // handle for model container
124  hid_t mapGroup_; // handle for map container
125  map< string, vector< hid_t > > classFieldToEvent_;
126  map< string, vector< string > > classFieldToEventSrc_;
127  map< string, hid_t > classFieldToUniform_;
128  // maps a path.srcFinfo to the <target dataset, row index > for
129  // storing uniform data in dataset.
130  map< string, pair< hid_t, unsigned int > > uniformSrcDatasetIndex_;
144  // The last number of rows in each dataset
145  // (/data/uniform/className/fieldName -> size)
146 
147  map< string, vector< unsigned int > > classFieldToSrcIndex_;
148  // the index of the recorded field in its dataset (objectPath/fieldName -> index)
149  map< string, unsigned int > objectFieldToIndex_;
150  // objectPath -> field - just for reuse later - avoid repeating
151  // extraction of field name from func_.
152  vector < pair< string, string > > objectField_;
153  map< string, vector < string > > classFieldToObjectField_;
154  vector < string > vars_;
155  string modelRoot_;
156 
157 };
158 #endif // _NSDFWRITER_H
159 #endif // USE_HDF5
160 
161 
162 /* NSDFWriter.h ends here */
uint32_t value
Definition: moosemodule.h:42
char map_type(const std::type_info &t)
Definition: cnpy.cpp:36
Definition: Eref.h:26
Definition: Cinfo.h:18