Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Public Attributes | Private Attributes | List of all members
Nektar::NekMeshUtils::Edge Class Reference

Represents an edge which joins two points. More...

#include <Edge.h>

Collaboration diagram for Nektar::NekMeshUtils::Edge:
Collaboration graph
[legend]

Public Member Functions

NEKMESHUTILS_EXPORT Edge (NodeSharedPtr pVertex1, NodeSharedPtr pVertex2, std::vector< NodeSharedPtr > pEdgeNodes, LibUtilities::PointsType pCurveType)
 Creates a new edge. More...
 
NEKMESHUTILS_EXPORT Edge (NodeSharedPtr pVertex1, NodeSharedPtr pVertex2)
 Creates a new linear edge. More...
 
NEKMESHUTILS_EXPORT Edge (const Edge &pSrc)
 Copies an existing edge. More...
 
NEKMESHUTILS_EXPORT ~Edge ()
 
NEKMESHUTILS_EXPORT unsigned int GetNodeCount () const
 Returns the total number of nodes defining the edge. More...
 
NEKMESHUTILS_EXPORT void GetCurvedNodes (std::vector< NodeSharedPtr > &nodeList) const
 
NEKMESHUTILS_EXPORT std::string GetXmlCurveString ()
 Creates a Nektar++ string listing the coordinates of all the nodes. More...
 
NEKMESHUTILS_EXPORT
SpatialDomains::SegGeomSharedPtr 
GetGeom (int coordDim)
 Generate a SpatialDomains::SegGeom object for this edge. More...
 
void MakeOrder (int order, SpatialDomains::GeometrySharedPtr geom, LibUtilities::PointsType edgeType, int coordDim, int &id)
 Make this edge an order order edge. More...
 

Public Attributes

unsigned int m_id
 ID of edge. More...
 
NodeSharedPtr m_n1
 First vertex node. More...
 
NodeSharedPtr m_n2
 Second vertex node. More...
 
std::vector< NodeSharedPtrm_edgeNodes
 List of control nodes between the first and second vertices. More...
 
LibUtilities::PointsType m_curveType
 Distributions of points along edge. More...
 
std::vector< std::pair
< ElementSharedPtr, int > > 
m_elLink
 Element(s) which are linked to this edge. More...
 
CADObjectSharedPtr m_parentCAD
 

Private Attributes

SpatialDomains::SegGeomSharedPtr m_geom
 

Detailed Description

Represents an edge which joins two points.

An edge is defined by two nodes (vertices) and, for high-order edges, a set of control nodes defining the shape of the edge.

Definition at line 58 of file Edge.h.

Constructor & Destructor Documentation

NEKMESHUTILS_EXPORT Nektar::NekMeshUtils::Edge::Edge ( NodeSharedPtr  pVertex1,
NodeSharedPtr  pVertex2,
std::vector< NodeSharedPtr pEdgeNodes,
LibUtilities::PointsType  pCurveType 
)
inline

Creates a new edge.

Definition at line 62 of file Edge.h.

66  : m_n1(pVertex1), m_n2(pVertex2), m_edgeNodes(pEdgeNodes),
67  m_curveType(pCurveType), m_geom(){}
NodeSharedPtr m_n1
First vertex node.
Definition: Edge.h:120
std::vector< NodeSharedPtr > m_edgeNodes
List of control nodes between the first and second vertices.
Definition: Edge.h:124
LibUtilities::PointsType m_curveType
Distributions of points along edge.
Definition: Edge.h:126
NodeSharedPtr m_n2
Second vertex node.
Definition: Edge.h:122
SpatialDomains::SegGeomSharedPtr m_geom
Definition: Edge.h:133
NEKMESHUTILS_EXPORT Nektar::NekMeshUtils::Edge::Edge ( NodeSharedPtr  pVertex1,
NodeSharedPtr  pVertex2 
)
inline

Creates a new linear edge.

Definition at line 70 of file Edge.h.

