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