Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Edge.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Edge.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 Edge.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKMESHUTILS_MESHELEMENTS_EDGE
37 #define NEKMESHUTILS_MESHELEMENTS_EDGE
38 
39 #include <SpatialDomains/SegGeom.h>
40 
43 
44 namespace Nektar
45 {
46 namespace NekMeshUtils
47 {
48 
49 class Element;
50 typedef boost::shared_ptr<Element> ElementSharedPtr;
51 
52 /**
53  * @brief Represents an edge which joins two points.
54  *
55  * An edge is defined by two nodes (vertices) and, for high-order edges,
56  * a set of control nodes defining the shape of the edge.
57  */
58 class Edge
59 {
60 public:
61  /// Creates a new edge.
63  NodeSharedPtr pVertex2,
64  std::vector<NodeSharedPtr> pEdgeNodes,
65  LibUtilities::PointsType pCurveType)
66  : m_n1(pVertex1), m_n2(pVertex2), m_edgeNodes(pEdgeNodes),
67  m_curveType(pCurveType), m_geom(){}
68 
69  /// Creates a new linear edge.
71  : m_n1(pVertex1), m_n2(pVertex2), m_edgeNodes(), m_curveType(), m_geom()
72  {}
73 
74  /// Copies an existing edge.
76  : m_n1(pSrc.m_n1), m_n2(pSrc.m_n2), m_edgeNodes(pSrc.m_edgeNodes),
78  {
79  }
80 
82  {
83  }
84 
85  /// Returns the total number of nodes defining the edge.
86  NEKMESHUTILS_EXPORT unsigned int GetNodeCount() const
87  {
88  return m_edgeNodes.size() + 2;
89  }
90 
92  std::vector<NodeSharedPtr> &nodeList) const
93  {
94  nodeList.push_back(m_n1);
95  for (int k = 0; k < m_edgeNodes.size(); ++k)
96  {
97  nodeList.push_back(m_edgeNodes[k]);
98  }
99  nodeList.push_back(m_n2);
100  }
101 
102  /// Creates a Nektar++ string listing the coordinates of all the
103  /// nodes.
105 
106  /// Generate a SpatialDomains::SegGeom object for this edge.
108 
109  /// Make this edge an order @p order edge. @see Element::MakeOrder.
110  void MakeOrder(int order,
112  LibUtilities::PointsType edgeType,
113  int coordDim,
114  int &id);
115 
116  /// ID of edge.
117  unsigned int m_id;
118  /// First vertex node.
120  /// Second vertex node.
122  /// List of control nodes between the first and second vertices.
123  std::vector<NodeSharedPtr> m_edgeNodes;
124  /// Distributions of points along edge.
126  /// Element(s) which are linked to this edge.
127  std::vector<std::pair<ElementSharedPtr, int> > m_elLink;
128 
130 
131 private:
133 };
134 /// Shared pointer to an edge.
135 typedef boost::shared_ptr<Edge> EdgeSharedPtr;
136 
137 NEKMESHUTILS_EXPORT bool operator==(EdgeSharedPtr const &p1,
138  EdgeSharedPtr const &p2);
139 NEKMESHUTILS_EXPORT bool operator<(EdgeSharedPtr const &p1,
140  EdgeSharedPtr const &p2);
141 
142 /**
143  * @brief Defines a hash function for edges.
144  *
145  * The hash of an edge is defined using the IDs of the two nodes which
146  * define it. First the minimum ID is hashed, then the maximum
147  * ID, which takes the two possible orientations into account.
148  */
149 struct EdgeHash : std::unary_function<EdgeSharedPtr, std::size_t>
150 {
151  std::size_t operator()(EdgeSharedPtr const &p) const
152  {
153  std::size_t seed = 0;
154  unsigned int id1 = p->m_n1->m_id;
155  unsigned int id2 = p->m_n2->m_id;
156  boost::hash_combine(seed, id1 < id2 ? id1 : id2);
157  boost::hash_combine(seed, id2 < id1 ? id1 : id2);
158  return seed;
159  }
160 };
161 typedef boost::unordered_set<EdgeSharedPtr, EdgeHash> EdgeSet;
162 }
163 }
164 
165 #endif
bool operator<(NodeSharedPtr const &p1, NodeSharedPtr const &p2)
Defines ordering between two NodeSharedPtr objects.
NEKMESHUTILS_EXPORT SpatialDomains::SegGeomSharedPtr GetGeom(int coordDim)
Generate a SpatialDomains::SegGeom object for this edge.
Definition: Edge.cpp:70
NEKMESHUTILS_EXPORT Edge(NodeSharedPtr pVertex1, NodeSharedPtr pVertex2, std::vector< NodeSharedPtr > pEdgeNodes, LibUtilities::PointsType pCurveType)
Creates a new edge.
Definition: Edge.h:62
NodeSharedPtr m_n1
First vertex node.
Definition: Edge.h:119
Represents an edge which joins two points.
Definition: Edge.h:58
Defines a hash function for edges.
Definition: Edge.h:149
bool operator==(ElmtConfig const &c1, ElmtConfig const &c2)
Compares two element config structs.
std::vector< NodeSharedPtr > m_edgeNodes
List of control nodes between the first and second vertices.
Definition: Edge.h:123
NEKMESHUTILS_EXPORT unsigned int GetNodeCount() const
Returns the total number of nodes defining the edge.
Definition: Edge.h:86
unsigned int m_id
ID of edge.
Definition: Edge.h:117
std::size_t operator()(EdgeSharedPtr const &p) const
Definition: Edge.h:151
NEKMESHUTILS_EXPORT std::string GetXmlCurveString()
Creates a Nektar++ string listing the coordinates of all the nodes.
Definition: Edge.cpp:50
CADObjectSharedPtr m_parentCAD
Definition: Edge.h:129
NEKMESHUTILS_EXPORT Edge(NodeSharedPtr pVertex1, NodeSharedPtr pVertex2)
Creates a new linear edge.
Definition: Edge.h:70
boost::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:60
NEKMESHUTILS_EXPORT void GetCurvedNodes(std::vector< NodeSharedPtr > &nodeList) const
Definition: Edge.h:91
LibUtilities::PointsType m_curveType
Distributions of points along edge.
Definition: Edge.h:125
boost::shared_ptr< Node > NodeSharedPtr
Definition: Node.h:50
NEKMESHUTILS_EXPORT ~Edge()
Definition: Edge.h:81
NodeSharedPtr m_n2
Second vertex node.
Definition: Edge.h:121
boost::shared_ptr< CADObject > CADObjectSharedPtr
Definition: CADObject.h:112
void MakeOrder(int order, SpatialDomains::GeometrySharedPtr geom, LibUtilities::PointsType edgeType, int coordDim, int &id)
Make this edge an order order edge.
Definition: Edge.cpp:108
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: Edge.h:135
NEKMESHUTILS_EXPORT Edge(const Edge &pSrc)
Copies an existing edge.
Definition: Edge.h:75
std::vector< std::pair< ElementSharedPtr, int > > m_elLink
Element(s) which are linked to this edge.
Definition: Edge.h:127
#define NEKMESHUTILS_EXPORT
boost::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:49
boost::unordered_set< EdgeSharedPtr, EdgeHash > EdgeSet
Definition: Edge.h:161
SpatialDomains::SegGeomSharedPtr m_geom
Definition: Edge.h:132
boost::shared_ptr< Geometry > GeometrySharedPtr
Definition: Geometry.h:53
Base class for element definitions.
Definition: Element.h:59