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

A 2-dimensional three-sided element. More...

#include <MeshElements.h>

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

Public Member Functions

 Triangle (ElmtConfig pConf, std::vector< NodeSharedPtr > pNodeList, std::vector< int > pTagList)
 Create a triangle element.
 Triangle (const Triangle &pSrc)
virtual ~Triangle ()
virtual
SpatialDomains::GeometrySharedPtr 
GetGeom (int coordDim)
 Generate a Nektar++ geometry object for this element.
virtual void Complete (int order)
 Complete this object.
- Public Member Functions inherited from Nektar::Utilities::Element
 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.
int GetMaxOrder ()
 Obtain the order of an element by looking at edges.
void Print ()

Static Public Member Functions

static ElementSharedPtr create (ElmtConfig pConf, std::vector< NodeSharedPtr > pNodeList, std::vector< int > pTagList)
 Creates an instance of this class.
static unsigned int GetNumNodes (ElmtConfig pConf)
 Return the number of nodes defining a triangle.

Static Public Attributes

static LibUtilities::ShapeType m_type
 Element type.

Additional Inherited Members

- Protected Attributes inherited from Nektar::Utilities::Element
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

A 2-dimensional three-sided element.

Definition at line 1327 of file MeshElements.h.

Constructor & Destructor Documentation

Triangle::Triangle ( ElmtConfig  pConf,
std::vector< NodeSharedPtr pNodeList,
std::vector< int >  pTagList 
)

Create a triangle element.

Definition at line 486 of file MeshElements.cpp.

References Nektar::LibUtilities::eNodalTriEvenlySpaced, Nektar::iterator, Nektar::Utilities::Element::m_conf, Nektar::Utilities::Element::m_curveType, Nektar::Utilities::Element::m_dim, Nektar::Utilities::Element::m_edge, Nektar::Utilities::ElmtConfig::m_edgeCurveType, Nektar::Utilities::ElmtConfig::m_faceNodes, Nektar::Utilities::ElmtConfig::m_order, Nektar::Utilities::ElmtConfig::m_reorient, Nektar::Utilities::Element::m_tag, Nektar::Utilities::Element::m_taglist, Nektar::Utilities::Element::m_vertex, and Nektar::Utilities::Element::m_volumeNodes.

