FinleyElements.h
Go to the documentation of this file.
/*****************************************************************************
*
* Copyright (c) 2003-2020 by The University of Queensland
* http://www.uq.edu.au
*
* Primary Business: Queensland, Australia
* Licensed under the Apache License, version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
* Development 2012-2013 by School of Earth Sciences
* Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
* Development from 2019 by School of Earth and Environmental Sciences
**
*****************************************************************************/
#ifndef __WEIPA_FINLEYELEMENTS_H__
#define __WEIPA_FINLEYELEMENTS_H__
#include <weipa/ElementData.h>
#include <weipa/FinleyNodes.h>
#ifdef USE_DUDLEY
#include <dudley/Dudley.h> // for DUDLEY_...
#include <dudley/ElementType.h> // for dudley::ElementTypeId
#endif
#ifdef USE_FINLEY
#include <finley/ReferenceElements.h> // for finley::ElementTypeId
#endif
class DBfile;
#ifdef NETCDF4
#include <ncFile.h>
#define NCFTYPE netCDF::NcFile&
#else
class NcFile;
#define NCFTYPE NcFile*
#endif
namespace dudley {
class ElementFile;
}
namespace finley {
class ElementFile;
}
namespace weipa {
struct FinleyElementInfo
{
ZoneType elementType, reducedElementType;
int elementFactor;
int elementSize, reducedElementSize;
const size_t* multiCellIndices;
bool useQuadNodes;
int quadDim;
};
class FinleyElements;
typedef boost::shared_ptr<FinleyElements> FinleyElements_ptr;
class FinleyElements : public ElementData
{
public:
FinleyElements(const std::string& elementName, FinleyNodes_ptr nodes);
FinleyElements(const FinleyElements& e);
virtual ~FinleyElements() {}
bool initFromDudley(const dudley::ElementFile* dudleyFile);
bool initFromFinley(const finley::ElementFile* finleyFile);
bool readFromNc(NCFTYPE ncfile);
void reorderGhostZones(int ownIndex);
void removeGhostZones(int ownIndex);
virtual void writeConnectivityVTK(std::ostream& os);
bool writeToSilo(DBfile* dbfile, const std::string& siloPath,
const StringVec& labels, const StringVec& units,
bool writeMeshData);
virtual StringVec getMeshNames() const;
virtual StringVec getVarNames() const;
virtual int getNumElements() const { return numElements; }
virtual int getNodesPerElement() const { return nodesPerElement; }
virtual int getGhostCount() const { return numGhostElements; }
virtual ZoneType getType() const { return type; }
#ifdef USE_FINLEY
finley::ElementTypeId getFinleyTypeId() const { return finleyTypeId; }
#endif
virtual const IntVec& getNodeList() const { return nodes; }
virtual const IntVec& getIDs() const { return ID; }
virtual const IntVec& getVarDataByName(const std::string varName) const;
virtual NodeData_ptr getNodes() const { return nodeMesh; }
virtual ElementData_ptr getReducedElements() const { return reducedElements; }
virtual const QuadMaskInfo& getQuadMask(int functionSpace) const;
virtual int getElementFactor() const { return elementFactor; }
private:
FinleyElements() {}
#ifdef USE_DUDLEY
FinleyElementInfo getDudleyTypeInfo(dudley::ElementTypeId typeId);
#endif
#ifdef USE_FINLEY
FinleyElementInfo getFinleyTypeInfo(finley::ElementTypeId typeId);
finley::ElementTypeId finleyTypeId;
#endif
void buildMeshes();
void buildReducedElements(const FinleyElementInfo& f);
IntVec prepareGhostIndices(int ownIndex);
void reorderArray(IntVec& v, const IntVec& idx, int elementsPerIndex);
QuadMaskInfo buildQuadMask(const CoordArray& quadNodes, int numQNodes);
FinleyElements_ptr reducedElements;
FinleyNodes_ptr nodeMesh;
FinleyNodes_ptr originalMesh;
std::string name;
int numElements;
int numGhostElements;
int nodesPerElement;
ZoneType type;
IntVec nodes;
IntVec color, ID, tag;
IntVec owner;
QuadMaskInfo quadMask, reducedQuadMask;
int elementFactor;
};
} // namespace weipa
#undef NCFTYPE
#endif // __WEIPA_FINLEYELEMENTS_H__
weipa::FinleyElements::reducedQuadMask
QuadMaskInfo reducedQuadMask
Definition: FinleyElements.h:191
dudley::ElementFile::Tag
int * Tag
Tag[i] is the tag of element i.
Definition: dudley/src/ElementFile.h:135
finley::Rec4_Contact
@ Rec4_Contact
Definition: ReferenceElements.h:87
finley::Line3
@ Line3
Definition: ReferenceElements.h:42
weipa::inside3D
bool inside3D(float x, float y, float z, float cx, float cy, float cz, float r)
Definition: FinleyElements.cpp:1104
dudley::Dudley_Point1
@ Dudley_Point1
Definition: ElementType.h:54
finley::Rec9
@ Rec9
Definition: ReferenceElements.h:50
FINLEY_REDUCED_FACE_ELEMENTS
#define FINLEY_REDUCED_FACE_ELEMENTS
Definition: Finley.h:75
finley::Rec8Face_Contact
@ Rec8Face_Contact
Definition: ReferenceElements.h:100
weipa::FinleyElements::getNodeList
virtual const IntVec & getNodeList() const
Returns a vector of the node IDs used by the elements.
Definition: FinleyElements.h:141
weipa::FinleyElements::buildQuadMask
QuadMaskInfo buildQuadMask(const CoordArray &quadNodes, int numQNodes)
Definition: FinleyElements.cpp:1198
finley::Hex20Face_Contact
@ Hex20Face_Contact
Definition: ReferenceElements.h:108
weipa::FinleyElements::buildMeshes
void buildMeshes()
Definition: FinleyElements.cpp:711
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:516
weipa::FinleyElementInfo::elementType
ZoneType elementType
Definition: FinleyElements.h:56
FINLEY_REDUCED_ELEMENTS
#define FINLEY_REDUCED_ELEMENTS
Definition: Finley.h:74
FINLEY_REDUCED_CONTACT_ELEMENTS_1
#define FINLEY_REDUCED_CONTACT_ELEMENTS_1
Definition: Finley.h:76
weipa::FinleyElements::tag
IntVec tag
Definition: FinleyElements.h:189
weipa::FinleyElementInfo
Holds information that is used to convert from finley element types to elements supported by Silo and...
Definition: FinleyElements.h:54
weipa::FinleyElements::numGhostElements
int numGhostElements
Definition: FinleyElements.h:185
finley::const_ReferenceElementSet_ptr
boost::shared_ptr< const ReferenceElementSet > const_ReferenceElementSet_ptr
Definition: ReferenceElementSets.h:94
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:771
dudley::Dudley_Tet4Face
@ Dudley_Tet4Face
Definition: ElementType.h:60
finley::Tet4Face_Contact
@ Tet4Face_Contact
Definition: ReferenceElements.h:104
finley::Line3_Contact
@ Line3_Contact
Definition: ReferenceElements.h:81
weipa::ZONETYPE_HEX
@ ZONETYPE_HEX
Definition: ElementData.h:58
weipa::QuadMaskInfo::mask
std::vector< IntVec > mask
Definition: ElementData.h:55
weipa::FinleyElements::~FinleyElements
virtual ~FinleyElements()
Destructor.
Definition: FinleyElements.h:87
weipa::sameSide
bool sameSide(float d1, float d2)
Definition: FinleyElements.cpp:1112
weipa::FinleyElements::prepareGhostIndices
IntVec prepareGhostIndices(int ownIndex)
Definition: FinleyElements.cpp:646
weipa::FinleyElements::getGhostCount
virtual int getGhostCount() const
Returns the number of "ghost" elements.
Definition: FinleyElements.h:130
weipa::FinleyElementInfo::elementSize
int elementSize
Definition: FinleyElements.h:58
hex20indices
static const size_t hex20indices[36 *3]
Definition: FinleyElements.cpp:93
finley::Tet10
@ Tet10
Definition: ReferenceElements.h:54
finley::ElementFile::Tag
int * Tag
Tag[i] is the tag of element i.
Definition: finley/src/ElementFile.h:143
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:147
weipa::FinleyElements::getNumElements
virtual int getNumElements() const
Returns the number of elements.
Definition: FinleyElements.h:124
finley::Tet10Macro
@ Tet10Macro
Definition: ReferenceElements.h:114
weipa::FinleyElements::initFromDudley
bool initFromDudley(const dudley::ElementFile *dudleyFile)
Initialises with data from a Dudley ElementFile instance.
Definition: FinleyElements.cpp:169
weipa::FinleyElements::getQuadMask
virtual const QuadMaskInfo & getQuadMask(int functionSpace) const
Returns a QuadMaskInfo structure for given functionspace code.
Definition: FinleyElements.cpp:535
weipa::FinleyElements::elementFactor
int elementFactor
Definition: FinleyElements.h:192
weipa::ZONETYPE_TRIANGLE
@ ZONETYPE_TRIANGLE
Definition: ElementData.h:62
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:670
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:54
finley::Tri6Face
@ Tri6Face
Definition: ReferenceElements.h:64
finley::Tet4Face
@ Tet4Face
Definition: ReferenceElements.h:72
finley::Line3Face
@ Line3Face
Definition: ReferenceElements.h:61
dudley::Dudley_Tri3Face
@ Dudley_Tri3Face
Definition: ElementType.h:59
weipa::FinleyElements::numElements
int numElements
Definition: FinleyElements.h:184
weipa::FinleyElements::ID
IntVec ID
Definition: FinleyElements.h:189
weipa::FinleyElementInfo::multiCellIndices
const size_t * multiCellIndices
Definition: FinleyElements.h:59
dudley::ElementFile::Owner
int * Owner
Owner[i] contains the rank that owns element i.
Definition: dudley/src/ElementFile.h:138
tri6indices
static const size_t tri6indices[4 *3]
Definition: FinleyElements.cpp:63
finley::Tet10Face
@ Tet10Face
Definition: ReferenceElements.h:73
finley::Tri6Face_Contact
@ Tri6Face_Contact
Definition: ReferenceElements.h:96
weipa::ZONETYPE_UNKNOWN
@ ZONETYPE_UNKNOWN
Definition: ElementData.h:56
finley::Rec8Face
@ Rec8Face
Definition: ReferenceElements.h:68
weipa::FinleyElements::getVarNames
virtual StringVec getVarNames() const
Returns a vector with the mesh variable names.
Definition: FinleyElements.cpp:503
finley::ElementFile::Nodes
index_t * Nodes
Definition: finley/src/ElementFile.h:158
finley::Rec8_Contact
@ Rec8_Contact
Definition: ReferenceElements.h:88
weipa::FinleyElements::nodesPerElement
int nodesPerElement
Definition: FinleyElements.h:186
weipa
Definition: DataVar.cpp:51
finley::Tri3
@ Tri3
Definition: ReferenceElements.h:44
finley::Rec9Macro
@ Rec9Macro
Definition: ReferenceElements.h:113
finley::Hex27
@ Hex27
Definition: ReferenceElements.h:58
finley::Line2Face
@ Line2Face
Definition: ReferenceElements.h:60
weipa::ZoneType
ZoneType
Definition: ElementData.h:41
finley::Rec9_Contact
@ Rec9_Contact
Definition: ReferenceElements.h:89
weipa::FinleyElements::getMeshNames
virtual StringVec getMeshNames() const
Returns the names of the meshes associated with the elements.
Definition: FinleyElements.cpp:487
weipa::QuadMaskInfo::factor
IntVec factor
Definition: ElementData.h:56
finley::Point1_Contact
@ Point1_Contact
Definition: ReferenceElements.h:79
tet10indices
static const size_t tet10indices[8 *4]
Definition: FinleyElements.cpp:83
paso::util::copy
void copy(dim_t N, double *out, const double *in)
out = in
Definition: PasoUtil.h:116
rec9indices
static const size_t rec9indices[4 *4]
Definition: FinleyElements.cpp:77
weipa::FinleyElementInfo::useQuadNodes
bool useQuadNodes
Definition: FinleyElements.h:60
finley::ElementFile::numElements
dim_t numElements
number of elements
Definition: finley/src/ElementFile.h:136
dudley
A suite of factory methods for creating 2D and 3D dudley domains.
Definition: dudley/src/Assemble.h:32
hex27indices
static const size_t hex27indices[8 *8]
Definition: FinleyElements.cpp:107
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:1119
finley::ElementFile::Owner
int * Owner
Owner[i] contains the rank that owns element i.
Definition: finley/src/ElementFile.h:146
weipa::FinleyElements_ptr
boost::shared_ptr< FinleyElements > FinleyElements_ptr
Definition: FinleyElements.h:64
dudley::Dudley_Line2Face
@ Dudley_Line2Face
Definition: ElementType.h:58
line3indices
static const size_t line3indices[2 *2]
Definition: FinleyElements.cpp:59
dudley::ElementFile::numElements
dim_t numElements
number of elements
Definition: dudley/src/ElementFile.h:127
weipa::FinleyElements::removeGhostZones
void removeGhostZones(int ownIndex)
Removes "ghost" elements.
Definition: FinleyElements.cpp:690
weipa::CoordArray
std::vector< float * > CoordArray
Definition: weipa.h:62
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:1138
dudley::ElementFile
Definition: dudley/src/ElementFile.h:66
finley::Tri6Macro
@ Tri6Macro
Definition: ReferenceElements.h:112
NCFTYPE
#define NCFTYPE
Definition: FinleyElements.h:39
finley::Hex27Macro
@ Hex27Macro
Definition: ReferenceElements.h:115
finley::Rec8
@ Rec8
Definition: ReferenceElements.h:49
dudley::ElementFile::Id
index_t * Id
Definition: dudley/src/ElementFile.h:132
finley::NoRef
@ NoRef
Definition: ReferenceElements.h:116
finley::Rec4Face
@ Rec4Face
Definition: ReferenceElements.h:67
weipa::ElementData_ptr
boost::shared_ptr< ElementData > ElementData_ptr
Definition: weipa.h:67
weipa::ElementData
Stores and manipulates one type of domain elements.
Definition: ElementData.h:63
finley::ElementFile::Color
index_t * Color
Definition: finley/src/ElementFile.h:164
weipa::FinleyElements::initFromFinley
bool initFromFinley(const finley::ElementFile *finleyFile)
Initialises with data from a Finley ElementFile instance.
Definition: FinleyElements.cpp:202
weipa::FinleyElements::getReducedElements
virtual ElementData_ptr getReducedElements() const
Returns the reduced elements.
Definition: FinleyElements.h:155
weipa::FinleyElements::type
ZoneType type
Definition: FinleyElements.h:187
finley::Hex8Face_Contact
@ Hex8Face_Contact
Definition: ReferenceElements.h:107
finley::Point1
@ Point1
Definition: ReferenceElements.h:40
weipa::FinleyElements::buildReducedElements
void buildReducedElements(const FinleyElementInfo &f)
Definition: FinleyElements.cpp:573
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:163
weipa::FinleyElementInfo::reducedElementType
ZoneType reducedElementType
Definition: FinleyElements.h:56
weipa::FinleyElements::nodeMesh
FinleyNodes_ptr nodeMesh
Definition: FinleyElements.h:181
finley::ElementFile::Id
index_t * Id
Definition: finley/src/ElementFile.h:140
finley::Hex20
@ Hex20
Definition: ReferenceElements.h:57
weipa::FinleyElements::reducedElements
FinleyElements_ptr reducedElements
Definition: FinleyElements.h:180
finley::Line3Face_Contact
@ Line3Face_Contact
Definition: ReferenceElements.h:93
finley::Tri3Face
@ Tri3Face
Definition: ReferenceElements.h:63
weipa::FinleyElements::getType
virtual ZoneType getType() const
Returns the type of the elements.
Definition: FinleyElements.h:133
weipa::FinleyElements::originalMesh
FinleyNodes_ptr originalMesh
Definition: FinleyElements.h:182
finley::Tri6_Contact
@ Tri6_Contact
Definition: ReferenceElements.h:84
weipa::FinleyElements::nodes
IntVec nodes
Definition: FinleyElements.h:188
rec8indices
static const size_t rec8indices[6 *3]
Definition: FinleyElements.cpp:69
weipa::ZONETYPE_QUAD
@ ZONETYPE_QUAD
Definition: ElementData.h:60
finley::Rec4Face_Contact
@ Rec4Face_Contact
Definition: ReferenceElements.h:99
weipa::FinleyElementInfo::reducedElementSize
int reducedElementSize
Definition: FinleyElements.h:58
weipa::FinleyElementInfo::quadDim
int quadDim
Definition: FinleyElements.h:61
finley::Hex8Face
@ Hex8Face
Definition: ReferenceElements.h:75
finley::Hex8
@ Hex8
Definition: ReferenceElements.h:56
finley::Tri6
@ Tri6
Definition: ReferenceElements.h:45
finley::Tri3_Contact
@ Tri3_Contact
Definition: ReferenceElements.h:83
weipa::FinleyElements::getNodes
virtual NodeData_ptr getNodes() const
Returns the node mesh instance used by the elements.
Definition: FinleyElements.h:152
finley::Line2Face_Contact
@ Line2Face_Contact
Definition: ReferenceElements.h:92
finley::Line2
@ Line2
Definition: ReferenceElements.h:41
finley::ElementTypeId
ElementTypeId
Definition: ReferenceElements.h:39
weipa::FinleyElements::writeConnectivityVTK
virtual void writeConnectivityVTK(std::ostream &os)
Writes connectivity data to a stream in VTK text format.
Definition: FinleyElements.cpp:734
weipa::pointInTri
static bool pointInTri(float x, float y, const float *p0, const float *p1, const float *p2)
Definition: FinleyElements.cpp:1174
finley::Line3Macro
@ Line3Macro
Definition: ReferenceElements.h:111
finley::Tet4
@ Tet4
Definition: ReferenceElements.h:53
dudley::Dudley_Tet4
@ Dudley_Tet4
Definition: ElementType.h:57
weipa::FinleyElements::name
std::string name
Definition: FinleyElements.h:183
weipa::NodeData_ptr
boost::shared_ptr< NodeData > NodeData_ptr
Definition: weipa.h:69
finley::Hex20Face
@ Hex20Face
Definition: ReferenceElements.h:76
weipa::StringVec
std::vector< std::string > StringVec
Definition: weipa.h:61
weipa::inside2D
bool inside2D(float x, float y, float cx, float cy, float r)
Definition: FinleyElements.cpp:1098
weipa::ZONETYPE_TET
@ ZONETYPE_TET
Definition: ElementData.h:61
finley::ElementFile
Definition: finley/src/ElementFile.h:76
weipa::inside1D
bool inside1D(float x, float c, float r)
Definition: FinleyElements.cpp:1092
weipa::FinleyElements::owner
IntVec owner
Definition: FinleyElements.h:190
dudley::ElementFile::Color
index_t * Color
Definition: dudley/src/ElementFile.h:152
finley::const_ShapeFunction_ptr
boost::shared_ptr< const ShapeFunction > const_ShapeFunction_ptr
Definition: ShapeFunctions.h:100
weipa::ZONETYPE_POLYGON
@ ZONETYPE_POLYGON
Definition: ElementData.h:59
finley::ReferenceElementSet
Definition: ReferenceElementSets.h:41
weipa::FinleyNodes
Stores and manipulates finley mesh nodes.
Definition: FinleyNodes.h:51
weipa::FinleyElements::color
IntVec color
Definition: FinleyElements.h:189
weipa::FinleyNodes_ptr
boost::shared_ptr< FinleyNodes > FinleyNodes_ptr
Definition: FinleyNodes.h:43
weipa::FinleyElements::readFromNc
bool readFromNc(NcFile *ncfile)
Reads element data from escript/finley NetCDF file.
Definition: FinleyElements.cpp:383
finley::ElementFile::referenceElementSet
const_ReferenceElementSet_ptr referenceElementSet
the reference element to be used
Definition: finley/src/ElementFile.h:134
weipa::FinleyElements::FinleyElements
FinleyElements()
Definition: FinleyElements.h:166
weipa::FinleyElements::quadMask
QuadMaskInfo quadMask
Definition: FinleyElements.h:191
weipa::FinleyElementInfo::elementFactor
int elementFactor
Definition: FinleyElements.h:57
weipa::FinleyElements::reorderArray
void reorderArray(IntVec &v, const IntVec &idx, int elementsPerIndex)
Definition: FinleyElements.cpp:549
dudley::Dudley_Line2
@ Dudley_Line2
Definition: ElementType.h:55
weipa::IntVec
std::vector< int > IntVec
Definition: weipa.h:60
weipa::FinleyElements
Stores and manipulates one type of finley mesh elements (cells, faces or contacts).
Definition: FinleyElements.h:76
finley
A suite of factory methods for creating various finley domains.
Definition: finley/src/Assemble.h:32
dudley::Dudley_Tri3
@ Dudley_Tri3
Definition: ElementType.h:56
finley::Tri3Face_Contact
@ Tri3Face_Contact
Definition: ReferenceElements.h:95
dudley::ElementTypeId
ElementTypeId
Definition: ElementType.h:39
dudley::ElementFile::etype
ElementTypeId etype
element type ID
Definition: dudley/src/ElementFile.h:167
finley::Line2_Contact
@ Line2_Contact
Definition: ReferenceElements.h:80
weipa::ZONETYPE_BEAM
@ ZONETYPE_BEAM
Definition: ElementData.h:57
finley::Tet10Face_Contact
@ Tet10Face_Contact
Definition: ReferenceElements.h:105
dudley::ElementFile::numNodes
int numNodes
number of nodes per element
Definition: dudley/src/ElementFile.h:144
weipa::FinleyElements::getIDs
virtual const IntVec & getIDs() const
Returns a vector of element IDs.
Definition: FinleyElements.h:144
finley::Rec4
@ Rec4
Definition: ReferenceElements.h:48
finley::ElementFile::numNodes
int numNodes
number of nodes per element
Definition: finley/src/ElementFile.h:152
weipa::FinleyElements::getNodesPerElement
virtual int getNodesPerElement() const
Returns the number of nodes per element.
Definition: FinleyElements.h:127