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  /// Copy an existing face.
76  m_geom(pSrc.m_geom){}
77 
79  {
80  }
81 
82  /// Equality is defined by matching all vertices.
84  {
86  for (it1 = m_vertexList.begin(); it1 != m_vertexList.end(); ++it1)
87  {
88  if (find(pSrc.m_vertexList.begin(),
89  pSrc.m_vertexList.end(),
90  *it1) == pSrc.m_vertexList.end())
91  {
92  return false;
93  }
94  }
95  return true;
96  }
97 
98  /// Returns the total number of nodes (vertices, edge nodes and
99  /// face nodes).
100  NEKMESHUTILS_EXPORT unsigned int GetNodeCount() const
101  {
102  unsigned int n = m_faceNodes.size();
103  for (int i = 0; i < m_edgeList.size(); ++i)
104  {
105  n += m_edgeList[i]->GetNodeCount();
106  }
107  n -= m_vertexList.size();
108  return n;
109  }
110 
111  /// Assemble a list of nodes on curved face
113  std::vector<NodeSharedPtr> &nodeList);
114 
115  /// Generates a string listing the coordinates of all nodes
116  /// associated with this face.
118 
119  /// Make this face an order @p order face. @see Element::MakeOrder.
120  void MakeOrder(int order,
123  int coordDim,
124  int &id);
125 
126  /// Generate either SpatialDomains::TriGeom or
127  /// SpatialDomains::QuadGeom for this element.
129 
130  /// ID of the face.
131  unsigned int m_id;
132  /// List of vertex nodes.
133  std::vector<NodeSharedPtr> m_vertexList;
134  /// List of corresponding edges.
135  std::vector<EdgeSharedPtr> m_edgeList;
136  /// List of face-interior nodes defining the shape of the face.
137  std::vector<NodeSharedPtr> m_faceNodes;
138  /// Distribution of points in this face.
140  /// Element(s) which are linked to this face.
141  std::vector<std::pair<ElementSharedPtr, int> > m_elLink;
142  /// Nektar++ representation of geometry
144 
146 };
147 
148 typedef boost::shared_ptr<Face> FaceSharedPtr;
149 
150 NEKMESHUTILS_EXPORT bool operator==(FaceSharedPtr const &p1,
151  FaceSharedPtr const &p2);
152 NEKMESHUTILS_EXPORT bool operator<(FaceSharedPtr const &p1,
153  FaceSharedPtr const &p2);
154 
155 struct FaceHash : std::unary_function<FaceSharedPtr, std::size_t>
156 {
157  std::size_t operator()(FaceSharedPtr const &p) const
158  {
159  unsigned int nVert = p->m_vertexList.size();
160  std::size_t seed = 0;
161  std::vector<unsigned int> ids(nVert);
162 
163  for (int i = 0; i < nVert; ++i)
164  {
165  ids[i] = p->m_vertexList[i]->m_id;
166  }
167 
168  std::sort(ids.begin(), ids.end());
169  boost::hash_range(seed, ids.begin(), ids.end());
170 
171  return seed;
172  }
173 };
174 typedef boost::unordered_set<FaceSharedPtr, FaceHash> FaceSet;
175 
176 }
177 }
178 
179 #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:83
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:137
NEKMESHUTILS_EXPORT unsigned int GetNodeCount() const
Returns the total number of nodes (vertices, edge nodes and face nodes).
Definition: Face.h:100
Represents a face comprised of three or more edges.
Definition: Face.h:61
NEKMESHUTILS_EXPORT ~Face()
Definition: Face.h:78
std::vector< std::pair< ElementSharedPtr, int > > m_elLink
Element(s) which are linked to this face.
Definition: Face.h:141
std::vector< EdgeSharedPtr > m_edgeList
List of corresponding edges.
Definition: Face.h:135
std::size_t operator()(FaceSharedPtr const &p) const
Definition: Face.h:157
unsigned int m_id
ID of the face.
Definition: Face.h:131
NEKMESHUTILS_EXPORT Face(const Face &pSrc)
Copy an existing face.
Definition: Face.h:73
bool operator==(ElmtConfig const &c1, ElmtConfig const &c2)
Compares two element config structs.
boost::unordered_set< FaceSharedPtr, FaceHash > FaceSet
Definition: Face.h:174
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:139
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:148
boost::shared_ptr< Geometry > GeometrySharedPtr
Definition: Geometry.h:53
CADObjectSharedPtr m_parentCAD
Definition: Face.h:145
std::vector< NodeSharedPtr > m_vertexList
List of vertex nodes.
Definition: Face.h:133
SpatialDomains::Geometry2DSharedPtr m_geom
Nektar++ representation of geometry.
Definition: Face.h:143