71  : m_n1(pVertex1), m_n2(pVertex2), m_edgeNodes(), m_curveType(), m_geom()
72  {}
NodeSharedPtr m_n1
First vertex node.
Definition: Edge.h:120
std::vector< NodeSharedPtr > m_edgeNodes
List of control nodes between the first and second vertices.
Definition: Edge.h:124
LibUtilities::PointsType m_curveType
Distributions of points along edge.
Definition: Edge.h:126
NodeSharedPtr m_n2
Second vertex node.
Definition: Edge.h:122
SpatialDomains::SegGeomSharedPtr m_geom
Definition: Edge.h:133
NEKMESHUTILS_EXPORT Nektar::NekMeshUtils::Edge::Edge ( const Edge pSrc)
inline

Copies an existing edge.

Definition at line 75 of file Edge.h.

76  : m_id(pSrc.m_id), m_n1(pSrc.m_n1), m_n2(pSrc.m_n2),
77  m_edgeNodes(pSrc.m_edgeNodes), m_curveType(pSrc.m_curveType),
78  m_elLink(pSrc.m_elLink), m_parentCAD(pSrc.m_parentCAD)
79  {
80  }
NodeSharedPtr m_n1
First vertex node.
Definition: Edge.h:120
std::vector< NodeSharedPtr > m_edgeNodes
List of control nodes between the first and second vertices.
Definition: Edge.h:124
unsigned int m_id
ID of edge.
Definition: Edge.h:118
CADObjectSharedPtr m_parentCAD
Definition: Edge.h:130
LibUtilities::PointsType m_curveType
Distributions of points along edge.
Definition: Edge.h:126
NodeSharedPtr m_n2
Second vertex node.
Definition: Edge.h:122
std::vector< std::pair< ElementSharedPtr, int > > m_elLink
Element(s) which are linked to this edge.
Definition: Edge.h:128
NEKMESHUTILS_EXPORT Nektar::NekMeshUtils::Edge::~Edge ( )
inline

Definition at line 82 of file Edge.h.

83  {
84  }

Member Function Documentation

NEKMESHUTILS_EXPORT void Nektar::NekMeshUtils::Edge::GetCurvedNodes ( std::vector< NodeSharedPtr > &  nodeList) const
inline

Definition at line 92 of file Edge.h.

References m_edgeNodes, m_n1, and m_n2.

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  }
NodeSharedPtr m_n1
First vertex node.
Definition: Edge.h:120
std::vector< NodeSharedPtr > m_edgeNodes
List of control nodes between the first and second vertices.
Definition: Edge.h:124
NodeSharedPtr m_n2
Second vertex node.
Definition: Edge.h:122
SpatialDomains::SegGeomSharedPtr Edge::GetGeom ( int  coordDim)

Generate a SpatialDomains::SegGeom object for this edge.

Definition at line 70 of file Edge.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Vmath::mutex, and CellMLToNektar.cellml_metadata::p.

71 {
72  static boost::mutex io_mutex;
73  boost::mutex::scoped_lock lock(io_mutex);
74 
75  // Create edge vertices.
78 
79  p[0] = m_n1->GetGeom(coordDim);
80  p[1] = m_n2->GetGeom(coordDim);
81 
82  // Create a curve if high-order information exists.
83  if (m_edgeNodes.size() > 0)
84  {
87  m_id, m_curveType);
88 
89  c->m_points.push_back(p[0]);
90  for (int i = 0; i < m_edgeNodes.size(); ++i)
91  {
92  c->m_points.push_back(m_edgeNodes[i]->GetGeom(coordDim));
93  }
94  c->m_points.push_back(p[1]);
95 
97  m_id, coordDim, p, c);
98  }
99  else
100  {
102  m_id, coordDim, p);
103  }
104 
105  return ret;
106 }
NEKMESHUTILS_EXPORT SpatialDomains::SegGeomSharedPtr GetGeom(int coordDim)
Generate a SpatialDomains::SegGeom object for this edge.
Definition: Edge.cpp:70
NodeSharedPtr m_n1
First vertex node.
Definition: Edge.h:120
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
boost::shared_ptr< Curve > CurveSharedPtr
Definition: Curve.hpp:62
std::vector< NodeSharedPtr > m_edgeNodes
List of control nodes between the first and second vertices.
Definition: Edge.h:124
unsigned int m_id
ID of edge.
Definition: Edge.h:118
boost::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:60
LibUtilities::PointsType m_curveType
Distributions of points along edge.
Definition: Edge.h:126
NodeSharedPtr m_n2
Second vertex node.
Definition: Edge.h:122
static boost::mutex mutex
Definition: Vmath.cpp:134
boost::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:60
NEKMESHUTILS_EXPORT unsigned int Nektar::NekMeshUtils::Edge::GetNodeCount ( ) const
inline

