/[escript]/trunk/dataexporter/src/NodeData.h
ViewVC logotype

Contents of /trunk/dataexporter/src/NodeData.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2846 - (show annotations)
Fri Jan 15 03:16:08 2010 UTC (10 years, 9 months ago) by caltinay
File MIME type: text/plain
File size: 3846 byte(s)
removeGhostNodes is broken and unnecessary anyway so removed.

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 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 #ifndef __NODEDATA_H__
15 #define __NODEDATA_H__
16
17 #include <escriptexport/escriptexport.h>
18
19 class DBfile;
20 class NcFile;
21 struct Finley_NodeFile;
22
23 namespace escriptexport {
24
25 /// \brief
26 class NodeData
27 {
28 public:
29 /// \brief Constructor with mesh name.
30 ESCRIPTEXPORT_DLL_API
31 NodeData(const std::string& meshName);
32
33 ESCRIPTEXPORT_DLL_API
34 NodeData(NodeData_ptr fullNodes, IntVec& requiredNodes,
35 const std::string& meshName);
36
37 /// \brief Copy constructor.
38 ESCRIPTEXPORT_DLL_API
39 NodeData(const NodeData& m);
40
41 /// \brief Virtual destructor
42 ESCRIPTEXPORT_DLL_API
43 virtual ~NodeData();
44
45 /// \brief Initialises with finley node file.
46 ESCRIPTEXPORT_DLL_API
47 bool initFromFinley(const Finley_NodeFile* finleyFile);
48
49 /// \brief Reads node data from a NetCDF file.
50 ESCRIPTEXPORT_DLL_API
51 bool readFromNc(NcFile* ncFile);
52
53 /// \brief Writes node data to a Silo file.
54 ESCRIPTEXPORT_DLL_API
55 bool writeToSilo(DBfile* dbfile);
56
57 /// \brief Sets the silo path to be used when saving.
58 ESCRIPTEXPORT_DLL_API
59 void setSiloPath(const std::string& path) { siloPath = path; }
60
61 /// \brief Returns an array of nodal data by the given name.
62 ///
63 /// The name must be one of the names returned by getVarNames().
64 ESCRIPTEXPORT_DLL_API
65 const IntVec& getVarDataByName(const std::string& name) const;
66
67 /// \brief Returns a vector with the mesh variable names.
68 ESCRIPTEXPORT_DLL_API
69 StringVec getVarNames() const;
70
71 /// \brief Returns the name of this node mesh.
72 ESCRIPTEXPORT_DLL_API
73 std::string getName() const { return name; }
74
75 /// \brief Returns full Silo mesh name, e.g. "/block0000/Nodes".
76 ESCRIPTEXPORT_DLL_API
77 std::string getFullSiloName() const;
78
79 /// \brief Returns the node ID array.
80 ESCRIPTEXPORT_DLL_API
81 const IntVec& getNodeIDs() const { return nodeID; }
82
83 /// \brief Returns a node ID to index mapping for this mesh.
84 ESCRIPTEXPORT_DLL_API
85 IndexMap getIndexMap() const;
86
87 /// \brief Returns the coordinates of the mesh nodes.
88 ESCRIPTEXPORT_DLL_API
89 const CoordArray& getCoords() const { return coords; }
90
91 /// \brief Returns the dimensionality of this mesh (2 or 3).
92 ESCRIPTEXPORT_DLL_API
93 int getNumDims() const { return numDims; }
94
95 /// \brief Returns the number of mesh nodes.
96 ESCRIPTEXPORT_DLL_API
97 int getNumNodes() const { return numNodes; }
98
99 protected:
100 CoordArray coords; /// x, y[, z] coordinates of nodes
101 int numDims; /// dimensionality (2 or 3)
102 int numNodes; /// number of nodes
103 IntVec nodeID; /// node IDs
104 IntVec nodeTag, nodeGDOF, nodeGNI, nodeGRDFI, nodeGRNI;
105 IntVec nodeDist; /// node distribution
106 std::string name; /// the name of this node mesh
107 std::string siloPath; /// the path to this mesh within the SILO file
108 };
109
110
111 inline IndexMap NodeData::getIndexMap() const
112 {
113 IndexMap nodeID2idx;
114 int idx = 0;
115 IntVec::const_iterator idIt;
116 for (idIt = nodeID.begin(); idIt != nodeID.end(); idIt++, idx++)
117 nodeID2idx[*idIt] = idx;
118 return nodeID2idx;
119 }
120
121 inline std::string NodeData::getFullSiloName() const
122 {
123 std::string result(siloPath);
124 if (result.length() == 0 || *result.rbegin() != '/')
125 result += '/';
126 result += name;
127 return result;
128 }
129
130 } // namespace escriptexport
131
132 #endif // __NODEDATA_H__
133

  ViewVC Help
Powered by ViewVC 1.1.26