Nektar++
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:
[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 GetCurvedNodes (std::vector< NodeSharedPtr > &nodeList) const
 get list of volume interior nodes More...
 
virtual NEKMESHUTILS_EXPORT StdRegions::Orientation GetEdgeOrient (int edgeId, EdgeSharedPtr edge)
 Get the edge orientation of edge with respect to the local element, which lies at edge index edgeId. More...
 
virtual NEKMESHUTILS_EXPORT void MakeOrder (int order, SpatialDomains::GeometrySharedPtr geom, LibUtilities::PointsType pType, int coordDim, int &id, bool justConfig=false)
 Insert interior (i.e. volume) points into this element to make the geometry an order order representation. More...
 
NEKMESHUTILS_EXPORT Array< OneD, NekDoubleNormal (bool inward=false)
 returns the normal to the element 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 LibUtilities::ShapeType GetShapeType () const
 returns the shapetype 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< NodeSharedPtrGetVertexList () const
 Access the list of vertex nodes. More...
 
NEKMESHUTILS_EXPORT std::vector< EdgeSharedPtrGetEdgeList () const
 Access the list of edges. More...
 
NEKMESHUTILS_EXPORT std::vector< FaceSharedPtrGetFaceList () const
 Access the list of faces. More...
 
NEKMESHUTILS_EXPORT std::vector< NodeSharedPtrGetVolumeNodes () 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 ()
 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, bool descend=true)
 Replace a vertex in the element. More...
 
NEKMESHUTILS_EXPORT void SetEdge (unsigned int p, EdgeSharedPtr pNew, bool descend=true)
 Replace an edge in the element. More...
 
NEKMESHUTILS_EXPORT void SetFace (unsigned int p, FaceSharedPtr pNew)
 Replace a face in the element. 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 bool HasBoundaryLinks ()
 Is this element connected to a boundary. 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 ()
 Generate a list of vertices (1D), edges (2D), or faces (3D). More...
 
NEKMESHUTILS_EXPORT std::string GetXmlCurveString ()
 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 bool IsDeformed ()
 Determines whether an element is deformed by inspecting whether there are any edge, face or volume interior nodes. More...
 
NEKMESHUTILS_EXPORT std::pair< Node, NodeGetBoundingBox ()
 Returns the approximate bounding box of this element based on the coordinates of all vertices, edges and faces of the element. Note that this does not robustly take into account the curvature of the element. More...
 
virtual NEKMESHUTILS_EXPORT int GetFaceVertex (int i, int j)
 Returns the local index of vertex j of face i. 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

- Public Attributes inherited from Nektar::NekMeshUtils::Element
CADObjectSharedPtr m_parentCAD
 
- 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 50 of file Triangle.h.

Constructor & Destructor Documentation

◆ Triangle() [1/2]

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

Create a triangle element.

Definition at line 55 of file Triangle.cpp.

References Nektar::LibUtilities::eNodalTriEvenlySpaced, 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.

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

◆ Triangle() [2/2]

NEKMESHUTILS_EXPORT Nektar::NekMeshUtils::Triangle::Triangle ( const Triangle pSrc)

◆ ~Triangle()

virtual NEKMESHUTILS_EXPORT Nektar::NekMeshUtils::Triangle::~Triangle ( )
inlinevirtual

Definition at line 67 of file Triangle.h.

References GetCurvedNodes(), GetEdgeOrient(), GetGeom(), GetNumNodes(), MakeOrder(), NEKMESHUTILS_EXPORT, and Normal().

68  {
69  }

Member Function Documentation

◆ create()

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 54 of file Triangle.h.

57  {
58  return std::make_shared<Triangle>(pConf, pNodeList, pTagList);
59  }

◆ GetCurvedNodes()

void Nektar::NekMeshUtils::Triangle::GetCurvedNodes ( std::vector< NodeSharedPtr > &  nodeList) const
virtual

get list of volume interior nodes

Reimplemented from Nektar::NekMeshUtils::Element.

Definition at line 168 of file Triangle.cpp.

References CellMLToNektar.pycml::copy(), Nektar::NekMeshUtils::Element::m_edge, Nektar::NekMeshUtils::Element::m_vertex, and Nektar::NekMeshUtils::Element::m_volumeNodes.

Referenced by ~Triangle().

169 {
170  int n = m_edge[0]->GetNodeCount();
171  nodeList.resize(n * (n + 1) / 2);
172 
173  // Populate nodelist
174  std::copy(m_vertex.begin(), m_vertex.end(), nodeList.begin());
175  for (int i = 0; i < 3; ++i)
176  {
177  std::copy(m_edge[i]->m_edgeNodes.begin(),
178  m_edge[i]->m_edgeNodes.end(),
179  nodeList.begin() + 3 + i * (n - 2));
180  if (m_edge[i]->m_n1 != m_vertex[i])
181  {
182  // If edge orientation is reversed relative to node ordering, we
183  // need to reverse order of nodes.
184  std::reverse(nodeList.begin() + 3 + i * (n - 2),
185  nodeList.begin() + 3 + (i + 1) * (n - 2));
186  }
187  }
188 
189  // Copy volume nodes.
190  std::copy(m_volumeNodes.begin(),
191  m_volumeNodes.end(),
192  nodeList.begin() + 3 * (n - 1));
193 }
def copy(self)
Definition: pycml.py:2663
std::vector< NodeSharedPtr > m_vertex
List of element vertex nodes.
Definition: Element.h:468
std::vector< EdgeSharedPtr > m_edge
List of element edges.
Definition: Element.h:470
std::vector< NodeSharedPtr > m_volumeNodes
List of element volume nodes.
Definition: Element.h:474