Returns the total number of nodes defining the edge.

Definition at line 87 of file Edge.h.

References m_edgeNodes.

88  {
89  return m_edgeNodes.size() + 2;
90  }
std::vector< NodeSharedPtr > m_edgeNodes
List of control nodes between the first and second vertices.
Definition: Edge.h:124
string Edge::GetXmlCurveString ( )

Creates a Nektar++ string listing the coordinates of all the nodes.

Definition at line 50 of file Edge.cpp.

51 {
52  std::vector<NodeSharedPtr> nodeList;
53 
54  GetCurvedNodes(nodeList);
55 
56  std::stringstream s;
57  std::string str;
58 
59  // put them into a string and return
60  for (int k = 0; k < nodeList.size(); ++k)
61  {
62  s << std::scientific << std::setprecision(8) << " "
63  << nodeList[k]->m_x << " " << nodeList[k]->m_y << " "
64  << nodeList[k]->m_z << " ";
65  }
66 
67  return s.str();
68 }
NEKMESHUTILS_EXPORT void GetCurvedNodes(std::vector< NodeSharedPtr > &nodeList) const
Definition: Edge.h:92
void Edge::MakeOrder ( int  order,
SpatialDomains::GeometrySharedPtr  geom,
LibUtilities::PointsType  edgeType,
int  coordDim,
int &  id 
)

Make this edge an order order edge.

See also
Element::MakeOrder.

Definition at line 108 of file Edge.cpp.

References Nektar::NekMeshUtils::CADType::eCurve, class_topology::Node, and Nektar::LibUtilities::PointsManager().

