/[escript]/branches/split/weipa/src/FinleyNodes.h
ViewVC logotype

Contents of /branches/split/weipa/src/FinleyNodes.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4724 - (show annotations)
Thu Mar 6 05:22:12 2014 UTC (5 years, 1 month ago) by jfenwick
File MIME type: text/plain
File size: 4258 byte(s)
Work towards parallel domains

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

  ViewVC Help
Powered by ViewVC 1.1.26