◆ GetEdgeOrient()

StdRegions::Orientation Nektar::NekMeshUtils::Triangle::GetEdgeOrient ( int  edgeId,
EdgeSharedPtr  edge 
)
virtual

Get the edge orientation of edge with respect to the local element, which lies at edge index edgeId.

Reimplemented from Nektar::NekMeshUtils::Element.

Definition at line 137 of file Triangle.cpp.

References ASSERTL1, Nektar::StdRegions::eBackwards, Nektar::StdRegions::eForwards, Nektar::StdRegions::eNoOrientation, and Nektar::NekMeshUtils::Element::m_vertex.

Referenced by ~Triangle().

138 {
139  int locVert = edgeId;
140  if (edge->m_n1 == m_vertex[locVert])
141  {
142  return StdRegions::eForwards;
143  }
144  else if (edge->m_n2 == m_vertex[locVert])
145  {
146  return StdRegions::eBackwards;
147  }
148  else
149  {
150  ASSERTL1(false, "Edge is not connected to this triangle.");
151  }
152 
154 }
std::vector< NodeSharedPtr > m_vertex
List of element vertex nodes.
Definition: Element.h:468
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250

◆ GetGeom()

SpatialDomains::GeometrySharedPtr Nektar::NekMeshUtils::Triangle::GetGeom ( int  coordDim)
virtual

Generate a Nektar++ geometry object for this element.

Reimplemented from Nektar::NekMeshUtils::Element.

Definition at line 120 of file Triangle.cpp.

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

Referenced by ~Triangle().

121 {
124 
125  for (int i = 0; i < 3; ++i)
126  {
127  edges[i] = m_edge[i]->GetGeom(coordDim);
128  }
129 
131  m_id, edges);
132  ret->Setup();
133 
134  return ret;
135 }
std::shared_ptr< TriGeom > TriGeomSharedPtr
Definition: TriGeom.h:58
std::vector< EdgeSharedPtr > m_edge
List of element edges.
Definition: Element.h:470
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
unsigned int m_id
ID of the element.
Definition: Element.h:458
std::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:62

◆ GetNumNodes()

unsigned int Nektar::NekMeshUtils::Triangle::GetNumNodes ( ElmtConfig  pConf)
static

Return the number of nodes defining a triangle.

Definition at line 159 of file Triangle.cpp.

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

Referenced by Nektar::Utilities::InputGmsh::GetNnodes(), and ~Triangle().

160 {
161  int n = pConf.m_order;
162  if (!pConf.m_faceNodes)
163  return (n + 1) + 2 * (n - 1) + 1;
164  else
165  return (n + 1) * (n + 2) / 2;
166 }

◆ MakeOrder()

void Nektar::NekMeshUtils::Triangle::MakeOrder ( int  order,
SpatialDomains::GeometrySharedPtr  geom,
LibUtilities::PointsType  edgeType,
int  coordDim,
int &  id,
bool  justConfig = false 
)
virtual

Insert interior (i.e. volume) points into this element to make the geometry an order order representation.

Parameters
orderThe desired polynomial order.
geomThe geometry object used to describe the curvature mapping.
edgeTypeThe points distribution to use on the volume.
coordDimThe coordinate (i.e. space) dimension.
idCounter which should be incremented to supply consistent vertex IDs.
justConfigIf true, then the configuration Element::m_conf will be updated but no nodes will be generated. This is used when considering boundary elements, which just require copying of face or edge interior nodes.

Reimplemented from Nektar::NekMeshUtils::Element.

Definition at line 195 of file Triangle.cpp.

References ASSERTL1, Nektar::LibUtilities::PointsKey::GetPointsDim(), Nektar::NekMeshUtils::Element::m_conf, Nektar::NekMeshUtils::Element::m_curveType, Nektar::NekMeshUtils::ElmtConfig::m_faceNodes, Nektar::NekMeshUtils::ElmtConfig::m_order, Nektar::NekMeshUtils::ElmtConfig::m_volumeNodes, Nektar::NekMeshUtils::Element::m_volumeNodes, class_topology::Node, and Nektar::LibUtilities::PointsManager().

Referenced by ~Triangle().

