Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // 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 
37 
40 
42 
43 namespace Nektar
44 {
45 namespace NekMeshUtils
46 {
47 
48 using namespace std;
49 
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 }
69 
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 }
107 
109  LibUtilities::PointsType edgeType, int coordDim, int &id)
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  {
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;
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 }
194 }
195 }
NEKMESHUTILS_EXPORT SpatialDomains::SegGeomSharedPtr GetGeom(int coordDim)
Generate a SpatialDomains::SegGeom object for this edge.
Definition: Edge.cpp:70
base class for CAD curves.
Definition: CADCurve.h:52
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
STL namespace.
boost::shared_ptr< Curve > CurveSharedPtr
Definition: Curve.hpp:62
NEKMESHUTILS_EXPORT std::string GetXmlCurveString()
Creates a Nektar++ string listing the coordinates of all the nodes.
Definition: Edge.cpp:50
boost::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:60
base class for a cad surface
Definition: CADSurf.h:55
PointsManagerT & PointsManager(void)
Defines a specification for a set of points.
Definition: Points.h:58
double NekDouble
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< CADSurf > CADSurfSharedPtr
Definition: CADSurf.h:172
static boost::mutex mutex
Definition: Vmath.cpp:134
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
boost::shared_ptr< Geometry > GeometrySharedPtr
Definition: Geometry.h:53
boost::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:60
boost::shared_ptr< CADCurve > CADCurveSharedPtr
Definition: CADCurve.h:194