escript Revision_
FinleyElements.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_FINLEYELEMENTS_H__
19#define __WEIPA_FINLEYELEMENTS_H__
20
21#include <weipa/ElementData.h>
22#include <weipa/FinleyNodes.h>
23
24#ifdef USE_DUDLEY
25#include <dudley/Dudley.h> // for DUDLEY_...
26#include <dudley/ElementType.h> // for dudley::ElementTypeId
27#endif
28#ifdef USE_FINLEY
29#include <finley/ReferenceElements.h> // for finley::ElementTypeId
30#endif
31
32class DBfile;
33
34#ifdef NETCDF4
35#include <ncFile.h>
36#define NCFTYPE netCDF::NcFile&
37#else
38class NcFile;
39#define NCFTYPE NcFile*
40#endif
41
42namespace dudley {
43 class ElementFile;
44}
45
46namespace finley {
47 class ElementFile;
48}
49
50namespace weipa {
51
63
64class FinleyElements;
65typedef boost::shared_ptr<FinleyElements> FinleyElements_ptr;
66
77{
78public:
79
81 FinleyElements(const std::string& elementName, FinleyNodes_ptr nodes);
82
85
87 virtual ~FinleyElements() {}
88
90 bool initFromDudley(const dudley::ElementFile* dudleyFile);
91
93 bool initFromFinley(const finley::ElementFile* finleyFile);
94
96 bool readFromNc(NCFTYPE ncfile);
97
100 void reorderGhostZones(int ownIndex);
101
103 void removeGhostZones(int ownIndex);
104
106 virtual void writeConnectivityVTK(std::ostream& os);
107
113 bool writeToSilo(DBfile* dbfile, const std::string& siloPath,
114 const StringVec& labels, const StringVec& units,
115 bool writeMeshData);
116
118 virtual StringVec getMeshNames() const;
119
121 virtual StringVec getVarNames() const;
122
124 virtual int getNumElements() const { return numElements; }
125
127 virtual int getNodesPerElement() const { return nodesPerElement; }
128
130 virtual int getGhostCount() const { return numGhostElements; }
131
133 virtual ZoneType getType() const { return type; }
134
135#ifdef USE_FINLEY
137 finley::ElementTypeId getFinleyTypeId() const { return finleyTypeId; }
138#endif
139
141 virtual const IntVec& getNodeList() const { return nodes; }
142
144 virtual const IntVec& getIDs() const { return ID; }
145
149 virtual const IntVec& getVarDataByName(const std::string varName) const;
150
152 virtual NodeData_ptr getNodes() const { return nodeMesh; }
153
156
158 virtual const QuadMaskInfo& getQuadMask(int functionSpace) const;
159
163 virtual int getElementFactor() const { return elementFactor; }
164
165private:
167#ifdef USE_DUDLEY
168 FinleyElementInfo getDudleyTypeInfo(dudley::ElementTypeId typeId);
169#endif
170#ifdef USE_FINLEY
171 FinleyElementInfo getFinleyTypeInfo(finley::ElementTypeId typeId);
172 finley::ElementTypeId finleyTypeId;
173#endif
174 void buildMeshes();
176 IntVec prepareGhostIndices(int ownIndex);
177 void reorderArray(IntVec& v, const IntVec& idx, int elementsPerIndex);
178 QuadMaskInfo buildQuadMask(const CoordArray& quadNodes, int numQNodes);
179
183 std::string name;
193};
194
195} // namespace weipa
196
197#undef NCFTYPE
198#endif // __WEIPA_FINLEYELEMENTS_H__
199
#define NCFTYPE
Definition FinleyElements.h:39
Definition dudley/src/ElementFile.h:53
Definition finley/src/ElementFile.h:63
Stores and manipulates one type of domain elements.
Definition ElementData.h:50
Stores and manipulates one type of finley mesh elements (cells, faces or contacts).
Definition FinleyElements.h:77
bool readFromNc(NcFile *ncfile)
Reads element data from escript/finley NetCDF file.
Definition FinleyElements.cpp:383
virtual void writeConnectivityVTK(std::ostream &os)
Writes connectivity data to a stream in VTK text format.
Definition FinleyElements.cpp:734
int nodesPerElement
Definition FinleyElements.h:186
int elementFactor
Definition FinleyElements.h:192
bool initFromDudley(const dudley::ElementFile *dudleyFile)
Initialises with data from a Dudley ElementFile instance.
Definition FinleyElements.cpp:169
virtual int getGhostCount() const
Returns the number of "ghost" elements.
Definition FinleyElements.h:130
IntVec color
Definition FinleyElements.h:189
IntVec tag
Definition FinleyElements.h:189
virtual StringVec getMeshNames() const
Returns the names of the meshes associated with the elements.
Definition FinleyElements.cpp:487
virtual int getElementFactor() const
If the original element type is not supported they are subdivided into N smaller elements (e....
Definition FinleyElements.h:163
virtual int getNumElements() const
Returns the number of elements.
Definition FinleyElements.h:124
virtual NodeData_ptr getNodes() const
Returns the node mesh instance used by the elements.
Definition FinleyElements.h:152
void reorderGhostZones(int ownIndex)
Moves "ghost" elements (whose owner does not match ownIndex) and the corresponding data to the end of...
Definition FinleyElements.cpp:670
void reorderArray(IntVec &v, const IntVec &idx, int elementsPerIndex)
Definition FinleyElements.cpp:549
int numGhostElements
Definition FinleyElements.h:185
IntVec nodes
Definition FinleyElements.h:188
void buildMeshes()
Definition FinleyElements.cpp:711
QuadMaskInfo quadMask
Definition FinleyElements.h:191
FinleyElements()
Definition FinleyElements.h:166
FinleyElements_ptr reducedElements
Definition FinleyElements.h:180
IntVec prepareGhostIndices(int ownIndex)
Definition FinleyElements.cpp:646
virtual int getNodesPerElement() const
Returns the number of nodes per element.
Definition FinleyElements.h:127
virtual StringVec getVarNames() const
Returns a vector with the mesh variable names.
Definition FinleyElements.cpp:503
IntVec ID
Definition FinleyElements.h:189
std::string name
Definition FinleyElements.h:183
bool initFromFinley(const finley::ElementFile *finleyFile)
Initialises with data from a Finley ElementFile instance.
Definition FinleyElements.cpp:202
virtual const IntVec & getIDs() const
Returns a vector of element IDs.
Definition FinleyElements.h:144
void buildReducedElements(const FinleyElementInfo &f)
Definition FinleyElements.cpp:573
IntVec owner
Definition FinleyElements.h:190
QuadMaskInfo buildQuadMask(const CoordArray &quadNodes, int numQNodes)
Definition FinleyElements.cpp:1198
FinleyNodes_ptr nodeMesh
Definition FinleyElements.h:181
virtual ElementData_ptr getReducedElements() const
Returns the reduced elements.
Definition FinleyElements.h:155
ZoneType type
Definition FinleyElements.h:187
FinleyNodes_ptr originalMesh
Definition FinleyElements.h:182
virtual const IntVec & getVarDataByName(const std::string varName) const
Returns an array of data values for the name provided.
Definition FinleyElements.cpp:516
void removeGhostZones(int ownIndex)
Removes "ghost" elements.
Definition FinleyElements.cpp:690
QuadMaskInfo reducedQuadMask
Definition FinleyElements.h:191
virtual ~FinleyElements()
Destructor.
Definition FinleyElements.h:87
virtual ZoneType getType() const
Returns the type of the elements.
Definition FinleyElements.h:133
virtual const IntVec & getNodeList() const
Returns a vector of the node IDs used by the elements.
Definition FinleyElements.h:141
int numElements
Definition FinleyElements.h:184
bool writeToSilo(DBfile *dbfile, const std::string &siloPath, const StringVec &labels, const StringVec &units, bool writeMeshData)
Writes element data into given directory in given Silo file.
Definition FinleyElements.cpp:771
virtual const QuadMaskInfo & getQuadMask(int functionSpace) const
Returns a QuadMaskInfo structure for given functionspace code.
Definition FinleyElements.cpp:535
A suite of factory methods for creating 2D and 3D dudley domains.
Definition dudley/src/Assemble.h:32
ElementTypeId
Definition ElementType.h:25
A suite of factory methods for creating various finley domains.
Definition finley/src/Assemble.h:32
ElementTypeId
Definition ReferenceElements.h:41
Definition DataVar.cpp:51
std::vector< std::string > StringVec
Definition weipa.h:61
boost::shared_ptr< ElementData > ElementData_ptr
Definition weipa.h:67
std::vector< int > IntVec
Definition weipa.h:60
boost::shared_ptr< NodeData > NodeData_ptr
Definition weipa.h:69
std::vector< float * > CoordArray
Definition weipa.h:62
ZoneType
Definition ElementData.h:27
boost::shared_ptr< FinleyElements > FinleyElements_ptr
Definition FinleyElements.h:65
boost::shared_ptr< FinleyNodes > FinleyNodes_ptr
Definition FinleyNodes.h:44
Holds information that is used to convert from finley element types to elements supported by Silo and...
Definition FinleyElements.h:55
ZoneType reducedElementType
Definition FinleyElements.h:56
int elementSize
Definition FinleyElements.h:58
int quadDim
Definition FinleyElements.h:61
const size_t * multiCellIndices
Definition FinleyElements.h:59
bool useQuadNodes
Definition FinleyElements.h:60
int elementFactor
Definition FinleyElements.h:57
int reducedElementSize
Definition FinleyElements.h:58
ZoneType elementType
Definition FinleyElements.h:56
This struct holds a mask (0's and 1's) that indicates which quad nodes contribute to a sub-element wh...
Definition ElementData.h:40