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

Static Public Attributes

static LibUtilities::ShapeType m_type
 Element type. More...
 

Additional Inherited Members

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

Detailed Description

A 2-dimensional three-sided element.

Definition at line 1346 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.

489  : Element(pConf, GetNumNodes(pConf), pNodeList.size())
490  {
491  m_tag = "T";
492  m_dim = 2;
493  m_taglist = pTagList;
495  int n = m_conf.m_order-1;
496 
497  // Create a map to relate edge nodes to a pair of vertices
498  // defining an edge. This is based on the ordering produced by
499  // gmsh.
500  map<pair<int,int>, int> edgeNodeMap;
501  map<pair<int,int>, int>::iterator it;
502  edgeNodeMap[pair<int,int>(1,2)] = 4;
503  edgeNodeMap[pair<int,int>(2,3)] = 4 + n;
504  edgeNodeMap[pair<int,int>(3,1)] = 4 + 2*n;
505 
506  // Add vertices. This logic will determine (in 2D) whether the
507  // element is clockwise (sum > 0) or counter-clockwise (sum < 0).
508  NekDouble sum = 0.0;
509  for (int i = 0; i < 3; ++i) {
510  int o = (i+1) % 3;
511  m_vertex.push_back(pNodeList[i]);
512  sum += (pNodeList[o]->m_x - pNodeList[i]->m_x) *
513  (pNodeList[o]->m_y + pNodeList[i]->m_y);
514  }
515 
516  // Create edges (with corresponding set of edge points)
517  for (it = edgeNodeMap.begin(); it != edgeNodeMap.end(); ++it)
518  {
519  vector<NodeSharedPtr> edgeNodes;
520  if (m_conf.m_order > 1) {
521  for (int j = it->second; j < it->second + n; ++j) {
522  edgeNodes.push_back(pNodeList[j-1]);
523  }
524  }
525  m_edge.push_back(EdgeSharedPtr(new Edge(pNodeList[it->first.first-1],
526  pNodeList[it->first.second-1],
527  edgeNodes,
529  }
530 
531  if (pConf.m_reorient)
532  {
533  if (sum > 0.0)
534  {
535  reverse(m_edge.begin(), m_edge.end());
536  }
537  }
538 
539  if (m_conf.m_faceNodes)
540  {
541  m_volumeNodes.insert(m_volumeNodes.begin(),
542  pNodeList.begin()+3*m_conf.m_order,
543  pNodeList.end());
544  }
545  }
LibUtilities::PointsType m_curveType
Volume curve type.
Definition: MeshElements.h:994
std::vector< NodeSharedPtr > m_volumeNodes
List of element volume nodes.
Definition: MeshElements.h:992
std::vector< int > m_taglist
List of integers specifying properties of the element.
Definition: MeshElements.h:984
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: MeshElements.h:318
unsigned int m_order
Order of the element.
Definition: MeshElements.h:629
bool m_faceNodes
Denotes whether the element contains face nodes. For 2D elements, if this is true then the element co...
Definition: MeshElements.h:622
double NekDouble
std::string m_tag
Tag character describing the element.
Definition: MeshElements.h:982
unsigned int m_dim
Dimension of the element.
Definition: MeshElements.h:978
LibUtilities::PointsType m_edgeCurveType
Distribution of points in edges.
Definition: MeshElements.h:634
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
std::vector< NodeSharedPtr > m_vertex
List of element vertex nodes.
Definition: MeshElements.h:986
2D Evenly-spaced points on a Triangle
Definition: PointsType.h:70
std::vector< EdgeSharedPtr > m_edge
List of element edges.
Definition: MeshElements.h:988
static unsigned int GetNumNodes(ElmtConfig pConf)
Return the number of nodes defining a triangle.
Element(ElmtConfig pConf, unsigned int pNumNodes, unsigned int pGotNodes)
ElmtConfig m_conf
Contains configuration of the element.
Definition: MeshElements.h:980
Nektar::Utilities::Triangle::Triangle ( const Triangle pSrc)
virtual Nektar::Utilities::Triangle::~Triangle ( )
inlinevirtual

Definition at line 1370 of file MeshElements.h.

1370 {}

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::MemoryManager< DataType >::AllocateSharedPtr(), 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.

584  {
585  int i, j;
586 
587  // Create basis key for a nodal tetrahedron.
588  LibUtilities::BasisKey B0(
589  LibUtilities::eOrtho_A, order+1,
590  LibUtilities::PointsKey(
592  LibUtilities::BasisKey B1(
593  LibUtilities::eOrtho_B, order+1,
594  LibUtilities::PointsKey(
596 
597  // Create a standard nodal triangle in order to get the
598  // Vandermonde matrix to perform interpolation to nodal points.
602 
604  boost::dynamic_pointer_cast<SpatialDomains::TriGeom>(
605  this->GetGeom(3));
606 
607  // Create basis key for a triangle.
608  LibUtilities::BasisKey C0(
609  LibUtilities::eOrtho_A, order+1,
610  LibUtilities::PointsKey(
612  LibUtilities::BasisKey C1(
613  LibUtilities::eOrtho_B, order+1,
614  LibUtilities::PointsKey(
616 
617  // Create a triangle.
620  C0, C1, geom);
621 
622  // Get coordinate array for tetrahedron.
623  int nqtot = tri->GetTotPoints();
624  Array<OneD, NekDouble> alloc(6*nqtot);
625  Array<OneD, NekDouble> xi(alloc);
626  Array<OneD, NekDouble> yi(alloc+ nqtot);
627  Array<OneD, NekDouble> zi(alloc+2*nqtot);
628  Array<OneD, NekDouble> xo(alloc+3*nqtot);
629  Array<OneD, NekDouble> yo(alloc+4*nqtot);
630  Array<OneD, NekDouble> zo(alloc+5*nqtot);
631  Array<OneD, NekDouble> tmp;
632 
633  tri->GetCoords(xi, yi, zi);
634 
635  for (i = 0; i < 3; ++i)
636  {
637  Array<OneD, NekDouble> coeffs(nodalTri->GetNcoeffs());
638  tri->FwdTrans(alloc+i*nqtot, coeffs);
639  // Apply Vandermonde matrix to project onto nodal space.
640  nodalTri->ModalToNodal(coeffs, tmp=alloc+(i+3)*nqtot);
641  }
642 
643  // Now extract points from the co-ordinate arrays into the
644  // edge/face/volume nodes. First, extract edge-interior nodes.
645  for (i = 0; i < 3; ++i)
646  {
647  int pos = 3 + i*(order-1);
648  m_edge[i]->m_edgeNodes.clear();
649  for (j = 0; j < order-1; ++j)
650  {
651  m_edge[i]->m_edgeNodes.push_back(
652  NodeSharedPtr(new Node(0, xo[pos+j], yo[pos+j], zo[pos+j])));
653  }
654  }
655 
656  // Extract face-interior nodes.
657  int pos = 3 + 3*(order-1);
658  for (i = pos; i < (order+1)*(order+2)/2; ++i)
659  {
660  m_volumeNodes.push_back(
661  NodeSharedPtr(new Node(0, xo[i], yo[i], zo[i])));
662  }
663 
664  m_conf.m_order = order;
665  m_conf.m_faceNodes = true;
666  m_conf.m_volumeNodes = true;
667  }
bool m_volumeNodes
Denotes whether the element contains volume (i.e. interior) nodes. These are not supported by either ...
Definition: MeshElements.h:627
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
std::vector< NodeSharedPtr > m_volumeNodes
List of element volume nodes.
Definition: MeshElements.h:992
boost::shared_ptr< Node > NodeSharedPtr
Shared pointer to a Node.
Definition: MeshElements.h:195
boost::shared_ptr< StdNodalTriExp > StdNodalTriExpSharedPtr
Gauss Radau pinned at x=-1, .
Definition: PointsType.h:57
Principle Orthogonal Functions .
Definition: BasisType.h:47
unsigned int m_order
Order of the element.
Definition: MeshElements.h:629
bool m_faceNodes
Denotes whether the element contains face nodes. For 2D elements, if this is true then the element co...
Definition: MeshElements.h:622
Principle Orthogonal Functions .
Definition: BasisType.h:46
virtual SpatialDomains::GeometrySharedPtr GetGeom(int coordDim)
Generate a Nektar++ geometry object for this element.
boost::shared_ptr< TriGeom > TriGeomSharedPtr
Definition: TriGeom.h:58
2D Evenly-spaced points on a Triangle
Definition: PointsType.h:70
std::vector< EdgeSharedPtr > m_edge
List of element edges.
Definition: MeshElements.h:988
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:50
boost::shared_ptr< TriExp > TriExpSharedPtr
Definition: TriExp.h:283
ElmtConfig m_conf
Contains configuration of the element.
Definition: MeshElements.h:980
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 1349 of file MeshElements.h.

1353  {
1354  ElementSharedPtr e = boost::shared_ptr<Element>(
1355  new Triangle(pConf, pNodeList, pTagList));
1356  vector<EdgeSharedPtr> m_edges = e->GetEdgeList();
1357  for (int i = 0; i < m_edges.size(); ++i)
1358  {
1359  m_edges[i]->m_elLink.push_back(pair<ElementSharedPtr, int>(e,i));
1360  }
1361  return e;
1362  }
boost::shared_ptr< Element > ElementSharedPtr
Shared pointer to an element.
Definition: MeshElements.h:63
Triangle(ElmtConfig pConf, std::vector< NodeSharedPtr > pNodeList, std::vector< int > pTagList)
Create a triangle element.
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::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::SpatialDomains::SegGeom::GetEdgeOrientation(), Nektar::Utilities::Element::m_edge, Nektar::Utilities::Element::m_id, and Nektar::Utilities::Element::m_vertex.

Referenced by Complete().

548  {
552 
553  for (int i = 0; i < 3; ++i)
554  {
555  edges[i] = m_edge [i]->GetGeom(coordDim);
556  verts[i] = m_vertex[i]->GetGeom(coordDim);
557  }
558 
559  StdRegions::Orientation edgeorient[3] = {
560  SpatialDomains::SegGeom::GetEdgeOrientation(*edges[0], *edges[1]),
561  SpatialDomains::SegGeom::GetEdgeOrientation(*edges[1], *edges[2]),
562  SpatialDomains::SegGeom::GetEdgeOrientation(*edges[2], *edges[0])
563  };
564 
566  AllocateSharedPtr(m_id, verts, edges, edgeorient);
567 
568  return ret;
569  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
static StdRegions::Orientation GetEdgeOrientation(const SegGeom &edge1, const SegGeom &edge2)
Get the orientation of edge1.
Definition: SegGeom.cpp:293
boost::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:60
unsigned int m_id
ID of the element.
Definition: MeshElements.h:976
std::vector< NodeSharedPtr > m_vertex
List of element vertex nodes.
Definition: MeshElements.h:986
boost::shared_ptr< TriGeom > TriGeomSharedPtr
Definition: TriGeom.h:58
std::vector< EdgeSharedPtr > m_edge
List of element edges.
Definition: MeshElements.h:988
boost::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:60
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().

575  {
576  int n = pConf.m_order;
577  if (!pConf.m_faceNodes)
578  return (n+1)+2*(n-1)+1;
579  else
580  return (n+1)*(n+2)/2;
581  }

Member Data Documentation

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

Element type.

Definition at line 1364 of file MeshElements.h.