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_id(pSrc.m_id), m_n1(pSrc.m_n1), m_n2(pSrc.m_n2),
79  {
80  }
81 
83  {
84  }
85 
86  /// Returns the total number of nodes defining the edge.
87  NEKMESHUTILS_EXPORT unsigned int GetNodeCount() const
88  {
89  return m_edgeNodes.size() + 2;
90  }
91 
93  std::vector<NodeSharedPtr> &nodeList) const
94  {
95  nodeList.push_back(m_n1);
96  for (int k = 0; k < m_edgeNodes.size(); ++k)
97  {
98  nodeList.push_back(m_edgeNodes[k]);
99  }
100  nodeList.push_back(m_n2);
101  }
102 
103  /// Creates a Nektar++ string listing the coordinates of all the
104  /// nodes.
106 
107  /// Generate a SpatialDomains::SegGeom object for this edge.
109 
110  /// Make this edge an order @p order edge. @see Element::MakeOrder.
111  void MakeOrder(int order,
113  LibUtilities::PointsType edgeType,
114  int coordDim,
115  int &id);
116 
117  /// ID of edge.
118  unsigned int m_id;
119  /// First vertex node.
121  /// Second vertex node.
123  /// List of control nodes between the first and second vertices.
124  std::vector<NodeSharedPtr> m_edgeNodes;
125  /// Distributions of points along edge.
127  /// Element(s) which are linked to this edge.
128  std::vector<std::pair<ElementSharedPtr, int> > m_elLink;
129 
131 
132 private:
134 };
135 /// Shared pointer to an edge.
136 typedef boost::shared_ptr<Edge> EdgeSharedPtr;
137 
138 NEKMESHUTILS_EXPORT bool operator==(EdgeSharedPtr const &p1,
139  EdgeSharedPtr const &p2);
140 NEKMESHUTILS_EXPORT bool operator<(EdgeSharedPtr const &p1,
141  EdgeSharedPtr const &p2);
142 
143 /**
144  * @brief Defines a hash function for edges.
145  *
146  * The hash of an edge is defined using the IDs of the two nodes which
147  * define it. First the minimum ID is hashed, then the maximum
148  * ID, which takes the two possible orientations into account.
149  */
150 struct EdgeHash : std::unary_function<EdgeSharedPtr, std::size_t>
151 {
152  std::size_t operator()(EdgeSharedPtr const &p) const
153  {
154  std::size_t seed = 0;
155  unsigned int id1 = p->m_n1->m_id;
156  unsigned int id2 = p->m_n2->m_id;
157  boost::hash_combine(seed, id1 < id2 ? id1 : id2);
158  boost::hash_combine(seed, id2 < id1 ? id1 : id2);
159  return seed;
160  }
161 };
162 typedef boost::unordered_set<EdgeSharedPtr, EdgeHash> EdgeSet;
163 }
164 }
165 
166 #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:120
Represents an edge which joins two points.
Definition: Edge.h:58
Defines a hash function for edges.
Definition: Edge.h:150
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:124
NEKMESHUTILS_EXPORT unsigned int GetNodeCount() const
Returns the total number of nodes defining the edge.
Definition: Edge.h:87
unsigned int m_id
ID of edge.
Definition: Edge.h:118
std::size_t operator()(EdgeSharedPtr const &p) const
Definition: Edge.h:152
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:130
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:92
LibUtilities::PointsType m_curveType
Distributions of points along edge.
Definition: Edge.h:126
boost::shared_ptr< Node > NodeSharedPtr
Definition: Node.h:50
NEKMESHUTILS_EXPORT ~Edge()
Definition: Edge.h:82
NodeSharedPtr m_n2
Second vertex node.
Definition: Edge.h:122
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:136
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:128
#define NEKMESHUTILS_EXPORT
boost::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:49
boost::unordered_set< EdgeSharedPtr, EdgeHash > EdgeSet
Definition: Edge.h:162
SpatialDomains::SegGeomSharedPtr m_geom
Definition: Edge.h:133
boost::shared_ptr< Geometry > GeometrySharedPtr
Definition: Geometry.h:53
Base class for element definitions.
Definition: Element.h:59