/[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 2206 - (show annotations)
Fri Jan 9 03:50:29 2009 UTC (12 years, 5 months ago) by caltinay
File MIME type: text/plain
File size: 2840 byte(s)
Added some more doxygen docu to escriptreader classes.

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 /// \brief
29 class Mesh
30 {
31 public:
32 /// \brief Constructor with mesh coordinates, dimensionality and size.
33 Mesh(CoordArray c, int nDims, int nNodes);
34
35 /// \brief Copy constructor.
36 Mesh(const Mesh& m);
37
38 /// \brief 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 /// \brief 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 /// \brief Returns an array with the coordinates of the mesh nodes.
60 const CoordArray& getCoords() const { return coords; }
61
62 /// \brief Returns the dimensionality of this mesh (2 or 3).
63 int getNumDims() const { return numDims; }
64
65 /// \brief Returns the number of mesh nodes.
66 int getNumNodes() const { return numNodes; }
67
68 protected:
69 /// \brief Protected default constructor.
70 Mesh() {}
71
72 void buildIndexMap();
73
74 CoordArray coords; /// x, y[, z] coordinates of mesh nodes
75 int numDims; /// dimensionality of mesh (2 or 3)
76 int numNodes; /// number of mesh nodes
77 IntVec nodeID; /// node IDs
78 IndexMap nodeID2idx; /// mapping of node ID -> array index
79 std::string name; /// the name of this mesh
80 std::string siloPath; /// absolute path in Silo file
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