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::NekMeshUtils::Triangle Class Reference

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

#include <Triangle.h>

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

Public Member Functions

NEKMESHUTILS_EXPORT Triangle (ElmtConfig pConf, std::vector< NodeSharedPtr > pNodeList, std::vector< int > pTagList)
 Create a triangle element. More...
 
NEKMESHUTILS_EXPORT Triangle (const Triangle &pSrc)
 
virtual NEKMESHUTILS_EXPORT ~Triangle ()
 
virtual NEKMESHUTILS_EXPORT
SpatialDomains::GeometrySharedPtr 
GetGeom (int coordDim)
 Generate a Nektar++ geometry object for this element. More...
 
virtual NEKMESHUTILS_EXPORT void Complete (int order)
 Complete this object. More...
 
- Public Member Functions inherited from Nektar::NekMeshUtils::Element
NEKMESHUTILS_EXPORT Element (ElmtConfig pConf, unsigned int pNumNodes, unsigned int pGotNodes)
 
NEKMESHUTILS_EXPORT unsigned int GetId () const
 Returns the ID of the element (or associated edge or face for boundary elements). More...
 
NEKMESHUTILS_EXPORT unsigned int GetDim () const
 Returns the expansion dimension of the element. More...
 
NEKMESHUTILS_EXPORT ElmtConfig GetConf () const
 Returns the configuration of the element. More...
 
NEKMESHUTILS_EXPORT std::string GetTag () const
 Returns the tag which defines the element shape. More...
 
NEKMESHUTILS_EXPORT NodeSharedPtr GetVertex (unsigned int i) const
 Access a vertex node. More...
 
NEKMESHUTILS_EXPORT EdgeSharedPtr GetEdge (unsigned int i) const
 Access an edge. More...
 
NEKMESHUTILS_EXPORT FaceSharedPtr GetFace (unsigned int i) const
 Access a face. More...
 
NEKMESHUTILS_EXPORT
std::vector< NodeSharedPtr
GetVertexList () const
 Access the list of vertex nodes. More...
 
NEKMESHUTILS_EXPORT
std::vector< EdgeSharedPtr
GetEdgeList () const
 Access the list of edges. More...
 
NEKMESHUTILS_EXPORT
std::vector< FaceSharedPtr
GetFaceList () const
 Access the list of faces. More...
 
NEKMESHUTILS_EXPORT
std::vector< NodeSharedPtr
GetVolumeNodes () const
 Access the list of volume nodes. More...
 
NEKMESHUTILS_EXPORT void SetVolumeNodes (std::vector< NodeSharedPtr > &nodes)
 
NEKMESHUTILS_EXPORT
LibUtilities::PointsType 
GetCurveType () const
 
NEKMESHUTILS_EXPORT void SetCurveType (LibUtilities::PointsType cT)
 
NEKMESHUTILS_EXPORT unsigned int GetNodeCount () const
 Returns the total number of nodes (vertices, edge nodes and face nodes and volume nodes). More...
 
NEKMESHUTILS_EXPORT
std::vector< int > 
GetTagList () const
 Access the list of tags associated with this element. More...
 
NEKMESHUTILS_EXPORT unsigned int GetVertexCount () const
 Returns the number of vertices. More...
 
NEKMESHUTILS_EXPORT unsigned int GetEdgeCount () const
 Returns the number of edges. More...
 
NEKMESHUTILS_EXPORT unsigned int GetFaceCount () const
 Returns the number of faces. More...
 
NEKMESHUTILS_EXPORT void SetId (unsigned int p)
 Change the ID of the element. More...
 
NEKMESHUTILS_EXPORT void SetVertex (unsigned int p, NodeSharedPtr pNew)
 Replace a vertex with another vertex object. More...
 
NEKMESHUTILS_EXPORT void SetEdge (unsigned int p, EdgeSharedPtr pNew)
 Replace an edge with another edge object. More...
 
NEKMESHUTILS_EXPORT void SetFace (unsigned int p, FaceSharedPtr pNew)
 Replace a face with another face object. More...
 
NEKMESHUTILS_EXPORT void SetEdgeLink (EdgeSharedPtr pLink)
 Set a correspondence between this element and an edge (2D boundary element). More...
 
NEKMESHUTILS_EXPORT EdgeSharedPtr GetEdgeLink ()
 Get correspondence between this element and an edge. More...
 
NEKMESHUTILS_EXPORT void SetFaceLink (FaceSharedPtr pLink)
 Set a correspondence between this element and a face (3D boundary element). More...
 
