Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Attributes | List of all members
Nektar::Utilities::Element Class Reference

Base class for element definitions. More...

#include <MeshElements.h>

Inheritance diagram for Nektar::Utilities::Element:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::Element:
Collaboration graph
[legend]

Public Member Functions

 Element (ElmtConfig pConf, unsigned int pNumNodes, unsigned int pGotNodes)
unsigned int GetId () const
 Returns the ID of the element (or associated edge or face for boundary elements).
unsigned int GetDim () const
 Returns the expansion dimension of the element.
ElmtConfig GetConf () const
 Returns the configuration of the element.
std::string GetTag () const
 Returns the tag which defines the element shape.
NodeSharedPtr GetVertex (unsigned int i) const
 Access a vertex node.
EdgeSharedPtr GetEdge (unsigned int i) const
 Access an edge.
FaceSharedPtr GetFace (unsigned int i) const
 Access a face.
std::vector< NodeSharedPtrGetVertexList () const
 Access the list of vertex nodes.
std::vector< EdgeSharedPtrGetEdgeList () const
 Access the list of edges.
std::vector< FaceSharedPtrGetFaceList () const
 Access the list of faces.
std::vector< NodeSharedPtrGetVolumeNodes () const
 Access the list of volume nodes.
void SetVolumeNodes (std::vector< NodeSharedPtr > &nodes)
LibUtilities::PointsType GetCurveType () const
void SetCurveType (LibUtilities::PointsType cT)
unsigned int GetNodeCount () const
 Returns the total number of nodes (vertices, edge nodes and face nodes and volume nodes).
std::vector< int > GetTagList () const
 Access the list of tags associated with this element.
unsigned int GetVertexCount () const
 Returns the number of vertices.
unsigned int GetEdgeCount () const
 Returns the number of edges.
unsigned int GetFaceCount () const
 Returns the number of faces.
void SetId (unsigned int p)
 Change the ID of the element.
void SetVertex (unsigned int p, NodeSharedPtr pNew)
 Replace a vertex with another vertex object.
void SetEdge (unsigned int p, EdgeSharedPtr pNew)
 Replace an edge with another edge object.
void SetFace (unsigned int p, FaceSharedPtr pNew)
 Replace a face with another face object.
void SetEdgeLink (EdgeSharedPtr pLink)
 Set a correspondence between this element and an edge (2D boundary element).
EdgeSharedPtr GetEdgeLink ()
 Get correspondence between this element and an edge.
void SetFaceLink (FaceSharedPtr pLink)
 Set a correspondence between this element and a face (3D boundary element).
FaceSharedPtr GetFaceLink ()
 Get correspondence between this element and a face.
void SetBoundaryLink (int i, int j)
 Set a correspondence between edge or face i and its representative boundary element m->element[expDim-1][j].
int GetBoundaryLink (int i)
 Get the location of the boundary face/edge i for this element.
void SetTagList (const std::vector< int > &tags)
 Set the list of tags associated with this element.
virtual std::string GetXmlString () const
 Generate a list of vertices (1D), edges (2D), or faces (3D).
std::string GetXmlCurveString () const
 Generates a string listing the coordinates of all nodes associated with this element.
virtual
SpatialDomains::GeometrySharedPtr 
GetGeom (int coordDim)
 Generate a Nektar++ geometry object for this element.
int GetMaxOrder ()
 Obtain the order of an element by looking at edges.
virtual void Complete (int order)
 Complete this object.
void Print ()

Protected Attributes

unsigned int m_id
 ID of the element.
unsigned int m_dim
 Dimension of the element.
ElmtConfig m_conf
 Contains configuration of the element.
std::string m_tag
 Tag character describing the element.
std::vector< int > m_taglist
 List of integers specifying properties of the element.
std::vector< NodeSharedPtrm_vertex
 List of element vertex nodes.
std::vector< EdgeSharedPtrm_edge
 List of element edges.
std::vector< FaceSharedPtrm_face
 List of element faces.
std::vector< NodeSharedPtrm_volumeNodes
 List of element volume nodes.
LibUtilities::PointsType m_curveType
 Volume curve type.
EdgeSharedPtr m_edgeLink
 Pointer to the corresponding edge if element is a 2D boundary.
FaceSharedPtr m_faceLink
 Pointer to the corresponding face if element is a 3D boundary.
std::map< int, int > m_boundaryLinks
 Array mapping faces/edges to the location of the appropriate boundary elements in m->element.
SpatialDomains::GeometrySharedPtr m_geom
 Nektar++ geometry object for this element.

