Nektar++
Face.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Face.h
4 //
5 // For more information, please see: http://www.nektar.info/
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Mesh face object.
32 //
33 ////////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKMESHUTILS_MESHELEMENTS_FACE
36 #define NEKMESHUTILS_MESHELEMENTS_FACE
37 
38 #include <boost/core/ignore_unused.hpp>
39 
41 #include <SpatialDomains/TriGeom.h>
43 
47 
48 namespace Nektar
49 {
50 namespace NekMeshUtils
51 {
52 
53 class Element;
54 typedef std::shared_ptr<Element> ElementSharedPtr;
55 
56 /**
57  * @brief Represents a face comprised of three or more edges.
58  *
59  * A face is defined by a list of vertices, a list of edges joining
60  * these vertices, and a list of control nodes within the interior of
61  * the face, defining the shape of the face.
62  */
63 class Face
64 {
65 public:
66  /// Create a new face.
67  NEKMESHUTILS_EXPORT Face(std::vector<NodeSharedPtr> pVertexList,
68  std::vector<NodeSharedPtr> pFaceNodes,
69  std::vector<EdgeSharedPtr> pEdgeList,
70  LibUtilities::PointsType pCurveType)
71  : m_vertexList(pVertexList), m_edgeList(pEdgeList),
72  m_faceNodes(pFaceNodes), m_curveType(pCurveType), m_geom()
73  {
74  }
75 
76  /// Copy an existing face.
78  : m_id(pSrc.m_id), m_vertexList(pSrc.m_vertexList),
80  m_curveType(pSrc.m_curveType), m_geom(pSrc.m_geom),
82  {
83  }
84 
86  {
87  }
88 
89  /// Equality is defined by matching all vertices.
91  {
92  std::vector<NodeSharedPtr>::iterator it1;
93  for (it1 = m_vertexList.begin(); it1 != m_vertexList.end(); ++it1)
94  {
95  if (find(pSrc.m_vertexList.begin(),
96  pSrc.m_vertexList.end(),
97  *it1) == pSrc.m_vertexList.end())
98  {
99  return false;
100  }
101  }
102  return true;
103  }
104 
105  /// Returns the total number of nodes (vertices, edge nodes and
106  /// face nodes).
107  NEKMESHUTILS_EXPORT unsigned int GetNodeCount() const
108  {
109  unsigned int n = m_faceNodes.size();
110  for (int i = 0; i < m_edgeList.size(); ++i)
111  {
112  n += m_edgeList[i]->GetNodeCount();
113  }
114  n -= m_vertexList.size();
115  return n;
116  }
117 
118  /// Assemble a list of nodes on curved face
120  std::vector<NodeSharedPtr> &nodeList);
121 
122  /// Generates a string listing the coordinates of all nodes
123  /// associated with this face.
125 
126  /// Make this face an order @p order face. @see Element::MakeOrder.
127  void MakeOrder(int order,
130  int coordDim,
131  int &id);
132 
133  /// Generate either SpatialDomains::TriGeom or
134  /// SpatialDomains::QuadGeom for this element.
136 
137  /// ID of the face.
138  unsigned int m_id;
139  /// List of vertex nodes.
140  std::vector<NodeSharedPtr> m_vertexList;
141  /// List of corresponding edges.
142  std::vector<EdgeSharedPtr> m_edgeList;
143  /// List of face-interior nodes defining the shape of the face.
144  std::vector<NodeSharedPtr> m_faceNodes;
145  /// Distribution of points in this face.
147  /// Element(s) which are linked to this face.
148  std::vector<std::pair<ElementSharedPtr, int> > m_elLink;
149  /// Nektar++ representation of geometry
151 
153 };
154 
155 typedef std::shared_ptr<Face> FaceSharedPtr;
156 
157 NEKMESHUTILS_EXPORT bool operator==(FaceSharedPtr const &p1,
158  FaceSharedPtr const &p2);
159 NEKMESHUTILS_EXPORT bool operator<(FaceSharedPtr const &p1,
160  FaceSharedPtr const &p2);
161 
162 struct FaceHash : std::unary_function<FaceSharedPtr, std::size_t>
163 {
164  std::size_t operator()(FaceSharedPtr const &p) const
165  {
166  unsigned int nVert = p->m_vertexList.size();
167  std::size_t seed = 0;
168  std::vector<unsigned int> ids(nVert);
169 
170  for (int i = 0; i < nVert; ++i)
171  {
172  ids[i] = p->m_vertexList[i]->m_id;
173  }
174 
175  std::sort(ids.begin(), ids.end());
176  hash_range(seed, ids.begin(), ids.end());
177 
178  return seed;
179  }
180 };
181 typedef std::unordered_set<FaceSharedPtr, FaceHash> FaceSet;
182 
183 }
184 }
185 
186 #endif
bool operator<(NodeSharedPtr const &p1, NodeSharedPtr const &p2)
Defines ordering between two NodeSharedPtr objects.
NEKMESHUTILS_EXPORT bool operator==(Face &pSrc)
Equality is defined by matching all vertices.
Definition: Face.h:90
std::size_t hash_range(Iter first, Iter last)
Definition: HashUtils.hpp:69
NEKMESHUTILS_EXPORT void GetCurvedNodes(std::vector< NodeSharedPtr > &nodeList)
Assemble a list of nodes on curved face.
Definition: Face.cpp:46
void MakeOrder(int order, SpatialDomains::GeometrySharedPtr geom, LibUtilities::PointsType pType, int coordDim, int &id)
Make this face an order order face.
Definition: Face.cpp:155
std::vector< NodeSharedPtr > m_faceNodes
List of face-interior nodes defining the shape of the face.
Definition: Face.h:144
NEKMESHUTILS_EXPORT unsigned int GetNodeCount() const
Returns the total number of nodes (vertices, edge nodes and face nodes).
Definition: Face.h:107
std::shared_ptr< Geometry2D > Geometry2DSharedPtr
Definition: Geometry.h:65
std::size_t operator()(FaceSharedPtr const &p) const
Definition: Face.h:164
Represents a face comprised of three or more edges.
Definition: Face.h:63
NEKMESHUTILS_EXPORT ~Face()
Definition: Face.h:85
std::vector< std::pair< ElementSharedPtr, int > > m_elLink
Element(s) which are linked to this face.
Definition: Face.h:148
std::vector< EdgeSharedPtr > m_edgeList
List of corresponding edges.
Definition: Face.h:142
unsigned int m_id
ID of the face.
Definition: Face.h:138
NEKMESHUTILS_EXPORT Face(const Face &pSrc)
Copy an existing face.
Definition: Face.h:77
std::shared_ptr< Face > FaceSharedPtr
Definition: Face.h:155
std::unordered_set< FaceSharedPtr, FaceHash > FaceSet
Definition: Face.h:181
std::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:49
std::shared_ptr< Geometry > GeometrySharedPtr
Definition: Geometry.h:53
NEKMESHUTILS_EXPORT std::string GetXmlCurveString()
Generates a string listing the coordinates of all nodes associated with this face.
Definition: Face.cpp:135
LibUtilities::PointsType m_curveType
Distribution of points in this face.
Definition: Face.h:146
NEKMESHUTILS_EXPORT Face(std::vector< NodeSharedPtr > pVertexList, std::vector< NodeSharedPtr > pFaceNodes, std::vector< EdgeSharedPtr > pEdgeList, LibUtilities::PointsType pCurveType)
Create a new face.
Definition: Face.h:67
NEKMESHUTILS_EXPORT SpatialDomains::Geometry2DSharedPtr GetGeom(int coordDim)
Generate either SpatialDomains::TriGeom or SpatialDomains::QuadGeom for this element.
Definition: Face.cpp:280
std::shared_ptr< CADObject > CADObjectSharedPtr
Definition: CADObject.h:133
#define NEKMESHUTILS_EXPORT
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:358
CADObjectSharedPtr m_parentCAD
Definition: Face.h:152
std::vector< NodeSharedPtr > m_vertexList
List of vertex nodes.
Definition: Face.h:140
SpatialDomains::Geometry2DSharedPtr m_geom
Nektar++ representation of geometry.
Definition: Face.h:150