escript  Revision_4925
FinleyNodes.h
Go to the documentation of this file.
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 
32 typedef boost::shared_ptr<FinleyNodes> FinleyNodes_ptr;
33 
39 class FinleyNodes : public NodeData
40 {
41 public:
43  FinleyNodes(const std::string& meshName);
44 
45  FinleyNodes(FinleyNodes_ptr fullNodes, IntVec& requiredNodes,
46  const std::string& meshName);
47 
49  FinleyNodes(const FinleyNodes& m);
50 
52  virtual ~FinleyNodes();
53 
55  bool initFromDudley(const Dudley_NodeFile* dudleyFile);
56 
58  bool initFromFinley(const finley::NodeFile* finleyFile);
59 
61  bool readFromNc(NcFile* ncFile);
62 
64  bool writeToSilo(DBfile* dbfile);
65 
67  virtual void writeCoordinatesVTK(std::ostream& os, int ownIndex);
68 
70  void setSiloPath(const std::string& path) { siloPath = path; }
71 
75  const IntVec& getVarDataByName(const std::string& name) const;
76 
78  virtual StringVec getVarNames() const;
79 
81  virtual std::string getName() const { return name; }
82 
84  std::string getFullSiloName() const;
85 
87  virtual const IntVec& getNodeIDs() const { return nodeID; }
88 
90  virtual const IntVec& getNodeDistribution() const { return nodeDist; }
91 
93  virtual const IntVec& getGlobalNodeIndices() const { return nodeGNI; }
94 
96  virtual const CoordArray& getCoords() const { return coords; }
97 
99  virtual int getNumDims() const { return numDims; }
100 
102  virtual int getNumNodes() const { return numNodes; }
103 
105  virtual int getGlobalNumNodes() const;
106 
107 protected:
109  int numDims;
110  int numNodes;
114  std::string name;
115  std::string siloPath;
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 
virtual const IntVec & getGlobalNodeIndices() const
Returns the global node index array.
Definition: FinleyNodes.h:93
std::vector< float * > CoordArray
Definition: weipa.h:57
boost::shared_ptr< FinleyNodes > FinleyNodes_ptr
Definition: FinleyNodes.h:31
IntVec nodeGRNI
Definition: FinleyNodes.h:112
Stores and manipulates finley mesh nodes.
Definition: FinleyNodes.h:39
IntVec nodeGNI
Definition: FinleyNodes.h:112
std::vector< std::string > StringVec
Definition: weipa.h:56
bool readFromNc(NcFile *ncFile)
Reads node data from a NetCDF file.
Definition: FinleyNodes.cpp:262
const IntVec & getVarDataByName(const std::string &name) const
Returns an array of nodal data by the given name.
Definition: FinleyNodes.cpp:338
virtual void writeCoordinatesVTK(std::ostream &os, int ownIndex)
Writes coordinates to a stream in VTK text format.
Definition: FinleyNodes.cpp:385
IntVec nodeID
number of nodes
Definition: FinleyNodes.h:111
bool writeToSilo(DBfile *dbfile)
Writes node data to a Silo file.
Definition: FinleyNodes.cpp:406
int numDims
x, y[, z] coordinates of nodes
Definition: FinleyNodes.h:109
IntVec nodeTag
node IDs
Definition: FinleyNodes.h:112
Definition: NodeData.h:26
virtual const IntVec & getNodeIDs() const
Returns the node ID array.
Definition: FinleyNodes.h:87
std::vector< int > IntVec
Definition: weipa.h:55
std::string siloPath
the name of this node mesh
Definition: FinleyNodes.h:115
virtual int getNumNodes() const
Returns the number of mesh nodes.
Definition: FinleyNodes.h:102
virtual StringVec getVarNames() const
Returns a vector with the mesh variable names.
Definition: FinleyNodes.cpp:359
bool initFromFinley(const finley::NodeFile *finleyFile)
Initialises with finley node file.
Definition: FinleyNodes.cpp:195
IntVec nodeGDOF
Definition: FinleyNodes.h:112
Definition: finley/src/NodeFile.h:31
IntVec nodeGRDFI
Definition: FinleyNodes.h:112
virtual const IntVec & getNodeDistribution() const
Returns the node distribution array.
Definition: FinleyNodes.h:90
virtual int getNumDims() const
Returns the dimensionality of this mesh (2 or 3).
Definition: FinleyNodes.h:99
bool initFromDudley(const Dudley_NodeFile *dudleyFile)
Initialises with dudley node file.
Definition: FinleyNodes.cpp:128
CoordArray coords
Definition: FinleyNodes.h:108
FinleyNodes(const std::string &meshName)
Constructor with mesh name.
Definition: FinleyNodes.cpp:41
Definition: dudley/src/NodeFile.h:28
int numNodes
dimensionality (2 or 3)
Definition: FinleyNodes.h:110
std::string name
node distribution
Definition: FinleyNodes.h:114
virtual ~FinleyNodes()
Virtual destructor.
Definition: FinleyNodes.cpp:118
std::string getFullSiloName() const
Returns full Silo mesh name, e.g. "/block0000/Nodes".
Definition: FinleyNodes.h:119
void setSiloPath(const std::string &path)
Sets the silo path to be used when saving.
Definition: FinleyNodes.h:70
virtual std::string getName() const
Returns the name of this node mesh.
Definition: FinleyNodes.h:81
virtual const CoordArray & getCoords() const
Returns the coordinates of the mesh nodes.
Definition: FinleyNodes.h:96
IntVec nodeDist
Definition: FinleyNodes.h:113
virtual int getGlobalNumNodes() const
Returns the total number of mesh nodes for a distributed mesh.
Definition: FinleyNodes.cpp:374