Detailed Description

Base class for element definitions.

An element is defined by a list of vertices, edges and faces (depending on the dimension of the problem). This base class provides the underlying structure.

Definition at line 647 of file MeshElements.h.

Constructor & Destructor Documentation

Element::Element ( ElmtConfig  pConf,
unsigned int  pNumNodes,
unsigned int  pGotNodes 
)

Definition at line 68 of file MeshElements.cpp.

References Nektar::Utilities::ElmtConfig::m_e.

: m_conf(pConf),
{
if (pNumNodes != pGotNodes)
{
cerr << "Number of modes mismatch for type "
<< pConf.m_e << "! Should be " << pNumNodes
<< " but got " << pGotNodes << " nodes." << endl;
abort();
}
}

Member Function Documentation

virtual void Nektar::Utilities::Element::Complete ( int  order)
inlinevirtual

Complete this object.

Reimplemented in Nektar::Utilities::Prism, Nektar::Utilities::Tetrahedron, Nektar::Utilities::Quadrilateral, and Nektar::Utilities::Triangle.

Definition at line 932 of file MeshElements.h.

References ASSERTL0.

{
ASSERTL0(false, "This function should be implemented at a shape level.");
}
int Nektar::Utilities::Element::GetBoundaryLink ( int  i)
inline

Get the location of the boundary face/edge i for this element.

Definition at line 781 of file MeshElements.h.

References Nektar::iterator.

{
if (it == m_boundaryLinks.end())
{
return -1;
}
else
{
return it->second;
}
}
ElmtConfig Nektar::Utilities::Element::GetConf ( ) const
inline

Returns the configuration of the element.

Definition at line 665 of file MeshElements.h.

{
return m_conf;
}
LibUtilities::PointsType Nektar::Utilities::Element::GetCurveType ( ) const
inline

Definition at line 705 of file MeshElements.h.

References Nektar::Utilities::Face::m_curveType.

{
return m_curveType;
}
unsigned int Nektar::Utilities::Element::GetDim ( ) const
inline

Returns the expansion dimension of the element.

Definition at line 661 of file MeshElements.h.

{
return m_dim;
}
EdgeSharedPtr Nektar::Utilities::Element::GetEdge ( unsigned int  i) const
inline

Access an edge.

Definition at line 679 of file MeshElements.h.

{
return m_edge[i];
}
unsigned int Nektar::Utilities::Element::GetEdgeCount ( ) const
inline

Returns the number of edges.

Definition at line 740 of file MeshElements.h.

{
return m_edge.size();
}
EdgeSharedPtr Nektar::Utilities::Element::GetEdgeLink ( )
inline

Get correspondence between this element and an edge.

Definition at line 763 of file MeshElements.h.

{
return m_edgeLink;
}
std::vector<EdgeSharedPtr> Nektar::Utilities::Element::GetEdgeList ( ) const
inline

Access the list of edges.

Definition at line 691 of file MeshElements.h.

Referenced by Nektar::Utilities::Triangle::create(), and Nektar::Utilities::Quadrilateral::create().

{
return m_edge;
}
FaceSharedPtr Nektar::Utilities::Element::GetFace ( unsigned int  i) const
inline

Access a face.

Definition at line 683 of file MeshElements.h.

{
return m_face[i];
}
unsigned int Nektar::Utilities::Element::GetFaceCount ( ) const
inline

Returns the number of faces.

Definition at line 744 of file MeshElements.h.

{
return m_face.size();
}
FaceSharedPtr Nektar::Utilities::Element::GetFaceLink ( )
inline

Get correspondence between this element and a face.

Definition at line 772 of file MeshElements.h.

{
return m_faceLink;
}
std::vector<FaceSharedPtr> Nektar::Utilities::Element::GetFaceList ( ) const
inline
virtual SpatialDomains::GeometrySharedPtr Nektar::Utilities::Element::GetGeom ( int  coordDim)
inlinevirtual

Generate a Nektar++ geometry object for this element.

Reimplemented in Nektar::Utilities::Hexahedron, Nektar::Utilities::Prism, Nektar::Utilities::Pyramid, Nektar::Utilities::Tetrahedron, Nektar::Utilities::Quadrilateral, Nektar::Utilities::Triangle, and Nektar::Utilities::Line.

Definition at line 925 of file MeshElements.h.

References ASSERTL0.

{
ASSERTL0(false, "This function should be implemented at a shape level.");
return boost::shared_ptr<SpatialDomains::Geometry>();
}
unsigned int Nektar::Utilities::Element::GetId ( ) const
inline

