Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Pyramid.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Pyramid.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 pyramid object.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
36 #include <SpatialDomains/PyrGeom.h>
38 
39 using namespace std;
40 
41 namespace Nektar
42 {
43 namespace NekMeshUtils
44 {
45 
46 LibUtilities::ShapeType Pyramid::type =
48  LibUtilities::ePyramid, Pyramid::create, "Pyramid");
49 
50 /// Vertex IDs that make up pyramid faces.
51 int Pyramid::m_faceIds[5][4] = {
52  {0, 1, 2, 3}, {0, 1, 4, -1}, {1, 2, 4, -1}, {3, 2, 4, -1}, {0, 3, 4, -1}
53 };
54 
55 /**
56  * @brief Create a pyramidic element.
57  */
58 Pyramid::Pyramid(ElmtConfig pConf,
59  vector<NodeSharedPtr> pNodeList,
60  vector<int> pTagList)
61  : Element(pConf, GetNumNodes(pConf), pNodeList.size())
62 {
63  m_tag = "P";
64  m_dim = 3;
65  m_taglist = pTagList;
66  int n = m_conf.m_order - 1;
67 
68  // This edge-node map is based on Nektar++ ordering.
69  map<pair<int, int>, int> edgeNodeMap;
70  map<pair<int, int>, int>::iterator it;
71  edgeNodeMap[pair<int, int>(1, 2)] = 6;
72  edgeNodeMap[pair<int, int>(2, 3)] = 6 + n;
73  edgeNodeMap[pair<int, int>(4, 3)] = 6 + 2 * n;
74  edgeNodeMap[pair<int, int>(1, 4)] = 6 + 3 * n;
75  edgeNodeMap[pair<int, int>(1, 5)] = 6 + 4 * n;
76  edgeNodeMap[pair<int, int>(2, 5)] = 6 + 5 * n;
77  edgeNodeMap[pair<int, int>(3, 5)] = 6 + 6 * n;
78  edgeNodeMap[pair<int, int>(4, 5)] = 6 + 7 * n;
79 
80  // Add vertices
81  for (int i = 0; i < 5; ++i)
82  {
83  m_vertex.push_back(pNodeList[i]);
84  }
85 
86  // Create edges (with corresponding set of edge points)
87  int eid = 0;
88  for (it = edgeNodeMap.begin(); it != edgeNodeMap.end(); ++it)
89  {
90  vector<NodeSharedPtr> edgeNodes;
91  if (m_conf.m_order > 1)
92  {
93  for (int j = it->second; j < it->second + n; ++j)
94  {
95  edgeNodes.push_back(pNodeList[j - 1]);
96  }
97  }
98  m_edge.push_back(EdgeSharedPtr(new Edge(pNodeList[it->first.first - 1],
99  pNodeList[it->first.second - 1],
100  edgeNodes,
102  m_edge.back()->m_id = eid++;
103  }
104 
105  // Create faces
106  int face_edges[5][4];
107  int faceoffset = 5 + 8 * n;
108  for (int j = 0; j < 5; ++j)
109  {
110  vector<NodeSharedPtr> faceVertices;
111  vector<EdgeSharedPtr> faceEdges;
112  vector<NodeSharedPtr> faceNodes;
113  int nEdge = j > 0 ? 3 : 4;
114 
115  for (int k = 0; k < nEdge; ++k)
116  {
117  faceVertices.push_back(m_vertex[m_faceIds[j][k]]);
118  NodeSharedPtr a = m_vertex[m_faceIds[j][k]];
119  NodeSharedPtr b = m_vertex[m_faceIds[j][(k + 1) % nEdge]];
120  for (unsigned int i = 0; i < m_edge.size(); ++i)
121  {
122  if ((m_edge[i]->m_n1 == a && m_edge[i]->m_n2 == b) ||
123  (m_edge[i]->m_n1 == b && m_edge[i]->m_n2 == a))
124  {
125  faceEdges.push_back(m_edge[i]);
126  face_edges[j][k] = i;
127  break;
128  }
129  }
130  }
131 
132  if (m_conf.m_faceNodes)
133  {
134  int facenodes = j == 0 ? n * n : n * (n - 1) / 2;
135  for (int i = 0; i < facenodes; ++i)
136  {
137  faceNodes.push_back(pNodeList[faceoffset + i]);
138  }
139  faceoffset += facenodes;
140  }
141  m_face.push_back(FaceSharedPtr(new Face(
142  faceVertices, faceNodes, faceEdges, m_conf.m_faceCurveType)));
143  }
144 
145  // Reorder edges to align with Nektar++ order.
146  vector<EdgeSharedPtr> tmp(8);
147  tmp[0] = m_edge[face_edges[0][0]];
148  tmp[1] = m_edge[face_edges[0][1]];
149  tmp[2] = m_edge[face_edges[0][2]];
150  tmp[3] = m_edge[face_edges[0][3]];
151  tmp[4] = m_edge[face_edges[1][2]];
152  tmp[5] = m_edge[face_edges[1][1]];
153  tmp[6] = m_edge[face_edges[3][1]];
154  tmp[7] = m_edge[face_edges[3][2]];
155  m_edge = tmp;
156 }
157 
159 {
161 
162  for (int i = 0; i < 5; ++i)
163  {
164  faces[i] = m_face[i]->GetGeom(coordDim);
165  }
166 
168 
169  return m_geom;
170 }
171 
172 /**
173  * @brief Return the number of nodes defining a pyramid.
174  */
175 unsigned int Pyramid::GetNumNodes(ElmtConfig pConf)
176 {
177  int n = pConf.m_order;
178  return 5 + 8 * (n - 1);
179 }
180 }
181 }
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
LibUtilities::PointsType m_faceCurveType
Distribution of points in faces.
Definition: ElementConfig.h:94
Represents an edge which joins two points.
Definition: Edge.h:58
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
Represents a face comprised of three or more edges.
Definition: Face.h:61
STL namespace.
virtual NEKMESHUTILS_EXPORT SpatialDomains::GeometrySharedPtr GetGeom(int coordDim)
Generate a Nektar++ geometry object for this element.
Definition: Pyramid.cpp:158
ElementFactory & GetElementFactory()
Definition: Element.cpp:47
ElmtConfig m_conf
Contains configuration of the element.
Definition: Element.h:380
std::vector< int > m_taglist
List of integers specifying properties of the element.
Definition: Element.h:384
LibUtilities::PointsType m_edgeCurveType
Distribution of points in edges.
Definition: ElementConfig.h:92
unsigned int m_order
Order of the element.
Definition: ElementConfig.h:87
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
std::vector< EdgeSharedPtr > m_edge
List of element edges.
Definition: Element.h:388
boost::shared_ptr< Node > NodeSharedPtr
Definition: Node.h:50
std::string m_tag
Tag character describing the element.
Definition: Element.h:382
boost::shared_ptr< Geometry2D > Geometry2DSharedPtr
Definition: Geometry2D.h:59
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: Edge.h:136
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
SpatialDomains::GeometrySharedPtr m_geom
Nektar++ geometry object for this element.
Definition: Element.h:403
static NEKMESHUTILS_EXPORT unsigned int GetNumNodes(ElmtConfig pConf)
Return the number of nodes defining a pyramid.
Definition: Pyramid.cpp:175
std::vector< FaceSharedPtr > m_face
List of element faces.
Definition: Element.h:390
boost::shared_ptr< Face > FaceSharedPtr
Definition: Face.h:153
static int m_faceIds[5][4]
Vertex IDs that make up pyramid faces.
Definition: Pyramid.h:85
boost::shared_ptr< Geometry > GeometrySharedPtr
Definition: Geometry.h:53
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