Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | List of all members
Nektar::NekMeshUtils::HOTriangle< T > Struct Template Reference

A lightweight struct for dealing with high-order triangle alignment. More...

#include <Triangle.h>

Collaboration diagram for Nektar::NekMeshUtils::HOTriangle< T >:
Collaboration graph
[legend]

Public Member Functions

 HOTriangle (std::vector< int > pVertId, std::vector< T > pSurfVerts)
 
 HOTriangle (std::vector< int > pVertId)
 
void Rotate (int nrot)
 Rotates the triangle of data points inside surfVerts counter-clockwise nrot times. More...
 
void Reflect ()
 Reflect data points inside surfVerts. More...
 
void Align (std::vector< int > vertId)
 Align this surface to a given vertex ID. More...
 

Public Attributes

std::vector< int > vertId
 The triangle vertex IDs. More...
 
std::vector< T > surfVerts
 The triangle surface vertices – templated so that this can either be nodes or IDs. More...
 

Detailed Description

template<typename T>
struct Nektar::NekMeshUtils::HOTriangle< T >

A lightweight struct for dealing with high-order triangle alignment.

The logic underlying these routines is taken from the original Nektar code.

Definition at line 53 of file Triangle.h.

Constructor & Destructor Documentation

template<typename T>
Nektar::NekMeshUtils::HOTriangle< T >::HOTriangle ( std::vector< int >  pVertId,
std::vector< T >  pSurfVerts 
)
inline

Definition at line 55 of file Triangle.h.

56  : vertId(pVertId), surfVerts(pSurfVerts)
57  {
58  }
std::vector< T > surfVerts
The triangle surface vertices – templated so that this can either be nodes or IDs.
Definition: Triangle.h:68
std::vector< int > vertId
The triangle vertex IDs.
Definition: Triangle.h:64
template<typename T>
Nektar::NekMeshUtils::HOTriangle< T >::HOTriangle ( std::vector< int >  pVertId)
inline

Definition at line 59 of file Triangle.h.

59  : vertId(pVertId)
60  {
61  }
std::vector< int > vertId
The triangle vertex IDs.
Definition: Triangle.h:64

Member Function Documentation

template<typename T>
void Nektar::NekMeshUtils::HOTriangle< T >::Align ( std::vector< int >  vertId)
inline

Align this surface to a given vertex ID.

Definition at line 138 of file Triangle.h.

References Nektar::NekMeshUtils::HOTriangle< T >::Reflect(), and Nektar::NekMeshUtils::HOTriangle< T >::Rotate().

Referenced by Nektar::NekMeshUtils::Tetrahedron::Tetrahedron(), and Nektar::Utilities::InputGmsh::TetReordering().

139  {
140  if (vertId[0] == this->vertId[0])
141  {
142  if (vertId[1] == this->vertId[1] || vertId[1] == this->vertId[2])
143  {
144  if (vertId[1] == this->vertId[2])
145  {
146  Rotate(1);
147  Reflect();
148  }
149  }
150  }
151  else if (vertId[0] == this->vertId[1])
152  {
153  if (vertId[1] == this->vertId[0] || vertId[1] == this->vertId[2])
154  {
155  if (vertId[1] == this->vertId[0])
156  {
157  Reflect();
158  }
159  else
160  {
161  Rotate(2);
162  }
163  }
164  }
165  else if (vertId[0] == this->vertId[2])
166  {
167  if (vertId[1] == this->vertId[0] || vertId[1] == this->vertId[1])
168  {
169  if (vertId[1] == this->vertId[1])
170  {
171  Rotate(2);
172  Reflect();
173  }
174  else
175  {
176  Rotate(1);
177  }
178  }
179  }
180  }
void Rotate(int nrot)
Rotates the triangle of data points inside surfVerts counter-clockwise nrot times.
Definition: Triangle.h:76
void Reflect()
Reflect data points inside surfVerts.
Definition: Triangle.h:112
template<typename T>
void Nektar::NekMeshUtils::HOTriangle< T >::Reflect ( )
inline

Reflect data points inside surfVerts.

This applies a mapping essentially doing the following reordering:

9 9 7 8 -> 8 7 4 5 6 6 5 4 0 1 2 3 3 2 1 0

Definition at line 112 of file Triangle.h.

Referenced by Nektar::NekMeshUtils::HOTriangle< T >::Align().

113  {
114  int i, j, cnt;
115  int np = ((int)sqrt(8.0 * surfVerts.size() + 1.0) - 1) / 2;
116  std::vector<T> tmp(np * np);
117 
118  for (cnt = i = 0; i < np; ++i)
119  {
120  for (j = 0; j < np - i; ++j, cnt++)
121  {
122  tmp[i * np + np - i - 1 - j] = surfVerts[cnt];
123  }
124  }
125 
126  for (cnt = i = 0; i < np; ++i)
127  {
128  for (j = 0; j < np - i; ++j, cnt++)
129  {
130  surfVerts[cnt] = tmp[i * np + j];
131  }
132  }
133  }
std::vector< T > surfVerts
The triangle surface vertices – templated so that this can either be nodes or IDs.
Definition: Triangle.h:68
template<typename T>
void Nektar::NekMeshUtils::HOTriangle< T >::Rotate ( int  nrot)
inline

Rotates the triangle of data points inside surfVerts counter-clockwise nrot times.

Parameters
nrotNumber of times to rotate triangle.

Definition at line 76 of file Triangle.h.

Referenced by Nektar::NekMeshUtils::HOTriangle< T >::Align().

77  {
78  int n, i, j, cnt;
79  int np = ((int)sqrt(8.0 * surfVerts.size() + 1.0) - 1) / 2;
80  std::vector<T> tmp(np * np);
81 
82  for (n = 0; n < nrot; ++n)
83  {
84  for (cnt = i = 0; i < np; ++i)
85  {
86  for (j = 0; j < np - i; ++j, cnt++)
87  {
88  tmp[i * np + j] = surfVerts[cnt];
89  }
90  }
91  for (cnt = i = 0; i < np; ++i)
92  {
93  for (j = 0; j < np - i; ++j, cnt++)
94  {
95  surfVerts[cnt] = tmp[(np - 1 - i - j) * np + i];
96  }
97  }
98  }
99  }
std::vector< T > surfVerts
The triangle surface vertices – templated so that this can either be nodes or IDs.
Definition: Triangle.h:68

Member Data Documentation

template<typename T>
std::vector<T> Nektar::NekMeshUtils::HOTriangle< T >::surfVerts

The triangle surface vertices – templated so that this can either be nodes or IDs.

Definition at line 68 of file Triangle.h.

Referenced by Nektar::NekMeshUtils::Tetrahedron::Tetrahedron(), and Nektar::Utilities::InputGmsh::TetReordering().

template<typename T>
std::vector<int> Nektar::NekMeshUtils::HOTriangle< T >::vertId

The triangle vertex IDs.

Definition at line 64 of file Triangle.h.