Returns the ID of the element (or associated edge or face for boundary elements).

Definition at line 655 of file MeshElements.h.

References Nektar::Utilities::Face::m_id.

{
if (m_faceLink.get() != 0) return m_faceLink->m_id;
if (m_edgeLink.get() != 0) return m_edgeLink->m_id;
return m_id;
}
int Element::GetMaxOrder ( )

Obtain the order of an element by looking at edges.

Definition at line 308 of file MeshElements.cpp.

References m_edge.

{
int i, ret = 1;
for (i = 0; i < m_edge.size(); ++i)
{
int edgeOrder = m_edge[i]->GetNodeCount()-1;
if (edgeOrder > ret)
{
ret = edgeOrder;
}
}
return ret;
}
unsigned int Nektar::Utilities::Element::GetNodeCount ( ) const
inline

Returns the total number of nodes (vertices, edge nodes and face nodes and volume nodes).

Definition at line 713 of file MeshElements.h.

{
unsigned int n = m_volumeNodes.size();
if (m_dim == 2)
{
for (int i = 0; i < m_edge.size(); ++i)
{
n += m_edge[i]->GetNodeCount();
}
n -= m_vertex.size();
}
else
{
cerr << "Not supported." << endl;
exit(1);
}
return n;
}
std::string Nektar::Utilities::Element::GetTag ( ) const
inline

Returns the tag which defines the element shape.

Definition at line 669 of file MeshElements.h.

{
if (m_faceLink.get() != 0) return "F";
if (m_edgeLink.get() != 0) return "E";
return m_tag;
}
std::vector<int> Nektar::Utilities::Element::GetTagList ( ) const
inline

Access the list of tags associated with this element.

Definition at line 732 of file MeshElements.h.

{
return m_taglist;
}
NodeSharedPtr Nektar::Utilities::Element::GetVertex ( unsigned int  i) const
inline

Access a vertex node.

Definition at line 675 of file MeshElements.h.

Referenced by Nektar::Utilities::InputNek::Process().

{
return m_vertex[i];
}
unsigned int Nektar::Utilities::Element::GetVertexCount ( ) const
inline

Returns the number of vertices.

Definition at line 736 of file MeshElements.h.

{
return m_vertex.size();
}
std::vector<NodeSharedPtr> Nektar::Utilities::Element::GetVertexList ( ) const
inline

Access the list of vertex nodes.

Definition at line 687 of file MeshElements.h.

{
return m_vertex;
}
std::vector<NodeSharedPtr> Nektar::Utilities::Element::GetVolumeNodes ( ) const
inline

Access the list of volume nodes.

Definition at line 699 of file MeshElements.h.

{
return m_volumeNodes;
}
std::string Nektar::Utilities::Element::GetXmlCurveString ( ) const
inline

Generates a string listing the coordinates of all nodes associated with this element.

Definition at line 827 of file MeshElements.h.

{
// Temporary node list for reordering
std::vector<NodeSharedPtr> nodeList;
// Node orderings are different for different elements.
// Triangle
if (m_vertex.size() == 3)
{
int n = m_edge[0]->GetNodeCount();
nodeList.resize(n*(n+1)/2);
// Populate nodelist
std::copy(m_vertex.begin(), m_vertex.end(), nodeList.begin());
for (int i = 0; i < 3; ++i)
{
std::copy(m_edge[i]->m_edgeNodes.begin(),
m_edge[i]->m_edgeNodes.end(),
nodeList.begin() + 3 + i*(n-2));
if (m_edge[i]->m_n1 != m_vertex[i])
{
// If edge orientation is reversed relative to node
// ordering, we need to reverse order of nodes.
std::reverse(nodeList.begin() + 3 + i*(n-2),
nodeList.begin() + 3 + (i+1)*(n-2));
}
}
// Copy volume nodes.
std::copy(m_volumeNodes.begin(), m_volumeNodes.end(),
nodeList.begin() + 3*(n-1));
}
// Quad
else if (m_dim == 2 && m_vertex.size() == 4)
{
int n = m_edge[0]->GetNodeCount();
nodeList.resize(n*n);
// Write vertices
nodeList[0] = m_vertex[0];
nodeList[n-1] = m_vertex[1];
nodeList[n*n-1] = m_vertex[2];
nodeList[n*(n-1)] = m_vertex[3];
// Write edge-interior
int skips[4][2] = {{0,1}, {n-1,n}, {n*n-1,-1}, {n*(n-1),-n}};
for (int i = 0; i < 4; ++i)
{
bool reverseEdge = m_edge[i]->m_n1 == m_vertex[i];
if (!reverseEdge)
{
for (int j = 1; j < n-1; ++j)
{
nodeList[skips[i][0] + j*skips[i][1]] =
m_edge[i]->m_edgeNodes[n-2-j];
}
}
else
{
for (int j = 1; j < n-1; ++j)
{
nodeList[skips[i][0] + j*skips[i][1]] =
m_edge[i]->m_edgeNodes[j-1];
}
}
}
// Write interior
for (int i = 1; i < n-1; ++i)
{
for (int j = 1; j < n-1; ++j)
{
nodeList[i*n+j] = m_volumeNodes[(i-1)*(n-2)+(j-1)];
}
}
}
else
{
cerr << "GetXmlCurveString for a " << m_vertex.size()
<< "-vertex element is not yet implemented." << endl;
}
// Finally generate the XML string corresponding to our new
// node reordering.
std::stringstream s;
std::string str;
for (int k = 0; k < nodeList.size(); ++k)
{
s << std::scientific << std::setprecision(8) << " "
<< nodeList[k]->m_x << " " << nodeList[k]->m_y
<< " " << nodeList[k]->m_z << " ";
}
return s.str();
}
virtual std::string Nektar::Utilities::Element::GetXmlString ( ) const
inlinevirtual

