/[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 2187 - (show annotations)
Tue Dec 23 04:13:15 2008 UTC (12 years, 5 months ago) by caltinay
File MIME type: text/plain
File size: 2643 byte(s)
Moved escriptreader related classes into own namespace.

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

  ViewVC Help
Powered by ViewVC 1.1.26