escript  Revision_
FinleyElements.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_FINLEYELEMENTS_H__
18 #define __WEIPA_FINLEYELEMENTS_H__
19 
20 #include <weipa/ElementData.h>
21 #include <weipa/FinleyNodes.h>
22 
23 #ifdef USE_DUDLEY
24 #include <dudley/Dudley.h> // for DUDLEY_...
25 #include <dudley/ElementType.h> // for dudley::ElementTypeId
26 #endif
27 #ifdef USE_FINLEY
28 #include <finley/ReferenceElements.h> // for finley::ElementTypeId
29 #endif
30 
31 class DBfile;
32 
33 #ifdef NETCDF4
34 #include <ncFile.h>
35 #define NCFTYPE netCDF::NcFile&
36 #else
37 class NcFile;
38 #define NCFTYPE NcFile*
39 #endif
40 
41 namespace dudley {
42  class ElementFile;
43 }
44 
45 namespace finley {
46  class ElementFile;
47 }
48 
49 namespace weipa {
50 
53 struct FinleyElementInfo
54 {
58  const size_t* multiCellIndices;
60  int quadDim;
61 };
62 
63 class FinleyElements;
64 typedef boost::shared_ptr<FinleyElements> FinleyElements_ptr;
65 
75 class FinleyElements : public ElementData
76 {
77 public:
78 
80  FinleyElements(const std::string& elementName, FinleyNodes_ptr nodes);
81 
84 
86  virtual ~FinleyElements() {}
87 
89  bool initFromDudley(const dudley::ElementFile* dudleyFile);
90 
92  bool initFromFinley(const finley::ElementFile* finleyFile);
93 
95  bool readFromNc(NCFTYPE ncfile);
96 
99  void reorderGhostZones(int ownIndex);
100 
102  void removeGhostZones(int ownIndex);
103 
105  virtual void writeConnectivityVTK(std::ostream& os);
106 
112  bool writeToSilo(DBfile* dbfile, const std::string& siloPath,
113  const StringVec& labels, const StringVec& units,
114  bool writeMeshData);
115 
117  virtual StringVec getMeshNames() const;
118 
120  virtual StringVec getVarNames() const;
121 
123  virtual int getNumElements() const { return numElements; }
124 
126  virtual int getNodesPerElement() const { return nodesPerElement; }
127 
129  virtual int getGhostCount() const { return numGhostElements; }
130 
132  virtual ZoneType getType() const { return type; }
133 
134 #ifdef USE_FINLEY
135  finley::ElementTypeId getFinleyTypeId() const { return finleyTypeId; }
137 #endif
138 
140  virtual const IntVec& getNodeList() const { return nodes; }
141 
143  virtual const IntVec& getIDs() const { return ID; }
144 
148  virtual const IntVec& getVarDataByName(const std::string varName) const;
149 
151  virtual NodeData_ptr getNodes() const { return nodeMesh; }
152 
154  virtual ElementData_ptr getReducedElements() const { return reducedElements; }
155 
157  virtual const QuadMaskInfo& getQuadMask(int functionSpace) const;
158 
162  virtual int getElementFactor() const { return elementFactor; }
163 
164 private:
165  FinleyElements() {}
166 #ifdef USE_DUDLEY
167  FinleyElementInfo getDudleyTypeInfo(dudley::ElementTypeId typeId);
168 #endif
169 #ifdef USE_FINLEY
170  FinleyElementInfo getFinleyTypeInfo(finley::ElementTypeId typeId);
171  finley::ElementTypeId finleyTypeId;
172 #endif
173  void buildMeshes();
175  IntVec prepareGhostIndices(int ownIndex);
176  void reorderArray(IntVec& v, const IntVec& idx, int elementsPerIndex);
177  QuadMaskInfo buildQuadMask(const CoordArray& quadNodes, int numQNodes);
178 
182  std::string name;
191  int elementFactor;
192 };
193 
194 } // namespace weipa
195 
196 #undef NCFTYPE
197 #endif // __WEIPA_FINLEYELEMENTS_H__
198 
weipa::FinleyElements::reducedQuadMask
QuadMaskInfo reducedQuadMask
Definition: FinleyElements.h:189
dudley::ElementFile::Tag
int * Tag
Tag[i] is the tag of element i.
Definition: dudley/src/ElementFile.h:131
finley::Rec4_Contact
Definition: ReferenceElements.h:84
finley::Line3
Definition: ReferenceElements.h:39
weipa::inside3D
bool inside3D(float x, float y, float z, float cx, float cy, float cz, float r)
Definition: FinleyElements.cpp:1102
dudley::Dudley_Point1
Definition: ElementType.h:48
finley::Rec9
Definition: ReferenceElements.h:47
FINLEY_REDUCED_FACE_ELEMENTS
#define FINLEY_REDUCED_FACE_ELEMENTS
Definition: Finley.h:69
finley::Rec8Face_Contact
Definition: ReferenceElements.h:97
weipa::FinleyElements::getNodeList
virtual const IntVec & getNodeList() const
Returns a vector of the node IDs used by the elements.
Definition: FinleyElements.h:139
weipa::FinleyElements::buildQuadMask
QuadMaskInfo buildQuadMask(const CoordArray &quadNodes, int numQNodes)
Definition: FinleyElements.cpp:1196
finley::Hex20Face_Contact
Definition: ReferenceElements.h:105
weipa::FinleyElements::buildMeshes
void buildMeshes()
Definition: FinleyElements.cpp:709
weipa::FinleyElements::getVarDataByName
virtual const IntVec & getVarDataByName(const std::string varName) const
Returns an array of data values for the name provided.
Definition: FinleyElements.cpp:514
weipa::FinleyElementInfo::elementType
ZoneType elementType
Definition: FinleyElements.h:54
FINLEY_REDUCED_ELEMENTS
#define FINLEY_REDUCED_ELEMENTS
Definition: Finley.h:68
FINLEY_REDUCED_CONTACT_ELEMENTS_1
#define FINLEY_REDUCED_CONTACT_ELEMENTS_1
Definition: Finley.h:70
weipa::FinleyElements::tag
IntVec tag
Definition: FinleyElements.h:187
weipa::FinleyElementInfo
Holds information that is used to convert from finley element types to elements supported by Silo and...
Definition: FinleyElements.h:52
weipa::FinleyElements::numGhostElements
int numGhostElements
Definition: FinleyElements.h:183
finley::const_ReferenceElementSet_ptr
boost::shared_ptr< const ReferenceElementSet > const_ReferenceElementSet_ptr
Definition: ReferenceElementSets.h:90
weipa::FinleyElements::writeToSilo
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:769
dudley::Dudley_Tet4Face
Definition: ElementType.h:54
finley::Tet4Face_Contact
Definition: ReferenceElements.h:101
finley::Line3_Contact
Definition: ReferenceElements.h:78
weipa::ZONETYPE_HEX
Definition: ElementData.h:52
weipa::QuadMaskInfo::mask
std::vector< IntVec > mask
Definition: ElementData.h:51
weipa::FinleyElements::~FinleyElements
virtual ~FinleyElements()
Destructor.
Definition: FinleyElements.h:85
weipa::sameSide
bool sameSide(float d1, float d2)
Definition: FinleyElements.cpp:1110
weipa::FinleyElements::prepareGhostIndices
IntVec prepareGhostIndices(int ownIndex)
Definition: FinleyElements.cpp:644
weipa::FinleyElements::getGhostCount
virtual int getGhostCount() const
Returns the number of "ghost" elements.
Definition: FinleyElements.h:128
weipa::FinleyElementInfo::elementSize
int elementSize
Definition: FinleyElements.h:56
hex20indices
static const size_t hex20indices[36 *3]
Definition: FinleyElements.cpp:91
finley::Tet10
Definition: ReferenceElements.h:51
finley::ElementFile::Tag
int * Tag
Tag[i] is the tag of element i.
Definition: finley/src/ElementFile.h:139
dudley::ElementFile::Nodes
index_t * Nodes
Nodes[INDEX(k, i, numNodes)] is the k-th node in the i-th element.
Definition: dudley/src/ElementFile.h:143
weipa::FinleyElements::getNumElements
virtual int getNumElements() const
Returns the number of elements.
Definition: FinleyElements.h:122
finley::Tet10Macro
Definition: ReferenceElements.h:111
weipa::FinleyElements::initFromDudley
bool initFromDudley(const dudley::ElementFile *dudleyFile)
Initialises with data from a Dudley ElementFile instance.
Definition: FinleyElements.cpp:167
weipa::FinleyElements::getQuadMask
virtual const QuadMaskInfo & getQuadMask(int functionSpace) const
Returns a QuadMaskInfo structure for given functionspace code.
Definition: FinleyElements.cpp:533
weipa::FinleyElements::elementFactor
int elementFactor
Definition: FinleyElements.h:190
weipa::ZONETYPE_TRIANGLE
Definition: ElementData.h:56
weipa::FinleyElements::reorderGhostZones
void reorderGhostZones(int ownIndex)
Moves "ghost" elements (whose owner does not match ownIndex) and the corresponding data to the end of...
Definition: FinleyElements.cpp:668
weipa::QuadMaskInfo
This struct holds a mask (0's and 1's) that indicates which quad nodes contribute to a sub-element wh...
Definition: ElementData.h:50
finley::Tri6Face
Definition: ReferenceElements.h:61
finley::Tet4Face
Definition: ReferenceElements.h:69
finley::Line3Face
Definition: ReferenceElements.h:58
dudley::Dudley_Tri3Face
Definition: ElementType.h:53
weipa::FinleyElements::numElements
int numElements
Definition: FinleyElements.h:182
weipa::FinleyElements::ID
IntVec ID
Definition: FinleyElements.h:187
weipa::FinleyElementInfo::multiCellIndices
const size_t * multiCellIndices
Definition: FinleyElements.h:57
dudley::ElementFile::Owner
int * Owner
Owner[i] contains the rank that owns element i.
Definition: dudley/src/ElementFile.h:134
tri6indices
static const size_t tri6indices[4 *3]
Definition: FinleyElements.cpp:61
finley::Tet10Face
Definition: ReferenceElements.h:70
finley::Tri6Face_Contact
Definition: ReferenceElements.h:93
weipa::ZONETYPE_UNKNOWN
Definition: ElementData.h:50
finley::Rec8Face
Definition: ReferenceElements.h:65
weipa::FinleyElements::getVarNames
virtual StringVec getVarNames() const
Returns a vector with the mesh variable names.
Definition: FinleyElements.cpp:501
finley::ElementFile::Nodes
index_t * Nodes
Definition: finley/src/ElementFile.h:154
finley::Rec8_Contact
Definition: ReferenceElements.h:85
weipa::FinleyElements::nodesPerElement
int nodesPerElement
Definition: FinleyElements.h:184
weipa
Definition: DataVar.cpp:49
finley::Tri3
Definition: ReferenceElements.h:41
finley::Rec9Macro
Definition: ReferenceElements.h:110
finley::Hex27
Definition: ReferenceElements.h:55
finley::Line2Face
Definition: ReferenceElements.h:57
weipa::ZoneType
ZoneType
Definition: ElementData.h:37
finley::Rec9_Contact
Definition: ReferenceElements.h:86
weipa::FinleyElements::getMeshNames
virtual StringVec getMeshNames() const
Returns the names of the meshes associated with the elements.
Definition: FinleyElements.cpp:485
weipa::QuadMaskInfo::factor
IntVec factor
Definition: ElementData.h:52
finley::Point1_Contact
Definition: ReferenceElements.h:76
tet10indices
static const size_t tet10indices[8 *4]
Definition: FinleyElements.cpp:81
paso::util::copy
void copy(dim_t N, double *out, const double *in)
out = in
Definition: PasoUtil.h:110
rec9indices
static const size_t rec9indices[4 *4]
Definition: FinleyElements.cpp:75
weipa::FinleyElementInfo::useQuadNodes
bool useQuadNodes
Definition: FinleyElements.h:58
finley::ElementFile::numElements
dim_t numElements
number of elements
Definition: finley/src/ElementFile.h:132
dudley
A suite of factory methods for creating 2D and 3D dudley domains.
Definition: dudley/src/Assemble.h:31
hex27indices
static const size_t hex27indices[8 *8]
Definition: FinleyElements.cpp:105
weipa::det4x4
static float det4x4(float m_00, float m_01, float m_02, float m_03, float m_10, float m_11, float m_12, float m_13, float m_20, float m_21, float m_22, float m_23, float m_30, float m_31, float m_32, float m_33)
Definition: FinleyElements.cpp:1117
finley::ElementFile::Owner
int * Owner
Owner[i] contains the rank that owns element i.
Definition: finley/src/ElementFile.h:142
weipa::FinleyElements_ptr
boost::shared_ptr< FinleyElements > FinleyElements_ptr
Definition: FinleyElements.h:62
dudley::Dudley_Line2Face
Definition: ElementType.h:52
line3indices
static const size_t line3indices[2 *2]
Definition: FinleyElements.cpp:57
dudley::ElementFile::numElements
dim_t numElements
number of elements
Definition: dudley/src/ElementFile.h:123
weipa::FinleyElements::removeGhostZones
void removeGhostZones(int ownIndex)
Removes "ghost" elements.
Definition: FinleyElements.cpp:688
weipa::CoordArray
std::vector< float * > CoordArray
Definition: weipa.h:60
weipa::pointInTet
static bool pointInTet(float x, float y, float z, const float *p0, const float *p1, const float *p2, const float *p3)
Definition: FinleyElements.cpp:1136
dudley::ElementFile
Definition: dudley/src/ElementFile.h:62
finley::Tri6Macro
Definition: ReferenceElements.h:109
NCFTYPE
#define NCFTYPE
Definition: FinleyElements.h:37
finley::Hex27Macro
Definition: ReferenceElements.h:112
finley::Rec8
Definition: ReferenceElements.h:46
dudley::ElementFile::Id
index_t * Id
Definition: dudley/src/ElementFile.h:128
finley::NoRef
Definition: ReferenceElements.h:113
finley::Rec4Face
Definition: ReferenceElements.h:64
weipa::ElementData_ptr
boost::shared_ptr< ElementData > ElementData_ptr
Definition: weipa.h:65
weipa::ElementData
Stores and manipulates one type of domain elements.
Definition: ElementData.h:59
finley::ElementFile::Color
index_t * Color
Definition: finley/src/ElementFile.h:160
weipa::FinleyElements::initFromFinley
bool initFromFinley(const finley::ElementFile *finleyFile)
Initialises with data from a Finley ElementFile instance.
Definition: FinleyElements.cpp:200
weipa::FinleyElements::getReducedElements
virtual ElementData_ptr getReducedElements() const
Returns the reduced elements.
Definition: FinleyElements.h:153
weipa::FinleyElements::type
ZoneType type
Definition: FinleyElements.h:185
finley::Hex8Face_Contact
Definition: ReferenceElements.h:104
finley::Point1
Definition: ReferenceElements.h:37
weipa::FinleyElements::buildReducedElements
void buildReducedElements(const FinleyElementInfo &f)
Definition: FinleyElements.cpp:571
weipa::FinleyElements::getElementFactor
virtual int getElementFactor() const
If the original element type is not supported they are subdivided into N smaller elements (e....
Definition: FinleyElements.h:161
weipa::FinleyElementInfo::reducedElementType
ZoneType reducedElementType
Definition: FinleyElements.h:54
weipa::FinleyElements::nodeMesh
FinleyNodes_ptr nodeMesh
Definition: FinleyElements.h:179
finley::ElementFile::Id
index_t * Id
Definition: finley/src/ElementFile.h:136
finley::Hex20
Definition: ReferenceElements.h:54
weipa::FinleyElements::reducedElements
FinleyElements_ptr reducedElements
Definition: FinleyElements.h:178
finley::Line3Face_Contact
Definition: ReferenceElements.h:90
finley::Tri3Face
Definition: ReferenceElements.h:60
weipa::FinleyElements::getType
virtual ZoneType getType() const
Returns the type of the elements.
Definition: FinleyElements.h:131
weipa::FinleyElements::originalMesh
FinleyNodes_ptr originalMesh
Definition: FinleyElements.h:180
finley::Tri6_Contact
Definition: ReferenceElements.h:81
weipa::FinleyElements::nodes
IntVec nodes
Definition: FinleyElements.h:186
rec8indices
static const size_t rec8indices[6 *3]
Definition: FinleyElements.cpp:67
weipa::ZONETYPE_QUAD
Definition: ElementData.h:54
finley::Rec4Face_Contact
Definition: ReferenceElements.h:96
weipa::FinleyElementInfo::reducedElementSize
int reducedElementSize
Definition: FinleyElements.h:56
weipa::FinleyElementInfo::quadDim
int quadDim
Definition: FinleyElements.h:59
finley::Hex8Face
Definition: ReferenceElements.h:72
finley::Hex8
Definition: ReferenceElements.h:53
finley::Tri6
Definition: ReferenceElements.h:42
finley::Tri3_Contact
Definition: ReferenceElements.h:80
weipa::FinleyElements::getNodes
virtual NodeData_ptr getNodes() const
Returns the node mesh instance used by the elements.
Definition: FinleyElements.h:150
finley::Line2Face_Contact
Definition: ReferenceElements.h:89
finley::Line2
Definition: ReferenceElements.h:38
finley::ElementTypeId
ElementTypeId
Definition: ReferenceElements.h:36
weipa::FinleyElements::writeConnectivityVTK
virtual void writeConnectivityVTK(std::ostream &os)
Writes connectivity data to a stream in VTK text format.
Definition: FinleyElements.cpp:732
weipa::pointInTri
static bool pointInTri(float x, float y, const float *p0, const float *p1, const float *p2)
Definition: FinleyElements.cpp:1172
finley::Line3Macro
Definition: ReferenceElements.h:108
finley::Tet4
Definition: ReferenceElements.h:50
dudley::Dudley_Tet4
Definition: ElementType.h:51
weipa::FinleyElements::name
std::string name
Definition: FinleyElements.h:181
weipa::NodeData_ptr
boost::shared_ptr< NodeData > NodeData_ptr
Definition: weipa.h:67
finley::Hex20Face
Definition: ReferenceElements.h:73
weipa::StringVec
std::vector< std::string > StringVec
Definition: weipa.h:59
weipa::inside2D
bool inside2D(float x, float y, float cx, float cy, float r)
Definition: FinleyElements.cpp:1096
weipa::ZONETYPE_TET
Definition: ElementData.h:55
finley::ElementFile
Definition: finley/src/ElementFile.h:72
weipa::inside1D
bool inside1D(float x, float c, float r)
Definition: FinleyElements.cpp:1090
weipa::FinleyElements::owner
IntVec owner
Definition: FinleyElements.h:188
dudley::ElementFile::Color
index_t * Color
Definition: dudley/src/ElementFile.h:148
finley::const_ShapeFunction_ptr
boost::shared_ptr< const ShapeFunction > const_ShapeFunction_ptr
Definition: ShapeFunctions.h:98
weipa::ZONETYPE_POLYGON
Definition: ElementData.h:53
finley::ReferenceElementSet
Definition: ReferenceElementSets.h:37
weipa::FinleyNodes
Stores and manipulates finley mesh nodes.
Definition: FinleyNodes.h:49
weipa::FinleyElements::color
IntVec color
Definition: FinleyElements.h:187
weipa::FinleyNodes_ptr
boost::shared_ptr< FinleyNodes > FinleyNodes_ptr
Definition: FinleyNodes.h:41
weipa::FinleyElements::readFromNc
bool readFromNc(NcFile *ncfile)
Reads element data from escript/finley NetCDF file.
Definition: FinleyElements.cpp:381
finley::ElementFile::referenceElementSet
const_ReferenceElementSet_ptr referenceElementSet
the reference element to be used
Definition: finley/src/ElementFile.h:130
weipa::FinleyElements::FinleyElements
FinleyElements()
Definition: FinleyElements.h:164
weipa::FinleyElements::quadMask
QuadMaskInfo quadMask
Definition: FinleyElements.h:189
weipa::FinleyElementInfo::elementFactor
int elementFactor
Definition: FinleyElements.h:55
weipa::FinleyElements::reorderArray
void reorderArray(IntVec &v, const IntVec &idx, int elementsPerIndex)
Definition: FinleyElements.cpp:547
dudley::Dudley_Line2
Definition: ElementType.h:49
weipa::IntVec
std::vector< int > IntVec
Definition: weipa.h:58
weipa::FinleyElements
Stores and manipulates one type of finley mesh elements (cells, faces or contacts).
Definition: FinleyElements.h:74
finley
A suite of factory methods for creating various finley domains.
Definition: finley/src/Assemble.h:31
dudley::Dudley_Tri3
Definition: ElementType.h:50
finley::Tri3Face_Contact
Definition: ReferenceElements.h:92
dudley::ElementTypeId
ElementTypeId
Definition: ElementType.h:35
dudley::ElementFile::etype
ElementTypeId etype
element type ID
Definition: dudley/src/ElementFile.h:163
finley::Line2_Contact
Definition: ReferenceElements.h:77
weipa::ZONETYPE_BEAM
Definition: ElementData.h:51
finley::Tet10Face_Contact
Definition: ReferenceElements.h:102
dudley::ElementFile::numNodes
int numNodes
number of nodes per element
Definition: dudley/src/ElementFile.h:140
weipa::FinleyElements::getIDs
virtual const IntVec & getIDs() const
Returns a vector of element IDs.
Definition: FinleyElements.h:142
finley::Rec4
Definition: ReferenceElements.h:45
finley::ElementFile::numNodes
int numNodes
number of nodes per element
Definition: finley/src/ElementFile.h:148
weipa::FinleyElements::getNodesPerElement
virtual int getNodesPerElement() const
Returns the number of nodes per element.
Definition: FinleyElements.h:125