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

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

  ViewVC Help
Powered by ViewVC 1.1.26