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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2886 - (show annotations)
Thu Jan 28 05:39:23 2010 UTC (9 years, 6 months ago) by caltinay
File MIME type: text/plain
File size: 4074 byte(s)
New version of saveVTK within dataexporter. Not pythonised yet since it needs
more testing and release 3.1 will not ship dataexporter.

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

  ViewVC Help
Powered by ViewVC 1.1.26