NEKMESHUTILS_EXPORT FaceSharedPtr GetFaceLink ()
 Get correspondence between this element and a face. More...
 
NEKMESHUTILS_EXPORT 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...
 
NEKMESHUTILS_EXPORT int GetBoundaryLink (int i)
 Get the location of the boundary face/edge i for this element. More...
 
NEKMESHUTILS_EXPORT void SetTagList (const std::vector< int > &tags)
 Set the list of tags associated with this element. More...
 
virtual NEKMESHUTILS_EXPORT
std::string 
GetXmlString () const
 Generate a list of vertices (1D), edges (2D), or faces (3D). More...
 
NEKMESHUTILS_EXPORT void GetCurvedNodes (std::vector< NodeSharedPtr > &nodeList) const
 
NEKMESHUTILS_EXPORT std::string GetXmlCurveString () const
 Generates a string listing the coordinates of all nodes associated with this element. More...
 
NEKMESHUTILS_EXPORT int GetMaxOrder ()
 Obtain the order of an element by looking at edges. More...
 
NEKMESHUTILS_EXPORT 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 NEKMESHUTILS_EXPORT
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::NekMeshUtils::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 186 of file Triangle.h.

Constructor & Destructor Documentation

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

Create a triangle element.

Definition at line 54 of file Triangle.cpp.

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

Referenced by create().

