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