/[escript]/trunk/tools/libescriptreader/src/escriptreader/MPDataSet.h
ViewVC logotype

Annotation of /trunk/tools/libescriptreader/src/escriptreader/MPDataSet.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2187 - (hide annotations)
Tue Dec 23 04:13:15 2008 UTC (12 years, 7 months ago) by caltinay
File MIME type: text/plain
File size: 2643 byte(s)
Moved escriptreader related classes into own namespace.

1 caltinay 2183
2     /*******************************************************
3     *
4     * Copyright (c) 2003-2008 by University of Queensland
5     * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13    
14     //
15     // MPDataSet.h
16     //
17     #ifndef __MPDATASET_H__
18     #define __MPDATASET_H__
19    
20     #include <string>
21     #include <vector>
22    
23     class DBfile;
24    
25 caltinay 2187 namespace EscriptReader {
26    
27     class DataVar;
28     class MeshWithElements;
29    
30 caltinay 2183 typedef std::vector<std::string> StringVec;
31     typedef std::vector<MeshWithElements*> MeshBlocks;
32    
33     struct VarInfo {
34     std::string fileName;
35     std::string varName;
36     DataVar* dataVar;
37     bool valid;
38     };
39     typedef std::vector<VarInfo> VarVector;
40    
41    
42     //
43     // Represents an escript/finley dataset including mesh and variables for one
44     // timestep. The domain may consist of multiple blocks.
45     //
46     class MPDataSet
47     {
48     public:
49     //
50     // Constructor
51     //
52     MPDataSet();
53    
54     //
55     // Destructor
56     //
57     ~MPDataSet();
58    
59     //
60     // Loads mesh and variables
61     //
62     bool load(const std::string meshFile, const StringVec& varFiles,
63     const StringVec& varNames, int nBlocks);
64    
65     //
66     // Loads only variables using given external mesh
67     //
68     bool load(const MeshBlocks& m, const std::string siloFile,
69     const StringVec& varFiles, const StringVec& varNames);
70    
71     //
72     // Saves the dataset to a Silo file
73     //
74     bool saveAsSilo(const std::string siloFile, bool useMultiMesh=true);
75    
76     //
77     // Returns the dataset's mesh. Caller is responsible for freeing the
78     // memory.
79     //
80     MeshBlocks extractMesh() { keepMesh = true; return meshBlocks; }
81    
82     const MeshBlocks& getMesh() const { return meshBlocks; }
83     const VarVector& getVariables() const { return variables; }
84     const VarVector& getMeshVariables() const { return meshVariables; }
85    
86     private:
87     typedef std::vector<DataVar*> DataParts;
88    
89     bool readMeshes();
90     bool readVariables();
91     void convertMeshVariables();
92     void assembleVariable(VarInfo& vi, const DataParts& parts);
93     void putSiloMultiMesh(DBfile* dbfile, std::string meshName);
94     void putSiloMultiTensor(DBfile* dbfile, const DataVar* var);
95     void putSiloMultiVar(DBfile* dbfile, std::string varName,
96     bool useMeshFile = false);
97    
98     int numParts;
99     bool keepMesh;
100     std::string meshFmt;
101     std::string siloMeshFile;
102     MeshBlocks meshBlocks;
103     VarVector variables, meshVariables;
104     };
105    
106 caltinay 2187 } // namespace EscriptReader
107    
108 caltinay 2183 #endif // __MPDATASET_H__
109    

  ViewVC Help
Powered by ViewVC 1.1.26