Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Line.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Line.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 line object.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
37 
39 
40 using namespace std;
41 
42 namespace Nektar
43 {
44 namespace NekMeshUtils
45 {
46 
47 LibUtilities::ShapeType Line::m_type =
49  LibUtilities::eSegment, Line::create, "Line");
50 
51 /**
52  * @brief Create a line element.
53  */
54 Line::Line(ElmtConfig pConf,
55  vector<NodeSharedPtr> pNodeList,
56  vector<int> pTagList)
57  : Element(pConf, GetNumNodes(pConf), pNodeList.size())
58 {
59  m_tag = "S";
60  m_dim = 1;
61  m_taglist = pTagList;
62  int n = m_conf.m_order - 1;
63 
64  // Add vertices
65  for (int i = 0; i < 2; ++i)
66  {
67  m_vertex.push_back(pNodeList[i]);
68  }
69 
70  if (m_conf.m_order > 1)
71  {
72  for (int j = 0; j < n; ++j)
73  {
74  m_volumeNodes.push_back(pNodeList[2 + j]);
75  }
76  }
77 }
78 
80 {
81  // Create edge vertices.
84 
85  p[0] = m_vertex[0]->GetGeom(coordDim);
86  p[1] = m_vertex[1]->GetGeom(coordDim);
87 
88  if (m_edge[0]->m_edgeNodes.size() > 0)
89  {
92  m_id, m_edge[0]->m_curveType);
93 
94  c->m_points.push_back(p[0]);
95  for (int i = 0; i < m_edge[0]->m_edgeNodes.size(); ++i)
96  {
97  c->m_points.push_back(m_edge[0]->m_edgeNodes[i]->GetGeom(coordDim));
98  }
99  c->m_points.push_back(p[1]);
100 
102  m_id, 2, p, c);
103  }
104  else
105  {
107  m_id, 2, p);
108  }
109 
110  return ret;
111 }
112 
113 
114 void Line::GetCurvedNodes(std::vector<NodeSharedPtr> &nodeList) const
115 {
116  nodeList.push_back(m_vertex[0]);
117  for (int i = 0; i < m_volumeNodes.size(); ++i)
118  {
119  nodeList.push_back(m_volumeNodes[i]);
120  }
121  nodeList.push_back(m_vertex[1]);
122 }
123 void Line::MakeOrder(int order,
126  int coordDim,
127  int &id,
128  bool justConfig)
129 {
130  m_conf.m_order = order;
131  m_curveType = pType;
132  m_conf.m_volumeNodes = false;
133  m_volumeNodes.clear();
134 
135  // Lines of order == 1 have no interior volume points.
136  if (order == 1)
137  {
138  m_conf.m_faceNodes = false;
139  return;
140  }
141 
142  m_conf.m_faceNodes = true;
143 
144  if (justConfig)
145  {
146  return;
147  }
148 
149  int nPoints = order + 1;
150  StdRegions::StdExpansionSharedPtr xmap = geom->GetXmap();
151 
153  LibUtilities::PointsKey pKey(nPoints, pType);
154  ASSERTL1(pKey.GetPointsDim() == 1, "Points distribution must be 1D");
155  LibUtilities::PointsManager()[pKey]->GetPoints(px);
156 
157  Array<OneD, Array<OneD, NekDouble> > phys(coordDim);
158 
159  for (int i = 0; i < coordDim; ++i)
160  {
161  phys[i] = Array<OneD, NekDouble>(xmap->GetTotPoints());
162  xmap->BwdTrans(geom->GetCoeffs(i), phys[i]);
163  }
164 
165  int nQuadIntPts = (nPoints - 2) * (nPoints - 2);
166  m_volumeNodes.resize(nQuadIntPts);
167 
168  for (int i = 1, cnt = 0; i < nPoints-1; ++i)
169  {
171  xp[0] = px[i];
172 
173  Array<OneD, NekDouble> x(3, 0.0);
174  for (int k = 0; k < coordDim; ++k)
175  {
176  x[k] = xmap->PhysEvaluate(xp, phys[k]);
177  }
178 
179  m_volumeNodes[cnt] = boost::shared_ptr<Node>(
180  new Node(id++, x[0], x[1], x[2]));
181  }
182 }
183 
184 /**
185  * @brief Return the number of nodes defining a line.
186  */
187 unsigned int Line::GetNumNodes(ElmtConfig pConf)
188 {
189  return pConf.m_order + 1;
190 }
191 }
192 }
bool m_faceNodes
Denotes whether the element contains face nodes. For 2D elements, if this is true then the element co...
Definition: ElementConfig.h:80
Basic information about an element.
Definition: ElementConfig.h:50
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
STL namespace.
ElementFactory & GetElementFactory()
Definition: Element.cpp:47
ElmtConfig m_conf
Contains configuration of the element.
Definition: Element.h:380
boost::shared_ptr< Curve > CurveSharedPtr
Definition: Curve.hpp:62
std::vector< int > m_taglist
List of integers specifying properties of the element.
Definition: Element.h:384
unsigned int m_order
Order of the element.
Definition: ElementConfig.h:87
static NEKMESHUTILS_EXPORT unsigned int GetNumNodes(ElmtConfig pConf)
Return the number of nodes defining a line.
Definition: Line.cpp:187
std::vector< NodeSharedPtr > m_vertex
List of element vertex nodes.
Definition: Element.h:386
unsigned int m_dim
Dimension of the element.
Definition: Element.h:378
bool m_volumeNodes
Denotes whether the element contains volume (i.e. interior) nodes. These are not supported by either ...
Definition: ElementConfig.h:85
boost::shared_ptr< SegGeom > SegGeomSharedPtr
Definition: Geometry2D.h:60
std::vector< EdgeSharedPtr > m_edge
List of element edges.
Definition: Element.h:388
virtual NEKMESHUTILS_EXPORT void GetCurvedNodes(std::vector< NodeSharedPtr > &nodeList) const
get list of volume interior nodes
Definition: Line.cpp:114
unsigned int GetPointsDim() const
Definition: Points.h:149
PointsManagerT & PointsManager(void)
Defines a specification for a set of points.
Definition: Points.h:58
std::vector< NodeSharedPtr > m_volumeNodes
List of element volume nodes.
Definition: Element.h:392
std::string m_tag
Tag character describing the element.
Definition: Element.h:382
virtual NEKMESHUTILS_EXPORT SpatialDomains::GeometrySharedPtr GetGeom(int coordDim)
Generate a Nektar++ geometry object for this element.
Definition: Line.cpp:79
unsigned int m_id
ID of the element.
Definition: Element.h:376
LibUtilities::PointsType m_curveType
Volume curve type.
Definition: Element.h:394
virtual NEKMESHUTILS_EXPORT void MakeOrder(int order, SpatialDomains::GeometrySharedPtr geom, LibUtilities::PointsType pType, int coordDim, int &id, bool justConfig=false)
Insert interior (i.e. volume) points into this element to make the geometry an order order representa...
Definition: Line.cpp:123
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:228
boost::shared_ptr< Geometry > GeometrySharedPtr
Definition: Geometry.h:53
boost::shared_ptr< PointGeom > PointGeomSharedPtr
Definition: Geometry.h:60
Base class for element definitions.
Definition: Element.h:59
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215