/[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 2183 - (hide annotations)
Fri Dec 19 03:52:50 2008 UTC (12 years, 7 months ago) by caltinay
File MIME type: text/plain
File size: 2585 byte(s)
Added escriptreader library with tools. For more information refer to README
file or wait for user documentation.

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 MeshWithElements;
24     class DataVar;
25     class DBfile;
26    
27     typedef std::vector<std::string> StringVec;
28     typedef std::vector<MeshWithElements*> MeshBlocks;
29    
30     struct VarInfo {
31     std::string fileName;
32     std::string varName;
33     DataVar* dataVar;
34     bool valid;
35     };
36     typedef std::vector<VarInfo> VarVector;
37    
38    
39     //
40     // Represents an escript/finley dataset including mesh and variables for one
41     // timestep. The domain may consist of multiple blocks.
42     //
43     class MPDataSet
44     {
45     public:
46     //
47     // Constructor
48     //
49     MPDataSet();
50    
51     //
52     // Destructor
53     //
54     ~MPDataSet();
55    
56     //
57     // Loads mesh and variables
58     //
59     bool load(const std::string meshFile, const StringVec& varFiles,
60     const StringVec& varNames, int nBlocks);
61    
62     //
63     // Loads only variables using given external mesh
64     //
65     bool load(const MeshBlocks& m, const std::string siloFile,
66     const StringVec& varFiles, const StringVec& varNames);
67    
68     //
69     // Saves the dataset to a Silo file
70     //
71     bool saveAsSilo(const std::string siloFile, bool useMultiMesh=true);
72    
73     //
74     // Returns the dataset's mesh. Caller is responsible for freeing the
75     // memory.
76     //
77     MeshBlocks extractMesh() { keepMesh = true; return meshBlocks; }
78    
79     const MeshBlocks& getMesh() const { return meshBlocks; }
80     const VarVector& getVariables() const { return variables; }
81     const VarVector& getMeshVariables() const { return meshVariables; }
82    
83     private:
84     typedef std::vector<DataVar*> DataParts;
85    
86     bool readMeshes();
87     bool readVariables();
88     void convertMeshVariables();
89     void assembleVariable(VarInfo& vi, const DataParts& parts);
90     void putSiloMultiMesh(DBfile* dbfile, std::string meshName);
91     void putSiloMultiTensor(DBfile* dbfile, const DataVar* var);
92     void putSiloMultiVar(DBfile* dbfile, std::string varName,
93     bool useMeshFile = false);
94    
95     int numParts;
96     bool keepMesh;
97     std::string meshFmt;
98     std::string siloMeshFile;
99     MeshBlocks meshBlocks;
100     VarVector variables, meshVariables;
101     };
102    
103     #endif // __MPDATASET_H__
104    

  ViewVC Help
Powered by ViewVC 1.1.26