202 {
203  m_conf.m_order = order;
204  m_curveType = pType;
205  m_conf.m_volumeNodes = false;
206  m_volumeNodes.clear();
207 
208  // Triangles of order < 3 have no interior volume points.
209  if (order == 1 || order == 2)
210  {
211  m_conf.m_faceNodes = false;
212  return;
213  }
214 
215  m_conf.m_faceNodes = true;
216 
217  if (justConfig)
218  {
219  return;
220  }
221 
222  int nPoints = order + 1;
223  StdRegions::StdExpansionSharedPtr xmap = geom->GetXmap();
224 
225  Array<OneD, NekDouble> px, py;
226  LibUtilities::PointsKey pKey(nPoints, pType);
227  ASSERTL1(pKey.GetPointsDim() == 2, "Points distribution must be 2D");
228  LibUtilities::PointsManager()[pKey]->GetPoints(px, py);
229 
230  Array<OneD, Array<OneD, NekDouble> > phys(coordDim);
231 
232  for (int i = 0; i < coordDim; ++i)
233  {
234  phys[i] = Array<OneD, NekDouble>(xmap->GetTotPoints());
235  xmap->BwdTrans(geom->GetCoeffs(i), phys[i]);
236  }
237 
238  const int nTriPts = nPoints * (nPoints + 1) / 2;
239  const int nTriIntPts = (nPoints - 3) * (nPoints - 2) / 2;
240  m_volumeNodes.resize(nTriIntPts);
241 
242  for (int i = 3 + 3*(nPoints-2), cnt = 0; i < nTriPts; ++i, ++cnt)
243  {
244  Array<OneD, NekDouble> xp(2);
245  xp[0] = px[i];
246  xp[1] = py[i];
247 
248  Array<OneD, NekDouble> x(3, 0.0);
249  for (int j = 0; j < coordDim; ++j)
250  {
251  x[j] = xmap->PhysEvaluate(xp, phys[j]);
252  }
253 
254  m_volumeNodes[cnt] = std::shared_ptr<Node>(
255  new Node(id++, x[0], x[1], x[2]));
256  }
257 
258  m_conf.m_order = order;
259  m_conf.m_faceNodes = true;
260  m_conf.m_volumeNodes = false;
261 }
bool m_faceNodes
Denotes whether the element contains face nodes. For 2D elements, if this is true then the element co...
Definition: ElementConfig.h:81
ElmtConfig m_conf
Contains configuration of the element.
Definition: Element.h:462
unsigned int m_order
Order of the element.
Definition: ElementConfig.h:88
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
bool m_volumeNodes
Denotes whether the element contains volume (i.e. interior) nodes. These are not supported by either ...
Definition: ElementConfig.h:86
PointsManagerT & PointsManager(void)
std::vector< NodeSharedPtr > m_volumeNodes
List of element volume nodes.
Definition: Element.h:474
LibUtilities::PointsType m_curveType
Volume curve type.
Definition: Element.h:476
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250

◆ Normal()

Array< OneD, NekDouble > Nektar::NekMeshUtils::Triangle::Normal ( bool  inward = false)
virtual

returns the normal to the element

Reimplemented from Nektar::NekMeshUtils::Element.

Definition at line 263 of file Triangle.cpp.

References Nektar::NekMeshUtils::CADOrientation::eBackwards, Nektar::NekMeshUtils::Element::m_parentCAD, and Nektar::NekMeshUtils::Element::m_vertex.

Referenced by ~Triangle().

264 {
265  Array<OneD, NekDouble> ret(3,0.0);
266 
267  ret[0] = (m_vertex[1]->m_y - m_vertex[0]->m_y) * (m_vertex[2]->m_z - m_vertex[0]->m_z) -
268  (m_vertex[1]->m_z - m_vertex[0]->m_z) * (m_vertex[2]->m_y - m_vertex[0]->m_y);
269  ret[1] = (m_vertex[1]->m_z - m_vertex[0]->m_z) * (m_vertex[2]->m_x - m_vertex[0]->m_x) -
270  (m_vertex[1]->m_x - m_vertex[0]->m_x) * (m_vertex[2]->m_z - m_vertex[0]->m_z);
271  ret[2] = (m_vertex[1]->m_x - m_vertex[0]->m_x) * (m_vertex[2]->m_y - m_vertex[0]->m_y) -
272  (m_vertex[1]->m_y - m_vertex[0]->m_y) * (m_vertex[2]->m_x - m_vertex[0]->m_x);
273 
274  NekDouble mt = ret[0] * ret[0] + ret[1] * ret[1] + ret[2] * ret[2];
275  mt = sqrt(mt);
276 
277  ret[0] /= mt;
278  ret[1] /= mt;
279  ret[2] /= mt;
280 
281  if(m_parentCAD)
282  {
283  //has cad so can orientate based on that
284  if(m_parentCAD->Orientation() == CADOrientation::eBackwards)
285  {
286  ret[0] *= -1.0;
287  ret[1] *= -1.0;
288  ret[2] *= -1.0;
289  }
290 
291  //by default normals point outwards so if we want inward for BLs
292  if(inward)
293  {
294  ret[0] *= -1.0;
295  ret[1] *= -1.0;
296  ret[2] *= -1.0;
297  }
298  }
299  return ret;
300 }
CADObjectSharedPtr m_parentCAD
Definition: Element.h:454
std::vector< NodeSharedPtr > m_vertex
List of element vertex nodes.
Definition: Element.h:468
double NekDouble

Member Data Documentation

◆ m_type

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

Element type.

Definition at line 61 of file Triangle.h.