escript  Revision_
FinleyNodes.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2018 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
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 
24 #ifdef NETCDF4
25 #include <ncFile.h>
26 #define NCFTYPE netCDF::NcFile&
27 
28 #else
29 class NcFile;
30 #define NCFTYPE NcFile*
31 #endif
32 
33 namespace finley {
34  class NodeFile;
35 }
36 namespace dudley {
37  class NodeFile;
38 }
39 
40 namespace weipa {
41 
43 typedef boost::shared_ptr<FinleyNodes> FinleyNodes_ptr;
44 
50 class FinleyNodes : public NodeData
51 {
52 public:
54  FinleyNodes(const std::string& meshName);
55 
56  FinleyNodes(FinleyNodes_ptr fullNodes, IntVec& requiredNodes,
57  const std::string& meshName);
58 
60  FinleyNodes(const FinleyNodes& m);
61 
63  virtual ~FinleyNodes();
64 
66  bool initFromDudley(const dudley::NodeFile* dudleyFile);
67 
69  bool initFromFinley(const finley::NodeFile* finleyFile);
70 
72  bool readFromNc(NCFTYPE ncFile);
73 
75  bool writeToSilo(DBfile* dbfile);
76 
78  virtual void writeCoordinatesVTK(std::ostream& os, int ownIndex);
79 
81  void setSiloPath(const std::string& path) { siloPath = path; }
82 
86  const IntVec& getVarDataByName(const std::string& name) const;
87 
89  virtual StringVec getVarNames() const;
90 
92  virtual std::string getName() const { return name; }
93 
95  std::string getFullSiloName() const;
96 
98  virtual const IntVec& getNodeIDs() const { return nodeID; }
99 
101  virtual const IntVec& getNodeDistribution() const { return nodeDist; }
102 
104  virtual const IntVec& getGlobalNodeIndices() const { return nodeGNI; }
105 
107  virtual const CoordArray& getCoords() const { return coords; }
108 
110  virtual int getNumDims() const { return numDims; }
111 
113  virtual int getNumNodes() const { return numNodes; }
114 
116  virtual int getGlobalNumNodes() const;
117 
118 protected:
120  int numDims;
121  int numNodes;
123  IntVec nodeTag, nodeGDOF, nodeGNI, nodeGRDFI, nodeGRNI;
125  std::string name;
126  std::string siloPath;
127 };
128 
129 
130 inline std::string FinleyNodes::getFullSiloName() const
131 {
132  std::string result(siloPath);
133  if (result.length() == 0 || *result.rbegin() != '/')
134  result += '/';
135  result += name;
136  return result;
137 }
138 
139 } // namespace weipa
140 
141 #undef NCFTYPE
142 #endif // __WEIPA_FINLEYNODES_H__
143 
std::vector< float * > CoordArray
Definition: weipa.h:61
boost::shared_ptr< FinleyNodes > FinleyNodes_ptr
Definition: FinleyNodes.h:42
Stores and manipulates finley mesh nodes.
Definition: FinleyNodes.h:50
virtual std::string getName() const
Returns the name of this node mesh.
Definition: FinleyNodes.h:92
std::vector< std::string > StringVec
Definition: weipa.h:60
IntVec nodeID
number of nodes
Definition: FinleyNodes.h:122
A suite of factory methods for creating various finley domains.
Definition: finley/src/Assemble.h:31
int numDims
x, y[, z] coordinates of nodes
Definition: FinleyNodes.h:120
IntVec nodeTag
node IDs
Definition: FinleyNodes.h:123
Definition: NodeData.h:26
Definition: DataVar.cpp:50
virtual const IntVec & getNodeIDs() const
Returns the node ID array.
Definition: FinleyNodes.h:98
std::vector< int > IntVec
Definition: weipa.h:59
std::string siloPath
the name of this node mesh
Definition: FinleyNodes.h:126
Definition: finley/src/NodeFile.h:40
A suite of factory methods for creating 2D and 3D dudley domains.
Definition: dudley/src/Assemble.h:31
virtual int getNumDims() const
Returns the dimensionality of this mesh (2 or 3).
Definition: FinleyNodes.h:110
#define NCFTYPE
Definition: FinleyNodes.h:30
virtual const CoordArray & getCoords() const
Returns the coordinates of the mesh nodes.
Definition: FinleyNodes.h:107
virtual const IntVec & getGlobalNodeIndices() const
Returns the global node index array.
Definition: FinleyNodes.h:104
CoordArray coords
Definition: FinleyNodes.h:119
virtual int getNumNodes() const
Returns the number of mesh nodes.
Definition: FinleyNodes.h:113
int numNodes
dimensionality (2 or 3)
Definition: FinleyNodes.h:121
std::string name
node distribution
Definition: FinleyNodes.h:125
void setSiloPath(const std::string &path)
Sets the silo path to be used when saving.
Definition: FinleyNodes.h:81
Definition: dudley/src/NodeFile.h:38
virtual const IntVec & getNodeDistribution() const
Returns the node distribution array.
Definition: FinleyNodes.h:101
IntVec nodeDist
Definition: FinleyNodes.h:124