Nektar++
Edge.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Edge.cpp
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 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Mesh Edge.
32 //
33 ////////////////////////////////////////////////////////////////////////////////
34 
35 #include <mutex>
36 
41 
42 namespace Nektar
43 {
44 namespace NekMeshUtils
45 {
46 
47 using namespace std;
48 
50 {
51  std::vector<NodeSharedPtr> nodeList;
52 
53  GetCurvedNodes(nodeList);
54 
55  std::stringstream s;
56  std::string str;
57 
58  // put them into a string and return
59  for (int k = 0; k < nodeList.size(); ++k)
60  {
61  s << std::scientific << std::setprecision(8) << " "
62  << nodeList[k]->m_x << " " << nodeList[k]->m_y << " "
63  << nodeList[k]->m_z << " ";
64  }
65 
66  return s.str();
67 }
68 
70 {
71  static std::mutex io_mutex;
72  std::unique_lock<std::mutex> lock(io_mutex);
73 
74  // Create edge vertices.
77 
78  p[0] = m_n1->GetGeom(coordDim);
79  p[1] = m_n2->GetGeom(coordDim);
80 
81  // Create a curve if high-order information exists.
82  if (m_edgeNodes.size() > 0)
83  {
86  m_id, m_curveType);
87 
88  c->m_points.push_back(p[0]);
89  for (int i = 0; i < m_edgeNodes.size(); ++i)
90  {
91  c->m_points.push_back(m_edgeNodes[i]->GetGeom(coordDim));
92  }
93  c->m_points.push_back(p[1]);
94 
96  m_id, coordDim, p, c);
97  }
98  else
99  {
101  m_id, coordDim, p);
102  }
103 
104  ret->Setup();
105 
106  return ret;
107 }
108 
110  LibUtilities::PointsType edgeType, int coordDim, int &id)
111 {
112  int nPoints = order + 1;
113  StdRegions::StdExpansionSharedPtr xmap = geom->GetXmap();
114 
115  Array<OneD, NekDouble> edgePoints;
116  LibUtilities::PointsKey edgeKey(nPoints, edgeType);
117  LibUtilities::PointsManager()[edgeKey]->GetPoints(edgePoints);
118 
119  Array<OneD, Array<OneD, NekDouble>> phys(coordDim);
120 
121  for (int i = 0; i < coordDim; ++i)
122  {
123  phys[i] = Array<OneD, NekDouble>(xmap->GetTotPoints());
124  xmap->BwdTrans(geom->GetCoeffs(i), phys[i]);
125  }
126 
127  m_edgeNodes.resize(nPoints - 2);
128 
129  for (int i = 1; i < nPoints - 1; ++i)
130  {
131  Array<OneD, NekDouble> x(3, 0.0);
132  for (int j = 0; j < coordDim; ++j)
133  {
134  x[j] = xmap->PhysEvaluate(edgePoints + i, phys[j]);
135  }
136 
137  m_edgeNodes[i - 1] =
138  std::shared_ptr<Node>(new Node(id++, x[0], x[1], x[2]));
139  }
140 
141  m_curveType = edgeType;
142 
143  if (m_parentCAD)
144  {
145  if (m_parentCAD->GetType() == CADType::eCurve)
146  {
148  std::dynamic_pointer_cast<CADCurve>(m_parentCAD);
149  for (int i = 0; i < m_edgeNodes.size(); i++)
150  {
152  loc[0] = m_edgeNodes[i]->m_x;
153  loc[1] = m_edgeNodes[i]->m_y;
154  loc[2] = m_edgeNodes[i]->m_z;
155  NekDouble t;
156  c->loct(loc, t);
157  m_edgeNodes[i]->SetCADCurve(c, t);
158  loc = c->P(t);
159  m_edgeNodes[i]->m_x = loc[0];
160  m_edgeNodes[i]->m_y = loc[1];
161  m_edgeNodes[i]->m_z = loc[2];
162 
163  vector<pair<CADSurfSharedPtr, CADOrientation::Orientation>> s =
164  c->GetAdjSurf();
165  for (int j = 0; j < s.size(); j++)
166  {
167  Array<OneD, NekDouble> uv = s[j].first->locuv(loc);
168  m_edgeNodes[i]->SetCADSurf(s[j].first, uv);
169  }
170  }
171  }
172  else
173  {
174  CADSurfSharedPtr s =
175  std::dynamic_pointer_cast<CADSurf>(m_parentCAD);
176  for (int i = 0; i < m_edgeNodes.size(); i++)
177  {
179  loc[0] = m_edgeNodes[i]->m_x;
180  loc[1] = m_edgeNodes[i]->m_y;
181  loc[2] = m_edgeNodes[i]->m_z;
182  Array<OneD, NekDouble> uv = s->locuv(loc);
183  loc = s->P(uv);
184  m_edgeNodes[i]->m_x = loc[0];
185  m_edgeNodes[i]->m_y = loc[1];
186  m_edgeNodes[i]->m_z = loc[2];
187  m_edgeNodes[i]->SetCADSurf(s, uv);
188  }
189  }
190  }
191 }
192 } // namespace NekMeshUtils
193 } // namespace Nektar
void MakeOrder(int order, SpatialDomains::GeometrySharedPtr geom, LibUtilities::PointsType edgeType, int coordDim, int &id)
Make this edge an order order edge.
Definition: Edge.cpp:109
std::shared_ptr< CADSurf > CADSurfSharedPtr
Definition: CADCurve.h:51
base class for CAD curves.
Definition: CADCurve.h:58
NEKMESHUTILS_EXPORT std::string GetXmlCurveString()
Creates a Nektar++ string listing the coordinates of all the nodes.
Definition: Edge.cpp:49
NEKMESHUTILS_EXPORT SpatialDomains::SegGeomSharedPtr GetGeom(int coordDim)
Generate a SpatialDomains::SegGeom object for this edge.
Definition: Edge.cpp:69
STL namespace.
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
std::shared_ptr< CADCurve > CADCurveSharedPtr
Definition: CADCurve.h:219
std::shared_ptr< Geometry > GeometrySharedPtr
Definition: Geometry.h:53
base class for a cad surface
Definition: CADSurf.h:71
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
PointsManagerT & PointsManager(void)
Defines a specification for a set of points.
Definition: Points.h:59
double NekDouble
std::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:59
std::shared_ptr< Curve > CurveSharedPtr
Definition: Curve.hpp:61
std::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:62