Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
NodalPrismElec.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File NodalPrismElec.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: 3D Nodal Prism eletrostatic Point Definitions
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
40 #include <vector>
41 
42 namespace Nektar
43 {
44 namespace LibUtilities
45 {
46 namespace
47 {
48 bool isVertex(int t, int y, int npts)
49 {
50  return (t == 0 && y == 0) || (t == 1 && y == 0) || (t == 2 && y == 0) ||
51  (t == 0 && y == (npts - 1)) || (t == 1 && y == (npts - 1)) ||
52  (t == 2 && y == (npts - 1));
53 }
54 
55 bool isEdge_01(int t, int y, int npts)
56 {
57  return y == 0 && t > 2 && t <= npts;
58 }
59 
60 bool isEdge_12(int t, int y, int npts)
61 {
62  return t == 1;
63 }
64 
65 bool isEdge_23(int t, int y, int npts)
66 {
67  return y == (npts - 1) && t > 2 && t <= npts;
68 }
69 
70 bool isEdge_30(int t, int y, int npts)
71 {
72  return t == 0;
73 }
74 
75 bool isEdge_04(int t, int y, int npts)
76 {
77  return y == 0 && t >= 3 + 2 * (npts - 2) && t < 3 + 3 * (npts - 2);
78 }
79 
80 bool isEdge_14(int t, int y, int npts)
81 {
82  return y == 0 && t >= 3 + (npts - 2) && t < 3 + 2 * (npts - 2);
83 }
84 
85 bool isEdge_25(int t, int y, int npts)
86 {
87  return y == npts - 1 && t >= 3 + (npts - 2) && t < 3 + 2 * (npts - 2);
88 }
89 
90 bool isEdge_35(int t, int y, int npts)
91 {
92  return y == npts - 1 && t >= 3 + 2 * (npts - 2) && t < 3 + 3 * (npts - 2);
93 }
94 
95 bool isEdge_45(int t, int y, int npts)
96 {
97  return t == 2;
98 }
99 
100 bool isEdge(int t, int y, int npts)
101 {
102  return isEdge_01(t, y, npts) || isEdge_12(t, y, npts) ||
103  isEdge_23(t, y, npts) || isEdge_30(t, y, npts) ||
104  isEdge_04(t, y, npts) || isEdge_14(t, y, npts) ||
105  isEdge_25(t, y, npts) || isEdge_35(t, y, npts) ||
106  isEdge_45(t, y, npts);
107 }
108 
109 bool isFace_0123(int t, int y, int npts)
110 {
111  return t < 3 + (npts - 2);
112 }
113 
114 bool isFace_014(int t, int y, int npts)
115 {
116  return y == 0;
117 }
118 
119 bool isFace_1254(int t, int y, int npts)
120 {
121  return t < 3 + 2 * (npts - 2) && t >= 3 + (npts - 2);
122 }
123 
124 bool isFace_325(int t, int y, int npts)
125 {
126  return y == (npts - 1);
127 }
128 
129 bool isFace_0354(int t, int y, int npts)
130 {
131  return t < 3 + 3 * (npts - 2) && t >= 3 + 2 * (npts - 2);
132 }
133 
134 bool isFace(int t, int y, int npts)
135 {
136  return isFace_0123(t, y, npts) || isFace_014(t, y, npts) ||
137  isFace_1254(t, y, npts) || isFace_325(t, y, npts) ||
138  isFace_0354(t, y, npts);
139 }
140 }
141 
142 // Calculate evenly spaced number of points
144 {
145  // Allocate the storage for points
147 
148  // Populate m_points
149  unsigned int npts = GetNumPoints();
150 
152  Array<OneD, NekDouble> u1, v1;
153  LibUtilities::PointsManager()[pkey1]->GetPoints(u1, v1);
156  LibUtilities::PointsManager()[pkey2]->GetPoints(u);
157 
158  for (int y = 0, index = 0; y < npts; y++)
159  {
160  for (int t = 0; t < u1.num_elements(); t++, index++)
161  {
162  m_points[0][index] = u1[t];
163  m_points[1][index] = u[y];
164  m_points[2][index] = v1[t];
165  }
166  }
167 
170  npts - 1, m_points[0], m_points[1], m_points[2]);
171 }
172 
174 {
175  unsigned int npts = GetNumPoints();
176  using std::vector;
177  vector<int> vertex;
178  vector<int> iEdge_01; // interior edge 0
179  vector<int> iEdge_12; // interior edge 1
180  vector<int> iEdge_23; // interior edge 2
181  vector<int> iEdge_30; // interior edge 3
182  vector<int> iEdge_04; // interior edge 4
183  vector<int> iEdge_14; // interior edge 5
184  vector<int> iEdge_25; // interior edge 6
185  vector<int> iEdge_35; // interior edge 7
186  vector<int> iEdge_45; // interior edge 8
187  vector<int> iFace_0123; // interior face 0
188  vector<int> iFace_014; // interior face 1
189  vector<int> iFace_1254; // interior face 2
190  vector<int> iFace_325; // interior face 3
191  vector<int> iFace_0354; // interior face 4
192  vector<int> interiorVolumePoints; // interior volume points
193  vector<int> map;
194 
195  // Build the lattice prism left to right - bottom to top
196  for (int y = 0, index = 0; y < npts; y++)
197  {
198  for (int t = 0; t < npts * (npts + 1) / 2; t++, index++)
199  {
200  if (isVertex(t, y, npts))
201  {
202  vertex.push_back(index);
203  }
204  else if (isEdge(t, y, npts))
205  {
206  if (isEdge_01(t, y, npts))
207  {
208  iEdge_01.push_back(index);
209  }
210  else if (isEdge_12(t, y, npts))
211  {
212  iEdge_12.push_back(index);
213  }
214  else if (isEdge_23(t, y, npts))
215  {
216  iEdge_23.push_back(index);
217  }
218  else if (isEdge_30(t, y, npts))
219  {
220  iEdge_30.push_back(index);
221  }
222  else if (isEdge_04(t, y, npts))
223  {
224  iEdge_04.push_back(index);
225  }
226  else if (isEdge_14(t, y, npts))
227  {
228  iEdge_14.push_back(index);
229  }
230  else if (isEdge_25(t, y, npts))
231  {
232  iEdge_25.push_back(index);
233  }
234  else if (isEdge_35(t, y, npts))
235  {
236  iEdge_35.push_back(index);
237  }
238  else if (isEdge_45(t, y, npts))
239  {
240  iEdge_45.push_back(index);
241  }
242  }
243  else if (isFace(t, y, npts))
244  {
245  if (isFace_0123(t, y, npts))
246  {
247  iFace_0123.push_back(index);
248  }
249  else if (isFace_014(t, y, npts))
250  {
251  iFace_014.push_back(index);
252  }
253  else if (isFace_1254(t, y, npts))
254  {
255  iFace_1254.push_back(index);
256  }
257  else if (isFace_325(t, y, npts))
258  {
259  iFace_325.push_back(index);
260  }
261  else if (isFace_0354(t, y, npts))
262  {
263  iFace_0354.push_back(index);
264  }
265  }
266  else
267  {
268  interiorVolumePoints.push_back(index);
269  }
270  }
271  }
272 
273  // sort vertices
274  swap(vertex[2], vertex[4]);
275  // sort edges
276  reverse(iEdge_23.begin(), iEdge_23.end());
277  reverse(iEdge_30.begin(), iEdge_30.end());
278  reverse(iEdge_04.begin(), iEdge_04.end());
279  reverse(iEdge_35.begin(), iEdge_35.end());
280 
281  // faces
282  for (int i = 0; i < npts - 2; i++)
283  {
284  for (int j = i + 1; j < npts - 2; j++)
285  {
286  swap(iFace_1254[i * (npts - 2) + j],
287  iFace_1254[j * (npts - 2) + i]);
288  }
289  }
290  for (int i = 0; i < npts - 2; i++)
291  {
292  reverse(iFace_0354.begin() + i * (npts - 2),
293  iFace_0354.begin() + i * (npts - 2) + npts - 2);
294  }
295  for (int i = 0; i < npts - 2; i++)
296  {
297  for (int j = i + 1; j < npts - 2; j++)
298  {
299  swap(iFace_0354[i * (npts - 2) + j],
300  iFace_0354[j * (npts - 2) + i]);
301  }
302  }
303 
304  for (unsigned int n = 0; n < vertex.size(); ++n)
305  {
306  map.push_back(vertex[n]);
307  }
308 
309  for (unsigned int n = 0; n < iEdge_01.size(); ++n)
310  {
311  map.push_back(iEdge_01[n]);
312  }
313 
314  for (unsigned int n = 0; n < iEdge_12.size(); ++n)
315  {
316  map.push_back(iEdge_12[n]);
317  }
318 
319  for (unsigned int n = 0; n < iEdge_23.size(); ++n)
320  {
321  map.push_back(iEdge_23[n]);
322  }
323 
324  for (unsigned int n = 0; n < iEdge_30.size(); ++n)
325  {
326  map.push_back(iEdge_30[n]);
327  }
328 
329  for (unsigned int n = 0; n < iEdge_04.size(); ++n)
330  {
331  map.push_back(iEdge_04[n]);
332  }
333 
334  for (unsigned int n = 0; n < iEdge_14.size(); ++n)
335  {
336  map.push_back(iEdge_14[n]);
337  }
338 
339  for (unsigned int n = 0; n < iEdge_25.size(); ++n)
340  {
341  map.push_back(iEdge_25[n]);
342  }
343 
344  for (unsigned int n = 0; n < iEdge_35.size(); ++n)
345  {
346  map.push_back(iEdge_35[n]);
347  }
348 
349  for (unsigned int n = 0; n < iEdge_45.size(); ++n)
350  {
351  map.push_back(iEdge_45[n]);
352  }
353 
354  for (unsigned int n = 0; n < iFace_0123.size(); ++n)
355  {
356  map.push_back(iFace_0123[n]);
357  }
358 
359  for (unsigned int n = 0; n < iFace_014.size(); ++n)
360  {
361  map.push_back(iFace_014[n]);
362  }
363 
364  for (unsigned int n = 0; n < iFace_1254.size(); ++n)
365  {
366  map.push_back(iFace_1254[n]);
367  }
368 
369  for (unsigned int n = 0; n < iFace_325.size(); ++n)
370  {
371  map.push_back(iFace_325[n]);
372  }
373 
374  for (unsigned int n = 0; n < iFace_0354.size(); ++n)
375  {
376  map.push_back(iFace_0354[n]);
377  }
378 
379  for (unsigned int n = 0; n < interiorVolumePoints.size(); ++n)
380  {
381  map.push_back(interiorVolumePoints[n]);
382  }
383 
384  Array<OneD, NekDouble> points[3];
388 
389  for (unsigned int index = 0; index < map.size(); ++index)
390  {
391  points[0][index] = m_points[0][index];
392  points[1][index] = m_points[1][index];
393  points[2][index] = m_points[2][index];
394  }
395 
396  for (unsigned int index = 0; index < map.size(); ++index)
397  {
398  m_points[0][index] = points[0][map[index]];
399  m_points[1][index] = points[1][map[index]];
400  m_points[2][index] = points[2][map[index]];
401  }
402 }
403 
405 {
406  // Allocate the storage for points
408 
409  typedef DataType T;
410 
411  // Solve the Vandermonde system of integrals for the weight vector
412  NekVector<T> w = m_util->GetWeights();
413 
415 }
416 
417 // ////////////////////////////////////////
418 // CalculateInterpMatrix()
420  const Array<OneD, const NekDouble> &xia,
421  const Array<OneD, const NekDouble> &yia,
423 {
425  xi[0] = xia;
426  xi[1] = yia;
427  xi[1] = zia;
428 
429  boost::shared_ptr<NekMatrix<NekDouble> > mat =
430  m_util->GetInterpolationMatrix(xi);
431  Vmath::Vcopy(mat->GetRows() * mat->GetColumns(), mat->GetRawPtr(), 1,
432  &interp[0], 1);
433 }
434 
435 // ////////////////////////////////////////
436 // CalculateDerivMatrix()
438 {
439  // Allocate the derivative matrix.
441 
442  m_derivmatrix[0] = m_util->GetDerivMatrix(0);
443  m_derivmatrix[1] = m_util->GetDerivMatrix(1);
444  m_derivmatrix[2] = m_util->GetDerivMatrix(2);
445 }
446 
447 boost::shared_ptr<PointsBaseType> NodalPrismElec::Create(const PointsKey &key)
448 {
449  boost::shared_ptr<PointsBaseType> returnval(
451 
452  returnval->Initialize();
453 
454  return returnval;
455 }
456 
457 }
458 }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
boost::shared_ptr< NodalUtilPrism > m_util
MatrixSharedPtrType m_derivmatrix[3]
Definition: Points.h:373
Array< OneD, DataType > m_points[3]
Definition: Points.h:371
void CalculateInterpMatrix(const Array< OneD, const NekDouble > &xi, const Array< OneD, const NekDouble > &yi, const Array< OneD, const NekDouble > &zi, Array< OneD, NekDouble > &interp)
unsigned int GetNumPoints() const
Definition: Points.h:268
static std::string npts
Definition: InputFld.cpp:43
PointsManagerT & PointsManager(void)
Array< OneD, DataType > m_weights
Definition: Points.h:372
Defines a specification for a set of points.
Definition: Points.h:58
static boost::shared_ptr< PointsBaseType > Create(const PointsKey &key)
unsigned int GetRows() const
Definition: NekVector.cpp:218
unsigned int GetTotNumPoints() const
Definition: Points.h:273
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1061
Array< OneD, DataType > & GetPtr()
Definition: NekVector.cpp:230
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:52
2D Nodal Electrostatic Points on a Triangle
Definition: PointsType.h:70