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