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

Contents of /trunk/tools/libescriptreader/src/escriptreader/Mesh.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2196 - (show annotations)
Wed Jan 7 06:14:59 2009 UTC (12 years, 5 months ago) by caltinay
File MIME type: text/plain
File size: 2613 byte(s)
As harsh as it sounds: removed obsolete friendship between DataVar and Mesh.
Updated and added documentation to some more methods.

1
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 // Mesh.h
16 //
17 #ifndef __MESH_H__
18 #define __MESH_H__
19
20 #include <escriptreader/common.h>
21
22 class DBfile;
23
24 namespace EscriptReader {
25
26 class ElementData;
27
28 //
29 //
30 //
31 class Mesh
32 {
33 public:
34 /// Constructor with mesh coordinates, dimensionality and size
35 Mesh(CoordArray c, int nDims, int nNodes);
36
37 /// Copy constructor
38 Mesh(const Mesh& m);
39
40 /// Virtual destructor
41 virtual ~Mesh();
42
43 virtual bool readFromNc(const std::string& ncFile);
44 virtual bool writeToSilo(DBfile* dbfile, const std::string& pathInSilo);
45
46 void setName(const std::string& n) { name = n; }
47 std::string getName() const { return name; }
48
49 void setSiloPath(const std::string& p) { siloPath = p; }
50 std::string getSiloPath() const { return siloPath; }
51
52 /// Returns full Silo mesh name, e.g. "/block0000/Elements"
53 std::string getFullSiloName() const;
54
55 const IntVec& getNodeIDs() const { return nodeID; }
56 void setNodeIDs(const IntVec& ids) { nodeID = ids; }
57
58 const IndexMap& getIndexMap() const { return nodeID2idx; }
59 void setIndexMap(const IndexMap& map) { nodeID2idx = map; }
60
61 const CoordArray& getCoords() const { return coords; }
62 int getNumDims() const { return numDims; }
63 int getNumNodes() const { return numNodes; }
64
65 protected:
66 /// Protected default constructor
67 Mesh() {}
68
69 void buildIndexMap();
70
71 CoordArray coords; // x, y[, z] coordinates of mesh nodes
72 int numDims; // dimensionality of mesh (2 or 3)
73 int numNodes; // number of mesh nodes
74 IntVec nodeID; // node IDs
75 IndexMap nodeID2idx; // mapping of node ID -> array index
76 std::string name; // the name of this mesh
77 std::string siloPath; // absolute path in Silo file
78 };
79
80
81 //
82 //
83 //
84 inline void Mesh::buildIndexMap()
85 {
86 nodeID2idx.clear();
87 int idx = 0;
88 IntVec::const_iterator idIt;
89 for (idIt = nodeID.begin(); idIt != nodeID.end(); idIt++, idx++)
90 nodeID2idx[*idIt] = idx;
91 }
92
93 inline std::string Mesh::getFullSiloName() const
94 {
95 if (siloPath == "/")
96 return siloPath + name;
97 else
98 return siloPath + std::string("/") + name;
99 }
100
101 } // namespace EscriptReader
102
103 #endif // __MESH_H__
104

  ViewVC Help
Powered by ViewVC 1.1.26