57  : Element(pConf, GetNumNodes(pConf), pNodeList.size())
58 {
59  m_tag = "T";
60  m_dim = 2;
61  m_taglist = pTagList;
63  int n = m_conf.m_order - 1;
64 
65  // Create a map to relate edge nodes to a pair of vertices
66  // defining an edge. This is based on the ordering produced by
67  // gmsh.
68  map<pair<int, int>, int> edgeNodeMap;
69  map<pair<int, int>, int>::iterator it;
70  edgeNodeMap[pair<int, int>(1, 2)] = 4;
71  edgeNodeMap[pair<int, int>(2, 3)] = 4 + n;
72  edgeNodeMap[pair<int, int>(3, 1)] = 4 + 2 * n;
73 
74  // Add vertices. This logic will determine (in 2D) whether the
75  // element is clockwise (sum > 0) or counter-clockwise (sum < 0).
76  NekDouble sum = 0.0;
77  for (int i = 0; i < 3; ++i)
78  {
79  int o = (i + 1) % 3;
80  m_vertex.push_back(pNodeList[i]);
81  sum += (pNodeList[o]->m_x - pNodeList[i]->m_x) *
82  (pNodeList[o]->m_y + pNodeList[i]->m_y);
83  }
84 
85  // Create edges (with corresponding set of edge points)
86  for (it = edgeNodeMap.begin(); it != edgeNodeMap.end(); ++it)
87  {
88  vector<NodeSharedPtr> edgeNodes;
89  if (m_conf.m_order > 1)
90  {
91  for (int j = it->second; j < it->second + n; ++j)
92  {
93  edgeNodes.push_back(pNodeList[j - 1]);
94  }
95  }
96  m_edge.push_back(EdgeSharedPtr(new Edge(pNodeList[it->first.first - 1],
97  pNodeList[it->first.second - 1],
98  edgeNodes,
100  }
101 
102  if (pConf.m_reorient)
103  {
104  if (sum > 0.0)
105  {
106  reverse(m_edge.begin(), m_edge.end());
107  }
108  }
109 
110  if (m_conf.m_faceNodes)
111  {
112  m_volumeNodes.insert(m_volumeNodes.begin(),
113  pNodeList.begin() + 3 * m_conf.m_order,
114  pNodeList.end());
115  }
116 }
bool m_faceNodes
Denotes whether the element contains face nodes. For 2D elements, if this is true then the element co...
Definition: Element.h:89
ElmtConfig m_conf
Contains configuration of the element.
Definition: Element.h:493
std::vector< int > m_taglist
List of integers specifying properties of the element.
Definition: Element.h:497
LibUtilities::PointsType m_edgeCurveType
Distribution of points in edges.
Definition: Element.h:101
unsigned int m_order
Order of the element.
Definition: Element.h:96
std::vector< NodeSharedPtr > m_vertex
List of element vertex nodes.
Definition: Element.h:499
unsigned int m_dim
Dimension of the element.
Definition: Element.h:491
std::vector< EdgeSharedPtr > m_edge
List of element edges.
Definition: Element.h:501
double NekDouble
std::vector< NodeSharedPtr > m_volumeNodes
List of element volume nodes.
Definition: Element.h:505
static NEKMESHUTILS_EXPORT unsigned int GetNumNodes(ElmtConfig pConf)
Return the number of nodes defining a triangle.
Definition: Triangle.cpp:144
std::string m_tag
Tag character describing the element.
Definition: Element.h:495
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: Edge.h:196
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
NEKMESHUTILS_EXPORT Element(ElmtConfig pConf, unsigned int pNumNodes, unsigned int pGotNodes)
Definition: Element.cpp:54
LibUtilities::PointsType m_curveType
Volume curve type.
Definition: Element.h:507
2D Evenly-spaced points on a Triangle
Definition: PointsType.h:70
NEKMESHUTILS_EXPORT Nektar::NekMeshUtils::Triangle::Triangle ( const Triangle pSrc)
virtual NEKMESHUTILS_EXPORT Nektar::NekMeshUtils::Triangle::~Triangle ( )
inlinevirtual

Definition at line 204 of file Triangle.h.

205  {
206  }

Member Function Documentation

void Triangle::Complete ( int  order)
virtual

Complete this object.

Reimplemented from Nektar::NekMeshUtils::Element.

Definition at line 153 of file Triangle.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::NekMeshUtils::Element::m_conf, Nektar::NekMeshUtils::Element::m_edge, Nektar::NekMeshUtils::ElmtConfig::m_faceNodes, Nektar::NekMeshUtils::ElmtConfig::m_order, Nektar::NekMeshUtils::ElmtConfig::m_volumeNodes, and Nektar::NekMeshUtils::Element::m_volumeNodes.

154 {
155  int i, j;
156 
157  // Create basis key for a nodal tetrahedron.
158  LibUtilities::BasisKey B0(
160  order + 1,
161  LibUtilities::PointsKey(order + 1,
163  LibUtilities::BasisKey B1(
165  order + 1,
166  LibUtilities::PointsKey(order + 1,
168 
169  // Create a standard nodal triangle in order to get the
170  // Vandermonde matrix to perform interpolation to nodal points.
174 
176  boost::dynamic_pointer_cast<SpatialDomains::TriGeom>(this->GetGeom(3));
177 
178  // Create basis key for a triangle.
179  LibUtilities::BasisKey C0(
181  order + 1,
182  LibUtilities::PointsKey(order + 1,
184  LibUtilities::BasisKey C1(
186  order + 1,
187  LibUtilities::PointsKey(order + 1,
189 
190  // Create a triangle.
193 
194  // Get coordinate array for tetrahedron.
195  int nqtot = tri->GetTotPoints();
196  Array<OneD, NekDouble> alloc(6 * nqtot);
197  Array<OneD, NekDouble> xi(alloc);
198  Array<OneD, NekDouble> yi(alloc + nqtot);
199  Array<OneD, NekDouble> zi(alloc + 2 * nqtot);
200  Array<OneD, NekDouble> xo(alloc + 3 * nqtot);
201  Array<OneD, NekDouble> yo(alloc + 4 * nqtot);
202  Array<OneD, NekDouble> zo(alloc + 5 * nqtot);
203  Array<OneD, NekDouble> tmp;
204 
205  tri->GetCoords(xi, yi, zi);
206 
207  for (i = 0; i < 3; ++i)
208  {
209  Array<OneD, NekDouble> coeffs(nodalTri->GetNcoeffs());
210  tri->FwdTrans(alloc + i * nqtot, coeffs);
211  // Apply Vandermonde matrix to project onto nodal space.
212  nodalTri->ModalToNodal(coeffs, tmp = alloc + (i + 3) * nqtot);
213  }
214 
215  // Now extract points from the co-ordinate arrays into the
216  // edge/face/volume nodes. First, extract edge-interior nodes.
217  for (i = 0; i < 3; ++i)
218  {
219  int pos = 3 + i * (order - 1);
220  m_edge[i]->m_edgeNodes.clear();
221  for (j = 0; j < order - 1; ++j)
222  {
223  m_edge[i]->m_edgeNodes.push_back(NodeSharedPtr(
224  new Node(0, xo[pos + j], yo[pos + j], zo[pos + j])));
225  }
226  }
227 
228  // Extract face-interior nodes.
229  int pos = 3 + 3 * (order - 1);
230  for (i = pos; i < (order + 1) * (order + 2) / 2; ++i)
231  {
232  m_volumeNodes.push_back(
233  NodeSharedPtr(new Node(0, xo[i], yo[i], zo[i])));
234  }
235 
236  m_conf.m_order = order;
237  m_conf.m_faceNodes = true;
238  m_conf.m_volumeNodes = true;
239 }
bool m_faceNodes
Denotes whether the element contains face nodes. For 2D elements, if this is true then the element co...
Definition: Element.h:89
virtual NEKMESHUTILS_EXPORT SpatialDomains::GeometrySharedPtr GetGeom(int coordDim)
Generate a Nektar++ geometry object for this element.
Definition: Triangle.cpp:118
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
ElmtConfig m_conf
Contains configuration of the element.
Definition: Element.h:493
boost::shared_ptr< StdNodalTriExp > StdNodalTriExpSharedPtr
Gauss Radau pinned at x=-1, .
Definition: PointsType.h:57
unsigned int m_order
Order of the element.
Definition: Element.h:96
Principle Orthogonal Functions .
Definition: BasisType.h:47
bool m_volumeNodes
Denotes whether the element contains volume (i.e. interior) nodes. These are not supported by either ...
Definition: Element.h:94
std::vector< EdgeSharedPtr > m_edge
List of element edges.
Definition: Element.h:501
boost::shared_ptr< Node > NodeSharedPtr
Definition: Node.h:50
Principle Orthogonal Functions .
Definition: BasisType.h:46
std::vector< NodeSharedPtr > m_volumeNodes
List of element volume nodes.
Definition: Element.h:505
boost::shared_ptr< TriGeom > TriGeomSharedPtr
Definition: TriGeom.h:58
2D Evenly-spaced points on a Triangle
Definition: PointsType.h:70
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:50
boost::shared_ptr< TriExp > TriExpSharedPtr
Definition: TriExp.h:291
static ElementSharedPtr Nektar::NekMeshUtils::Triangle::create ( ElmtConfig  pConf,
std::vector< NodeSharedPtr pNodeList,
std::vector< int >  pTagList 
)
inlinestatic

Creates an instance of this class.

Definition at line 190 of file Triangle.h.

References Triangle().

193  {
194  return boost::shared_ptr<Element>(
195  new Triangle(pConf, pNodeList, pTagList));
196  }
NEKMESHUTILS_EXPORT Triangle(ElmtConfig pConf, std::vector< NodeSharedPtr > pNodeList, std::vector< int > pTagList)
Create a triangle element.
Definition: Triangle.cpp:54
SpatialDomains::GeometrySharedPtr Triangle::GetGeom ( int  coordDim)
virtual

Generate a Nektar++ geometry object for this element.

Reimplemented from Nektar::NekMeshUtils::Element.

Definition at line 118 of file Triangle.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::SpatialDomains::SegGeom::GetEdgeOrientation(), Nektar::NekMeshUtils::Element::m_edge, Nektar::NekMeshUtils::Element::m_id, and Nektar::NekMeshUtils::Element::m_vertex.

Referenced by Complete().

119 {
123 
124  for (int i = 0; i < 3; ++i)
125  {
126  edges[i] = m_edge[i]->GetGeom(coordDim);
127  verts[i] = m_vertex[i]->GetGeom(coordDim);
128  }
129 
130  StdRegions::Orientation edgeorient[3] = {
131  SpatialDomains::SegGeom::GetEdgeOrientation(*edges[0], *edges[1]),
132  SpatialDomains::SegGeom::GetEdgeOrientation(*edges[1], *edges[2]),
133  SpatialDomains::SegGeom::GetEdgeOrientation(*edges[2], *edges[0])};
134 
136  m_id, verts, edges, edgeorient);
137 
138  return ret;
139 }
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
std::vector< NodeSharedPtr > m_vertex
List of element vertex nodes.
Definition: Element.h:499
boost::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:60
std::vector< EdgeSharedPtr > m_edge
List of element edges.
Definition: Element.h:501
unsigned int m_id
ID of the element.
Definition: Element.h:489
boost::shared_ptr< TriGeom > TriGeomSharedPtr
Definition: TriGeom.h:58
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 144 of file Triangle.cpp.

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

145 {
146  int n = pConf.m_order;
147  if (!pConf.m_faceNodes)
148  return (n + 1) + 2 * (n - 1) + 1;
149  else
150  return (n + 1) * (n + 2) / 2;
151 }

Member Data Documentation

LibUtilities::ShapeType Triangle::m_type
static
Initial value:

Element type.

Definition at line 198 of file Triangle.h.