Nektar++
PrismExp.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: PrismExp.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: PrismExp routines
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <boost/core/ignore_unused.hpp>
36 
39 #include <LocalRegions/PrismExp.h>
40 #include <SpatialDomains/SegGeom.h>
41 
42 using namespace std;
43 
44 namespace Nektar
45 {
46 namespace LocalRegions
47 {
48 
49 PrismExp::PrismExp(const LibUtilities::BasisKey &Ba,
50  const LibUtilities::BasisKey &Bb,
51  const LibUtilities::BasisKey &Bc,
53  : StdExpansion(LibUtilities::StdPrismData::getNumberOfCoefficients(
54  Ba.GetNumModes(), Bb.GetNumModes(), Bc.GetNumModes()),
55  3, Ba, Bb, Bc),
56  StdExpansion3D(LibUtilities::StdPrismData::getNumberOfCoefficients(
57  Ba.GetNumModes(), Bb.GetNumModes(), Bc.GetNumModes()),
58  Ba, Bb, Bc),
59  StdPrismExp(Ba, Bb, Bc), Expansion(geom), Expansion3D(geom),
60  m_matrixManager(
61  std::bind(&Expansion3D::CreateMatrix, this, std::placeholders::_1),
62  std::string("PrismExpMatrix")),
63  m_staticCondMatrixManager(std::bind(&Expansion::CreateStaticCondMatrix,
64  this, std::placeholders::_1),
65  std::string("PrismExpStaticCondMatrix"))
66 {
67 }
68 
70  : StdExpansion(T), StdExpansion3D(T), StdPrismExp(T), Expansion(T),
71  Expansion3D(T), m_matrixManager(T.m_matrixManager),
72  m_staticCondMatrixManager(T.m_staticCondMatrixManager)
73 {
74 }
75 
76 //-------------------------------
77 // Integration Methods
78 //-------------------------------
79 
80 /**
81  * \brief Integrate the physical point list \a inarray over prismatic
82  * region and return the value.
83  *
84  * Inputs:\n
85  *
86  * - \a inarray: definition of function to be returned at quadrature
87  * point of expansion.
88  *
89  * Outputs:\n
90  *
91  * - returns \f$\int^1_{-1}\int^1_{-1}\int^1_{-1} u(\bar \eta_1,
92  * \xi_2, \xi_3) J[i,j,k] d \bar \eta_1 d \xi_2 d \xi_3 \f$ \n \f$ =
93  * \sum_{i=0}^{Q_1 - 1} \sum_{j=0}^{Q_2 - 1} \sum_{k=0}^{Q_3 - 1}
94  * u(\bar \eta_{1i}^{0,0}, \xi_{2j}^{0,0},\xi_{3k}^{1,0})w_{i}^{0,0}
95  * w_{j}^{0,0} \hat w_{k}^{1,0} \f$ \n where \f$ inarray[i,j, k] =
96  * u(\bar \eta_{1i}^{0,0}, \xi_{2j}^{0,0},\xi_{3k}^{1,0}) \f$, \n
97  * \f$\hat w_{i}^{1,0} = \frac {w_{j}^{1,0}} {2} \f$ \n and \f$
98  * J[i,j,k] \f$ is the Jacobian evaluated at the quadrature point.
99  */
101 {
102  int nquad0 = m_base[0]->GetNumPoints();
103  int nquad1 = m_base[1]->GetNumPoints();
104  int nquad2 = m_base[2]->GetNumPoints();
106  Array<OneD, NekDouble> tmp(nquad0 * nquad1 * nquad2);
107 
108  // Multiply inarray with Jacobian
109  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
110  {
111  Vmath::Vmul(nquad0 * nquad1 * nquad2, &jac[0], 1,
112  (NekDouble *)&inarray[0], 1, &tmp[0], 1);
113  }
114  else
115  {
116  Vmath::Smul(nquad0 * nquad1 * nquad2, (NekDouble)jac[0],
117  (NekDouble *)&inarray[0], 1, &tmp[0], 1);
118  }
119 
120  // Call StdPrismExp version.
121  return StdPrismExp::v_Integral(tmp);
122 }
123 
124 //----------------------------
125 // Differentiation Methods
126 //----------------------------
128  Array<OneD, NekDouble> &out_d0,
129  Array<OneD, NekDouble> &out_d1,
130  Array<OneD, NekDouble> &out_d2)
131 {
132  int nqtot = GetTotPoints();
133 
135  m_metricinfo->GetDerivFactors(GetPointsKeys());
136  Array<OneD, NekDouble> diff0(nqtot);
137  Array<OneD, NekDouble> diff1(nqtot);
138  Array<OneD, NekDouble> diff2(nqtot);
139 
140  StdPrismExp::v_PhysDeriv(inarray, diff0, diff1, diff2);
141 
142  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
143  {
144  if (out_d0.size())
145  {
146  Vmath::Vmul(nqtot, &df[0][0], 1, &diff0[0], 1, &out_d0[0], 1);
147  Vmath::Vvtvp(nqtot, &df[1][0], 1, &diff1[0], 1, &out_d0[0], 1,
148  &out_d0[0], 1);
149  Vmath::Vvtvp(nqtot, &df[2][0], 1, &diff2[0], 1, &out_d0[0], 1,
150  &out_d0[0], 1);
151  }
152 
153  if (out_d1.size())
154  {
155  Vmath::Vmul(nqtot, &df[3][0], 1, &diff0[0], 1, &out_d1[0], 1);
156  Vmath::Vvtvp(nqtot, &df[4][0], 1, &diff1[0], 1, &out_d1[0], 1,
157  &out_d1[0], 1);
158  Vmath::Vvtvp(nqtot, &df[5][0], 1, &diff2[0], 1, &out_d1[0], 1,
159  &out_d1[0], 1);
160  }
161 
162  if (out_d2.size())
163  {
164  Vmath::Vmul(nqtot, &df[6][0], 1, &diff0[0], 1, &out_d2[0], 1);
165  Vmath::Vvtvp(nqtot, &df[7][0], 1, &diff1[0], 1, &out_d2[0], 1,
166  &out_d2[0], 1);
167  Vmath::Vvtvp(nqtot, &df[8][0], 1, &diff2[0], 1, &out_d2[0], 1,
168  &out_d2[0], 1);
169  }
170  }
171  else // regular geometry
172  {
173  if (out_d0.size())
174  {
175  Vmath::Smul(nqtot, df[0][0], &diff0[0], 1, &out_d0[0], 1);
176  Blas::Daxpy(nqtot, df[1][0], &diff1[0], 1, &out_d0[0], 1);
177  Blas::Daxpy(nqtot, df[2][0], &diff2[0], 1, &out_d0[0], 1);
178  }
179 
180  if (out_d1.size())
181  {
182  Vmath::Smul(nqtot, df[3][0], &diff0[0], 1, &out_d1[0], 1);
183  Blas::Daxpy(nqtot, df[4][0], &diff1[0], 1, &out_d1[0], 1);
184  Blas::Daxpy(nqtot, df[5][0], &diff2[0], 1, &out_d1[0], 1);
185  }
186 
187  if (out_d2.size())
188  {
189  Vmath::Smul(nqtot, df[6][0], &diff0[0], 1, &out_d2[0], 1);
190  Blas::Daxpy(nqtot, df[7][0], &diff1[0], 1, &out_d2[0], 1);
191  Blas::Daxpy(nqtot, df[8][0], &diff2[0], 1, &out_d2[0], 1);
192  }
193  }
194 }
195 
196 //---------------------------------------
197 // Transforms
198 //---------------------------------------
199 
200 /**
201  * \brief Forward transform from physical quadrature space stored in
202  * \a inarray and evaluate the expansion coefficients and store in \a
203  * (this)->m_coeffs
204  *
205  * Inputs:\n
206  *
207  * - \a inarray: array of physical quadrature points to be transformed
208  *
209  * Outputs:\n
210  *
211  * - (this)->_coeffs: updated array of expansion coefficients.
212  */
214  Array<OneD, NekDouble> &outarray)
215 {
216  if (m_base[0]->Collocation() && m_base[1]->Collocation() &&
217  m_base[2]->Collocation())
218  {
219  Vmath::Vcopy(GetNcoeffs(), &inarray[0], 1, &outarray[0], 1);
220  }
221  else
222  {
223  v_IProductWRTBase(inarray, outarray);
224 
225  // get Mass matrix inverse
226  MatrixKey masskey(StdRegions::eInvMass, DetShapeType(), *this);
227  DNekScalMatSharedPtr matsys = m_matrixManager[masskey];
228 
229  // copy inarray in case inarray == outarray
230  DNekVec in(m_ncoeffs, outarray);
231  DNekVec out(m_ncoeffs, outarray, eWrapper);
232 
233  out = (*matsys) * in;
234  }
235 }
236 
237 //---------------------------------------
238 // Inner product functions
239 //---------------------------------------
240 
241 /**
242  * \brief Calculate the inner product of inarray with respect to the
243  * basis B=base0*base1*base2 and put into outarray:
244  *
245  * \f$ \begin{array}{rcl} I_{pqr} = (\phi_{pqr}, u)_{\delta} & = &
246  * \sum_{i=0}^{nq_0} \sum_{j=0}^{nq_1} \sum_{k=0}^{nq_2} \psi_{p}^{a}
247  * (\bar \eta_{1i}) \psi_{q}^{a} (\xi_{2j}) \psi_{pr}^{b} (\xi_{3k})
248  * w_i w_j w_k u(\bar \eta_{1,i} \xi_{2,j} \xi_{3,k}) J_{i,j,k}\\ & =
249  * & \sum_{i=0}^{nq_0} \psi_p^a(\bar \eta_{1,i}) \sum_{j=0}^{nq_1}
250  * \psi_{q}^a(\xi_{2,j}) \sum_{k=0}^{nq_2} \psi_{pr}^b u(\bar
251  * \eta_{1i},\xi_{2j},\xi_{3k}) J_{i,j,k} \end{array} \f$ \n
252  *
253  * where
254  *
255  * \f$ \phi_{pqr} (\xi_1 , \xi_2 , \xi_3) = \psi_p^a (\bar \eta_1)
256  * \psi_{q}^a (\xi_2) \psi_{pr}^b (\xi_3) \f$ \n
257  *
258  * which can be implemented as \n \f$f_{pr} (\xi_{3k}) =
259  * \sum_{k=0}^{nq_3} \psi_{pr}^b u(\bar \eta_{1i},\xi_{2j},\xi_{3k})
260  * J_{i,j,k} = {\bf B_3 U} \f$ \n \f$ g_{q} (\xi_{3k}) =
261  * \sum_{j=0}^{nq_1} \psi_{q}^a (\xi_{2j}) f_{pr} (\xi_{3k}) = {\bf
262  * B_2 F} \f$ \n \f$ (\phi_{pqr}, u)_{\delta} = \sum_{k=0}^{nq_0}
263  * \psi_{p}^a (\xi_{3k}) g_{q} (\xi_{3k}) = {\bf B_1 G} \f$
264  */
266  Array<OneD, NekDouble> &outarray)
267 {
268  v_IProductWRTBase_SumFac(inarray, outarray);
269 }
270 
272  const Array<OneD, const NekDouble> &inarray,
273  Array<OneD, NekDouble> &outarray, bool multiplybyweights)
274 {
275  const int nquad0 = m_base[0]->GetNumPoints();
276  const int nquad1 = m_base[1]->GetNumPoints();
277  const int nquad2 = m_base[2]->GetNumPoints();
278  const int order0 = m_base[0]->GetNumModes();
279  const int order1 = m_base[1]->GetNumModes();
280 
281  Array<OneD, NekDouble> wsp(order0 * nquad2 * (nquad1 + order1));
282 
283  if (multiplybyweights)
284  {
285  Array<OneD, NekDouble> tmp(nquad0 * nquad1 * nquad2);
286 
287  MultiplyByQuadratureMetric(inarray, tmp);
288 
290  m_base[0]->GetBdata(), m_base[1]->GetBdata(), m_base[2]->GetBdata(),
291  tmp, outarray, wsp, true, true, true);
292  }
293  else
294  {
296  m_base[0]->GetBdata(), m_base[1]->GetBdata(), m_base[2]->GetBdata(),
297  inarray, outarray, wsp, true, true, true);
298  }
299 }
300 
301 /**
302  * @brief Calculates the inner product \f$ I_{pqr} = (u,
303  * \partial_{x_i} \phi_{pqr}) \f$.
304  *
305  * The derivative of the basis functions is performed using the chain
306  * rule in order to incorporate the geometric factors. Assuming that
307  * the basis functions are a tensor product
308  * \f$\phi_{pqr}(\eta_1,\eta_2,\eta_3) =
309  * \phi_1(\eta_1)\phi_2(\eta_2)\phi_3(\eta_3)\f$, this yields the
310  * result
311  *
312  * \f[
313  * I_{pqr} = \sum_{j=1}^3 \left(u, \frac{\partial u}{\partial \eta_j}
314  * \frac{\partial \eta_j}{\partial x_i}\right)
315  * \f]
316  *
317  * In the tetrahedral element, we must also incorporate a second set
318  * of geometric factors which incorporate the collapsed co-ordinate
319  * system, so that
320  *
321  * \f[ \frac{\partial\eta_j}{\partial x_i} = \sum_{k=1}^3
322  * \frac{\partial\eta_j}{\partial\xi_k}\frac{\partial\xi_k}{\partial
323  * x_i} \f]
324  *
325  * These derivatives can be found on p152 of Sherwin & Karniadakis.
326  *
327  * @param dir Direction in which to take the derivative.
328  * @param inarray The function \f$ u \f$.
329  * @param outarray Value of the inner product.
330  */
332  const int dir, const Array<OneD, const NekDouble> &inarray,
333  Array<OneD, NekDouble> &outarray)
334 {
335  v_IProductWRTDerivBase_SumFac(dir, inarray, outarray);
336 }
337 
339  const int dir, const Array<OneD, const NekDouble> &inarray,
340  Array<OneD, NekDouble> &outarray)
341 {
342  const int nquad0 = m_base[0]->GetNumPoints();
343  const int nquad1 = m_base[1]->GetNumPoints();
344  const int nquad2 = m_base[2]->GetNumPoints();
345  const int order0 = m_base[0]->GetNumModes();
346  const int order1 = m_base[1]->GetNumModes();
347  const int nqtot = nquad0 * nquad1 * nquad2;
348 
349  Array<OneD, NekDouble> tmp1(nqtot);
350  Array<OneD, NekDouble> tmp2(nqtot);
351  Array<OneD, NekDouble> tmp3(nqtot);
352  Array<OneD, NekDouble> tmp4(nqtot);
354  Array<OneD, NekDouble> wsp(order0 * nquad2 * (nquad1 + order1));
355 
356  MultiplyByQuadratureMetric(inarray, tmp1);
357 
359  tmp2D[0] = tmp2;
360  tmp2D[1] = tmp3;
361  tmp2D[2] = tmp4;
362 
363  PrismExp::v_AlignVectorToCollapsedDir(dir, tmp1, tmp2D);
364 
365  IProductWRTBase_SumFacKernel(m_base[0]->GetDbdata(), m_base[1]->GetBdata(),
366  m_base[2]->GetBdata(), tmp2, outarray, wsp,
367  true, true, true);
368 
369  IProductWRTBase_SumFacKernel(m_base[0]->GetBdata(), m_base[1]->GetDbdata(),
370  m_base[2]->GetBdata(), tmp3, tmp6, wsp, true,
371  true, true);
372 
373  Vmath::Vadd(m_ncoeffs, tmp6, 1, outarray, 1, outarray, 1);
374 
375  IProductWRTBase_SumFacKernel(m_base[0]->GetBdata(), m_base[1]->GetBdata(),
376  m_base[2]->GetDbdata(), tmp4, tmp6, wsp, true,
377  true, true);
378 
379  Vmath::Vadd(m_ncoeffs, tmp6, 1, outarray, 1, outarray, 1);
380 }
381 
383  const int dir, const Array<OneD, const NekDouble> &inarray,
384  Array<OneD, Array<OneD, NekDouble>> &outarray)
385 {
386  const int nquad0 = m_base[0]->GetNumPoints();
387  const int nquad1 = m_base[1]->GetNumPoints();
388  const int nquad2 = m_base[2]->GetNumPoints();
389  const int order0 = m_base[0]->GetNumModes();
390  const int order1 = m_base[1]->GetNumModes();
391  const int nqtot = nquad0 * nquad1 * nquad2;
392 
393  const Array<OneD, const NekDouble> &z0 = m_base[0]->GetZ();
394  const Array<OneD, const NekDouble> &z2 = m_base[2]->GetZ();
395 
396  Array<OneD, NekDouble> gfac0(nquad0);
397  Array<OneD, NekDouble> gfac2(nquad2);
398  Array<OneD, NekDouble> tmp1(nqtot);
399  Array<OneD, NekDouble> tmp5(nqtot);
401  Array<OneD, NekDouble> wsp(order0 * nquad2 * (nquad1 + order1));
402 
403  Array<OneD, NekDouble> tmp2 = outarray[0];
404  Array<OneD, NekDouble> tmp3 = outarray[1];
405  Array<OneD, NekDouble> tmp4 = outarray[2];
406 
407  const Array<TwoD, const NekDouble> &df =
408  m_metricinfo->GetDerivFactors(GetPointsKeys());
409 
410  Vmath::Vcopy(nqtot, inarray, 1, tmp1, 1); // Dir3 metric
411 
412  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
413  {
414  Vmath::Vmul(nqtot, &df[3 * dir][0], 1, tmp1.get(), 1, tmp2.get(), 1);
415  Vmath::Vmul(nqtot, &df[3 * dir + 1][0], 1, tmp1.get(), 1, tmp3.get(),
416  1);
417  Vmath::Vmul(nqtot, &df[3 * dir + 2][0], 1, tmp1.get(), 1, tmp4.get(),
418  1);
419  }
420  else
421  {
422  Vmath::Smul(nqtot, df[3 * dir][0], tmp1.get(), 1, tmp2.get(), 1);
423  Vmath::Smul(nqtot, df[3 * dir + 1][0], tmp1.get(), 1, tmp3.get(), 1);
424  Vmath::Smul(nqtot, df[3 * dir + 2][0], tmp1.get(), 1, tmp4.get(), 1);
425  }
426 
427  // set up geometric factor: (1+z0)/2
428  for (int i = 0; i < nquad0; ++i)
429  {
430  gfac0[i] = 0.5 * (1 + z0[i]);
431  }
432 
433  // Set up geometric factor: 2/(1-z2)
434  for (int i = 0; i < nquad2; ++i)
435  {
436  gfac2[i] = 2.0 / (1 - z2[i]);
437  }
438 
439  const int nq01 = nquad0 * nquad1;
440 
441  for (int i = 0; i < nquad2; ++i)
442  {
443  Vmath::Smul(nq01, gfac2[i], &tmp2[0] + i * nq01, 1, &tmp2[0] + i * nq01,
444  1);
445  Vmath::Smul(nq01, gfac2[i], &tmp4[0] + i * nq01, 1, &tmp5[0] + i * nq01,
446  1);
447  }
448 
449  for (int i = 0; i < nquad1 * nquad2; ++i)
450  {
451  Vmath::Vmul(nquad0, &gfac0[0], 1, &tmp5[0] + i * nquad0, 1,
452  &tmp5[0] + i * nquad0, 1);
453  }
454 
455  Vmath::Vadd(nqtot, &tmp2[0], 1, &tmp5[0], 1, &tmp2[0], 1);
456 }
457 
458 //---------------------------------------
459 // Evaluation functions
460 //---------------------------------------
461 
463 {
465  m_base[0]->GetBasisKey(), m_base[1]->GetBasisKey(),
466  m_base[2]->GetBasisKey());
467 }
468 
470 {
472  m_base[0]->GetPointsKey());
474  m_base[1]->GetPointsKey());
476  m_base[2]->GetPointsKey());
477 
479  bkey0, bkey1, bkey2);
480 }
481 
482 /**
483  * @brief Get the coordinates #coords at the local coordinates
484  * #Lcoords.
485  */
487  Array<OneD, NekDouble> &coords)
488 {
489  int i;
490 
491  ASSERTL1(Lcoords[0] <= -1.0 && Lcoords[0] >= 1.0 && Lcoords[1] <= -1.0 &&
492  Lcoords[1] >= 1.0 && Lcoords[2] <= -1.0 && Lcoords[2] >= 1.0,
493  "Local coordinates are not in region [-1,1]");
494 
495  m_geom->FillGeom();
496 
497  for (i = 0; i < m_geom->GetCoordim(); ++i)
498  {
499  coords[i] = m_geom->GetCoord(i, Lcoords);
500  }
501 }
502 
504  Array<OneD, NekDouble> &coords_1,
505  Array<OneD, NekDouble> &coords_2)
506 {
507  Expansion::v_GetCoords(coords_0, coords_1, coords_2);
508 }
509 
510 /**
511  * Given the local cartesian coordinate \a Lcoord evaluate the
512  * value of physvals at this point by calling through to the
513  * StdExpansion method
514  */
516  const Array<OneD, const NekDouble> &Lcoord,
517  const Array<OneD, const NekDouble> &physvals)
518 {
519  // Evaluate point in local (eta) coordinates.
520  return StdExpansion3D::v_PhysEvaluate(Lcoord, physvals);
521 }
522 
524  const Array<OneD, const NekDouble> &physvals)
525 {
526  Array<OneD, NekDouble> Lcoord(3);
527 
528  ASSERTL0(m_geom, "m_geom not defined");
529 
530  m_geom->GetLocCoords(coord, Lcoord);
531 
532  return StdExpansion3D::v_PhysEvaluate(Lcoord, physvals);
533 }
534 
536  const Array<OneD, const NekDouble> &inarray,
537  std::array<NekDouble, 3> &firstOrderDerivs)
538 {
539  Array<OneD, NekDouble> Lcoord(3);
540  ASSERTL0(m_geom, "m_geom not defined");
541  m_geom->GetLocCoords(coord, Lcoord);
542  return StdPrismExp::v_PhysEvaluate(Lcoord, inarray, firstOrderDerivs);
543 }
544 
545 //---------------------------------------
546 // Helper functions
547 //---------------------------------------
548 
550  const NekDouble *data, const std::vector<unsigned int> &nummodes,
551  const int mode_offset, NekDouble *coeffs,
552  std::vector<LibUtilities::BasisType> &fromType)
553 {
554  boost::ignore_unused(fromType);
555 
556  int data_order0 = nummodes[mode_offset];
557  int fillorder0 = min(m_base[0]->GetNumModes(), data_order0);
558  int data_order1 = nummodes[mode_offset + 1];
559  int order1 = m_base[1]->GetNumModes();
560  int fillorder1 = min(order1, data_order1);
561  int data_order2 = nummodes[mode_offset + 2];
562  int order2 = m_base[2]->GetNumModes();
563  int fillorder2 = min(order2, data_order2);
564 
565  switch (m_base[0]->GetBasisType())
566  {
568  {
569  int i, j;
570  int cnt = 0;
571  int cnt1 = 0;
572 
574  "Extraction routine not set up for this basis");
576  "Extraction routine not set up for this basis");
577 
578  Vmath::Zero(m_ncoeffs, coeffs, 1);
579  for (j = 0; j < fillorder0; ++j)
580  {
581  for (i = 0; i < fillorder1; ++i)
582  {
583  Vmath::Vcopy(fillorder2 - j, &data[cnt], 1, &coeffs[cnt1],
584  1);
585  cnt += data_order2 - j;
586  cnt1 += order2 - j;
587  }
588 
589  // count out data for j iteration
590  for (i = fillorder1; i < data_order1; ++i)
591  {
592  cnt += data_order2 - j;
593  }
594 
595  for (i = fillorder1; i < order1; ++i)
596  {
597  cnt1 += order2 - j;
598  }
599  }
600  }
601  break;
602  default:
603  ASSERTL0(false, "basis is either not set up or not "
604  "hierarchicial");
605  }
606 }
607 
608 void PrismExp::v_GetTracePhysMap(const int face, Array<OneD, int> &outarray)
609 {
610  int nquad0 = m_base[0]->GetNumPoints();
611  int nquad1 = m_base[1]->GetNumPoints();
612  int nquad2 = m_base[2]->GetNumPoints();
613  int nq0 = 0;
614  int nq1 = 0;
615 
616  switch (face)
617  {
618  case 0:
619  nq0 = nquad0;
620  nq1 = nquad1;
621  if (outarray.size() != nq0 * nq1)
622  {
623  outarray = Array<OneD, int>(nq0 * nq1);
624  }
625 
626  // Directions A and B positive
627  for (int i = 0; i < nquad0 * nquad1; ++i)
628  {
629  outarray[i] = i;
630  }
631  break;
632  case 1:
633 
634  nq0 = nquad0;
635  nq1 = nquad2;
636  if (outarray.size() != nq0 * nq1)
637  {
638  outarray = Array<OneD, int>(nq0 * nq1);
639  }
640 
641  // Direction A and B positive
642  for (int k = 0; k < nquad2; k++)
643  {
644  for (int i = 0; i < nquad0; ++i)
645  {
646  outarray[k * nquad0 + i] = (nquad0 * nquad1 * k) + i;
647  }
648  }
649 
650  break;
651  case 2:
652 
653  nq0 = nquad1;
654  nq1 = nquad2;
655  if (outarray.size() != nq0 * nq1)
656  {
657  outarray = Array<OneD, int>(nq0 * nq1);
658  }
659 
660  // Directions A and B positive
661  for (int j = 0; j < nquad1 * nquad2; ++j)
662  {
663  outarray[j] = nquad0 - 1 + j * nquad0;
664  }
665  break;
666  case 3:
667  nq0 = nquad0;
668  nq1 = nquad2;
669  if (outarray.size() != nq0 * nq1)
670  {
671  outarray = Array<OneD, int>(nq0 * nq1);
672  }
673 
674  // Direction A and B positive
675  for (int k = 0; k < nquad2; k++)
676  {
677  for (int i = 0; i < nquad0; ++i)
678  {
679  outarray[k * nquad0 + i] =
680  nquad0 * (nquad1 - 1) + (nquad0 * nquad1 * k) + i;
681  }
682  }
683  break;
684  case 4:
685 
686  nq0 = nquad1;
687  nq1 = nquad2;
688  if (outarray.size() != nq0 * nq1)
689  {
690  outarray = Array<OneD, int>(nq0 * nq1);
691  }
692 
693  // Directions A and B positive
694  for (int j = 0; j < nquad1 * nquad2; ++j)
695  {
696  outarray[j] = j * nquad0;
697  }
698  break;
699  default:
700  ASSERTL0(false, "face value (> 4) is out of range");
701  break;
702  }
703 }
704 
705 /** \brief Get the normals along specficied face
706  * Get the face normals interplated to a points0 x points 0
707  * type distribution
708  **/
709 void PrismExp::v_ComputeTraceNormal(const int face)
710 {
711  const SpatialDomains::GeomFactorsSharedPtr &geomFactors =
712  GetGeom()->GetMetricInfo();
713 
715  for (int i = 0; i < ptsKeys.size(); ++i)
716  {
717  // Need at least 2 points for computing normals
718  if (ptsKeys[i].GetNumPoints() == 1)
719  {
720  LibUtilities::PointsKey pKey(2, ptsKeys[i].GetPointsType());
721  ptsKeys[i] = pKey;
722  }
723  }
724 
725  SpatialDomains::GeomType type = geomFactors->GetGtype();
726  const Array<TwoD, const NekDouble> &df =
727  geomFactors->GetDerivFactors(ptsKeys);
728  const Array<OneD, const NekDouble> &jac = geomFactors->GetJac(ptsKeys);
729 
730  int nq0 = ptsKeys[0].GetNumPoints();
731  int nq1 = ptsKeys[1].GetNumPoints();
732  int nq2 = ptsKeys[2].GetNumPoints();
733  int nq01 = nq0 * nq1;
734  int nqtot;
735 
736  LibUtilities::BasisKey tobasis0 = GetTraceBasisKey(face, 0);
737  LibUtilities::BasisKey tobasis1 = GetTraceBasisKey(face, 1);
738 
739  // Number of quadrature points in face expansion.
740  int nq_face = tobasis0.GetNumPoints() * tobasis1.GetNumPoints();
741 
742  int vCoordDim = GetCoordim();
743  int i;
744 
747  for (i = 0; i < vCoordDim; ++i)
748  {
749  normal[i] = Array<OneD, NekDouble>(nq_face);
750  }
751 
752  size_t nqb = nq_face;
753  size_t nbnd = face;
756 
757  // Regular geometry case
758  if (type == SpatialDomains::eRegular ||
760  {
761  NekDouble fac;
762  // Set up normals
763  switch (face)
764  {
765  case 0:
766  {
767  for (i = 0; i < vCoordDim; ++i)
768  {
769  normal[i][0] = -df[3 * i + 2][0];
770  ;
771  }
772  break;
773  }
774  case 1:
775  {
776  for (i = 0; i < vCoordDim; ++i)
777  {
778  normal[i][0] = -df[3 * i + 1][0];
779  }
780  break;
781  }
782  case 2:
783  {
784  for (i = 0; i < vCoordDim; ++i)
785  {
786  normal[i][0] = df[3 * i][0] + df[3 * i + 2][0];
787  }
788  break;
789  }
790  case 3:
791  {
792  for (i = 0; i < vCoordDim; ++i)
793  {
794  normal[i][0] = df[3 * i + 1][0];
795  }
796  break;
797  }
798  case 4:
799  {
800  for (i = 0; i < vCoordDim; ++i)
801  {
802  normal[i][0] = -df[3 * i][0];
803  }
804  break;
805  }
806  default:
807  ASSERTL0(false, "face is out of range (face < 4)");
808  }
809 
810  // Normalise resulting vector.
811  fac = 0.0;
812  for (i = 0; i < vCoordDim; ++i)
813  {
814  fac += normal[i][0] * normal[i][0];
815  }
816  fac = 1.0 / sqrt(fac);
817 
818  Vmath::Fill(nqb, fac, length, 1);
819 
820  for (i = 0; i < vCoordDim; ++i)
821  {
822  Vmath::Fill(nq_face, fac * normal[i][0], normal[i], 1);
823  }
824  }
825  else
826  {
827  // Set up deformed normals.
828  int j, k;
829 
830  // Determine number of quadrature points on the face of 3D elmt
831  if (face == 0)
832  {
833  nqtot = nq0 * nq1;
834  }
835  else if (face == 1 || face == 3)
836  {
837  nqtot = nq0 * nq2;
838  }
839  else
840  {
841  nqtot = nq1 * nq2;
842  }
843 
844  LibUtilities::PointsKey points0;
845  LibUtilities::PointsKey points1;
846 
847  Array<OneD, NekDouble> faceJac(nqtot);
848  Array<OneD, NekDouble> normals(vCoordDim * nqtot, 0.0);
849 
850  // Extract Jacobian along face and recover local derivatives
851  // (dx/dr) for polynomial interpolation by multiplying m_gmat by
852  // jacobian
853  switch (face)
854  {
855  case 0:
856  {
857  for (j = 0; j < nq01; ++j)
858  {
859  normals[j] = -df[2][j] * jac[j];
860  normals[nqtot + j] = -df[5][j] * jac[j];
861  normals[2 * nqtot + j] = -df[8][j] * jac[j];
862  faceJac[j] = jac[j];
863  }
864 
865  points0 = ptsKeys[0];
866  points1 = ptsKeys[1];
867  break;
868  }
869 
870  case 1:
871  {
872  for (j = 0; j < nq0; ++j)
873  {
874  for (k = 0; k < nq2; ++k)
875  {
876  int tmp = j + nq01 * k;
877  normals[j + k * nq0] = -df[1][tmp] * jac[tmp];
878  normals[nqtot + j + k * nq0] = -df[4][tmp] * jac[tmp];
879  normals[2 * nqtot + j + k * nq0] =
880  -df[7][tmp] * jac[tmp];
881  faceJac[j + k * nq0] = jac[tmp];
882  }
883  }
884 
885  points0 = ptsKeys[0];
886  points1 = ptsKeys[2];
887  break;
888  }
889 
890  case 2:
891  {
892  for (j = 0; j < nq1; ++j)
893  {
894  for (k = 0; k < nq2; ++k)
895  {
896  int tmp = nq0 - 1 + nq0 * j + nq01 * k;
897  normals[j + k * nq1] =
898  (df[0][tmp] + df[2][tmp]) * jac[tmp];
899  normals[nqtot + j + k * nq1] =
900  (df[3][tmp] + df[5][tmp]) * jac[tmp];
901  normals[2 * nqtot + j + k * nq1] =
902  (df[6][tmp] + df[8][tmp]) * jac[tmp];
903  faceJac[j + k * nq1] = jac[tmp];
904  }
905  }
906 
907  points0 = ptsKeys[1];
908  points1 = ptsKeys[2];
909  break;
910  }
911 
912  case 3:
913  {
914  for (j = 0; j < nq0; ++j)
915  {
916  for (k = 0; k < nq2; ++k)
917  {
918  int tmp = nq0 * (nq1 - 1) + j + nq01 * k;
919  normals[j + k * nq0] = df[1][tmp] * jac[tmp];
920  normals[nqtot + j + k * nq0] = df[4][tmp] * jac[tmp];
921  normals[2 * nqtot + j + k * nq0] =
922  df[7][tmp] * jac[tmp];
923  faceJac[j + k * nq0] = jac[tmp];
924  }
925  }
926 
927  points0 = ptsKeys[0];
928  points1 = ptsKeys[2];
929  break;
930  }
931 
932  case 4:
933  {
934  for (j = 0; j < nq1; ++j)
935  {
936  for (k = 0; k < nq2; ++k)
937  {
938  int tmp = j * nq0 + nq01 * k;
939  normals[j + k * nq1] = -df[0][tmp] * jac[tmp];
940  normals[nqtot + j + k * nq1] = -df[3][tmp] * jac[tmp];
941  normals[2 * nqtot + j + k * nq1] =
942  -df[6][tmp] * jac[tmp];
943  faceJac[j + k * nq1] = jac[tmp];
944  }
945  }
946 
947  points0 = ptsKeys[1];
948  points1 = ptsKeys[2];
949  break;
950  }
951 
952  default:
953  ASSERTL0(false, "face is out of range (face < 4)");
954  }
955 
956  Array<OneD, NekDouble> work(nq_face, 0.0);
957  // Interpolate Jacobian and invert
958  LibUtilities::Interp2D(points0, points1, faceJac,
959  tobasis0.GetPointsKey(), tobasis1.GetPointsKey(),
960  work);
961  Vmath::Sdiv(nq_face, 1.0, &work[0], 1, &work[0], 1);
962 
963  // Interpolate normal and multiply by inverse Jacobian.
964  for (i = 0; i < vCoordDim; ++i)
965  {
966  LibUtilities::Interp2D(points0, points1, &normals[i * nqtot],
967  tobasis0.GetPointsKey(),
968  tobasis1.GetPointsKey(), &normal[i][0]);
969  Vmath::Vmul(nq_face, work, 1, normal[i], 1, normal[i], 1);
970  }
971 
972  // Normalise to obtain unit normals.
973  Vmath::Zero(nq_face, work, 1);
974  for (i = 0; i < GetCoordim(); ++i)
975  {
976  Vmath::Vvtvp(nq_face, normal[i], 1, normal[i], 1, work, 1, work, 1);
977  }
978 
979  Vmath::Vsqrt(nq_face, work, 1, work, 1);
980  Vmath::Sdiv(nq_face, 1.0, work, 1, work, 1);
981 
982  Vmath::Vcopy(nqb, work, 1, length, 1);
983 
984  for (i = 0; i < GetCoordim(); ++i)
985  {
986  Vmath::Vmul(nq_face, normal[i], 1, work, 1, normal[i], 1);
987  }
988  }
989 }
990 
992  Array<OneD, NekDouble> &outarray,
993  const StdRegions::StdMatrixKey &mkey)
994 {
995  StdExpansion::MassMatrixOp_MatFree(inarray, outarray, mkey);
996 }
997 
999  Array<OneD, NekDouble> &outarray,
1000  const StdRegions::StdMatrixKey &mkey)
1001 {
1002  PrismExp::LaplacianMatrixOp_MatFree(inarray, outarray, mkey);
1003 }
1004 
1005 void PrismExp::v_LaplacianMatrixOp(const int k1, const int k2,
1006  const Array<OneD, const NekDouble> &inarray,
1007  Array<OneD, NekDouble> &outarray,
1008  const StdRegions::StdMatrixKey &mkey)
1009 {
1010  StdExpansion::LaplacianMatrixOp_MatFree(k1, k2, inarray, outarray, mkey);
1011 }
1012 
1014  Array<OneD, NekDouble> &outarray,
1015  const StdRegions::StdMatrixKey &mkey)
1016 {
1017  PrismExp::v_HelmholtzMatrixOp_MatFree(inarray, outarray, mkey);
1018 }
1019 
1021  const StdRegions::StdMatrixKey &mkey)
1022 {
1023  int nq = GetTotPoints();
1024 
1025  // Calculate sqrt of the Jacobian
1027  Array<OneD, NekDouble> sqrt_jac(nq);
1028  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
1029  {
1030  Vmath::Vsqrt(nq, jac, 1, sqrt_jac, 1);
1031  }
1032  else
1033  {
1034  Vmath::Fill(nq, sqrt(jac[0]), sqrt_jac, 1);
1035  }
1036 
1037  // Multiply array by sqrt(Jac)
1038  Vmath::Vmul(nq, sqrt_jac, 1, array, 1, array, 1);
1039 
1040  // Apply std region filter
1041  StdPrismExp::v_SVVLaplacianFilter(array, mkey);
1042 
1043  // Divide by sqrt(Jac)
1044  Vmath::Vdiv(nq, array, 1, sqrt_jac, 1, array, 1);
1045 }
1046 
1047 //---------------------------------------
1048 // Matrix creation functions
1049 //---------------------------------------
1050 
1052 {
1053  DNekMatSharedPtr returnval;
1054 
1055  switch (mkey.GetMatrixType())
1056  {
1064  returnval = Expansion3D::v_GenMatrix(mkey);
1065  break;
1066  default:
1067  returnval = StdPrismExp::v_GenMatrix(mkey);
1068  break;
1069  }
1070 
1071  return returnval;
1072 }
1073 
1075  const StdRegions::StdMatrixKey &mkey)
1076 {
1077  LibUtilities::BasisKey bkey0 = m_base[0]->GetBasisKey();
1078  LibUtilities::BasisKey bkey1 = m_base[1]->GetBasisKey();
1079  LibUtilities::BasisKey bkey2 = m_base[2]->GetBasisKey();
1081  MemoryManager<StdPrismExp>::AllocateSharedPtr(bkey0, bkey1, bkey2);
1082 
1083  return tmp->GetStdMatrix(mkey);
1084 }
1085 
1087 {
1088  return m_matrixManager[mkey];
1089 }
1090 
1092 {
1093  m_matrixManager.DeleteObject(mkey);
1094 }
1095 
1097  const MatrixKey &mkey)
1098 {
1099  return m_staticCondMatrixManager[mkey];
1100 }
1101 
1103 {
1104  m_staticCondMatrixManager.DeleteObject(mkey);
1105 }
1106 
1107 /**
1108  * @brief Calculate the Laplacian multiplication in a matrix-free
1109  * manner.
1110  *
1111  * This function is the kernel of the Laplacian matrix-free operator,
1112  * and is used in #v_HelmholtzMatrixOp_MatFree to determine the effect
1113  * of the Helmholtz operator in a similar fashion.
1114  *
1115  * The majority of the calculation is precisely the same as in the
1116  * hexahedral expansion; however the collapsed co-ordinate system must
1117  * be taken into account when constructing the geometric factors. How
1118  * this is done is detailed more exactly in the tetrahedral expansion.
1119  * On entry to this function, the input #inarray must be in its
1120  * backwards-transformed state (i.e. \f$\mathbf{u} =
1121  * \mathbf{B}\hat{\mathbf{u}}\f$). The output is in coefficient space.
1122  *
1123  * @see %TetExp::v_HelmholtzMatrixOp_MatFree
1124  */
1126  const Array<OneD, const NekDouble> &inarray,
1128 {
1129  int nquad0 = m_base[0]->GetNumPoints();
1130  int nquad1 = m_base[1]->GetNumPoints();
1131  int nquad2 = m_base[2]->GetNumPoints();
1132  int nqtot = nquad0 * nquad1 * nquad2;
1133  int i;
1134 
1135  // Set up temporary storage.
1136  Array<OneD, NekDouble> alloc(11 * nqtot, 0.0);
1137  Array<OneD, NekDouble> wsp1(alloc); // TensorDeriv 1
1138  Array<OneD, NekDouble> wsp2(alloc + 1 * nqtot); // TensorDeriv 2
1139  Array<OneD, NekDouble> wsp3(alloc + 2 * nqtot); // TensorDeriv 3
1140  Array<OneD, NekDouble> g0(alloc + 3 * nqtot); // g0
1141  Array<OneD, NekDouble> g1(alloc + 4 * nqtot); // g1
1142  Array<OneD, NekDouble> g2(alloc + 5 * nqtot); // g2
1143  Array<OneD, NekDouble> g3(alloc + 6 * nqtot); // g3
1144  Array<OneD, NekDouble> g4(alloc + 7 * nqtot); // g4
1145  Array<OneD, NekDouble> g5(alloc + 8 * nqtot); // g5
1146  Array<OneD, NekDouble> h0(alloc + 3 * nqtot); // h0 == g0
1147  Array<OneD, NekDouble> h1(alloc + 6 * nqtot); // h1 == g3
1148  Array<OneD, NekDouble> wsp4(alloc + 4 * nqtot); // wsp4 == g1
1149  Array<OneD, NekDouble> wsp5(alloc + 5 * nqtot); // wsp5 == g2
1150  Array<OneD, NekDouble> wsp6(alloc + 8 * nqtot); // wsp6 == g5
1151  Array<OneD, NekDouble> wsp7(alloc + 3 * nqtot); // wsp7 == g0
1152  Array<OneD, NekDouble> wsp8(alloc + 9 * nqtot); // wsp8
1153  Array<OneD, NekDouble> wsp9(alloc + 10 * nqtot); // wsp9
1154 
1155  const Array<OneD, const NekDouble> &base0 = m_base[0]->GetBdata();
1156  const Array<OneD, const NekDouble> &base1 = m_base[1]->GetBdata();
1157  const Array<OneD, const NekDouble> &base2 = m_base[2]->GetBdata();
1158  const Array<OneD, const NekDouble> &dbase0 = m_base[0]->GetDbdata();
1159  const Array<OneD, const NekDouble> &dbase1 = m_base[1]->GetDbdata();
1160  const Array<OneD, const NekDouble> &dbase2 = m_base[2]->GetDbdata();
1161 
1162  // Step 1. LAPLACIAN MATRIX OPERATION
1163  // wsp1 = du_dxi1 = D_xi1 * wsp0 = D_xi1 * u
1164  // wsp2 = du_dxi2 = D_xi2 * wsp0 = D_xi2 * u
1165  // wsp3 = du_dxi3 = D_xi3 * wsp0 = D_xi3 * u
1166  StdExpansion3D::PhysTensorDeriv(inarray, wsp1, wsp2, wsp3);
1167 
1168  const Array<TwoD, const NekDouble> &df =
1169  m_metricinfo->GetDerivFactors(GetPointsKeys());
1170  const Array<OneD, const NekDouble> &z0 = m_base[0]->GetZ();
1171  const Array<OneD, const NekDouble> &z2 = m_base[2]->GetZ();
1172 
1173  // Step 2. Calculate the metric terms of the collapsed
1174  // coordinate transformation (Spencer's book P152)
1175  for (i = 0; i < nquad2; ++i)
1176  {
1177  Vmath::Fill(nquad0 * nquad1, 2.0 / (1.0 - z2[i]),
1178  &h0[0] + i * nquad0 * nquad1, 1);
1179  Vmath::Fill(nquad0 * nquad1, 2.0 / (1.0 - z2[i]),
1180  &h1[0] + i * nquad0 * nquad1, 1);
1181  }
1182  for (i = 0; i < nquad0; i++)
1183  {
1184  Blas::Dscal(nquad1 * nquad2, 0.5 * (1 + z0[i]), &h1[0] + i, nquad0);
1185  }
1186 
1187  // Step 3. Construct combined metric terms for physical space to
1188  // collapsed coordinate system. Order of construction optimised
1189  // to minimise temporary storage
1190  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
1191  {
1192  // wsp4 = d eta_1/d x_1
1193  Vmath::Vvtvvtp(nqtot, &df[0][0], 1, &h0[0], 1, &df[2][0], 1, &h1[0], 1,
1194  &wsp4[0], 1);
1195  // wsp5 = d eta_2/d x_1
1196  Vmath::Vvtvvtp(nqtot, &df[3][0], 1, &h0[0], 1, &df[5][0], 1, &h1[0], 1,
1197  &wsp5[0], 1);
1198  // wsp6 = d eta_3/d x_1d
1199  Vmath::Vvtvvtp(nqtot, &df[6][0], 1, &h0[0], 1, &df[8][0], 1, &h1[0], 1,
1200  &wsp6[0], 1);
1201 
1202  // g0 (overwrites h0)
1203  Vmath::Vvtvvtp(nqtot, &wsp4[0], 1, &wsp4[0], 1, &wsp5[0], 1, &wsp5[0],
1204  1, &g0[0], 1);
1205  Vmath::Vvtvp(nqtot, &wsp6[0], 1, &wsp6[0], 1, &g0[0], 1, &g0[0], 1);
1206 
1207  // g3 (overwrites h1)
1208  Vmath::Vvtvvtp(nqtot, &df[1][0], 1, &wsp4[0], 1, &df[4][0], 1, &wsp5[0],
1209  1, &g3[0], 1);
1210  Vmath::Vvtvp(nqtot, &df[7][0], 1, &wsp6[0], 1, &g3[0], 1, &g3[0], 1);
1211 
1212  // g4
1213  Vmath::Vvtvvtp(nqtot, &df[2][0], 1, &wsp4[0], 1, &df[5][0], 1, &wsp5[0],
1214  1, &g4[0], 1);
1215  Vmath::Vvtvp(nqtot, &df[8][0], 1, &wsp6[0], 1, &g4[0], 1, &g4[0], 1);
1216 
1217  // Overwrite wsp4/5/6 with g1/2/5
1218  // g1
1219  Vmath::Vvtvvtp(nqtot, &df[1][0], 1, &df[1][0], 1, &df[4][0], 1,
1220  &df[4][0], 1, &g1[0], 1);
1221  Vmath::Vvtvp(nqtot, &df[7][0], 1, &df[7][0], 1, &g1[0], 1, &g1[0], 1);
1222 
1223  // g2
1224  Vmath::Vvtvvtp(nqtot, &df[2][0], 1, &df[2][0], 1, &df[5][0], 1,
1225  &df[5][0], 1, &g2[0], 1);
1226  Vmath::Vvtvp(nqtot, &df[8][0], 1, &df[8][0], 1, &g2[0], 1, &g2[0], 1);
1227 
1228  // g5
1229  Vmath::Vvtvvtp(nqtot, &df[1][0], 1, &df[2][0], 1, &df[4][0], 1,
1230  &df[5][0], 1, &g5[0], 1);
1231  Vmath::Vvtvp(nqtot, &df[7][0], 1, &df[8][0], 1, &g5[0], 1, &g5[0], 1);
1232  }
1233  else
1234  {
1235  // wsp4 = d eta_1/d x_1
1236  Vmath::Svtsvtp(nqtot, df[0][0], &h0[0], 1, df[2][0], &h1[0], 1,
1237  &wsp4[0], 1);
1238  // wsp5 = d eta_2/d x_1
1239  Vmath::Svtsvtp(nqtot, df[3][0], &h0[0], 1, df[5][0], &h1[0], 1,
1240  &wsp5[0], 1);
1241  // wsp6 = d eta_3/d x_1
1242  Vmath::Svtsvtp(nqtot, df[6][0], &h0[0], 1, df[8][0], &h1[0], 1,
1243  &wsp6[0], 1);
1244 
1245  // g0 (overwrites h0)
1246  Vmath::Vvtvvtp(nqtot, &wsp4[0], 1, &wsp4[0], 1, &wsp5[0], 1, &wsp5[0],
1247  1, &g0[0], 1);
1248  Vmath::Vvtvp(nqtot, &wsp6[0], 1, &wsp6[0], 1, &g0[0], 1, &g0[0], 1);
1249 
1250  // g3 (overwrites h1)
1251  Vmath::Svtsvtp(nqtot, df[1][0], &wsp4[0], 1, df[4][0], &wsp5[0], 1,
1252  &g3[0], 1);
1253  Vmath::Svtvp(nqtot, df[7][0], &wsp6[0], 1, &g3[0], 1, &g3[0], 1);
1254 
1255  // g4
1256  Vmath::Svtsvtp(nqtot, df[2][0], &wsp4[0], 1, df[5][0], &wsp5[0], 1,
1257  &g4[0], 1);
1258  Vmath::Svtvp(nqtot, df[8][0], &wsp6[0], 1, &g4[0], 1, &g4[0], 1);
1259 
1260  // Overwrite wsp4/5/6 with g1/2/5
1261  // g1
1262  Vmath::Fill(nqtot,
1263  df[1][0] * df[1][0] + df[4][0] * df[4][0] +
1264  df[7][0] * df[7][0],
1265  &g1[0], 1);
1266 
1267  // g2
1268  Vmath::Fill(nqtot,
1269  df[2][0] * df[2][0] + df[5][0] * df[5][0] +
1270  df[8][0] * df[8][0],
1271  &g2[0], 1);
1272 
1273  // g5
1274  Vmath::Fill(nqtot,
1275  df[1][0] * df[2][0] + df[4][0] * df[5][0] +
1276  df[7][0] * df[8][0],
1277  &g5[0], 1);
1278  }
1279  // Compute component derivatives into wsp7, 8, 9 (wsp7 overwrites
1280  // g0).
1281  Vmath::Vvtvvtp(nqtot, &g0[0], 1, &wsp1[0], 1, &g3[0], 1, &wsp2[0], 1,
1282  &wsp7[0], 1);
1283  Vmath::Vvtvp(nqtot, &g4[0], 1, &wsp3[0], 1, &wsp7[0], 1, &wsp7[0], 1);
1284  Vmath::Vvtvvtp(nqtot, &g1[0], 1, &wsp2[0], 1, &g3[0], 1, &wsp1[0], 1,
1285  &wsp8[0], 1);
1286  Vmath::Vvtvp(nqtot, &g5[0], 1, &wsp3[0], 1, &wsp8[0], 1, &wsp8[0], 1);
1287  Vmath::Vvtvvtp(nqtot, &g2[0], 1, &wsp3[0], 1, &g4[0], 1, &wsp1[0], 1,
1288  &wsp9[0], 1);
1289  Vmath::Vvtvp(nqtot, &g5[0], 1, &wsp2[0], 1, &wsp9[0], 1, &wsp9[0], 1);
1290 
1291  // Step 4.
1292  // Multiply by quadrature metric
1293  MultiplyByQuadratureMetric(wsp7, wsp7);
1294  MultiplyByQuadratureMetric(wsp8, wsp8);
1295  MultiplyByQuadratureMetric(wsp9, wsp9);
1296 
1297  // Perform inner product w.r.t derivative bases.
1298  IProductWRTBase_SumFacKernel(dbase0, base1, base2, wsp7, wsp1, wsp, false,
1299  true, true);
1300  IProductWRTBase_SumFacKernel(base0, dbase1, base2, wsp8, wsp2, wsp, true,
1301  false, true);
1302  IProductWRTBase_SumFacKernel(base0, base1, dbase2, wsp9, outarray, wsp,
1303  true, true, false);
1304 
1305  // Step 5.
1306  // Sum contributions from wsp1, wsp2 and outarray.
1307  Vmath::Vadd(m_ncoeffs, wsp1.get(), 1, outarray.get(), 1, outarray.get(), 1);
1308  Vmath::Vadd(m_ncoeffs, wsp2.get(), 1, outarray.get(), 1, outarray.get(), 1);
1309 }
1310 
1312  bool oldstandard)
1313 {
1314  boost::ignore_unused(oldstandard);
1315 
1316  int np0 = m_base[0]->GetNumPoints();
1317  int np1 = m_base[1]->GetNumPoints();
1318  int np2 = m_base[2]->GetNumPoints();
1319  int np = max(np0, max(np1, np2));
1320  Array<OneD, int> prismpt(6);
1321  bool standard = true;
1322 
1323  int vid0 = m_geom->GetVid(0);
1324  int vid1 = m_geom->GetVid(1);
1325  int vid2 = m_geom->GetVid(4);
1326  int rotate = 0;
1327 
1328  // sort out prism rotation according to
1329  if ((vid2 < vid1) && (vid2 < vid0)) // top triangle vertex is lowest id
1330  {
1331  rotate = 0;
1332  if (vid0 > vid1)
1333  {
1334  standard = false; // reverse base direction
1335  }
1336  }
1337  else if ((vid1 < vid2) && (vid1 < vid0))
1338  {
1339  rotate = 1;
1340  if (vid2 > vid0)
1341  {
1342  standard = false; // reverse base direction
1343  }
1344  }
1345  else if ((vid0 < vid2) && (vid0 < vid1))
1346  {
1347  rotate = 2;
1348  if (vid1 > vid2)
1349  {
1350  standard = false; // reverse base direction
1351  }
1352  }
1353 
1354  conn = Array<OneD, int>(12 * (np - 1) * (np - 1) * (np - 1));
1355 
1356  int row = 0;
1357  int rowp1 = 0;
1358  int plane = 0;
1359  int row1 = 0;
1360  int row1p1 = 0;
1361  int planep1 = 0;
1362  int cnt = 0;
1363 
1364  Array<OneD, int> rot(3);
1365 
1366  rot[0] = (0 + rotate) % 3;
1367  rot[1] = (1 + rotate) % 3;
1368  rot[2] = (2 + rotate) % 3;
1369 
1370  // lower diagonal along 1-3 on base
1371  for (int i = 0; i < np - 1; ++i)
1372  {
1373  planep1 += (np - i) * np;
1374  row = 0; // current plane row offset
1375  rowp1 = 0; // current plane row plus one offset
1376  row1 = 0; // next plane row offset
1377  row1p1 = 0; // nex plane row plus one offset
1378  if (standard == false)
1379  {
1380  for (int j = 0; j < np - 1; ++j)
1381  {
1382  rowp1 += np - i;
1383  row1p1 += np - i - 1;
1384  for (int k = 0; k < np - i - 2; ++k)
1385  {
1386  // bottom prism block
1387  prismpt[rot[0]] = plane + row + k;
1388  prismpt[rot[1]] = plane + row + k + 1;
1389  prismpt[rot[2]] = planep1 + row1 + k;
1390 
1391  prismpt[3 + rot[0]] = plane + rowp1 + k;
1392  prismpt[3 + rot[1]] = plane + rowp1 + k + 1;
1393  prismpt[3 + rot[2]] = planep1 + row1p1 + k;
1394 
1395  conn[cnt++] = prismpt[0];
1396  conn[cnt++] = prismpt[1];
1397  conn[cnt++] = prismpt[3];
1398  conn[cnt++] = prismpt[2];
1399 
1400  conn[cnt++] = prismpt[5];
1401  conn[cnt++] = prismpt[2];
1402  conn[cnt++] = prismpt[3];
1403  conn[cnt++] = prismpt[4];
1404 
1405  conn[cnt++] = prismpt[3];
1406  conn[cnt++] = prismpt[1];
1407  conn[cnt++] = prismpt[4];
1408  conn[cnt++] = prismpt[2];
1409 
1410  // upper prism block.
1411  prismpt[rot[0]] = planep1 + row1 + k + 1;
1412  prismpt[rot[1]] = planep1 + row1 + k;
1413  prismpt[rot[2]] = plane + row + k + 1;
1414 
1415  prismpt[3 + rot[0]] = planep1 + row1p1 + k + 1;
1416  prismpt[3 + rot[1]] = planep1 + row1p1 + k;
1417  prismpt[3 + rot[2]] = plane + rowp1 + k + 1;
1418 
1419  conn[cnt++] = prismpt[0];
1420  conn[cnt++] = prismpt[1];
1421  conn[cnt++] = prismpt[2];
1422  conn[cnt++] = prismpt[5];
1423 
1424  conn[cnt++] = prismpt[5];
1425  conn[cnt++] = prismpt[0];
1426  conn[cnt++] = prismpt[4];
1427  conn[cnt++] = prismpt[1];
1428 
1429  conn[cnt++] = prismpt[3];
1430  conn[cnt++] = prismpt[4];
1431  conn[cnt++] = prismpt[0];
1432  conn[cnt++] = prismpt[5];
1433  }
1434 
1435  // bottom prism block
1436  prismpt[rot[0]] = plane + row + np - i - 2;
1437  prismpt[rot[1]] = plane + row + np - i - 1;
1438  prismpt[rot[2]] = planep1 + row1 + np - i - 2;
1439 
1440  prismpt[3 + rot[0]] = plane + rowp1 + np - i - 2;
1441  prismpt[3 + rot[1]] = plane + rowp1 + np - i - 1;
1442  prismpt[3 + rot[2]] = planep1 + row1p1 + np - i - 2;
1443 
1444  conn[cnt++] = prismpt[0];
1445  conn[cnt++] = prismpt[1];
1446  conn[cnt++] = prismpt[3];
1447  conn[cnt++] = prismpt[2];
1448 
1449  conn[cnt++] = prismpt[5];
1450  conn[cnt++] = prismpt[2];
1451  conn[cnt++] = prismpt[3];
1452  conn[cnt++] = prismpt[4];
1453 
1454  conn[cnt++] = prismpt[3];
1455  conn[cnt++] = prismpt[1];
1456  conn[cnt++] = prismpt[4];
1457  conn[cnt++] = prismpt[2];
1458 
1459  row += np - i;
1460  row1 += np - i - 1;
1461  }
1462  }
1463  else
1464  { // lower diagonal along 0-4 on base
1465  for (int j = 0; j < np - 1; ++j)
1466  {
1467  rowp1 += np - i;
1468  row1p1 += np - i - 1;
1469  for (int k = 0; k < np - i - 2; ++k)
1470  {
1471  // bottom prism block
1472  prismpt[rot[0]] = plane + row + k;
1473  prismpt[rot[1]] = plane + row + k + 1;
1474  prismpt[rot[2]] = planep1 + row1 + k;
1475 
1476  prismpt[3 + rot[0]] = plane + rowp1 + k;
1477  prismpt[3 + rot[1]] = plane + rowp1 + k + 1;
1478  prismpt[3 + rot[2]] = planep1 + row1p1 + k;
1479 
1480  conn[cnt++] = prismpt[0];
1481  conn[cnt++] = prismpt[1];
1482  conn[cnt++] = prismpt[4];
1483  conn[cnt++] = prismpt[2];
1484 
1485  conn[cnt++] = prismpt[4];
1486  conn[cnt++] = prismpt[3];
1487  conn[cnt++] = prismpt[0];
1488  conn[cnt++] = prismpt[2];
1489 
1490  conn[cnt++] = prismpt[3];
1491  conn[cnt++] = prismpt[4];
1492  conn[cnt++] = prismpt[5];
1493  conn[cnt++] = prismpt[2];
1494 
1495  // upper prism block.
1496  prismpt[rot[0]] = planep1 + row1 + k + 1;
1497  prismpt[rot[1]] = planep1 + row1 + k;
1498  prismpt[rot[2]] = plane + row + k + 1;
1499 
1500  prismpt[3 + rot[0]] = planep1 + row1p1 + k + 1;
1501  prismpt[3 + rot[1]] = planep1 + row1p1 + k;
1502  prismpt[3 + rot[2]] = plane + rowp1 + k + 1;
1503 
1504  conn[cnt++] = prismpt[0];
1505  conn[cnt++] = prismpt[2];
1506  conn[cnt++] = prismpt[1];
1507  conn[cnt++] = prismpt[5];
1508 
1509  conn[cnt++] = prismpt[3];
1510  conn[cnt++] = prismpt[5];
1511  conn[cnt++] = prismpt[0];
1512  conn[cnt++] = prismpt[1];
1513 
1514  conn[cnt++] = prismpt[5];
1515  conn[cnt++] = prismpt[3];
1516  conn[cnt++] = prismpt[4];
1517  conn[cnt++] = prismpt[1];
1518  }
1519 
1520  // bottom prism block
1521  prismpt[rot[0]] = plane + row + np - i - 2;
1522  prismpt[rot[1]] = plane + row + np - i - 1;
1523  prismpt[rot[2]] = planep1 + row1 + np - i - 2;
1524 
1525  prismpt[3 + rot[0]] = plane + rowp1 + np - i - 2;
1526  prismpt[3 + rot[1]] = plane + rowp1 + np - i - 1;
1527  prismpt[3 + rot[2]] = planep1 + row1p1 + np - i - 2;
1528 
1529  conn[cnt++] = prismpt[0];
1530  conn[cnt++] = prismpt[1];
1531  conn[cnt++] = prismpt[4];
1532  conn[cnt++] = prismpt[2];
1533 
1534  conn[cnt++] = prismpt[4];
1535  conn[cnt++] = prismpt[3];
1536  conn[cnt++] = prismpt[0];
1537  conn[cnt++] = prismpt[2];
1538 
1539  conn[cnt++] = prismpt[3];
1540  conn[cnt++] = prismpt[4];
1541  conn[cnt++] = prismpt[5];
1542  conn[cnt++] = prismpt[2];
1543 
1544  row += np - i;
1545  row1 += np - i - 1;
1546  }
1547  }
1548  plane += (np - i) * np;
1549  }
1550 }
1551 
1552 /** @brief: This method gets all of the factors which are
1553  required as part of the Gradient Jump Penalty
1554  stabilisation and involves the product of the normal and
1555  geometric factors along the element trace.
1556 */
1558  Array<OneD, Array<OneD, NekDouble>> &d0factors,
1559  Array<OneD, Array<OneD, NekDouble>> &d1factors,
1560  Array<OneD, Array<OneD, NekDouble>> &d2factors)
1561 {
1562  int nquad0 = GetNumPoints(0);
1563  int nquad1 = GetNumPoints(1);
1564  int nquad2 = GetNumPoints(2);
1565 
1566  const Array<TwoD, const NekDouble> &df =
1567  m_metricinfo->GetDerivFactors(GetPointsKeys());
1568 
1569  if (d0factors.size() != 5)
1570  {
1571  d0factors = Array<OneD, Array<OneD, NekDouble>>(5);
1572  d1factors = Array<OneD, Array<OneD, NekDouble>>(5);
1573  d2factors = Array<OneD, Array<OneD, NekDouble>>(5);
1574  }
1575 
1576  if (d0factors[0].size() != nquad0 * nquad1)
1577  {
1578  d0factors[0] = Array<OneD, NekDouble>(nquad0 * nquad1);
1579  d1factors[0] = Array<OneD, NekDouble>(nquad0 * nquad1);
1580  d2factors[0] = Array<OneD, NekDouble>(nquad0 * nquad1);
1581  }
1582 
1583  if (d0factors[1].size() != nquad0 * nquad2)
1584  {
1585  d0factors[1] = Array<OneD, NekDouble>(nquad0 * nquad2);
1586  d0factors[3] = Array<OneD, NekDouble>(nquad0 * nquad2);
1587  d1factors[1] = Array<OneD, NekDouble>(nquad0 * nquad2);
1588  d1factors[3] = Array<OneD, NekDouble>(nquad0 * nquad2);
1589  d2factors[1] = Array<OneD, NekDouble>(nquad0 * nquad2);
1590  d2factors[3] = Array<OneD, NekDouble>(nquad0 * nquad2);
1591  }
1592 
1593  if (d0factors[2].size() != nquad1 * nquad2)
1594  {
1595  d0factors[2] = Array<OneD, NekDouble>(nquad1 * nquad2);
1596  d0factors[4] = Array<OneD, NekDouble>(nquad1 * nquad2);
1597  d1factors[2] = Array<OneD, NekDouble>(nquad1 * nquad2);
1598  d1factors[4] = Array<OneD, NekDouble>(nquad1 * nquad2);
1599  d2factors[2] = Array<OneD, NekDouble>(nquad1 * nquad2);
1600  d2factors[4] = Array<OneD, NekDouble>(nquad1 * nquad2);
1601  }
1602 
1603  // Outwards normals
1604  const Array<OneD, const Array<OneD, NekDouble>> &normal_0 =
1605  GetTraceNormal(0);
1606  const Array<OneD, const Array<OneD, NekDouble>> &normal_1 =
1607  GetTraceNormal(1);
1608  const Array<OneD, const Array<OneD, NekDouble>> &normal_2 =
1609  GetTraceNormal(2);
1610  const Array<OneD, const Array<OneD, NekDouble>> &normal_3 =
1611  GetTraceNormal(3);
1612  const Array<OneD, const Array<OneD, NekDouble>> &normal_4 =
1613  GetTraceNormal(4);
1614 
1615  int ncoords = normal_0.size();
1616 
1617  // first gather together standard cartesian inner products
1618  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
1619  {
1620  // face 0
1621  for (int i = 0; i < nquad0 * nquad1; ++i)
1622  {
1623  d0factors[0][i] = df[0][i] * normal_0[0][i];
1624  d1factors[0][i] = df[1][i] * normal_0[0][i];
1625  d2factors[0][i] = df[2][i] * normal_0[0][i];
1626  }
1627 
1628  for (int n = 1; n < ncoords; ++n)
1629  {
1630  for (int i = 0; i < nquad0 * nquad1; ++i)
1631  {
1632  d0factors[0][i] += df[3 * n][i] * normal_0[n][i];
1633  d1factors[0][i] += df[3 * n + 1][i] * normal_0[n][i];
1634  d2factors[0][i] += df[3 * n + 2][i] * normal_0[n][i];
1635  }
1636  }
1637 
1638  // faces 1 and 3
1639  for (int j = 0; j < nquad2; ++j)
1640  {
1641  for (int i = 0; i < nquad0; ++i)
1642  {
1643  d0factors[1][i] = df[0][j * nquad0 * nquad1 + i] *
1644  normal_1[0][j * nquad0 + i];
1645  d0factors[3][i] =
1646  df[0][(j + 1) * nquad0 * nquad1 - nquad0 + i] *
1647  normal_3[0][j * nquad0 + i];
1648  d1factors[1][i] = df[1][j * nquad0 * nquad1 + i] *
1649  normal_1[0][j * nquad0 + i];
1650  d1factors[3][i] =
1651  df[1][(j + 1) * nquad0 * nquad1 - nquad0 + i] *
1652  normal_3[0][j * nquad0 + i];
1653  d2factors[1][i] = df[2][j * nquad0 * nquad1 + i] *
1654  normal_1[0][j * nquad0 + i];
1655  d2factors[3][i] =
1656  df[2][(j + 1) * nquad0 * nquad1 - nquad0 + i] *
1657  normal_3[0][j * nquad0 + i];
1658  }
1659  }
1660 
1661  for (int n = 1; n < ncoords; ++n)
1662  {
1663  for (int j = 0; j < nquad2; ++j)
1664  {
1665  for (int i = 0; i < nquad0; ++i)
1666  {
1667  d0factors[1][i] = df[3 * n][j * nquad0 * nquad1 + i] *
1668  normal_1[0][j * nquad0 + i];
1669  d0factors[3][i] =
1670  df[3 * n][(j + 1) * nquad0 * nquad1 - nquad0 + i] *
1671  normal_3[0][j * nquad0 + i];
1672  d1factors[1][i] = df[3 * n + 1][j * nquad0 * nquad1 + i] *
1673  normal_1[0][j * nquad0 + i];
1674  d1factors[3][i] =
1675  df[3 * n + 1][(j + 1) * nquad0 * nquad1 - nquad0 + i] *
1676  normal_3[0][j * nquad0 + i];
1677  d2factors[1][i] = df[3 * n + 2][j * nquad0 * nquad1 + i] *
1678  normal_1[0][j * nquad0 + i];
1679  d2factors[3][i] =
1680  df[3 * n + 2][(j + 1) * nquad0 * nquad1 - nquad0 + i] *
1681  normal_3[0][j * nquad0 + i];
1682  }
1683  }
1684  }
1685 
1686  // faces 2 and 4
1687  for (int j = 0; j < nquad2; ++j)
1688  {
1689  for (int i = 0; i < nquad1; ++i)
1690  {
1691  d0factors[2][j * nquad1 + i] =
1692  df[0][j * nquad0 * nquad1 + (i + 1) * nquad0 - 1] *
1693  normal_2[0][j * nquad1 + i];
1694  d0factors[4][j * nquad1 + i] =
1695  df[0][j * nquad0 * nquad1 + i * nquad0] *
1696  normal_4[0][j * nquad1 + i];
1697  d1factors[2][j * nquad1 + i] =
1698  df[1][j * nquad0 * nquad1 + (i + 1) * nquad0 - 1] *
1699  normal_2[0][j * nquad1 + i];
1700  d1factors[4][j * nquad1 + i] =
1701  df[1][j * nquad0 * nquad1 + i * nquad0] *
1702  normal_4[0][j * nquad1 + i];
1703  d2factors[2][j * nquad1 + i] =
1704  df[2][j * nquad0 * nquad1 + (i + 1) * nquad0 - 1] *
1705  normal_2[0][j * nquad1 + i];
1706  d2factors[4][j * nquad1 + i] =
1707  df[2][j * nquad0 * nquad1 + i * nquad0] *
1708  normal_4[0][j * nquad1 + i];
1709  }
1710  }
1711 
1712  for (int n = 1; n < ncoords; ++n)
1713  {
1714  for (int j = 0; j < nquad2; ++j)
1715  {
1716  for (int i = 0; i < nquad1; ++i)
1717  {
1718  d0factors[2][j * nquad1 + i] +=
1719  df[3 * n][j * nquad0 * nquad1 + (i + 1) * nquad0 - 1] *
1720  normal_2[n][j * nquad0 + i];
1721  d0factors[4][j * nquad0 + i] +=
1722  df[3 * n][i * nquad0 + j * nquad0 * nquad1] *
1723  normal_4[n][j * nquad0 + i];
1724  d1factors[2][j * nquad1 + i] +=
1725  df[3 * n + 1]
1726  [j * nquad0 * nquad1 + (i + 1) * nquad0 - 1] *
1727  normal_2[n][j * nquad0 + i];
1728  d1factors[4][j * nquad0 + i] +=
1729  df[3 * n + 1][i * nquad0 + j * nquad0 * nquad1] *
1730  normal_4[n][j * nquad0 + i];
1731  d2factors[2][j * nquad1 + i] +=
1732  df[3 * n + 2]
1733  [j * nquad0 * nquad1 + (i + 1) * nquad0 - 1] *
1734  normal_2[n][j * nquad0 + i];
1735  d2factors[4][j * nquad0 + i] +=
1736  df[3 * n + 2][i * nquad0 + j * nquad0 * nquad1] *
1737  normal_4[n][j * nquad0 + i];
1738  }
1739  }
1740  }
1741  }
1742  else
1743  {
1744  // Face 0
1745  for (int i = 0; i < nquad0 * nquad1; ++i)
1746  {
1747  d0factors[0][i] = df[0][0] * normal_0[0][i];
1748  d1factors[0][i] = df[1][0] * normal_0[0][i];
1749  d2factors[0][i] = df[2][0] * normal_0[0][i];
1750  }
1751 
1752  for (int n = 1; n < ncoords; ++n)
1753  {
1754  for (int i = 0; i < nquad0 * nquad1; ++i)
1755  {
1756  d0factors[0][i] += df[3 * n][0] * normal_0[n][i];
1757  d1factors[0][i] += df[3 * n + 1][0] * normal_0[n][i];
1758  d2factors[0][i] += df[3 * n + 2][0] * normal_0[n][i];
1759  }
1760  }
1761 
1762  // faces 1 and 3
1763  for (int i = 0; i < nquad0 * nquad2; ++i)
1764  {
1765  d0factors[1][i] = df[0][0] * normal_1[0][i];
1766  d0factors[3][i] = df[0][0] * normal_3[0][i];
1767 
1768  d1factors[1][i] = df[1][0] * normal_1[0][i];
1769  d1factors[3][i] = df[1][0] * normal_3[0][i];
1770 
1771  d2factors[1][i] = df[2][0] * normal_1[0][i];
1772  d2factors[3][i] = df[2][0] * normal_3[0][i];
1773  }
1774 
1775  for (int n = 1; n < ncoords; ++n)
1776  {
1777  for (int i = 0; i < nquad0 * nquad2; ++i)
1778  {
1779  d0factors[1][i] += df[3 * n][0] * normal_1[n][i];
1780  d0factors[3][i] += df[3 * n][0] * normal_3[n][i];
1781 
1782  d1factors[1][i] += df[3 * n + 1][0] * normal_1[n][i];
1783  d1factors[3][i] += df[3 * n + 1][0] * normal_3[n][i];
1784 
1785  d2factors[1][i] += df[3 * n + 2][0] * normal_1[n][i];
1786  d2factors[3][i] += df[3 * n + 2][0] * normal_3[n][i];
1787  }
1788  }
1789 
1790  // faces 2 and 4
1791  for (int i = 0; i < nquad1 * nquad2; ++i)
1792  {
1793  d0factors[2][i] = df[0][0] * normal_2[0][i];
1794  d0factors[4][i] = df[0][0] * normal_4[0][i];
1795 
1796  d1factors[2][i] = df[1][0] * normal_2[0][i];
1797  d1factors[4][i] = df[1][0] * normal_4[0][i];
1798 
1799  d2factors[2][i] = df[2][0] * normal_2[0][i];
1800  d2factors[4][i] = df[2][0] * normal_4[0][i];
1801  }
1802 
1803  for (int n = 1; n < ncoords; ++n)
1804  {
1805  for (int i = 0; i < nquad1 * nquad2; ++i)
1806  {
1807  d0factors[2][i] += df[3 * n][0] * normal_2[n][i];
1808  d0factors[4][i] += df[3 * n][0] * normal_4[n][i];
1809 
1810  d1factors[2][i] += df[3 * n + 1][0] * normal_2[n][i];
1811  d1factors[4][i] += df[3 * n + 1][0] * normal_4[n][i];
1812 
1813  d2factors[2][i] += df[3 * n + 2][0] * normal_2[n][i];
1814  d2factors[4][i] += df[3 * n + 2][0] * normal_4[n][i];
1815  }
1816  }
1817  }
1818 }
1819 } // namespace LocalRegions
1820 } // namespace Nektar
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249
Describes the specification for a Basis.
Definition: Basis.h:50
int GetNumPoints() const
Return points order at which basis is defined.
Definition: Basis.h:130
PointsKey GetPointsKey() const
Return distribution of points.
Definition: Basis.h:147
Defines a specification for a set of points.
Definition: Points.h:59
virtual DNekMatSharedPtr v_GenMatrix(const StdRegions::StdMatrixKey &mkey) override
std::map< int, NormalVector > m_traceNormals
Definition: Expansion.h:278
std::map< int, Array< OneD, NekDouble > > m_elmtBndNormDirElmtLen
the element length in each element boundary(Vertex, edge or face) normal direction calculated based o...
Definition: Expansion.h:288
SpatialDomains::GeometrySharedPtr GetGeom() const
Definition: Expansion.cpp:171
SpatialDomains::GeometrySharedPtr m_geom
Definition: Expansion.h:275
virtual void v_GetCoords(Array< OneD, NekDouble > &coords_1, Array< OneD, NekDouble > &coords_2, Array< OneD, NekDouble > &coords_3) override
Definition: Expansion.cpp:535
SpatialDomains::GeomFactorsSharedPtr m_metricinfo
Definition: Expansion.h:276
const NormalVector & GetTraceNormal(const int id)
Definition: Expansion.cpp:255
virtual void v_AlignVectorToCollapsedDir(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray) override
Definition: PrismExp.cpp:382
virtual DNekMatSharedPtr v_CreateStdMatrix(const StdRegions::StdMatrixKey &mkey) override
Definition: PrismExp.cpp:1074
virtual DNekMatSharedPtr v_GenMatrix(const StdRegions::StdMatrixKey &mkey) override
Definition: PrismExp.cpp:1051
virtual StdRegions::StdExpansionSharedPtr v_GetStdExp(void) const override
Definition: PrismExp.cpp:462
virtual void v_LaplacianMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::StdMatrixKey &mkey) override
Definition: PrismExp.cpp:998
void v_DropLocStaticCondMatrix(const MatrixKey &mkey) override
Definition: PrismExp.cpp:1102
virtual void v_HelmholtzMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::StdMatrixKey &mkey) override
Definition: PrismExp.cpp:1013
virtual void v_GetSimplexEquiSpacedConnectivity(Array< OneD, int > &conn, bool standard=true) override
Definition: PrismExp.cpp:1311
virtual void v_IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Calculate the inner product of inarray with respect to the basis B=base0*base1*base2 and put into out...
Definition: PrismExp.cpp:265
virtual DNekScalMatSharedPtr v_GetLocMatrix(const MatrixKey &mkey) override
Definition: PrismExp.cpp:1086
void v_IProductWRTDerivBase(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Calculates the inner product .
Definition: PrismExp.cpp:331
virtual void v_PhysDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_d0, Array< OneD, NekDouble > &out_d1, Array< OneD, NekDouble > &out_d2) override
Calculate the derivative of the physical points.
Definition: PrismExp.cpp:127
LibUtilities::NekManager< MatrixKey, DNekScalBlkMat, MatrixKey::opLess > m_staticCondMatrixManager
Definition: PrismExp.h:202
virtual void v_IProductWRTBase_SumFac(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool multiplybyweights=true) override
Definition: PrismExp.cpp:271
virtual void v_ExtractDataToCoeffs(const NekDouble *data, const std::vector< unsigned int > &nummodes, const int mode_offset, NekDouble *coeffs, std::vector< LibUtilities::BasisType > &fromType) override
Definition: PrismExp.cpp:549
virtual void v_GetCoord(const Array< OneD, const NekDouble > &Lcoords, Array< OneD, NekDouble > &coords) override
Get the coordinates #coords at the local coordinates #Lcoords.
Definition: PrismExp.cpp:486
virtual void v_NormalTraceDerivFactors(Array< OneD, Array< OneD, NekDouble >> &d0factors, Array< OneD, Array< OneD, NekDouble >> &d1factors, Array< OneD, Array< OneD, NekDouble >> &d2factors) override
: This method gets all of the factors which are required as part of the Gradient Jump Penalty stabili...
Definition: PrismExp.cpp:1557
virtual StdRegions::StdExpansionSharedPtr v_GetLinStdExp(void) const override
Definition: PrismExp.cpp:469
void v_ComputeTraceNormal(const int face) override
Get the normals along specficied face Get the face normals interplated to a points0 x points 0 type d...
Definition: PrismExp.cpp:709
virtual void v_MassMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::StdMatrixKey &mkey) override
Definition: PrismExp.cpp:991
virtual void v_LaplacianMatrixOp_MatFree_Kernel(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, Array< OneD, NekDouble > &wsp) override
Calculate the Laplacian multiplication in a matrix-free manner.
Definition: PrismExp.cpp:1125
void v_IProductWRTDerivBase_SumFac(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Definition: PrismExp.cpp:338
virtual NekDouble v_StdPhysEvaluate(const Array< OneD, const NekDouble > &Lcoord, const Array< OneD, const NekDouble > &physvals) override
Definition: PrismExp.cpp:515
virtual void v_FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Forward transform from physical quadrature space stored in inarray and evaluate the expansion coeffic...
Definition: PrismExp.cpp:213
PrismExp(const LibUtilities::BasisKey &Ba, const LibUtilities::BasisKey &Bb, const LibUtilities::BasisKey &Bc, const SpatialDomains::PrismGeomSharedPtr &geom)
Constructor using BasisKey class for quadrature points and order definition.
Definition: PrismExp.cpp:49
virtual void v_GetTracePhysMap(const int face, Array< OneD, int > &outarray) override
Definition: PrismExp.cpp:608
void v_DropLocMatrix(const MatrixKey &mkey) override
Definition: PrismExp.cpp:1091
virtual NekDouble v_PhysEvaluate(const Array< OneD, const NekDouble > &coord, const Array< OneD, const NekDouble > &physvals) override
This function evaluates the expansion at a single (arbitrary) point of the domain.
Definition: PrismExp.cpp:523
virtual void v_SVVLaplacianFilter(Array< OneD, NekDouble > &array, const StdRegions::StdMatrixKey &mkey) override
Definition: PrismExp.cpp:1020
LibUtilities::NekManager< MatrixKey, DNekScalMat, MatrixKey::opLess > m_matrixManager
Definition: PrismExp.h:200
virtual DNekScalBlkMatSharedPtr v_GetLocStaticCondMatrix(const MatrixKey &mkey) override
Definition: PrismExp.cpp:1096
virtual NekDouble v_Integral(const Array< OneD, const NekDouble > &inarray) override
Integrate the physical point list inarray over prismatic region and return the value.
Definition: PrismExp.cpp:100
virtual void v_GetCoords(Array< OneD, NekDouble > &coords_1, Array< OneD, NekDouble > &coords_2, Array< OneD, NekDouble > &coords_3) override
Definition: PrismExp.cpp:503
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
void IProductWRTBase_SumFacKernel(const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &base1, const Array< OneD, const NekDouble > &base2, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, Array< OneD, NekDouble > &wsp, bool doCheckCollDir0, bool doCheckCollDir1, bool doCheckCollDir2)
virtual void v_HelmholtzMatrixOp_MatFree(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::StdMatrixKey &mkey) override
int GetNcoeffs(void) const
This function returns the total number of coefficients used in the expansion.
Definition: StdExpansion.h:130
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
Definition: StdExpansion.h:140
LibUtilities::BasisType GetBasisType(const int dir) const
This function returns the type of basis used in the dir direction.
Definition: StdExpansion.h:162
const LibUtilities::PointsKeyVector GetPointsKeys() const
const LibUtilities::BasisKey GetTraceBasisKey(const int i, int k=-1) const
This function returns the basis key belonging to the i-th trace.
Definition: StdExpansion.h:305
void LaplacianMatrixOp_MatFree(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdMatrixKey &mkey)
LibUtilities::ShapeType DetShapeType() const
This function returns the shape of the expansion domain.
Definition: StdExpansion.h:373
LibUtilities::PointsType GetPointsType(const int dir) const
This function returns the type of quadrature points used in the dir direction.
Definition: StdExpansion.h:211
int GetNumPoints(const int dir) const
This function returns the number of quadrature points in the dir direction.
Definition: StdExpansion.h:224
void MultiplyByQuadratureMetric(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdExpansion.h:729
Array< OneD, LibUtilities::BasisSharedPtr > m_base
MatrixType GetMatrixType() const
Definition: StdMatrixKey.h:85
static void Dscal(const int &n, const double &alpha, double *x, const int &incx)
BLAS level 1: x = alpha x.
Definition: Blas.hpp:168
static void Daxpy(const int &n, const double &alpha, const double *x, const int &incx, const double *y, const int &incy)
BLAS level 1: y = alpha x plus y.
Definition: Blas.hpp:154
void Interp2D(const BasisKey &fbasis0, const BasisKey &fbasis1, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, const BasisKey &tbasis1, Array< OneD, NekDouble > &to)
this function interpolates a 2D function evaluated at the quadrature points of the 2D basis,...
Definition: Interp.cpp:106
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:250
@ eModified_B
Principle Modified Functions .
Definition: BasisType.h:51
@ eModified_A
Principle Modified Functions .
Definition: BasisType.h:50
std::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
Definition: GeomFactors.h:62
std::shared_ptr< PrismGeom > PrismGeomSharedPtr
Definition: PrismGeom.h:85
GeomType
Indicates the type of element geometry.
@ eRegular
Geometry is straight-sided with constant geometric factors.
@ eMovingRegular
Currently unused.
@ eDeformed
Geometry is curved or has non-constant factors.
std::shared_ptr< StdPrismExp > StdPrismExpSharedPtr
Definition: StdPrismExp.h:239
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:79
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:75
double NekDouble
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
Definition: Vmath.cpp:534
void Svtsvtp(int n, const T alpha, const T *x, int incx, const T beta, const T *y, int incy, T *z, int incz)
svtvvtp (scalar times vector plus scalar times vector):
Definition: Vmath.cpp:751
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.cpp:209
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
Definition: Vmath.cpp:622
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:574
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:359
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition: Vmath.cpp:248
void Sdiv(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha/y.
Definition: Vmath.cpp:324
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
Definition: Vmath.cpp:284
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:492
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.cpp:45
void Vvtvvtp(int n, const T *v, int incv, const T *w, int incw, const T *x, int incx, const T *y, int incy, T *z, int incz)
vvtvvtp (vector times vector plus vector times vector):
Definition: Vmath.cpp:692
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1255
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294