Generate a list of vertices (1D), edges (2D), or faces (3D).

Definition at line 798 of file MeshElements.h.

{
std::stringstream s;
switch (m_dim)
{
case 1:
for(int j=0; j< m_vertex.size(); ++j)
{
s << std::setw(5) << m_vertex[j]->m_id << " ";
}
break;
case 2:
for(int j=0; j< m_edge.size(); ++j)
{
s << std::setw(5) << m_edge[j]->m_id << " ";
}
break;
case 3:
for(int j=0; j< m_face.size(); ++j)
{
s << std::setw(5) << m_face[j]->m_id << " ";
}
break;
}
return s.str();
}
void Nektar::Utilities::Element::Print ( )
inline

Definition at line 936 of file MeshElements.h.

{
int i, j;
for (i = 0; i < m_vertex.size(); ++i)
{
cout << m_vertex[i]->m_x << " " << m_vertex[i]->m_y << " " << m_vertex[i]->m_z << endl;
}
for (i = 0; i < m_edge.size(); ++i)
{
for (j = 0; j < m_edge[i]->m_edgeNodes.size(); ++j)
{
NodeSharedPtr n = m_edge[i]->m_edgeNodes[j];
cout << n->m_x << " " << n->m_y << " " << n->m_z << endl;
}
}
for (i = 0; i < m_face.size(); ++i)
{
for (j = 0; j < m_face[i]->m_faceNodes.size(); ++j)
{
NodeSharedPtr n = m_face[i]->m_faceNodes[j];
cout << n->m_x << " " << n->m_y << " " << n->m_z << endl;
}
}
}
void Nektar::Utilities::Element::SetBoundaryLink ( int  i,
int  j 
)
inline

Set a correspondence between edge or face i and its representative boundary element m->element[expDim-1][j].

Definition at line 777 of file MeshElements.h.

{
}
void Nektar::Utilities::Element::SetCurveType ( LibUtilities::PointsType  cT)
inline

Definition at line 708 of file MeshElements.h.

References Nektar::Utilities::Face::m_curveType.

{
}
void Element::SetEdge ( unsigned int  p,
EdgeSharedPtr  pNew 
)

Replace an edge with another edge object.

Replace an edge in the element.

When an edge is replaced, the element faces are also searched and the corresponding face edges are updated to maintain consistency.

Parameters
pIndex of the edge to replace.
pNewNew edge.

Definition at line 276 of file MeshElements.cpp.

References m_edge, and m_face.

{
EdgeSharedPtr vOld = m_edge[p];
m_edge[p] = pNew;
for (unsigned int i = 0; i < m_face.size(); ++i)
{
for (unsigned int j = 0; j < m_face[i]->m_edgeList.size(); ++j)
{
if (m_face[i]->m_edgeList[j] == vOld)
{
m_face[i]->m_edgeList[j] = pNew;
}
}
}
}
void Nektar::Utilities::Element::SetEdgeLink ( EdgeSharedPtr  pLink)
inline

Set a correspondence between this element and an edge (2D boundary element).

Definition at line 759 of file MeshElements.h.

{
m_edgeLink = pLink;
}
void Element::SetFace ( unsigned int  p,
FaceSharedPtr  pNew 
)

Replace a face with another face object.

