escript  Revision_
FinleyNodes.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2020 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-2017 by Centre for Geoscience Computing (GeoComp)
14 * Development from 2019 by School of Earth and Environmental Sciences
15 **
16 *****************************************************************************/
17 
18 #ifndef __WEIPA_FINLEYNODES_H__
19 #define __WEIPA_FINLEYNODES_H__
20 
21 #include <weipa/NodeData.h>
22 
23 class DBfile;
24 
25 #ifdef NETCDF4
26 #include <ncFile.h>
27 #define NCFTYPE netCDF::NcFile&
28 
29 #else
30 class NcFile;
31 #define NCFTYPE NcFile*
32 #endif
33 
34 namespace finley {
35  class NodeFile;
36 }
37 namespace dudley {
38  class NodeFile;
39 }
40 
41 namespace weipa {
42 
43 class FinleyNodes;
44 typedef boost::shared_ptr<FinleyNodes> FinleyNodes_ptr;
45 
51 class FinleyNodes : public NodeData
52 {
53 public:
55  FinleyNodes(const std::string& meshName);
56 
57  FinleyNodes(FinleyNodes_ptr fullNodes, IntVec& requiredNodes,
58  const std::string& meshName);
59 
61  FinleyNodes(const FinleyNodes& m);
62 
64  virtual ~FinleyNodes();
65 
67  bool initFromDudley(const dudley::NodeFile* dudleyFile);
68 
70  bool initFromFinley(const finley::NodeFile* finleyFile);
71 
73  bool readFromNc(NCFTYPE ncFile);
74 
76  bool writeToSilo(DBfile* dbfile);
77 
79  virtual void writeCoordinatesVTK(std::ostream& os, int ownIndex);
80 
82  void setSiloPath(const std::string& path) { siloPath = path; }
83 
87  const IntVec& getVarDataByName(const std::string& name) const;
88 
90  virtual StringVec getVarNames() const;
91 
93  virtual std::string getName() const { return name; }
94 
96  std::string getFullSiloName() const;
97 
99  virtual const IntVec& getNodeIDs() const { return nodeID; }
100 
102  virtual const IntVec& getNodeDistribution() const { return nodeDist; }
103 
105  virtual const IntVec& getGlobalNodeIndices() const { return nodeGNI; }
106 
108  virtual const CoordArray& getCoords() const { return coords; }
109 
111  virtual int getNumDims() const { return numDims; }
112 
114  virtual int getNumNodes() const { return numNodes; }
115 
117  virtual int getGlobalNumNodes() const;
118 
119 protected:
121  int numDims;
122  int numNodes;
126  std::string name;
127  std::string siloPath;
128 };
129 
130 
131 inline std::string FinleyNodes::getFullSiloName() const
132 {
133  std::string result(siloPath);
134  if (result.length() == 0 || *result.rbegin() != '/')
135  result += '/';
136  result += name;
137  return result;
138 }
139 
140 } // namespace weipa
141 
142 #undef NCFTYPE
143 #endif // __WEIPA_FINLEYNODES_H__
144 
#define NCFTYPE
Definition: FinleyNodes.h:31
Definition: dudley/src/NodeFile.h:40
Definition: finley/src/NodeFile.h:42
Stores and manipulates finley mesh nodes.
Definition: FinleyNodes.h:52
bool initFromDudley(const dudley::NodeFile *dudleyFile)
Initialises with dudley node file.
Definition: FinleyNodes.cpp:142
std::string siloPath
the name of this node mesh
Definition: FinleyNodes.h:127
virtual void writeCoordinatesVTK(std::ostream &os, int ownIndex)
Writes coordinates to a stream in VTK text format.
Definition: FinleyNodes.cpp:444
IntVec nodeGRDFI
Definition: FinleyNodes.h:124
IntVec nodeGNI
Definition: FinleyNodes.h:124
virtual const IntVec & getNodeIDs() const
Returns the node ID array.
Definition: FinleyNodes.h:99
virtual const IntVec & getNodeDistribution() const
Returns the node distribution array.
Definition: FinleyNodes.h:102
int numDims
x, y[, z] coordinates of nodes
Definition: FinleyNodes.h:121
virtual const CoordArray & getCoords() const
Returns the coordinates of the mesh nodes.
Definition: FinleyNodes.h:108
virtual int getGlobalNumNodes() const
Returns the total number of mesh nodes for a distributed mesh.
Definition: FinleyNodes.cpp:433
virtual int getNumNodes() const
Returns the number of mesh nodes.
Definition: FinleyNodes.h:114
virtual StringVec getVarNames() const
Returns a vector with the mesh variable names.
Definition: FinleyNodes.cpp:418
IntVec nodeTag
node IDs
Definition: FinleyNodes.h:124
std::string getFullSiloName() const
Returns full Silo mesh name, e.g. "/block0000/Nodes".
Definition: FinleyNodes.h:131
virtual int getNumDims() const
Returns the dimensionality of this mesh (2 or 3).
Definition: FinleyNodes.h:111
IntVec nodeDist
Definition: FinleyNodes.h:125
std::string name
node distribution
Definition: FinleyNodes.h:126
bool initFromFinley(const finley::NodeFile *finleyFile)
Initialises with finley node file.
Definition: FinleyNodes.cpp:189
virtual ~FinleyNodes()
Virtual destructor.
Definition: FinleyNodes.cpp:132
virtual std::string getName() const
Returns the name of this node mesh.
Definition: FinleyNodes.h:93
IntVec nodeID
number of nodes
Definition: FinleyNodes.h:123
IntVec nodeGRNI
Definition: FinleyNodes.h:124
FinleyNodes(const std::string &meshName)
Constructor with mesh name.
Definition: FinleyNodes.cpp:55
virtual const IntVec & getGlobalNodeIndices() const
Returns the global node index array.
Definition: FinleyNodes.h:105
CoordArray coords
Definition: FinleyNodes.h:120
int numNodes
dimensionality (2 or 3)
Definition: FinleyNodes.h:122
IntVec nodeGDOF
Definition: FinleyNodes.h:124
void setSiloPath(const std::string &path)
Sets the silo path to be used when saving.
Definition: FinleyNodes.h:82
bool writeToSilo(DBfile *dbfile)
Writes node data to a Silo file.
Definition: FinleyNodes.cpp:465
bool readFromNc(NcFile *ncFile)
Reads node data from a NetCDF file.
Definition: FinleyNodes.cpp:320
const IntVec & getVarDataByName(const std::string &name) const
Returns an array of nodal data by the given name.
Definition: FinleyNodes.cpp:397
Definition: NodeData.h:28
A suite of factory methods for creating 2D and 3D dudley domains.
Definition: dudley/src/Assemble.h:32
A suite of factory methods for creating various finley domains.
Definition: finley/src/Assemble.h:32
Definition: DataVar.cpp:51
std::vector< std::string > StringVec
Definition: weipa.h:61
std::vector< int > IntVec
Definition: weipa.h:60
std::vector< float * > CoordArray
Definition: weipa.h:62
boost::shared_ptr< FinleyNodes > FinleyNodes_ptr
Definition: FinleyNodes.h:43