Nektar++
StdPrismExp.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: StdPrismExp.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: Prismatic routines built upon StdExpansion3D
32//
33///////////////////////////////////////////////////////////////////////////////
34
37
38using namespace std;
39
40namespace Nektar::StdRegions
41{
42
44 const LibUtilities::BasisKey &Bb,
45 const LibUtilities::BasisKey &Bc)
46 : StdExpansion(LibUtilities::StdPrismData::getNumberOfCoefficients(
47 Ba.GetNumModes(), Bb.GetNumModes(), Bc.GetNumModes()),
48 3, Ba, Bb, Bc),
49 StdExpansion3D(LibUtilities::StdPrismData::getNumberOfCoefficients(
50 Ba.GetNumModes(), Bb.GetNumModes(), Bc.GetNumModes()),
51 Ba, Bb, Bc)
52{
53 ASSERTL0(Ba.GetNumModes() <= Bc.GetNumModes(),
54 "order in 'a' direction is higher than order in 'c' direction");
55}
56
57//---------------------------------------
58// Differentiation Methods
59//---------------------------------------
60
61/**
62 * \brief Calculate the derivative of the physical points
63 *
64 * The derivative is evaluated at the nodal physical points.
65 * Derivatives with respect to the local Cartesian coordinates.
66 *
67 * \f$\begin{Bmatrix} \frac {\partial} {\partial \xi_1} \\ \frac
68 * {\partial} {\partial \xi_2} \\ \frac {\partial} {\partial \xi_3}
69 * \end{Bmatrix} = \begin{Bmatrix} \frac 2 {(1-\eta_3)} \frac \partial
70 * {\partial \bar \eta_1} \\ \frac {\partial} {\partial \xi_2} \ \
71 * \frac {(1 + \bar \eta_1)} {(1 - \eta_3)} \frac \partial {\partial
72 * \bar \eta_1} + \frac {\partial} {\partial \eta_3} \end{Bmatrix}\f$
73 */
74
76 Array<OneD, NekDouble> &out_dxi1,
77 Array<OneD, NekDouble> &out_dxi2,
78 Array<OneD, NekDouble> &out_dxi3)
79{
80 int Qx = m_base[0]->GetNumPoints();
81 int Qy = m_base[1]->GetNumPoints();
82 int Qz = m_base[2]->GetNumPoints();
83 int Qtot = Qx * Qy * Qz;
84
85 Array<OneD, NekDouble> dEta_bar1(Qtot, 0.0);
86
88 eta_x = m_base[0]->GetZ();
89 eta_z = m_base[2]->GetZ();
90
91 int i, k;
92
93 bool Do_1 = (out_dxi1.size() > 0) ? true : false;
94 bool Do_3 = (out_dxi3.size() > 0) ? true : false;
95
96 // out_dXi2 is just a tensor derivative so is just passed through
97 if (Do_3)
98 {
99 PhysTensorDeriv(u_physical, dEta_bar1, out_dxi2, out_dxi3);
100 }
101 else if (Do_1)
102 {
103 PhysTensorDeriv(u_physical, dEta_bar1, out_dxi2, NullNekDouble1DArray);
104 }
105 else // case if just require 2nd direction
106 {
107 PhysTensorDeriv(u_physical, NullNekDouble1DArray, out_dxi2,
109 }
110
111 if (Do_1)
112 {
113 for (k = 0; k < Qz; ++k)
114 {
115 Vmath::Smul(Qx * Qy, 2.0 / (1.0 - eta_z[k]),
116 &dEta_bar1[0] + k * Qx * Qy, 1,
117 &out_dxi1[0] + k * Qx * Qy, 1);
118 }
119 }
120
121 if (Do_3)
122 {
123 // divide dEta_Bar1 by (1-eta_z)
124 for (k = 0; k < Qz; ++k)
125 {
126 Vmath::Smul(Qx * Qy, 1.0 / (1.0 - eta_z[k]),
127 &dEta_bar1[0] + k * Qx * Qy, 1,
128 &dEta_bar1[0] + k * Qx * Qy, 1);
129 }
130
131 // Multiply dEta_Bar1 by (1+eta_x) and add ot out_dxi3
132 for (i = 0; i < Qx; ++i)
133 {
134 Vmath::Svtvp(Qz * Qy, 1.0 + eta_x[i], &dEta_bar1[0] + i, Qx,
135 &out_dxi3[0] + i, Qx, &out_dxi3[0] + i, Qx);
136 }
137 }
138}
139
140void StdPrismExp::v_PhysDeriv(const int dir,
141 const Array<OneD, const NekDouble> &inarray,
142 Array<OneD, NekDouble> &outarray)
143{
144 switch (dir)
145 {
146 case 0:
147 {
148 v_PhysDeriv(inarray, outarray, NullNekDouble1DArray,
150 break;
151 }
152
153 case 1:
154 {
155 v_PhysDeriv(inarray, NullNekDouble1DArray, outarray,
157 break;
158 }
159
160 case 2:
161 {
163 outarray);
164 break;
165 }
166
167 default:
168 {
169 ASSERTL1(false, "input dir is out of range");
170 }
171 break;
172 }
173}
174
179{
180 StdPrismExp::v_PhysDeriv(inarray, out_d0, out_d1, out_d2);
181}
182
184 const Array<OneD, const NekDouble> &inarray,
185 Array<OneD, NekDouble> &outarray)
186{
187 StdPrismExp::v_PhysDeriv(dir, inarray, outarray);
188}
189
190//---------------------------------------
191// Transforms
192//---------------------------------------
193
194/**
195 * @note 'r' (base[2]) runs fastest in this element.
196 *
197 * Perform backwards transformation at the quadrature points:
198 *
199 * \f$ u^{\delta} (\xi_{1i}, \xi_{2j}, \xi_{3k}) = \sum_{m(pqr)} \hat
200 * u_{pqr} \phi_{pqr} (\xi_{1i}, \xi_{2j}, \xi_{3k})\f$
201 *
202 * In the prism this expansion becomes:
203 *
204 * \f$ u (\xi_{1i}, \xi_{2j}, \xi_{3k}) = \sum_{p=0}^{Q_x} \psi_p^a
205 * (\xi_{1i}) \lbrace { \sum_{q=0}^{Q_y} \psi_{q}^a (\xi_{2j})
206 * \lbrace { \sum_{r=0}^{Q_z} \hat u_{pqr} \psi_{pr}^b (\xi_{3k})
207 * \rbrace} \rbrace}. \f$
208 *
209 * And sumfactorizing step of the form is as:\\
210 *
211 * \f$ f_{pr} (\xi_{3k}) = \sum_{r=0}^{Q_z} \hat u_{pqr} \psi_{pr}^b
212 * (\xi_{3k}),\\
213 *
214 * g_{p} (\xi_{2j}, \xi_{3k}) = \sum_{r=0}^{Q_y} \psi_{p}^a (\xi_{2j})
215 * f_{pr} (\xi_{3k}),\ \
216 *
217 * u(\xi_{1i}, \xi_{2j}, \xi_{3k}) = \sum_{p=0}^{Q_x} \psi_{p}^a
218 * (\xi_{1i}) g_{p} (\xi_{2j}, \xi_{3k}). \f$
219 */
221 Array<OneD, NekDouble> &outarray)
222{
225 "Basis[1] is not a general tensor type");
226
229 "Basis[2] is not a general tensor type");
230
231 if (m_base[0]->Collocation() && m_base[1]->Collocation() &&
232 m_base[2]->Collocation())
233 {
235 m_base[2]->GetNumPoints(),
236 inarray, 1, outarray, 1);
237 }
238 else
239 {
240 StdPrismExp::v_BwdTrans_SumFac(inarray, outarray);
241 }
242}
243
245 Array<OneD, NekDouble> &outarray)
246{
247 int nquad1 = m_base[1]->GetNumPoints();
248 int nquad2 = m_base[2]->GetNumPoints();
249 int order0 = m_base[0]->GetNumModes();
250 int order1 = m_base[1]->GetNumModes();
251
252 Array<OneD, NekDouble> wsp(nquad2 * order1 * order0 +
253 nquad1 * nquad2 * order0);
254
255 BwdTrans_SumFacKernel(m_base[0]->GetBdata(), m_base[1]->GetBdata(),
256 m_base[2]->GetBdata(), inarray, outarray, wsp, true,
257 true, true);
258}
259
261 const Array<OneD, const NekDouble> &base0,
262 const Array<OneD, const NekDouble> &base1,
263 const Array<OneD, const NekDouble> &base2,
264 const Array<OneD, const NekDouble> &inarray,
266 [[maybe_unused]] bool doCheckCollDir0,
267 [[maybe_unused]] bool doCheckCollDir1,
268 [[maybe_unused]] bool doCheckCollDir2)
269{
270 int i, mode;
271 int nquad0 = m_base[0]->GetNumPoints();
272 int nquad1 = m_base[1]->GetNumPoints();
273 int nquad2 = m_base[2]->GetNumPoints();
274 int nummodes0 = m_base[0]->GetNumModes();
275 int nummodes1 = m_base[1]->GetNumModes();
276 int nummodes2 = m_base[2]->GetNumModes();
277 Array<OneD, NekDouble> tmp0 = wsp;
278 Array<OneD, NekDouble> tmp1 = tmp0 + nquad2 * nummodes1 * nummodes0;
279
280 for (i = mode = 0; i < nummodes0; ++i)
281 {
282 Blas::Dgemm('N', 'N', nquad2, nummodes1, nummodes2 - i, 1.0,
283 base2.get() + mode * nquad2, nquad2,
284 inarray.get() + mode * nummodes1, nummodes2 - i, 0.0,
285 tmp0.get() + i * nquad2 * nummodes1, nquad2);
286 mode += nummodes2 - i;
287 }
288
290 {
291 for (i = 0; i < nummodes1; i++)
292 {
293 Blas::Daxpy(nquad2, inarray[1 + i * nummodes2],
294 base2.get() + nquad2, 1,
295 tmp0.get() + nquad2 * (nummodes1 + i), 1);
296 }
297 }
298
299 for (i = 0; i < nummodes0; i++)
300 {
301 Blas::Dgemm('N', 'T', nquad1, nquad2, nummodes1, 1.0, base1.get(),
302 nquad1, tmp0.get() + i * nquad2 * nummodes1, nquad2, 0.0,
303 tmp1.get() + i * nquad2 * nquad1, nquad1);
304 }
305
306 Blas::Dgemm('N', 'T', nquad0, nquad2 * nquad1, nummodes0, 1.0, base0.get(),
307 nquad0, tmp1.get(), nquad2 * nquad1, 0.0, outarray.get(),
308 nquad0);
309}
310
311/**
312 * \brief Forward transform from physical quadrature space stored in
313 * \a inarray and evaluate the expansion coefficients and store in \a
314 * outarray
315 *
316 * Inputs:\n
317 * - \a inarray: array of physical quadrature points to be transformed
318 *
319 * Outputs:\n
320 * - \a outarray: updated array of expansion coefficients.
321 */
323 Array<OneD, NekDouble> &outarray)
324{
325 v_IProductWRTBase(inarray, outarray);
326
327 // Get Mass matrix inverse
328 StdMatrixKey masskey(eInvMass, DetShapeType(), *this);
329 DNekMatSharedPtr matsys = GetStdMatrix(masskey);
330
331 // copy inarray in case inarray == outarray
332 DNekVec in(m_ncoeffs, outarray);
333 DNekVec out(m_ncoeffs, outarray, eWrapper);
334
335 out = (*matsys) * in;
336}
337
338//---------------------------------------
339// Inner product functions
340//---------------------------------------
341
342/**
343 * \brief Calculate the inner product of inarray with respect to the
344 * basis B=base0*base1*base2 and put into outarray:
345 *
346 * \f$ \begin{array}{rcl} I_{pqr} = (\phi_{pqr}, u)_{\delta} & = &
347 * \sum_{i=0}^{nq_0} \sum_{j=0}^{nq_1} \sum_{k=0}^{nq_2} \psi_{p}^{a}
348 * (\bar \eta_{1i}) \psi_{q}^{a} (\xi_{2j}) \psi_{pr}^{b} (\xi_{3k})
349 * w_i w_j w_k u(\bar \eta_{1,i} \xi_{2,j} \xi_{3,k}) J_{i,j,k}\\ & =
350 * & \sum_{i=0}^{nq_0} \psi_p^a(\bar \eta_{1,i}) \sum_{j=0}^{nq_1}
351 * \psi_{q}^a(\xi_{2,j}) \sum_{k=0}^{nq_2} \psi_{pr}^b u(\bar
352 * \eta_{1i},\xi_{2j},\xi_{3k}) J_{i,j,k} \end{array} \f$ \n
353 *
354 * where
355 *
356 * \f$ \phi_{pqr} (\xi_1 , \xi_2 , \xi_3) = \psi_p^a (\bar \eta_1)
357 * \psi_{q}^a (\xi_2) \psi_{pr}^b (\xi_3) \f$ \n
358 *
359 * which can be implemented as \n
360 *
361 * \f$f_{pr} (\xi_{3k}) = \sum_{k=0}^{nq_3} \psi_{pr}^b u(\bar
362 * \eta_{1i},\xi_{2j},\xi_{3k}) J_{i,j,k} = {\bf B_3 U} \f$ \n \f$
363 * g_{q} (\xi_{3k}) = \sum_{j=0}^{nq_1} \psi_{q}^a (\xi_{2j}) f_{pr}
364 * (\xi_{3k}) = {\bf B_2 F} \f$ \n \f$ (\phi_{pqr}, u)_{\delta} =
365 * \sum_{k=0}^{nq_0} \psi_{p}^a (\xi_{3k}) g_{q} (\xi_{3k}) = {\bf B_1
366 * G} \f$
367 */
369 Array<OneD, NekDouble> &outarray)
370{
373 "Basis[1] is not a general tensor type");
374
377 "Basis[2] is not a general tensor type");
378
379 if (m_base[0]->Collocation() && m_base[1]->Collocation())
380 {
381 MultiplyByQuadratureMetric(inarray, outarray);
382 }
383 else
384 {
385 StdPrismExp::v_IProductWRTBase_SumFac(inarray, outarray);
386 }
387}
388
390 const Array<OneD, const NekDouble> &inarray,
391 Array<OneD, NekDouble> &outarray, bool multiplybyweights)
392{
393 int nquad1 = m_base[1]->GetNumPoints();
394 int nquad2 = m_base[2]->GetNumPoints();
395 int order0 = m_base[0]->GetNumModes();
396 int order1 = m_base[1]->GetNumModes();
397
398 Array<OneD, NekDouble> wsp(order0 * nquad2 * (nquad1 + order1));
399
400 if (multiplybyweights)
401 {
402 Array<OneD, NekDouble> tmp(inarray.size());
403
404 MultiplyByQuadratureMetric(inarray, tmp);
406 m_base[0]->GetBdata(), m_base[1]->GetBdata(), m_base[2]->GetBdata(),
407 tmp, outarray, wsp, true, true, true);
408 }
409 else
410 {
412 m_base[0]->GetBdata(), m_base[1]->GetBdata(), m_base[2]->GetBdata(),
413 inarray, outarray, wsp, true, true, true);
414 }
415}
416
418 const Array<OneD, const NekDouble> &base0,
419 const Array<OneD, const NekDouble> &base1,
420 const Array<OneD, const NekDouble> &base2,
421 const Array<OneD, const NekDouble> &inarray,
423 [[maybe_unused]] bool doCheckCollDir0,
424 [[maybe_unused]] bool doCheckCollDir1,
425 [[maybe_unused]] bool doCheckCollDir2)
426{
427 // Interior prism implementation based on Spen's book page
428 // 119. and 608.
429 const int nquad0 = m_base[0]->GetNumPoints();
430 const int nquad1 = m_base[1]->GetNumPoints();
431 const int nquad2 = m_base[2]->GetNumPoints();
432 const int order0 = m_base[0]->GetNumModes();
433 const int order1 = m_base[1]->GetNumModes();
434 const int order2 = m_base[2]->GetNumModes();
435
436 int i, mode;
437
438 ASSERTL1(wsp.size() >= nquad1 * nquad2 * order0 + nquad2 * order0 * order1,
439 "Insufficient workspace size");
440
441 Array<OneD, NekDouble> tmp0 = wsp;
442 Array<OneD, NekDouble> tmp1 = wsp + nquad1 * nquad2 * order0;
443
444 // Inner product with respect to the '0' direction
445 Blas::Dgemm('T', 'N', nquad1 * nquad2, order0, nquad0, 1.0, inarray.get(),
446 nquad0, base0.get(), nquad0, 0.0, tmp0.get(), nquad1 * nquad2);
447
448 // Inner product with respect to the '1' direction
449 Blas::Dgemm('T', 'N', nquad2 * order0, order1, nquad1, 1.0, tmp0.get(),
450 nquad1, base1.get(), nquad1, 0.0, tmp1.get(), nquad2 * order0);
451
452 // Inner product with respect to the '2' direction
453 for (mode = i = 0; i < order0; ++i)
454 {
455 Blas::Dgemm('T', 'N', order2 - i, order1, nquad2, 1.0,
456 base2.get() + mode * nquad2, nquad2,
457 tmp1.get() + i * nquad2, nquad2 * order0, 0.0,
458 outarray.get() + mode * order1, order2 - i);
459 mode += order2 - i;
460 }
461
462 // Fix top singular vertices; performs phi_{0,q,1} +=
463 // phi_1(xi_1)*phi_q(xi_2)*phi_{01}*phi_r(xi_2).
465 {
466 for (i = 0; i < order1; ++i)
467 {
468 mode = GetMode(0, i, 1);
469 outarray[mode] +=
470 Blas::Ddot(nquad2, base2.get() + nquad2, 1,
471 tmp1.get() + i * order0 * nquad2 + nquad2, 1);
472 }
473 }
474}
475
476/**
477 * \brief Inner product of \a inarray over region with respect to the
478 * object's default expansion basis; output in \a outarray.
479 */
481 const int dir, const Array<OneD, const NekDouble> &inarray,
482 Array<OneD, NekDouble> &outarray)
483{
484 v_IProductWRTDerivBase_SumFac(dir, inarray, outarray);
485}
486
488 const int dir, const Array<OneD, const NekDouble> &inarray,
489 Array<OneD, NekDouble> &outarray)
490{
491 ASSERTL0(dir >= 0 && dir <= 2, "input dir is out of range");
492
493 int i;
494 int order0 = m_base[0]->GetNumModes();
495 int order1 = m_base[1]->GetNumModes();
496 int nquad0 = m_base[0]->GetNumPoints();
497 int nquad1 = m_base[1]->GetNumPoints();
498 int nquad2 = m_base[2]->GetNumPoints();
499
500 const Array<OneD, const NekDouble> &z0 = m_base[0]->GetZ();
501 const Array<OneD, const NekDouble> &z2 = m_base[2]->GetZ();
502 Array<OneD, NekDouble> gfac0(nquad0);
503 Array<OneD, NekDouble> gfac2(nquad2);
504 Array<OneD, NekDouble> tmp0(nquad0 * nquad1 * nquad2);
505 Array<OneD, NekDouble> wsp(order0 * nquad2 * (nquad1 + order1));
506
507 // set up geometric factor: (1+z0)/2
508 for (i = 0; i < nquad0; ++i)
509 {
510 gfac0[i] = 0.5 * (1 + z0[i]);
511 }
512
513 // Set up geometric factor: 2/(1-z2)
514 for (i = 0; i < nquad2; ++i)
515 {
516 gfac2[i] = 2.0 / (1 - z2[i]);
517 }
518
519 // Scale first derivative term by gfac2.
520 if (dir != 1)
521 {
522 for (i = 0; i < nquad2; ++i)
523 {
524 Vmath::Smul(nquad0 * nquad1, gfac2[i],
525 &inarray[0] + i * nquad0 * nquad1, 1,
526 &tmp0[0] + i * nquad0 * nquad1, 1);
527 }
528 MultiplyByQuadratureMetric(tmp0, tmp0);
529 }
530
531 switch (dir)
532 {
533 case 0:
534 {
536 m_base[0]->GetDbdata(), m_base[1]->GetBdata(),
537 m_base[2]->GetBdata(), tmp0, outarray, wsp, true, true, true);
538 break;
539 }
540 case 1:
541 {
542 MultiplyByQuadratureMetric(inarray, tmp0);
544 m_base[0]->GetBdata(), m_base[1]->GetDbdata(),
545 m_base[2]->GetBdata(), tmp0, outarray, wsp, true, true, true);
546 break;
547 }
548
549 case 2:
550 {
552
553 // Scale eta_1 derivative with gfac0.
554 for (i = 0; i < nquad1 * nquad2; ++i)
555 {
556 Vmath::Vmul(nquad0, &gfac0[0], 1, &tmp0[0] + i * nquad0, 1,
557 &tmp0[0] + i * nquad0, 1);
558 }
559
561 m_base[0]->GetDbdata(), m_base[1]->GetBdata(),
562 m_base[2]->GetBdata(), tmp0, tmp1, wsp, true, true, true);
563
564 MultiplyByQuadratureMetric(inarray, tmp0);
566 m_base[0]->GetBdata(), m_base[1]->GetBdata(),
567 m_base[2]->GetDbdata(), tmp0, outarray, wsp, true, true, true);
568
569 Vmath::Vadd(m_ncoeffs, &tmp1[0], 1, &outarray[0], 1, &outarray[0],
570 1);
571 break;
572 }
573 }
574}
575
576//---------------------------------------
577// Evaluation functions
578//---------------------------------------
579
582{
583 NekDouble d2 = 1.0 - xi[2];
584 if (fabs(d2) < NekConstants::kNekZeroTol)
585 {
586 if (d2 >= 0.)
587 {
589 }
590 else
591 {
593 }
594 }
595 eta[2] = xi[2]; // eta_z = xi_z
596 eta[1] = xi[1]; // eta_y = xi_y
597 eta[0] = 2.0 * (1.0 + xi[0]) / d2 - 1.0;
598}
599
602{
603 xi[0] = (1.0 + eta[0]) * (1.0 - eta[2]) * 0.5 - 1.0;
604 xi[1] = eta[1];
605 xi[2] = eta[2];
606}
607
611{
612 Array<OneD, const NekDouble> etaBar_x = m_base[0]->GetZ();
613 Array<OneD, const NekDouble> eta_y = m_base[1]->GetZ();
614 Array<OneD, const NekDouble> eta_z = m_base[2]->GetZ();
615 int Qx = GetNumPoints(0);
616 int Qy = GetNumPoints(1);
617 int Qz = GetNumPoints(2);
618
619 // Convert collapsed coordinates into cartesian coordinates: eta --> xi
620 for (int k = 0; k < Qz; ++k)
621 {
622 for (int j = 0; j < Qy; ++j)
623 {
624 for (int i = 0; i < Qx; ++i)
625 {
626 int s = i + Qx * (j + Qy * k);
627 xi_x[s] = (1.0 - eta_z[k]) * (1.0 + etaBar_x[i]) / 2.0 - 1.0;
628 xi_y[s] = eta_y[j];
629 xi_z[s] = eta_z[k];
630 }
631 }
632 }
633}
634
636 const Array<OneD, NekDouble> &coord,
637 const Array<OneD, const NekDouble> &inarray,
638 std::array<NekDouble, 3> &firstOrderDerivs)
639{
640 // Collapse coordinates
641 Array<OneD, NekDouble> coll(3, 0.0);
642 LocCoordToLocCollapsed(coord, coll);
643
644 // If near singularity do the old interpolation matrix method
645 if ((1 - coll[2]) < 1e-5)
646 {
647 int totPoints = GetTotPoints();
648 Array<OneD, NekDouble> EphysDeriv0(totPoints), EphysDeriv1(totPoints),
649 EphysDeriv2(totPoints);
650 PhysDeriv(inarray, EphysDeriv0, EphysDeriv1, EphysDeriv2);
651
653 I[0] = GetBase()[0]->GetI(coll);
654 I[1] = GetBase()[1]->GetI(coll + 1);
655 I[2] = GetBase()[2]->GetI(coll + 2);
656
657 firstOrderDerivs[0] = PhysEvaluate(I, EphysDeriv0);
658 firstOrderDerivs[1] = PhysEvaluate(I, EphysDeriv1);
659 firstOrderDerivs[2] = PhysEvaluate(I, EphysDeriv2);
660 return PhysEvaluate(I, inarray);
661 }
662
663 NekDouble val = BaryTensorDeriv(coll, inarray, firstOrderDerivs);
664
665 NekDouble dEta_bar1 = firstOrderDerivs[0];
666
667 NekDouble fac = 2.0 / (1.0 - coll[2]);
668 firstOrderDerivs[0] = fac * dEta_bar1;
669
670 // divide dEta_Bar1 by (1-eta_z)
671 fac = 1.0 / (1.0 - coll[2]);
672 dEta_bar1 = fac * dEta_bar1;
673
674 // Multiply dEta_Bar1 by (1+eta_x) and add ot out_dxi3
675 fac = 1.0 + coll[0];
676 firstOrderDerivs[2] += fac * dEta_bar1;
677
678 return val;
679}
680
681void StdPrismExp::v_FillMode(const int mode, Array<OneD, NekDouble> &outarray)
682{
684 tmp[mode] = 1.0;
685 StdPrismExp::v_BwdTrans(tmp, outarray);
686}
687
689 const Array<OneD, const NekDouble> &coords, int mode)
690{
692 LocCoordToLocCollapsed(coords, coll);
693
694 const int nm1 = m_base[1]->GetNumModes();
695 const int nm2 = m_base[2]->GetNumModes();
696 const int b = 2 * nm2 + 1;
697
698 const int mode0 = floor(0.5 * (b - sqrt(b * b - 8.0 * mode / nm1)));
699 const int tmp =
700 mode - nm1 * (mode0 * (nm2 - 1) + 1 - (mode0 - 2) * (mode0 - 1) / 2);
701 const int mode1 = tmp / (nm2 - mode0);
702 const int mode2 = tmp % (nm2 - mode0);
703
704 if (mode0 == 0 && mode2 == 1 &&
706 {
707 // handle collapsed top edge to remove mode0 terms
708 return StdExpansion::BaryEvaluateBasis<1>(coll[1], mode1) *
709 StdExpansion::BaryEvaluateBasis<2>(coll[2], mode2);
710 }
711 else
712 {
713 return StdExpansion::BaryEvaluateBasis<0>(coll[0], mode0) *
714 StdExpansion::BaryEvaluateBasis<1>(coll[1], mode1) *
715 StdExpansion::BaryEvaluateBasis<2>(coll[2], mode2);
716 }
717}
718
719void StdPrismExp::v_GetTraceNumModes(const int fid, int &numModes0,
720 int &numModes1, Orientation faceOrient)
721{
722 int nummodes[3] = {m_base[0]->GetNumModes(), m_base[1]->GetNumModes(),
723 m_base[2]->GetNumModes()};
724 switch (fid)
725 {
726 // base quad
727 case 0:
728 {
729 numModes0 = nummodes[0];
730 numModes1 = nummodes[1];
731 }
732 break;
733 // front and back quad
734 case 2:
735 case 4:
736 {
737 numModes0 = nummodes[1];
738 numModes1 = nummodes[2];
739 }
740 break;
741 // triangles
742 case 1:
743 case 3:
744 {
745 numModes0 = nummodes[0];
746 numModes1 = nummodes[2];
747 }
748 break;
749 }
750
751 if (faceOrient >= eDir1FwdDir2_Dir2FwdDir1)
752 {
753 std::swap(numModes0, numModes1);
754 }
755}
756
757int StdPrismExp::v_GetEdgeNcoeffs(const int i) const
758{
759 ASSERTL2(i >= 0 && i <= 8, "edge id is out of range");
760
761 if (i == 0 || i == 2)
762 {
763 return GetBasisNumModes(0);
764 }
765 else if (i == 1 || i == 3 || i == 8)
766 {
767 return GetBasisNumModes(1);
768 }
769 else
770 {
771 return GetBasisNumModes(2);
772 }
773}
774
775//---------------------------------------
776// Helper functions
777//---------------------------------------
778
780{
781 return 6;
782}
783
785{
786 return 9;
787}
788
790{
791 return 5;
792}
793
794/**
795 * \brief Return Shape of region, using ShapeType enum list;
796 * i.e. prism.
797 */
799{
801}
802
804{
807 "BasisType is not a boundary interior form");
810 "BasisType is not a boundary interior form");
813 "BasisType is not a boundary interior form");
814
815 int P = m_base[0]->GetNumModes();
816 int Q = m_base[1]->GetNumModes();
817 int R = m_base[2]->GetNumModes();
818
820}
821
823{
826 "BasisType is not a boundary interior form");
829 "BasisType is not a boundary interior form");
832 "BasisType is not a boundary interior form");
833
834 int P = m_base[0]->GetNumModes() - 1;
835 int Q = m_base[1]->GetNumModes() - 1;
836 int R = m_base[2]->GetNumModes() - 1;
837
838 return (P + 1) * (Q + 1) // 1 rect. face on base
839 + 2 * (Q + 1) * (R + 1) // other 2 rect. faces
840 + 2 * (R + 1) + P * (1 + 2 * R - P); // 2 tri. faces
841}
842
843int StdPrismExp::v_GetTraceNcoeffs(const int i) const
844{
845 ASSERTL2(i >= 0 && i <= 4, "face id is out of range");
846 if (i == 0)
847 {
848 return GetBasisNumModes(0) * GetBasisNumModes(1);
849 }
850 else if (i == 1 || i == 3)
851 {
852 int P = GetBasisNumModes(0) - 1, Q = GetBasisNumModes(2) - 1;
853 return Q + 1 + (P * (1 + 2 * Q - P)) / 2;
854 }
855 else
856 {
857 return GetBasisNumModes(1) * GetBasisNumModes(2);
858 }
859}
860
862{
863 ASSERTL2(i >= 0 && i <= 4, "face id is out of range");
864
865 int Pi = GetBasisNumModes(0) - 2;
866 int Qi = GetBasisNumModes(1) - 2;
867 int Ri = GetBasisNumModes(2) - 2;
868
869 if (i == 0)
870 {
871 return Pi * Qi;
872 }
873 else if (i == 1 || i == 3)
874 {
875 return Pi * (2 * Ri - Pi - 1) / 2;
876 }
877 else
878 {
879 return Qi * Ri;
880 }
881}
882
884{
885 ASSERTL2(i >= 0 && i <= 4, "face id is out of range");
886
887 if (i == 0)
888 {
889 return m_base[0]->GetNumPoints() * m_base[1]->GetNumPoints();
890 }
891 else if (i == 1 || i == 3)
892 {
893 return m_base[0]->GetNumPoints() * m_base[2]->GetNumPoints();
894 }
895 else
896 {
897 return m_base[1]->GetNumPoints() * m_base[2]->GetNumPoints();
898 }
899}
900
902 const int j) const
903{
904 ASSERTL2(i >= 0 && i <= 4, "face id is out of range");
905 ASSERTL2(j == 0 || j == 1, "face direction is out of range");
906
907 if (i == 0)
908 {
909 return m_base[j]->GetPointsKey();
910 }
911 else if (i == 1 || i == 3)
912 {
913 return m_base[2 * j]->GetPointsKey();
914 }
915 else
916 {
917 return m_base[j + 1]->GetPointsKey();
918 }
919}
920
922 const int k) const
923{
924 ASSERTL2(i >= 0 && i <= 4, "face id is out of range");
925 ASSERTL2(k >= 0 && k <= 1, "basis key id is out of range");
926
927 switch (i)
928 {
929 case 0:
930 {
932 m_base[k]->GetNumPoints(),
933 m_base[k]->GetNumModes());
934 }
935 case 2:
936 case 4:
937 {
938 return EvaluateQuadFaceBasisKey(k, m_base[k + 1]->GetBasisType(),
939 m_base[k + 1]->GetNumPoints(),
940 m_base[k + 1]->GetNumModes());
941 }
942 case 1:
943 case 3:
944 {
945 return EvaluateTriFaceBasisKey(k, m_base[2 * k]->GetBasisType(),
946 m_base[2 * k]->GetNumPoints(),
947 m_base[2 * k]->GetNumModes());
948 }
949 break;
950 }
951
952 // Should never get here.
954}
955
957 const std::vector<unsigned int> &nummodes, int &modes_offset)
958{
960 nummodes[modes_offset], nummodes[modes_offset + 1],
961 nummodes[modes_offset + 2]);
962
963 modes_offset += 3;
964 return nmodes;
965}
966
968{
970 (m_base[1]->GetBasisType() == LibUtilities::eModified_A) &&
972}
973
974//---------------------------------------
975// Mappings
976//---------------------------------------
977
978int StdPrismExp::v_GetVertexMap(const int vId, bool useCoeffPacking)
979{
983 "Mapping not defined for this type of basis");
984
985 int l = 0;
986
987 if (useCoeffPacking == true) // follow packing of coefficients i.e q,r,p
988 {
989 switch (vId)
990 {
991 case 0:
992 l = GetMode(0, 0, 0);
993 break;
994 case 1:
995 l = GetMode(0, 0, 1);
996 break;
997 case 2:
998 l = GetMode(0, 1, 0);
999 break;
1000 case 3:
1001 l = GetMode(0, 1, 1);
1002 break;
1003 case 4:
1004 l = GetMode(1, 0, 0);
1005 break;
1006 case 5:
1007 l = GetMode(1, 1, 0);
1008 break;
1009 default:
1010 ASSERTL0(false, "local vertex id must be between 0 and 5");
1011 }
1012 }
1013 else
1014 {
1015 switch (vId)
1016 {
1017 case 0:
1018 l = GetMode(0, 0, 0);
1019 break;
1020 case 1:
1021 l = GetMode(1, 0, 0);
1022 break;
1023 case 2:
1024 l = GetMode(1, 1, 0);
1025 break;
1026 case 3:
1027 l = GetMode(0, 1, 0);
1028 break;
1029 case 4:
1030 l = GetMode(0, 0, 1);
1031 break;
1032 case 5:
1033 l = GetMode(0, 1, 1);
1034 break;
1035 default:
1036 ASSERTL0(false, "local vertex id must be between 0 and 5");
1037 }
1038 }
1039
1040 return l;
1041}
1042
1044{
1047 "BasisType is not a boundary interior form");
1050 "BasisType is not a boundary interior form");
1053 "BasisType is not a boundary interior form");
1054
1055 int P = m_base[0]->GetNumModes() - 1, p;
1056 int Q = m_base[1]->GetNumModes() - 1, q;
1057 int R = m_base[2]->GetNumModes() - 1, r;
1058
1059 int nIntCoeffs = m_ncoeffs - NumBndryCoeffs();
1060
1061 if (outarray.size() != nIntCoeffs)
1062 {
1063 outarray = Array<OneD, unsigned int>(nIntCoeffs);
1064 }
1065
1066 int idx = 0;
1067
1068 // Loop over all interior modes.
1069 for (p = 2; p <= P; ++p)
1070 {
1071 for (q = 2; q <= Q; ++q)
1072 {
1073 for (r = 1; r <= R - p; ++r)
1074 {
1075 outarray[idx++] = GetMode(p, q, r);
1076 }
1077 }
1078 }
1079}
1080
1082{
1085 "BasisType is not a boundary interior form");
1088 "BasisType is not a boundary interior form");
1091 "BasisType is not a boundary interior form");
1092
1093 int P = m_base[0]->GetNumModes() - 1, p;
1094 int Q = m_base[1]->GetNumModes() - 1, q;
1095 int R = m_base[2]->GetNumModes() - 1, r;
1096 int idx = 0;
1097
1098 int nBnd = NumBndryCoeffs();
1099
1100 if (maparray.size() != nBnd)
1101 {
1102 maparray = Array<OneD, unsigned int>(nBnd);
1103 }
1104
1105 // Loop over all boundary modes (in ascending order).
1106 for (p = 0; p <= P; ++p)
1107 {
1108 // First two q-r planes are entirely boundary modes.
1109 if (p <= 1)
1110 {
1111 for (q = 0; q <= Q; ++q)
1112 {
1113 for (r = 0; r <= R - p; ++r)
1114 {
1115 maparray[idx++] = GetMode(p, q, r);
1116 }
1117 }
1118 }
1119 else
1120 {
1121 // Remaining q-r planes contain boundary modes on the two
1122 // left-hand sides and bottom edge.
1123 for (q = 0; q <= Q; ++q)
1124 {
1125 if (q <= 1)
1126 {
1127 for (r = 0; r <= R - p; ++r)
1128 {
1129 maparray[idx++] = GetMode(p, q, r);
1130 }
1131 }
1132 else
1133 {
1134 maparray[idx++] = GetMode(p, q, 0);
1135 }
1136 }
1137 }
1138 }
1139}
1140
1141void StdPrismExp::v_GetTraceCoeffMap(const unsigned int fid,
1142 Array<OneD, unsigned int> &maparray)
1143{
1145 "Method only implemented if BasisType is identical"
1146 "in x and y directions");
1149 "Method only implemented for Modified_A BasisType"
1150 "(x and y direction) and Modified_B BasisType (z "
1151 "direction)");
1152 int p, q, r, idx = 0;
1153 int P = 0, Q = 0;
1154
1155 switch (fid)
1156 {
1157 case 0:
1158 P = m_base[0]->GetNumModes();
1159 Q = m_base[1]->GetNumModes();
1160 break;
1161 case 1:
1162 case 3:
1163 P = m_base[0]->GetNumModes();
1164 Q = m_base[2]->GetNumModes();
1165 break;
1166 case 2:
1167 case 4:
1168 P = m_base[1]->GetNumModes();
1169 Q = m_base[2]->GetNumModes();
1170 break;
1171 default:
1172 ASSERTL0(false, "fid must be between 0 and 4");
1173 }
1174
1175 if (maparray.size() != P * Q)
1176 {
1177 maparray = Array<OneD, unsigned int>(P * Q);
1178 }
1179
1180 // Set up ordering inside each 2D face. Also for triangular faces,
1181 // populate signarray.
1182 switch (fid)
1183 {
1184 case 0: // Bottom quad
1185 for (q = 0; q < Q; ++q)
1186 {
1187 for (p = 0; p < P; ++p)
1188 {
1189 maparray[q * P + p] = GetMode(p, q, 0);
1190 }
1191 }
1192 break;
1193 case 1: // Left triangle
1194 for (p = 0; p < P; ++p)
1195 {
1196 for (r = 0; r < Q - p; ++r)
1197 {
1198 maparray[idx++] = GetMode(p, 0, r);
1199 }
1200 }
1201 break;
1202 case 2: // Slanted quad
1203 for (q = 0; q < P; ++q)
1204 {
1205 maparray[q] = GetMode(1, q, 0);
1206 }
1207 for (q = 0; q < P; ++q)
1208 {
1209 maparray[P + q] = GetMode(0, q, 1);
1210 }
1211 for (r = 1; r < Q - 1; ++r)
1212 {
1213 for (q = 0; q < P; ++q)
1214 {
1215 maparray[(r + 1) * P + q] = GetMode(1, q, r);
1216 }
1217 }
1218 break;
1219 case 3: // Right triangle
1220 for (p = 0; p < P; ++p)
1221 {
1222 for (r = 0; r < Q - p; ++r)
1223 {
1224 maparray[idx++] = GetMode(p, 1, r);
1225 }
1226 }
1227 break;
1228 case 4: // Rear quad
1229 for (r = 0; r < Q; ++r)
1230 {
1231 for (q = 0; q < P; ++q)
1232 {
1233 maparray[r * P + q] = GetMode(0, q, r);
1234 }
1235 }
1236 break;
1237 default:
1238 ASSERTL0(false, "Face to element map unavailable.");
1239 }
1240}
1241
1242void StdPrismExp::v_GetElmtTraceToTraceMap(const unsigned int fid,
1243 Array<OneD, unsigned int> &maparray,
1244 Array<OneD, int> &signarray,
1245 Orientation faceOrient, int P, int Q)
1246{
1248 "Method only implemented if BasisType is identical"
1249 "in x and y directions");
1252 "Method only implemented for Modified_A BasisType"
1253 "(x and y direction) and Modified_B BasisType (z "
1254 "direction)");
1255
1256 int i, j, k, p, r, nFaceCoeffs, idx = 0;
1257 int nummodesA = 0, nummodesB = 0;
1258
1259 switch (fid)
1260 {
1261 case 0:
1262 nummodesA = m_base[0]->GetNumModes();
1263 nummodesB = m_base[1]->GetNumModes();
1264 break;
1265 case 1:
1266 case 3:
1267 nummodesA = m_base[0]->GetNumModes();
1268 nummodesB = m_base[2]->GetNumModes();
1269 break;
1270 case 2:
1271 case 4:
1272 nummodesA = m_base[1]->GetNumModes();
1273 nummodesB = m_base[2]->GetNumModes();
1274 break;
1275 default:
1276 ASSERTL0(false, "fid must be between 0 and 4");
1277 }
1278
1279 if (P == -1)
1280 {
1281 P = nummodesA;
1282 Q = nummodesB;
1283 nFaceCoeffs = GetTraceNcoeffs(fid);
1284 }
1285 else if (fid == 1 || fid == 3)
1286 {
1287 nFaceCoeffs = P * (2 * Q - P + 1) / 2;
1288 }
1289 else
1290 {
1291 nFaceCoeffs = P * Q;
1292 }
1293
1294 // Allocate the map array and sign array; set sign array to ones (+)
1295 if (maparray.size() != nFaceCoeffs)
1296 {
1297 maparray = Array<OneD, unsigned int>(nFaceCoeffs);
1298 }
1299
1300 if (signarray.size() != nFaceCoeffs)
1301 {
1302 signarray = Array<OneD, int>(nFaceCoeffs, 1);
1303 }
1304 else
1305 {
1306 fill(signarray.get(), signarray.get() + nFaceCoeffs, 1);
1307 }
1308
1309 int minPA = min(nummodesA, P);
1310 int minQB = min(nummodesB, Q);
1311 // triangular faces
1312 if (fid == 1 || fid == 3)
1313 {
1314 // zero signmap and set maparray to zero if elemental
1315 // modes are not as large as face modesl
1316 idx = 0;
1317 int cnt = 0;
1318
1319 for (j = 0; j < minPA; ++j)
1320 {
1321 // set maparray
1322 for (k = 0; k < minQB - j; ++k, ++cnt)
1323 {
1324 maparray[idx++] = cnt;
1325 }
1326
1327 cnt += nummodesB - minQB;
1328
1329 // idx += nummodesB-j;
1330 for (k = nummodesB - j; k < Q - j; ++k)
1331 {
1332 signarray[idx] = 0.0;
1333 maparray[idx++] = maparray[0];
1334 }
1335 }
1336#if 0 // no required?
1337 for (j = minPA; j < nummodesA; ++j)
1338 {
1339 // set maparray
1340 for (k = 0; k < minQB-j; ++k, ++cnt)
1341 {
1342 maparray[idx++] = cnt;
1343 }
1344
1345 cnt += nummodesB-minQB;
1346
1347 //idx += nummodesB-j;
1348 for (k = nummodesB-j; k < Q-j; ++k)
1349 {
1350 signarray[idx] = 0.0;
1351 maparray[idx++] = maparray[0];
1352 }
1353 }
1354#endif
1355 for (j = nummodesA; j < P; ++j)
1356 {
1357 for (k = 0; k < Q - j; ++k)
1358 {
1359 signarray[idx] = 0.0;
1360 maparray[idx++] = maparray[0];
1361 }
1362 }
1363
1364 // Triangles only have one possible orientation (base
1365 // direction reversed); swap edge modes.
1366 if (faceOrient == eDir1BwdDir1_Dir2FwdDir2)
1367 {
1368 idx = 0;
1369 for (p = 0; p < P; ++p)
1370 {
1371 for (r = 0; r < Q - p; ++r, idx++)
1372 {
1373 if (p > 1)
1374 {
1375 signarray[idx] = p % 2 ? -1 : 1;
1376 }
1377 }
1378 }
1379
1380 swap(maparray[0], maparray[Q]);
1381 for (i = 1; i < Q - 1; ++i)
1382 {
1383 swap(maparray[i + 1], maparray[Q + i]);
1384 }
1385 }
1386 }
1387 else
1388 {
1389 // Set up an array indexing for quads, since the
1390 // ordering may need to be transposed.
1391 Array<OneD, int> arrayindx(nFaceCoeffs, -1);
1392
1393 for (i = 0; i < Q; i++)
1394 {
1395 for (j = 0; j < P; j++)
1396 {
1397 if (faceOrient < eDir1FwdDir2_Dir2FwdDir1)
1398 {
1399 arrayindx[i * P + j] = i * P + j;
1400 }
1401 else
1402 {
1403 arrayindx[i * P + j] = j * Q + i;
1404 }
1405 }
1406 }
1407
1408 // zero signmap and set maparray to zero if elemental
1409 // modes are not as large as face modesl
1410 for (j = 0; j < P; ++j)
1411 {
1412 // set up default maparray
1413 for (k = 0; k < Q; k++)
1414 {
1415 maparray[arrayindx[j + k * P]] = j + k * nummodesA;
1416 }
1417
1418 for (k = nummodesB; k < Q; ++k)
1419 {
1420 signarray[arrayindx[j + k * P]] = 0.0;
1421 maparray[arrayindx[j + k * P]] = maparray[0];
1422 }
1423 }
1424
1425 for (j = nummodesA; j < P; ++j)
1426 {
1427 for (k = 0; k < Q; ++k)
1428 {
1429 signarray[arrayindx[j + k * P]] = 0.0;
1430 maparray[arrayindx[j + k * P]] = maparray[0];
1431 }
1432 }
1433
1434 // The code below is exactly the same as that taken from
1435 // StdHexExp and reverses the 'b' and 'a' directions as
1436 // appropriate (1st and 2nd if statements respectively) in
1437 // quadrilateral faces.
1438 if (faceOrient == eDir1FwdDir1_Dir2BwdDir2 ||
1439 faceOrient == eDir1BwdDir1_Dir2BwdDir2 ||
1440 faceOrient == eDir1BwdDir2_Dir2FwdDir1 ||
1441 faceOrient == eDir1BwdDir2_Dir2BwdDir1)
1442 {
1443 if (faceOrient < eDir1FwdDir2_Dir2FwdDir1)
1444 {
1445 for (i = 3; i < Q; i += 2)
1446 {
1447 for (j = 0; j < P; j++)
1448 {
1449 signarray[arrayindx[i * P + j]] *= -1;
1450 }
1451 }
1452
1453 for (i = 0; i < P; i++)
1454 {
1455 swap(maparray[i], maparray[i + P]);
1456 swap(signarray[i], signarray[i + P]);
1457 }
1458 }
1459 else
1460 {
1461 for (i = 0; i < Q; i++)
1462 {
1463 for (j = 3; j < P; j += 2)
1464 {
1465 signarray[arrayindx[i * P + j]] *= -1;
1466 }
1467 }
1468
1469 for (i = 0; i < Q; i++)
1470 {
1471 swap(maparray[i], maparray[i + Q]);
1472 swap(signarray[i], signarray[i + Q]);
1473 }
1474 }
1475 }
1476
1477 if (faceOrient == eDir1BwdDir1_Dir2FwdDir2 ||
1478 faceOrient == eDir1BwdDir1_Dir2BwdDir2 ||
1479 faceOrient == eDir1FwdDir2_Dir2BwdDir1 ||
1480 faceOrient == eDir1BwdDir2_Dir2BwdDir1)
1481 {
1482 if (faceOrient < eDir1FwdDir2_Dir2FwdDir1)
1483 {
1484 for (i = 0; i < Q; i++)
1485 {
1486 for (j = 3; j < P; j += 2)
1487 {
1488 signarray[arrayindx[i * P + j]] *= -1;
1489 }
1490 }
1491
1492 for (i = 0; i < Q; i++)
1493 {
1494 swap(maparray[i * P], maparray[i * P + 1]);
1495 swap(signarray[i * P], signarray[i * P + 1]);
1496 }
1497 }
1498 else
1499 {
1500 for (i = 3; i < Q; i += 2)
1501 {
1502 for (j = 0; j < P; j++)
1503 {
1504 signarray[arrayindx[i * P + j]] *= -1;
1505 }
1506 }
1507
1508 for (i = 0; i < P; i++)
1509 {
1510 swap(maparray[i * Q], maparray[i * Q + 1]);
1511 swap(signarray[i * Q], signarray[i * Q + 1]);
1512 }
1513 }
1514 }
1515 }
1516}
1517
1519 const int eid, Array<OneD, unsigned int> &maparray,
1520 Array<OneD, int> &signarray, const Orientation edgeOrient)
1521{
1522 int i;
1523 bool signChange;
1524 const int P = m_base[0]->GetNumModes() - 1;
1525 const int Q = m_base[1]->GetNumModes() - 1;
1526 const int R = m_base[2]->GetNumModes() - 1;
1527 const int nEdgeIntCoeffs = v_GetEdgeNcoeffs(eid) - 2;
1528
1529 if (maparray.size() != nEdgeIntCoeffs)
1530 {
1531 maparray = Array<OneD, unsigned int>(nEdgeIntCoeffs);
1532 }
1533
1534 if (signarray.size() != nEdgeIntCoeffs)
1535 {
1536 signarray = Array<OneD, int>(nEdgeIntCoeffs, 1);
1537 }
1538 else
1539 {
1540 fill(signarray.get(), signarray.get() + nEdgeIntCoeffs, 1);
1541 }
1542
1543 // If edge is oriented backwards, change sign of modes which have
1544 // degree 2n+1, n >= 1.
1545 signChange = edgeOrient == eBackwards;
1546
1547 switch (eid)
1548 {
1549 case 0:
1550 for (i = 2; i <= P; ++i)
1551 {
1552 maparray[i - 2] = GetMode(i, 0, 0);
1553 }
1554 break;
1555
1556 case 1:
1557 for (i = 2; i <= Q; ++i)
1558 {
1559 maparray[i - 2] = GetMode(1, i, 0);
1560 }
1561 break;
1562
1563 case 2:
1564 // Base quad; reverse direction.
1565 // signChange = !signChange;
1566 for (i = 2; i <= P; ++i)
1567 {
1568 maparray[i - 2] = GetMode(i, 1, 0);
1569 }
1570 break;
1571
1572 case 3:
1573 // Base quad; reverse direction.
1574 // signChange = !signChange;
1575 for (i = 2; i <= Q; ++i)
1576 {
1577 maparray[i - 2] = GetMode(0, i, 0);
1578 }
1579 break;
1580
1581 case 4:
1582 for (i = 2; i <= R; ++i)
1583 {
1584 maparray[i - 2] = GetMode(0, 0, i);
1585 }
1586 break;
1587
1588 case 5:
1589 for (i = 1; i <= R - 1; ++i)
1590 {
1591 maparray[i - 1] = GetMode(1, 0, i);
1592 }
1593 break;
1594
1595 case 6:
1596 for (i = 1; i <= R - 1; ++i)
1597 {
1598 maparray[i - 1] = GetMode(1, 1, i);
1599 }
1600 break;
1601
1602 case 7:
1603 for (i = 2; i <= R; ++i)
1604 {
1605 maparray[i - 2] = GetMode(0, 1, i);
1606 }
1607 break;
1608
1609 case 8:
1610 for (i = 2; i <= Q; ++i)
1611 {
1612 maparray[i - 2] = GetMode(0, i, 1);
1613 }
1614 break;
1615
1616 default:
1617 ASSERTL0(false, "Edge not defined.");
1618 break;
1619 }
1620
1621 if (signChange)
1622 {
1623 for (i = 1; i < nEdgeIntCoeffs; i += 2)
1624 {
1625 signarray[i] = -1;
1626 }
1627 }
1628}
1629
1631 const int fid, Array<OneD, unsigned int> &maparray,
1632 Array<OneD, int> &signarray, const Orientation faceOrient)
1633{
1634 const int P = m_base[0]->GetNumModes() - 1;
1635 const int Q = m_base[1]->GetNumModes() - 1;
1636 const int R = m_base[2]->GetNumModes() - 1;
1637 const int nFaceIntCoeffs = v_GetTraceIntNcoeffs(fid);
1638 int p, q, r, idx = 0;
1639 int nummodesA = 0;
1640 int nummodesB = 0;
1641 int i = 0;
1642 int j = 0;
1643
1644 if (maparray.size() != nFaceIntCoeffs)
1645 {
1646 maparray = Array<OneD, unsigned int>(nFaceIntCoeffs);
1647 }
1648
1649 if (signarray.size() != nFaceIntCoeffs)
1650 {
1651 signarray = Array<OneD, int>(nFaceIntCoeffs, 1);
1652 }
1653 else
1654 {
1655 fill(signarray.get(), signarray.get() + nFaceIntCoeffs, 1);
1656 }
1657
1658 // Set up an array indexing for quad faces, since the ordering may
1659 // need to be transposed depending on orientation.
1660 Array<OneD, int> arrayindx(nFaceIntCoeffs);
1661 if (fid != 1 && fid != 3)
1662 {
1663 if (fid == 0) // Base quad
1664 {
1665 nummodesA = P - 1;
1666 nummodesB = Q - 1;
1667 }
1668 else // front and back quad
1669 {
1670 nummodesA = Q - 1;
1671 nummodesB = R - 1;
1672 }
1673
1674 for (i = 0; i < nummodesB; i++)
1675 {
1676 for (j = 0; j < nummodesA; j++)
1677 {
1678 if (faceOrient < eDir1FwdDir2_Dir2FwdDir1)
1679 {
1680 arrayindx[i * nummodesA + j] = i * nummodesA + j;
1681 }
1682 else
1683 {
1684 arrayindx[i * nummodesA + j] = j * nummodesB + i;
1685 }
1686 }
1687 }
1688 }
1689
1690 switch (fid)
1691 {
1692 case 0: // Bottom quad
1693 for (q = 2; q <= Q; ++q)
1694 {
1695 for (p = 2; p <= P; ++p)
1696 {
1697 maparray[arrayindx[(q - 2) * nummodesA + (p - 2)]] =
1698 GetMode(p, q, 0);
1699 }
1700 }
1701 break;
1702
1703 case 1: // Left triangle
1704 for (p = 2; p <= P; ++p)
1705 {
1706 for (r = 1; r <= R - p; ++r)
1707 {
1708 if (faceOrient == eDir1BwdDir1_Dir2FwdDir2)
1709 {
1710 signarray[idx] = p % 2 ? -1 : 1;
1711 }
1712 maparray[idx++] = GetMode(p, 0, r);
1713 }
1714 }
1715 break;
1716
1717 case 2: // Slanted quad
1718 for (r = 1; r <= R - 1; ++r)
1719 {
1720 for (q = 2; q <= Q; ++q)
1721 {
1722 maparray[arrayindx[(r - 1) * nummodesA + (q - 2)]] =
1723 GetMode(1, q, r);
1724 }
1725 }
1726 break;
1727
1728 case 3: // Right triangle
1729 for (p = 2; p <= P; ++p)
1730 {
1731 for (r = 1; r <= R - p; ++r)
1732 {
1733 if (faceOrient == eDir1BwdDir1_Dir2FwdDir2)
1734 {
1735 signarray[idx] = p % 2 ? -1 : 1;
1736 }
1737 maparray[idx++] = GetMode(p, 1, r);
1738 }
1739 }
1740 break;
1741
1742 case 4: // Back quad
1743 for (r = 2; r <= R; ++r)
1744 {
1745 for (q = 2; q <= Q; ++q)
1746 {
1747 maparray[arrayindx[(r - 2) * nummodesA + (q - 2)]] =
1748 GetMode(0, q, r);
1749 }
1750 }
1751 break;
1752
1753 default:
1754 ASSERTL0(false, "Face interior map not available.");
1755 }
1756
1757 // Triangular faces are processed in the above switch loop; for
1758 // remaining quad faces, set up orientation if necessary.
1759 if (fid == 1 || fid == 3)
1760 {
1761 return;
1762 }
1763
1764 if (faceOrient == eDir1FwdDir1_Dir2BwdDir2 ||
1765 faceOrient == eDir1BwdDir1_Dir2BwdDir2 ||
1766 faceOrient == eDir1BwdDir2_Dir2FwdDir1 ||
1767 faceOrient == eDir1BwdDir2_Dir2BwdDir1)
1768 {
1769 if (faceOrient < eDir1FwdDir2_Dir2FwdDir1)
1770 {
1771 for (i = 1; i < nummodesB; i += 2)
1772 {
1773 for (j = 0; j < nummodesA; j++)
1774 {
1775 signarray[arrayindx[i * nummodesA + j]] *= -1;
1776 }
1777 }
1778 }
1779 else
1780 {
1781 for (i = 0; i < nummodesB; i++)
1782 {
1783 for (j = 1; j < nummodesA; j += 2)
1784 {
1785 signarray[arrayindx[i * nummodesA + j]] *= -1;
1786 }
1787 }
1788 }
1789 }
1790
1791 if (faceOrient == eDir1BwdDir1_Dir2FwdDir2 ||
1792 faceOrient == eDir1BwdDir1_Dir2BwdDir2 ||
1793 faceOrient == eDir1FwdDir2_Dir2BwdDir1 ||
1794 faceOrient == eDir1BwdDir2_Dir2BwdDir1)
1795 {
1796 if (faceOrient < eDir1FwdDir2_Dir2FwdDir1)
1797 {
1798 for (i = 0; i < nummodesB; i++)
1799 {
1800 for (j = 1; j < nummodesA; j += 2)
1801 {
1802 signarray[arrayindx[i * nummodesA + j]] *= -1;
1803 }
1804 }
1805 }
1806 else
1807 {
1808 for (i = 1; i < nummodesB; i += 2)
1809 {
1810 for (j = 0; j < nummodesA; j++)
1811 {
1812 signarray[arrayindx[i * nummodesA + j]] *= -1;
1813 }
1814 }
1815 }
1816 }
1817}
1818
1819//---------------------------------------
1820// Wrapper functions
1821//---------------------------------------
1822
1824{
1825
1826 MatrixType mtype = mkey.GetMatrixType();
1827
1828 DNekMatSharedPtr Mat;
1829
1830 switch (mtype)
1831 {
1833 {
1834 int nq0 = m_base[0]->GetNumPoints();
1835 int nq1 = m_base[1]->GetNumPoints();
1836 int nq2 = m_base[2]->GetNumPoints();
1837 int nq;
1838
1839 // take definition from key
1841 {
1842 nq = (int)mkey.GetConstFactor(eFactorConst);
1843 }
1844 else
1845 {
1846 nq = max(nq0, max(nq1, nq2));
1847 }
1848
1849 int neq =
1852 Array<OneD, NekDouble> coll(3);
1854 Array<OneD, NekDouble> tmp(nq0);
1855
1856 Mat =
1857 MemoryManager<DNekMat>::AllocateSharedPtr(neq, nq0 * nq1 * nq2);
1858 int cnt = 0;
1859 for (int i = 0; i < nq; ++i)
1860 {
1861 for (int j = 0; j < nq; ++j)
1862 {
1863 for (int k = 0; k < nq - i; ++k, ++cnt)
1864 {
1865 coords[cnt] = Array<OneD, NekDouble>(3);
1866 coords[cnt][0] = -1.0 + 2 * k / (NekDouble)(nq - 1);
1867 coords[cnt][1] = -1.0 + 2 * j / (NekDouble)(nq - 1);
1868 coords[cnt][2] = -1.0 + 2 * i / (NekDouble)(nq - 1);
1869 }
1870 }
1871 }
1872
1873 for (int i = 0; i < neq; ++i)
1874 {
1875 LocCoordToLocCollapsed(coords[i], coll);
1876
1877 I[0] = m_base[0]->GetI(coll);
1878 I[1] = m_base[1]->GetI(coll + 1);
1879 I[2] = m_base[2]->GetI(coll + 2);
1880
1881 // interpolate first coordinate direction
1882 NekDouble fac;
1883 for (int k = 0; k < nq2; ++k)
1884 {
1885 for (int j = 0; j < nq1; ++j)
1886 {
1887
1888 fac = (I[1]->GetPtr())[j] * (I[2]->GetPtr())[k];
1889 Vmath::Smul(nq0, fac, I[0]->GetPtr(), 1, tmp, 1);
1890
1891 Vmath::Vcopy(nq0, &tmp[0], 1,
1892 Mat->GetRawPtr() + k * nq0 * nq1 * neq +
1893 j * nq0 * neq + i,
1894 neq);
1895 }
1896 }
1897 }
1898 }
1899 break;
1900 default:
1901 {
1903 }
1904 break;
1905 }
1906
1907 return Mat;
1908}
1909
1911{
1912 return v_GenMatrix(mkey);
1913}
1914
1915/**
1916 * @brief Compute the local mode number in the expansion for a
1917 * particular tensorial combination.
1918 *
1919 * Modes are numbered with the r index travelling fastest, followed by
1920 * q and then p, and each q-r plane is of size (R+1-p). For example,
1921 * with P=1, Q=2, R=3, the indexing inside each q-r plane (with r
1922 * increasing upwards and q to the right) is:
1923 *
1924 * p = 0: p = 1:
1925 * -----------------------
1926 * 3 7 11
1927 * 2 6 10 14 17 20
1928 * 1 5 9 13 16 19
1929 * 0 4 8 12 15 18
1930 *
1931 * Note that in this element, we must have that \f$ P <= R \f$.
1932 */
1933int StdPrismExp::GetMode(int p, int q, int r)
1934{
1935 int Q = m_base[1]->GetNumModes() - 1;
1936 int R = m_base[2]->GetNumModes() - 1;
1937
1938 return r + // Skip along stacks (r-direction)
1939 q * (R + 1 - p) + // Skip along columns (q-direction)
1940 (Q + 1) * (p * R + 1 -
1941 (p - 2) * (p - 1) / 2); // Skip along rows (p-direction)
1942}
1943
1945 const Array<OneD, const NekDouble> &inarray,
1946 Array<OneD, NekDouble> &outarray)
1947{
1948 int i, j;
1949 int nquad0 = m_base[0]->GetNumPoints();
1950 int nquad1 = m_base[1]->GetNumPoints();
1951 int nquad2 = m_base[2]->GetNumPoints();
1952
1953 const Array<OneD, const NekDouble> &w0 = m_base[0]->GetW();
1954 const Array<OneD, const NekDouble> &w1 = m_base[1]->GetW();
1955 const Array<OneD, const NekDouble> &w2 = m_base[2]->GetW();
1956
1957 const Array<OneD, const NekDouble> &z2 = m_base[2]->GetZ();
1958
1959 // Multiply by integration constants in x-direction
1960 for (i = 0; i < nquad1 * nquad2; ++i)
1961 {
1962 Vmath::Vmul(nquad0, inarray.get() + i * nquad0, 1, w0.get(), 1,
1963 outarray.get() + i * nquad0, 1);
1964 }
1965
1966 // Multiply by integration constants in y-direction
1967 for (j = 0; j < nquad2; ++j)
1968 {
1969 for (i = 0; i < nquad1; ++i)
1970 {
1971 Blas::Dscal(nquad0, w1[i],
1972 &outarray[0] + i * nquad0 + j * nquad0 * nquad1, 1);
1973 }
1974 }
1975
1976 // Multiply by integration constants in z-direction; need to
1977 // incorporate factor (1-eta_3)/2 into weights, but only if using
1978 // GLL quadrature points.
1979 switch (m_base[2]->GetPointsType())
1980 {
1981 // (1,0) Jacobi inner product.
1982 case LibUtilities::eGaussRadauMAlpha1Beta0:
1983 for (i = 0; i < nquad2; ++i)
1984 {
1985 Blas::Dscal(nquad0 * nquad1, 0.5 * w2[i],
1986 &outarray[0] + i * nquad0 * nquad1, 1);
1987 }
1988 break;
1989
1990 default:
1991 for (i = 0; i < nquad2; ++i)
1992 {
1993 Blas::Dscal(nquad0 * nquad1, 0.5 * (1 - z2[i]) * w2[i],
1994 &outarray[0] + i * nquad0 * nquad1, 1);
1995 }
1996 break;
1997 }
1998}
1999
2001 const StdMatrixKey &mkey)
2002{
2003 // Generate an orthonogal expansion
2004 int qa = m_base[0]->GetNumPoints();
2005 int qb = m_base[1]->GetNumPoints();
2006 int qc = m_base[2]->GetNumPoints();
2007 int nmodes_a = m_base[0]->GetNumModes();
2008 int nmodes_b = m_base[1]->GetNumModes();
2009 int nmodes_c = m_base[2]->GetNumModes();
2010 // Declare orthogonal basis.
2014
2018 StdPrismExp OrthoExp(Ba, Bb, Bc);
2019
2020 Array<OneD, NekDouble> orthocoeffs(OrthoExp.GetNcoeffs());
2021 int i, j, k, cnt = 0;
2022
2023 // project onto modal space.
2024 OrthoExp.FwdTrans(array, orthocoeffs);
2025
2027 {
2028 // Rodrigo's power kernel
2030 NekDouble SvvDiffCoeff =
2033
2034 for (int i = 0; i < nmodes_a; ++i)
2035 {
2036 for (int j = 0; j < nmodes_b; ++j)
2037 {
2038 NekDouble fac1 = std::max(
2039 pow((1.0 * i) / (nmodes_a - 1), cutoff * nmodes_a),
2040 pow((1.0 * j) / (nmodes_b - 1), cutoff * nmodes_b));
2041
2042 for (int k = 0; k < nmodes_c - i; ++k)
2043 {
2044 NekDouble fac =
2045 std::max(fac1, pow((1.0 * k) / (nmodes_c - 1),
2046 cutoff * nmodes_c));
2047
2048 orthocoeffs[cnt] *= SvvDiffCoeff * fac;
2049 cnt++;
2050 }
2051 }
2052 }
2053 }
2054 else if (mkey.ConstFactorExists(
2055 eFactorSVVDGKerDiffCoeff)) // Rodrigo/Mansoor's DG Kernel
2056 {
2059
2060 int max_abc = max(nmodes_a - kSVVDGFiltermodesmin,
2061 nmodes_b - kSVVDGFiltermodesmin);
2062 max_abc = max(max_abc, nmodes_c - kSVVDGFiltermodesmin);
2063 // clamp max_abc
2064 max_abc = max(max_abc, 0);
2065 max_abc = min(max_abc, kSVVDGFiltermodesmax - kSVVDGFiltermodesmin);
2066
2067 for (int i = 0; i < nmodes_a; ++i)
2068 {
2069 for (int j = 0; j < nmodes_b; ++j)
2070 {
2071 int maxij = max(i, j);
2072
2073 for (int k = 0; k < nmodes_c - i; ++k)
2074 {
2075 int maxijk = max(maxij, k);
2076 maxijk = min(maxijk, kSVVDGFiltermodesmax - 1);
2077
2078 orthocoeffs[cnt] *=
2079 SvvDiffCoeff * kSVVDGFilter[max_abc][maxijk];
2080 cnt++;
2081 }
2082 }
2083 }
2084 }
2085 else
2086 {
2087 // SVV filter paramaters (how much added diffusion relative
2088 // to physical one and fraction of modes from which you
2089 // start applying this added diffusion)
2090 //
2091 NekDouble SvvDiffCoeff =
2093 NekDouble SVVCutOff =
2095
2096 // Defining the cut of mode
2097 int cutoff_a = (int)(SVVCutOff * nmodes_a);
2098 int cutoff_b = (int)(SVVCutOff * nmodes_b);
2099 int cutoff_c = (int)(SVVCutOff * nmodes_c);
2100 // To avoid the fac[j] from blowing up
2101 NekDouble epsilon = 1;
2102
2103 int nmodes = min(min(nmodes_a, nmodes_b), nmodes_c);
2104 NekDouble cutoff = min(min(cutoff_a, cutoff_b), cutoff_c);
2105
2106 //------"New" Version August 22nd '13--------------------
2107 for (i = 0; i < nmodes_a; ++i) // P
2108 {
2109 for (j = 0; j < nmodes_b; ++j) // Q
2110 {
2111 for (k = 0; k < nmodes_c - i; ++k) // R
2112 {
2113 if (j >= cutoff || i + k >= cutoff)
2114 {
2115 orthocoeffs[cnt] *=
2116 (SvvDiffCoeff *
2117 exp(-(i + k - nmodes) * (i + k - nmodes) /
2118 ((NekDouble)((i + k - cutoff + epsilon) *
2119 (i + k - cutoff + epsilon)))) *
2120 exp(-(j - nmodes) * (j - nmodes) /
2121 ((NekDouble)((j - cutoff + epsilon) *
2122 (j - cutoff + epsilon)))));
2123 }
2124 else
2125 {
2126 orthocoeffs[cnt] *= 0.0;
2127 }
2128 cnt++;
2129 }
2130 }
2131 }
2132 }
2133
2134 // backward transform to physical space
2135 OrthoExp.BwdTrans(orthocoeffs, array);
2136}
2137
2139 int numMin, const Array<OneD, const NekDouble> &inarray,
2140 Array<OneD, NekDouble> &outarray)
2141{
2142 int nquad0 = m_base[0]->GetNumPoints();
2143 int nquad1 = m_base[1]->GetNumPoints();
2144 int nquad2 = m_base[2]->GetNumPoints();
2145 int nqtot = nquad0 * nquad1 * nquad2;
2146 int nmodes0 = m_base[0]->GetNumModes();
2147 int nmodes1 = m_base[1]->GetNumModes();
2148 int nmodes2 = m_base[2]->GetNumModes();
2149 int numMax = nmodes0;
2150
2152 Array<OneD, NekDouble> coeff_tmp1(m_ncoeffs, 0.0);
2153 Array<OneD, NekDouble> phys_tmp(nqtot, 0.0);
2154 Array<OneD, NekDouble> tmp, tmp2, tmp3, tmp4;
2155
2156 const LibUtilities::PointsKey Pkey0 = m_base[0]->GetPointsKey();
2157 const LibUtilities::PointsKey Pkey1 = m_base[1]->GetPointsKey();
2158 const LibUtilities::PointsKey Pkey2 = m_base[2]->GetPointsKey();
2159
2160 LibUtilities::BasisKey bortho0(LibUtilities::eOrtho_A, nmodes0, Pkey0);
2161 LibUtilities::BasisKey bortho1(LibUtilities::eOrtho_A, nmodes1, Pkey1);
2162 LibUtilities::BasisKey bortho2(LibUtilities::eOrtho_B, nmodes2, Pkey2);
2163
2164 int cnt = 0;
2165 int u = 0;
2166 int i = 0;
2168
2170 bortho0, bortho1, bortho2);
2171
2172 BwdTrans(inarray, phys_tmp);
2173 OrthoPrismExp->FwdTrans(phys_tmp, coeff);
2174
2175 // filtering
2176 for (u = 0; u < numMin; ++u)
2177 {
2178 for (i = 0; i < numMin; ++i)
2179 {
2180 Vmath::Vcopy(numMin - u, tmp = coeff + cnt, 1,
2181 tmp2 = coeff_tmp1 + cnt, 1);
2182 cnt += numMax - u;
2183 }
2184
2185 for (i = numMin; i < numMax; ++i)
2186 {
2187 cnt += numMax - u;
2188 }
2189 }
2190
2191 OrthoPrismExp->BwdTrans(coeff_tmp1, phys_tmp);
2192 StdPrismExp::FwdTrans(phys_tmp, outarray);
2193}
2194} // namespace Nektar::StdRegions
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed to...
Definition: ErrorUtil.hpp:265
Describes the specification for a Basis.
Definition: Basis.h:45
int GetNumModes() const
Returns the order of the basis.
Definition: Basis.h:74
Defines a specification for a set of points.
Definition: Points.h:50
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
void BwdTrans_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)
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)
NekDouble BaryTensorDeriv(const Array< OneD, NekDouble > &coord, const Array< OneD, const NekDouble > &inarray, std::array< NekDouble, 3 > &firstOrderDerivs)
void PhysTensorDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray_d1, Array< OneD, NekDouble > &outarray_d2, Array< OneD, NekDouble > &outarray_d3)
Calculate the 3D derivative in the local tensor/collapsed coordinate at the physical points.
The base class for all shapes.
Definition: StdExpansion.h:65
int GetNcoeffs(void) const
This function returns the total number of coefficients used in the expansion.
Definition: StdExpansion.h:124
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
Definition: StdExpansion.h:134
LibUtilities::BasisType GetBasisType(const int dir) const
This function returns the type of basis used in the dir direction.
Definition: StdExpansion.h:156
DNekMatSharedPtr GetStdMatrix(const StdMatrixKey &mkey)
Definition: StdExpansion.h:603
void LocCoordToLocCollapsed(const Array< OneD, const NekDouble > &xi, Array< OneD, NekDouble > &eta)
Convert local cartesian coordinate xi into local collapsed coordinates eta.
const Array< OneD, const LibUtilities::BasisSharedPtr > & GetBase() const
This function gets the shared point to basis.
Definition: StdExpansion.h:100
DNekMatSharedPtr CreateGeneralMatrix(const StdMatrixKey &mkey)
this function generates the mass matrix
NekDouble PhysEvaluate(const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &physvals)
This function evaluates the expansion at a single (arbitrary) point of the domain.
Definition: StdExpansion.h:919
LibUtilities::ShapeType DetShapeType() const
This function returns the shape of the expansion domain.
Definition: StdExpansion.h:367
void BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
This function performs the Backward transformation from coefficient space to physical space.
Definition: StdExpansion.h:424
int GetTraceNcoeffs(const int i) const
This function returns the number of expansion coefficients belonging to the i-th trace.
Definition: StdExpansion.h:261
LibUtilities::PointsType GetPointsType(const int dir) const
This function returns the type of quadrature points used in the dir direction.
Definition: StdExpansion.h:205
void FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
This function performs the Forward transformation from physical space to coefficient space.
int GetNumPoints(const int dir) const
This function returns the number of quadrature points in the dir direction.
Definition: StdExpansion.h:218
void MultiplyByQuadratureMetric(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdExpansion.h:723
int GetBasisNumModes(const int dir) const
This function returns the number of expansion modes in the dir direction.
Definition: StdExpansion.h:169
void PhysDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_d0, Array< OneD, NekDouble > &out_d1=NullNekDouble1DArray, Array< OneD, NekDouble > &out_d2=NullNekDouble1DArray)
Definition: StdExpansion.h:849
Array< OneD, LibUtilities::BasisSharedPtr > m_base
MatrixType GetMatrixType() const
Definition: StdMatrixKey.h:83
NekDouble GetConstFactor(const ConstFactorType &factor) const
Definition: StdMatrixKey.h:124
bool ConstFactorExists(const ConstFactorType &factor) const
Definition: StdMatrixKey.h:133
Class representing a prismatic element in reference space.
Definition: StdPrismExp.h:45
void v_SVVLaplacianFilter(Array< OneD, NekDouble > &array, const StdMatrixKey &mkey) override
void v_GetElmtTraceToTraceMap(const unsigned int fid, Array< OneD, unsigned int > &maparray, Array< OneD, int > &signarray, Orientation faceOrient, int P, int Q) override
void v_ReduceOrderCoeffs(int numMin, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
void v_GetEdgeInteriorToElementMap(const int tid, Array< OneD, unsigned int > &maparray, Array< OneD, int > &signarray, const Orientation traceOrient=eDir1FwdDir1_Dir2FwdDir2) override
LibUtilities::PointsKey v_GetTracePointsKey(const int i, const int j) const override
int v_GetVertexMap(int localVertexId, bool useCoeffPacking=false) override
int v_CalcNumberOfCoefficients(const std::vector< unsigned int > &nummodes, int &modes_offset) override
int v_GetTraceIntNcoeffs(const int i) const override
StdPrismExp(const LibUtilities::BasisKey &Ba, const LibUtilities::BasisKey &Bb, const LibUtilities::BasisKey &Bc)
Definition: StdPrismExp.cpp:43
int v_NumBndryCoeffs() const override
void v_FillMode(const int mode, Array< OneD, NekDouble > &outarray) override
NekDouble v_PhysEvaluateBasis(const Array< OneD, const NekDouble > &coords, int mode) final
void v_BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
const LibUtilities::BasisKey v_GetTraceBasisKey(const int i, const int k) const override
void v_IProductWRTBase_SumFac(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool multiplybyweights=true) override
LibUtilities::ShapeType v_DetShapeType() const override
Return Shape of region, using ShapeType enum list; i.e. prism.
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...
int v_GetNverts() const override
int v_NumDGBndryCoeffs() const override
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: StdPrismExp.cpp:75
void v_GetTraceNumModes(const int fid, int &numModes0, int &numModes1, Orientation faceOrient=eDir1FwdDir1_Dir2FwdDir2) override
void v_GetCoords(Array< OneD, NekDouble > &xi_x, Array< OneD, NekDouble > &xi_y, Array< OneD, NekDouble > &xi_z) override
void v_GetBoundaryMap(Array< OneD, unsigned int > &outarray) override
DNekMatSharedPtr v_CreateStdMatrix(const StdMatrixKey &mkey) override
void v_IProductWRTDerivBase_SumFac(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
int v_GetNtraces() const override
void v_StdPhysDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_d0, Array< OneD, NekDouble > &out_d1, Array< OneD, NekDouble > &out_d2) override
int GetMode(int I, int J, int K)
Compute the local mode number in the expansion for a particular tensorial combination.
int v_GetTraceNcoeffs(const int i) const override
void v_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) override
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...
NekDouble v_PhysEvaluate(const Array< OneD, NekDouble > &coord, const Array< OneD, const NekDouble > &inarray, std::array< NekDouble, 3 > &firstOrderDerivs) override
void v_BwdTrans_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) override
int v_GetEdgeNcoeffs(const int i) const override
void v_LocCollapsedToLocCoord(const Array< OneD, const NekDouble > &eta, Array< OneD, NekDouble > &xi) override
void v_GetInteriorMap(Array< OneD, unsigned int > &outarray) override
void v_BwdTrans_SumFac(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
void v_GetTraceCoeffMap(const unsigned int fid, Array< OneD, unsigned int > &maparray) override
void v_GetTraceInteriorToElementMap(const int tid, Array< OneD, unsigned int > &maparray, Array< OneD, int > &signarray, const Orientation traceOrient=eDir1FwdDir1_Dir2FwdDir2) override
void v_MultiplyByStdQuadratureMetric(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
DNekMatSharedPtr v_GenMatrix(const StdMatrixKey &mkey) override
int v_GetTraceNumPoints(const int i) const override
bool v_IsBoundaryInteriorExpansion() const override
int v_GetNedges() const override
void v_IProductWRTDerivBase(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Inner product of inarray over region with respect to the object's default expansion basis; output in ...
void v_LocCoordToLocCollapsed(const Array< OneD, const NekDouble > &xi, Array< OneD, NekDouble > &eta) override
static void Dscal(const int &n, const double &alpha, double *x, const int &incx)
BLAS level 1: x = alpha x.
Definition: Blas.hpp:149
static double Ddot(const int &n, const double *x, const int &incx, const double *y, const int &incy)
BLAS level 1: output = .
Definition: Blas.hpp:163
static void Dgemm(const char &transa, const char &transb, const int &m, const int &n, const int &k, const double &alpha, const double *a, const int &lda, const double *b, const int &ldb, const double &beta, double *c, const int &ldc)
BLAS level 3: Matrix-matrix multiply C = A x B where op(A)[m x k], op(B)[k x n], C[m x n] DGEMM perfo...
Definition: Blas.hpp:383
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:135
int getNumberOfCoefficients(int Na, int Nb, int Nc)
Definition: ShapeType.hpp:279
int getNumberOfBndCoefficients(int Na, int Nb, int Nc)
Definition: ShapeType.hpp:290
static const BasisKey NullBasisKey(eNoBasisType, 0, NullPointsKey)
Defines a null basis with no type or points.
@ eModified_B
Principle Modified Functions .
Definition: BasisType.h:49
@ P
Monomial polynomials .
Definition: BasisType.h:62
@ eOrtho_A
Principle Orthogonal Functions .
Definition: BasisType.h:42
@ eModified_C
Principle Modified Functions .
Definition: BasisType.h:50
@ eGLL_Lagrange
Lagrange for SEM basis .
Definition: BasisType.h:56
@ eOrtho_C
Principle Orthogonal Functions .
Definition: BasisType.h:46
@ eOrtho_B
Principle Orthogonal Functions .
Definition: BasisType.h:44
@ eModified_A
Principle Modified Functions .
Definition: BasisType.h:48
static const NekDouble kNekZeroTol
std::shared_ptr< StdPrismExp > StdPrismExpSharedPtr
Definition: StdPrismExp.h:218
LibUtilities::BasisKey EvaluateTriFaceBasisKey(const int facedir, const LibUtilities::BasisType faceDirBasisType, const int numpoints, const int nummodes)
const int kSVVDGFiltermodesmin
Definition: StdRegions.hpp:472
const int kSVVDGFiltermodesmax
Definition: StdRegions.hpp:473
LibUtilities::BasisKey EvaluateQuadFaceBasisKey(const int facedir, const LibUtilities::BasisType faceDirBasisType, const int numpoints, const int nummodes)
const NekDouble kSVVDGFilter[9][11]
Definition: StdRegions.hpp:475
std::vector< double > q(NPUPPER *NPUPPER)
static Array< OneD, NekDouble > NullNekDouble1DArray
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:75
double NekDouble
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.hpp:72
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.hpp:396
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.hpp:180
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.hpp:100
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294