Replace a face in the element.

When a face is replaced, no other consistency checks are required.

Parameters
pIndex of the face to replace.
pNewNew face.

Definition at line 300 of file MeshElements.cpp.

References m_face.

{
m_face[p] = pNew;
}
void Nektar::Utilities::Element::SetFaceLink ( FaceSharedPtr  pLink)
inline

Set a correspondence between this element and a face (3D boundary element).

Definition at line 768 of file MeshElements.h.

{
m_faceLink = pLink;
}
void Nektar::Utilities::Element::SetId ( unsigned int  p)
inline

Change the ID of the element.

Definition at line 748 of file MeshElements.h.

References Nektar::Utilities::Face::m_id.

{
m_id = p;
}
void Nektar::Utilities::Element::SetTagList ( const std::vector< int > &  tags)
inline

Set the list of tags associated with this element.

Definition at line 793 of file MeshElements.h.

{
m_taglist = tags;
}
void Element::SetVertex ( unsigned int  p,
NodeSharedPtr  pNew 
)

Replace a vertex with another vertex object.

Replace a vertex in the element.

When a vertex is replaced, the element edges and faces are also searched and the corresponding edge/face nodes are updated to maintain consistency.

Parameters
pIndex of the vertex to replace.
pNewNew vertex.

Definition at line 228 of file MeshElements.cpp.

References m_edge, m_face, and m_vertex.

{
m_vertex[p] = pNew;
for (unsigned int i = 0; i < m_edge.size(); ++i)
{
if (m_edge[i]->m_n1 == vOld)
{
m_edge[i]->m_n1 = pNew;
}
else if (m_edge[i]->m_n2 == vOld)
{
m_edge[i]->m_n2 = pNew;
}
}
for (unsigned int i = 0; i < m_face.size(); ++i)
{
// Replace vertices in faces
for (unsigned int j = 0; j < m_face[i]->m_vertexList.size(); ++j)
{
if (m_face[i]->m_vertexList[j] == vOld)
{
m_face[i]->m_vertexList[j] = pNew;
}
}
for (unsigned int j = 0; j < m_face[i]->m_edgeList.size(); ++j)
{
if (m_face[i]->m_edgeList[j]->m_n1 == vOld)
{
m_face[i]->m_edgeList[j]->m_n1 = pNew;
}
else if (m_face[i]->m_edgeList[j]->m_n2 == vOld)
{
m_face[i]->m_edgeList[j]->m_n2 = pNew;
}
}
}
}
void Nektar::Utilities::Element::SetVolumeNodes ( std::vector< NodeSharedPtr > &  nodes)
inline

Definition at line 702 of file MeshElements.h.

{
m_volumeNodes = nodes;
}

Member Data Documentation

std::map<int,int> Nektar::Utilities::Element::m_boundaryLinks
protected

Array mapping faces/edges to the location of the appropriate boundary elements in m->element.

Definition at line 988 of file MeshElements.h.

ElmtConfig Nektar::Utilities::Element::m_conf
protected
LibUtilities::PointsType Nektar::Utilities::Element::m_curveType
protected

Volume curve type.

Definition at line 981 of file MeshElements.h.

Referenced by Nektar::Utilities::Line::GetGeom(), and Nektar::Utilities::Triangle::Triangle().

unsigned int Nektar::Utilities::Element::m_dim
protected
std::vector<EdgeSharedPtr> Nektar::Utilities::Element::m_edge
protected
EdgeSharedPtr Nektar::Utilities::Element::m_edgeLink
protected

Pointer to the corresponding edge if element is a 2D boundary.

Definition at line 983 of file MeshElements.h.

std::vector<FaceSharedPtr> Nektar::Utilities::Element::m_face
protected
FaceSharedPtr Nektar::Utilities::Element::m_faceLink
protected

Pointer to the corresponding face if element is a 3D boundary.

Definition at line 985 of file MeshElements.h.

SpatialDomains::GeometrySharedPtr Nektar::Utilities::Element::m_geom
protected

Nektar++ geometry object for this element.

Definition at line 990 of file MeshElements.h.

Referenced by Nektar::Utilities::Pyramid::GetGeom().

unsigned int Nektar::Utilities::Element::m_id
protected
std::string Nektar::Utilities::Element::m_tag
protected
std::vector<int> Nektar::Utilities::Element::m_taglist
protected
std::vector<NodeSharedPtr> Nektar::Utilities::Element::m_vertex
protected
std::vector<NodeSharedPtr> Nektar::Utilities::Element::m_volumeNodes
protected