: Element(pConf, GetNumNodes(pConf), pNodeList.size())
{
m_tag = "T";
m_dim = 2;
m_taglist = pTagList;
int n = m_conf.m_order-1;
// Create a map to relate edge nodes to a pair of vertices
// defining an edge. This is based on the ordering produced by
// gmsh.
map<pair<int,int>, int> edgeNodeMap;
map<pair<int,int>, int>::iterator it;
edgeNodeMap[pair<int,int>(1,2)] = 4;
edgeNodeMap[pair<int,int>(2,3)] = 4 + n;
edgeNodeMap[pair<int,int>(3,1)] = 4 + 2*n;
// Add vertices. This logic will determine (in 2D) whether the
// element is clockwise (sum > 0) or counter-clockwise (sum < 0).
NekDouble sum = 0.0;
for (int i = 0; i < 3; ++i) {
int o = (i+1) % 3;
m_vertex.push_back(pNodeList[i]);
sum += (pNodeList[o]->m_x - pNodeList[i]->m_x) *
(pNodeList[o]->m_y + pNodeList[i]->m_y);
}
// Create edges (with corresponding set of edge points)
for (it = edgeNodeMap.begin(); it != edgeNodeMap.end(); ++it)
{
vector<NodeSharedPtr> edgeNodes;
if (m_conf.m_order > 1) {
for (int j = it->second; j < it->second + n; ++j) {
edgeNodes.push_back(pNodeList[j-1]);
}
}
m_edge.push_back(EdgeSharedPtr(new Edge(pNodeList[it->first.first-1],
pNodeList[it->first.second-1],
edgeNodes,
}
if (pConf.m_reorient)
{
if (sum > 0.0)
{
reverse(m_edge.begin(), m_edge.end());
}
}
{
m_volumeNodes.insert(m_volumeNodes.begin(),
pNodeList.begin()+3*m_conf.m_order,
pNodeList.end());
}
}
Nektar::Utilities::Triangle::Triangle ( const Triangle pSrc)
virtual Nektar::Utilities::Triangle::~Triangle ( )
inlinevirtual

Definition at line 1351 of file MeshElements.h.

{}

Member Function Documentation

void Triangle::Complete ( int  order)
virtual

Complete this object.

Reimplemented from Nektar::Utilities::Element.

Definition at line 583 of file MeshElements.cpp.

References Nektar::LibUtilities::eGaussLobattoLegendre, Nektar::LibUtilities::eGaussRadauMAlpha1Beta0, Nektar::LibUtilities::eNodalTriEvenlySpaced, Nektar::LibUtilities::eOrtho_A, Nektar::LibUtilities::eOrtho_B, GetGeom(), Nektar::Utilities::Element::m_conf, Nektar::Utilities::Element::m_edge, Nektar::Utilities::ElmtConfig::m_faceNodes, Nektar::Utilities::ElmtConfig::m_order, Nektar::Utilities::ElmtConfig::m_volumeNodes, and Nektar::Utilities::Element::m_volumeNodes.

{
int i, j;
// Create basis key for a nodal tetrahedron.
LibUtilities::BasisKey B0(
LibUtilities::PointsKey(
LibUtilities::BasisKey B1(
LibUtilities::PointsKey(
// Create a standard nodal triangle in order to get the
// Vandermonde matrix to perform interpolation to nodal points.
MemoryManager<StdRegions::StdNodalTriExp>::AllocateSharedPtr(
boost::dynamic_pointer_cast<SpatialDomains::TriGeom>(
this->GetGeom(3));
// Create basis key for a triangle.
LibUtilities::BasisKey C0(
LibUtilities::PointsKey(
LibUtilities::BasisKey C1(
LibUtilities::PointsKey(
// Create a triangle.
MemoryManager<LocalRegions::TriExp>::AllocateSharedPtr(
C0, C1, geom);
// Get coordinate array for tetrahedron.
int nqtot = tri->GetTotPoints();
Array<OneD, NekDouble> alloc(6*nqtot);
Array<OneD, NekDouble> xi(alloc);
Array<OneD, NekDouble> yi(alloc+ nqtot);
Array<OneD, NekDouble> zi(alloc+2*nqtot);
Array<OneD, NekDouble> xo(alloc+3*nqtot);
Array<OneD, NekDouble> yo(alloc+4*nqtot);
Array<OneD, NekDouble> zo(alloc+5*nqtot);
Array<OneD, NekDouble> tmp;
tri->GetCoords(xi, yi, zi);
for (i = 0; i < 3; ++i)
{
Array<OneD, NekDouble> coeffs(nodalTri->GetNcoeffs());
tri->FwdTrans(alloc+i*nqtot, coeffs);
// Apply Vandermonde matrix to project onto nodal space.
nodalTri->ModalToNodal(coeffs, tmp=alloc+(i+3)*nqtot);
}
// Now extract points from the co-ordinate arrays into the
// edge/face/volume nodes. First, extract edge-interior nodes.
for (i = 0; i < 3; ++i)
{
int pos = 3 + i*(order-1);
m_edge[i]->m_edgeNodes.clear();
for (j = 0; j < order-1; ++j)
{
m_edge[i]->m_edgeNodes.push_back(
NodeSharedPtr(new Node(0, xo[pos+j], yo[pos+j], zo[pos+j])));
}
}
// Extract face-interior nodes.
int pos = 3 + 3*(order-1);
for (i = pos; i < (order+1)*(order+2)/2; ++i)
{
m_volumeNodes.push_back(
NodeSharedPtr(new Node(0, xo[i], yo[i], zo[i])));
}
m_conf.m_order = order;
}
static ElementSharedPtr Nektar::Utilities::Triangle::create ( ElmtConfig  pConf,
std::vector< NodeSharedPtr pNodeList,
std::vector< int >  pTagList 
)
inlinestatic

Creates an instance of this class.

Definition at line 1330 of file MeshElements.h.

References Nektar::Utilities::Element::GetEdgeList().

{
ElementSharedPtr e = boost::shared_ptr<Element>(
new Triangle(pConf, pNodeList, pTagList));
vector<EdgeSharedPtr> m_edges = e->GetEdgeList();
for (int i = 0; i < m_edges.size(); ++i)
{
m_edges[i]->m_elLink.push_back(pair<ElementSharedPtr, int>(e,i));
}
return e;
}
SpatialDomains::GeometrySharedPtr Triangle::GetGeom ( int  coordDim)
virtual

Generate a Nektar++ geometry object for this element.

Reimplemented from Nektar::Utilities::Element.

Definition at line 547 of file MeshElements.cpp.

References Nektar::SpatialDomains::SegGeom::GetEdgeOrientation(), Nektar::Utilities::Element::m_edge, Nektar::Utilities::Element::m_id, and Nektar::Utilities::Element::m_vertex.

Referenced by Complete().

{
for (int i = 0; i < 3; ++i)
{
edges[i] = m_edge [i]->GetGeom(coordDim);
verts[i] = m_vertex[i]->GetGeom(coordDim);
}
StdRegions::Orientation edgeorient[3] = {
};
ret = MemoryManager<SpatialDomains::TriGeom>::
AllocateSharedPtr(m_id, verts, edges, edgeorient);
return ret;
}
unsigned int Triangle::GetNumNodes ( ElmtConfig  pConf)
static

Return the number of nodes defining a triangle.

Definition at line 574 of file MeshElements.cpp.

References Nektar::Utilities::ElmtConfig::m_faceNodes, and Nektar::Utilities::ElmtConfig::m_order.

Referenced by Nektar::Utilities::InputGmsh::GetNnodes().

{
int n = pConf.m_order;
if (!pConf.m_faceNodes)
return (n+1)+2*(n-1)+1;
else
return (n+1)*(n+2)/2;
}

Member Data Documentation

LibUtilities::ShapeType Triangle::m_type
static
Initial value:
RegisterCreatorFunction(LibUtilities::eTriangle, Triangle::create, "Triangle")

Element type.

Definition at line 1345 of file MeshElements.h.