Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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 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, NekDouble
Normal (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< 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 ()
 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 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...
 
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 51 of file MeshElements/Triangle.h.

Constructor & Destructor Documentation

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

Create a triangle element.

Definition at line 56 of file MeshElements/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().

59  : Element(pConf, GetNumNodes(pConf), pNodeList.size())
60 {
61  m_tag = "T";
62  m_dim = 2;
63  m_taglist = pTagList;
65  int n = m_conf.m_order - 1;
66 
67  // Create a map to relate edge nodes to a pair of vertices
68  // defining an edge. This is based on the ordering produced by
69  // gmsh.
70  map<pair<int, int>, int> edgeNodeMap;
71  map<pair<int, int>, int>::iterator it;
72  edgeNodeMap[pair<int, int>(1, 2)] = 4;
73  edgeNodeMap[pair<int, int>(2, 3)] = 4 + n;
74  edgeNodeMap[pair<int, int>(3, 1)] = 4 + 2 * n;
75 
76  // Add vertices. This logic will determine (in 2D) whether the
77  // element is clockwise (sum > 0) or counter-clockwise (sum < 0).
78  NekDouble sum = 0.0;
79  for (int i = 0; i < 3; ++i)
80  {
81  int o = (i + 1) % 3;
82  m_vertex.push_back(pNodeList[i]);
83  sum += (pNodeList[o]->m_x - pNodeList[i]->m_x) *
84  (pNodeList[o]->m_y + pNodeList[i]->m_y);
85  }
86 
87  // Create edges (with corresponding set of edge points)
88  for (it = edgeNodeMap.begin(); it != edgeNodeMap.end(); ++it)
89  {
90  vector<NodeSharedPtr> edgeNodes;
91  if (m_conf.m_order > 1)
92  {
93  for (int j = it->second; j < it->second + n; ++j)
94  {
95  edgeNodes.push_back(pNodeList[j - 1]);
96  }
97  }
98  m_edge.push_back(EdgeSharedPtr(new Edge(pNodeList[it->first.first - 1],
99  pNodeList[it->first.second - 1],
100  edgeNodes,
102  }
103 
104  if (pConf.m_reorient)
105  {
106  if (sum > 0.0)
107  {
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:80
ElmtConfig m_conf
Contains configuration of the element.
Definition: Element.h:380
std::vector< int > m_taglist
List of integers specifying properties of the element.
Definition: Element.h:384
LibUtilities::PointsType m_edgeCurveType
Distribution of points in edges.
Definition: ElementConfig.h:92
unsigned int m_order
Order of the element.
Definition: ElementConfig.h:87
std::vector< NodeSharedPtr > m_vertex
List of element vertex nodes.
Definition: Element.h:386
unsigned int m_dim
Dimension of the element.
Definition: Element.h:378
std::vector< EdgeSharedPtr > m_edge
List of element edges.
Definition: Element.h:388
double NekDouble
std::vector< NodeSharedPtr > m_volumeNodes
List of element volume nodes.
Definition: Element.h:392
static NEKMESHUTILS_EXPORT unsigned int GetNumNodes(ElmtConfig pConf)
Return the number of nodes defining a triangle.
std::string m_tag
Tag character describing the element.
Definition: Element.h:382
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: Edge.h:136
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:394
2D Evenly-spaced points on a Triangle
Definition: PointsType.h:72
NEKMESHUTILS_EXPORT Nektar::NekMeshUtils::Triangle::Triangle ( const Triangle pSrc)
virtual NEKMESHUTILS_EXPORT Nektar::NekMeshUtils::Triangle::~Triangle ( )
inlinevirtual

Definition at line 69 of file MeshElements/Triangle.h.

70  {
71  }

Member Function Documentation

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 55 of file MeshElements/Triangle.h.

References Triangle().

58  {
59  return boost::shared_ptr<Element>(
60  new Triangle(pConf, pNodeList, pTagList));
61  }
NEKMESHUTILS_EXPORT Triangle(ElmtConfig pConf, std::vector< NodeSharedPtr > pNodeList, std::vector< int > pTagList)
Create a triangle element.
void Triangle::GetCurvedNodes ( std::vector< NodeSharedPtr > &  nodeList) const
virtual

get list of volume interior nodes

Reimplemented from Nektar::NekMeshUtils::Element.

Definition at line 174 of file MeshElements/Triangle.cpp.

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

175 {
176  int n = m_edge[0]->GetNodeCount();
177  nodeList.resize(n * (n + 1) / 2);
178 
179  // Populate nodelist
180  std::copy(m_vertex.begin(), m_vertex.end(), nodeList.begin());
181  for (int i = 0; i < 3; ++i)
182  {
183  std::copy(m_edge[i]->m_edgeNodes.begin(),
184  m_edge[i]->m_edgeNodes.end(),
185  nodeList.begin() + 3 + i * (n - 2));
186  if (m_edge[i]->m_n1 != m_vertex[i])
187  {
188  // If edge orientation is reversed relative to node ordering, we
189  // need to reverse order of nodes.
190  std::reverse(nodeList.begin() + 3 + i * (n - 2),
191  nodeList.begin() + 3 + (i + 1) * (n - 2));
192  }
193  }
194 
195  // Copy volume nodes.
196  std::copy(m_volumeNodes.begin(),
197  m_volumeNodes.end(),
198  nodeList.begin() + 3 * (n - 1));
199 }
std::vector< NodeSharedPtr > m_vertex
List of element vertex nodes.
Definition: Element.h:386
std::vector< EdgeSharedPtr > m_edge
List of element edges.
Definition: Element.h:388
std::vector< NodeSharedPtr > m_volumeNodes
List of element volume nodes.
Definition: Element.h:392
StdRegions::Orientation 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 143 of file MeshElements/Triangle.cpp.

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

144 {
145  int locVert = edgeId;
146  if (edge->m_n1 == m_vertex[locVert])
147  {
148  return StdRegions::eForwards;
149  }
150  else if (edge->m_n2 == m_vertex[locVert])
151  {
152  return StdRegions::eBackwards;
153  }
154  else
155  {
156  ASSERTL1(false, "Edge is not connected to this triangle.");
157  }
158 
160 }
std::vector< NodeSharedPtr > m_vertex
List of element vertex nodes.
Definition: Element.h:386
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:228
SpatialDomains::GeometrySharedPtr Triangle::GetGeom ( int  coordDim)
virtual

Generate a Nektar++ geometry object for this element.

Reimplemented from Nektar::NekMeshUtils::Element.

Definition at line 120 of file MeshElements/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.

121 {
125 
126  for (int i = 0; i < 3; ++i)
127  {
128  edges[i] = m_edge[i]->GetGeom(coordDim);
129  verts[i] = m_vertex[i]->GetGeom(coordDim);
130  }
131 
132  StdRegions::Orientation edgeorient[3] = {
133  SpatialDomains::SegGeom::GetEdgeOrientation(*edges[0], *edges[1]),
134  SpatialDomains::SegGeom::GetEdgeOrientation(*edges[1], *edges[2]),
135  SpatialDomains::SegGeom::GetEdgeOrientation(*edges[2], *edges[0])};
136 
138  m_id, verts, edges, edgeorient);
139 
140  return ret;
141 }
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:386
boost::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:60
std::vector< EdgeSharedPtr > m_edge
List of element edges.
Definition: Element.h:388
unsigned int m_id
ID of the element.
Definition: Element.h:376
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 165 of file MeshElements/Triangle.cpp.

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

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

166 {
167  int n = pConf.m_order;
168  if (!pConf.m_faceNodes)
169  return (n + 1) + 2 * (n - 1) + 1;
170  else
171  return (n + 1) * (n + 2) / 2;
172 }
void 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 201 of file MeshElements/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().

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

returns the normal to the element

Reimplemented from Nektar::NekMeshUtils::Element.

Definition at line 269 of file MeshElements/Triangle.cpp.

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

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

Member Data Documentation

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

Element type.

Definition at line 63 of file MeshElements/Triangle.h.