110 {
111  int nPoints = order + 1;
112  StdRegions::StdExpansionSharedPtr xmap = geom->GetXmap();
113 
114  Array<OneD, NekDouble> edgePoints;
115  LibUtilities::PointsKey edgeKey(nPoints, edgeType);
116  LibUtilities::PointsManager()[edgeKey]->GetPoints(edgePoints);
117 
118  Array<OneD, Array<OneD, NekDouble> > phys(coordDim);
119 
120  for (int i = 0; i < coordDim; ++i)
121  {
122  phys[i] = Array<OneD, NekDouble>(xmap->GetTotPoints());
123  xmap->BwdTrans(geom->GetCoeffs(i), phys[i]);
124  }
125 
126  m_edgeNodes.resize(nPoints - 2);
127 
128  for (int i = 1; i < nPoints - 1; ++i)
129  {
130  Array<OneD, NekDouble> x(3, 0.0);
131  for (int j = 0; j < coordDim; ++j)
132  {
133  x[j] = xmap->PhysEvaluate(edgePoints + i, phys[j]);
134  }
135 
136  m_edgeNodes[i - 1] =
137  boost::shared_ptr<Node>(new Node(id++, x[0], x[1], x[2]));
138  }
139 
140  m_curveType = edgeType;
141 
142  if (m_parentCAD)
143  {
144  if (m_parentCAD->GetType() == CADType::eCurve)
145  {
147  boost::dynamic_pointer_cast<CADCurve>(m_parentCAD);
148  for (int i = 0; i < m_edgeNodes.size(); i++)
149  {
150  Array<OneD, NekDouble> loc(3);
151  loc[0] = m_edgeNodes[i]->m_x;
152  loc[1] = m_edgeNodes[i]->m_y;
153  loc[2] = m_edgeNodes[i]->m_z;
154  NekDouble t = c->loct(loc);
155  m_edgeNodes[i]->SetCADCurve(c->GetId(), c, t);
156  loc = c->P(t);
157  m_edgeNodes[i]->m_x = loc[0];
158  m_edgeNodes[i]->m_y = loc[1];
159  m_edgeNodes[i]->m_z = loc[2];
160 
161  std::vector<
162  std::pair<CADSurfSharedPtr, CADOrientation::Orientation> >
163  s = c->GetAdjSurf();
164  for (int j = 0; j < s.size(); j++)
165  {
166  Array<OneD, NekDouble> uv(2);
167  s[j].first->ProjectTo(loc, uv);
168  m_edgeNodes[i]->SetCADSurf(s[j].first->GetId(), s[j].first,
169  uv);
170  }
171  }
172  }
173  else
174  {
175  CADSurfSharedPtr s =
176  boost::dynamic_pointer_cast<CADSurf>(m_parentCAD);
177  for (int i = 0; i < m_edgeNodes.size(); i++)
178  {
179  Array<OneD, NekDouble> loc(3);
180  loc[0] = m_edgeNodes[i]->m_x;
181  loc[1] = m_edgeNodes[i]->m_y;
182  loc[2] = m_edgeNodes[i]->m_z;
183  Array<OneD, NekDouble> uv(2);
184  s->ProjectTo(loc, uv);
185  loc = s->P(uv);
186  m_edgeNodes[i]->m_x = loc[0];
187  m_edgeNodes[i]->m_y = loc[1];
188  m_edgeNodes[i]->m_z = loc[2];
189  m_edgeNodes[i]->SetCADSurf(s->GetId(), s, uv);
190  }
191  }
192  }
193 }
std::vector< NodeSharedPtr > m_edgeNodes
List of control nodes between the first and second vertices.
Definition: Edge.h:124
CADObjectSharedPtr m_parentCAD
Definition: Edge.h:130
LibUtilities::PointsType m_curveType
Distributions of points along edge.
Definition: Edge.h:126
PointsManagerT & PointsManager(void)
double NekDouble
boost::shared_ptr< CADSurf > CADSurfSharedPtr
Definition: CADSurf.h:172
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
boost::shared_ptr< CADCurve > CADCurveSharedPtr
Definition: CADCurve.h:194

Member Data Documentation

LibUtilities::PointsType Nektar::NekMeshUtils::Edge::m_curveType

Distributions of points along edge.

Definition at line 126 of file Edge.h.

std::vector<NodeSharedPtr> Nektar::NekMeshUtils::Edge::m_edgeNodes

List of control nodes between the first and second vertices.

Definition at line 124 of file Edge.h.

Referenced by GetCurvedNodes(), and GetNodeCount().

std::vector<std::pair<ElementSharedPtr, int> > Nektar::NekMeshUtils::Edge::m_elLink

Element(s) which are linked to this edge.

Definition at line 128 of file Edge.h.

SpatialDomains::SegGeomSharedPtr Nektar::NekMeshUtils::Edge::m_geom
private

Definition at line 133 of file Edge.h.

unsigned int Nektar::NekMeshUtils::Edge::m_id

ID of edge.

Definition at line 118 of file Edge.h.

NodeSharedPtr Nektar::NekMeshUtils::Edge::m_n1

First vertex node.

Definition at line 120 of file Edge.h.

Referenced by GetCurvedNodes().

NodeSharedPtr Nektar::NekMeshUtils::Edge::m_n2

Second vertex node.

Definition at line 122 of file Edge.h.

Referenced by GetCurvedNodes().

CADObjectSharedPtr Nektar::NekMeshUtils::Edge::m_parentCAD

Definition at line 130 of file Edge.h.