Nektar++
Loading...
Searching...
No Matches
StdSegExp.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: StdSegExp.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: Routines within Standard Segment Expansions
32//
33///////////////////////////////////////////////////////////////////////////////
34
36#include <LibUtilities/Foundations/ManagerAccess.h> // for PointsManager, etc
38
39using namespace std;
43
44namespace Nektar::StdRegions
45{
46// Declaration of scalar routine
50
51/** \brief Constructor using BasisKey class for quadrature points and
52 * order definition
53 *
54 * \param Ba BasisKey class definition containing order and quadrature
55 * points.
56 */
58 : StdExpansion(Ba.GetNumModes(), 1, Ba),
59 StdExpansion1D(Ba.GetNumModes(), Ba)
60{
61 // cache integration weights for future use
62 m_weights.push_back(m_base[0]->GetW());
63}
64
65/** \brief Return Shape of region, using ShapeType enum list.
66 * i.e. Segment
67 */
72
74{
75
76 bool returnval = false;
77
79 {
80 returnval = true;
81 }
82
84 {
85 returnval = true;
86 }
87
88 return returnval;
89}
90
91//---------------------------------------------------------------------
92// Differentiation Methods
93//---------------------------------------------------------------------
94/** \brief Evaluate the derivative \f$ d/d{\xi_1} \f$ at the physical
95 * quadrature points given by \a inarray and return in \a outarray.
96 *
97 * This is a wrapper around StdExpansion1D::Tensor_Deriv
98 * \param inarray array of a function evaluated at the quadrature points
99 * \param outarray the resulting array of the derivative \f$
100 * du/d_{\xi_1}|_{\xi_{1i}} \f$ will be stored in the array \a outarra
101 */
102
105 [[maybe_unused]] Array<OneD, NekDouble> &out_d1,
106 [[maybe_unused]] Array<OneD, NekDouble> &out_d2)
107{
108 PhysTensorDeriv(inarray, out_d0);
109}
110
111//---------------------------------------------------------------------
112// Transforms
113//---------------------------------------------------------------------
114
115/** \brief Backward transform from coefficient space given
116 * in \a inarray and evaluate at the physical quadrature
117 * points \a outarray
118 *
119 * Operation can be evaluated as \f$ u(\xi_{1i}) =
120 * \sum_{p=0}^{order-1} \hat{u}_p \phi_p(\xi_{1i}) \f$ or equivalently
121 * \f$ {\bf u} = {\bf B}^T {\bf \hat{u}} \f$ where
122 * \f${\bf B}[i][j] = \phi_i(\xi_{1j}), \mbox{\_coeffs}[p] = {\bf
123 * \hat{u}}[p] \f$
124 *
125 * The function takes the coefficient array \a inarray as
126 * input for the transformation
127 *
128 * \param inarray: the coeffficients of the expansion
129 *
130 * \param outarray: the resulting array of the values of the function at
131 * the physical quadrature points will be stored in the array \a outarray
132 */
133
135 Array<OneD, NekDouble> &outarray)
136{
137 int nquad0 = m_base[0]->GetNumPoints();
138
139 if (m_base[0]->Collocation())
140 {
141 std::memcpy(outarray.data(), inarray.data(),
142 nquad0 * sizeof(NekDouble));
143 }
144 else
145 {
146 const Array<OneD, const NekDouble> base0 = m_base[0]->GetBdata();
147
148 int nmodes0 = m_base[0]->GetNumModes();
149
150 // Switch statment using boost_pp and macros. This unfolls intwo a
151 // nested swtich statement where the outer swtich statement runs
152 // from SMIN to SMAX for modal order and the inner switch
153 // statemets run from the outer value of the case to 2*SMAX for
154 // the quadrature order. If you want to see it unwrapped compile
155 // in verbose mode and add --preprocess to the c++ command.
156 // Default case
157#undef BWDTRANS_DEF
158#define BWDTRANS_DEF \
159 BwdTransSegKernel(nmodes0, nquad0, (const vec_t *)base0.data(), \
160 (const vec_t *)inarray.data(), (vec_t *)outarray.data())
161
162 // Inner loop case over quarature points
163#undef BWDTRANS_Q
164#define BWDTRANS_Q(r, i) \
165 case NQ(i): \
166 BwdTransSegKernel(NM(i), NQ(i), (const vec_t *)base0.data(), \
167 (const vec_t *)inarray.data(), \
168 (vec_t *)outarray.data()); \
169 break;
170
171 // outer loop case over modes
172#undef BWDTRANS_M
173#define BWDTRANS_M(r, i) \
174 case NM(i): \
175 { \
176 switch (nquad0) \
177 { \
178 BOOST_PP_FOR_##r((NM(i), NM_P1(i), BOOST_PP_MUL(2, NM(i))), \
179 STDLEV2TEST1, STDLEV2UPDATE1, BWDTRANS_Q) default \
180 : BWDTRANS_DEF; \
181 break; \
182 } \
183 } \
184 break;
185
186 // templated cases on equi-ordered modes and standard quad
187 // usage where quad order goes from mode order to 2(*mode
188 // order)
189 switch (nmodes0)
190 {
191 BOOST_PP_FOR((SMIN, 0, SMAX), STDLEV2TEST, STDLEV2UPDATE,
193 default:
195 break;
196 }
197 }
198}
199
201 const Array<OneD, const NekDouble> &inarray,
202 Array<OneD, NekDouble> &outarray)
203{
204 int n_coeffs = inarray.size();
205
206 Array<OneD, NekDouble> coeff(n_coeffs);
207 Array<OneD, NekDouble> coeff_tmp(n_coeffs, 0.0);
210
211 int nmodes0 = m_base[0]->GetNumModes();
212
213 Vmath::Vcopy(n_coeffs, inarray, 1, coeff_tmp, 1);
214
215 const LibUtilities::PointsKey Pkey0(nmodes0,
217
218 LibUtilities::BasisKey b0(m_base[0]->GetBasisType(), nmodes0, Pkey0);
219
220 LibUtilities::BasisKey bortho0(LibUtilities::eOrtho_A, nmodes0, Pkey0);
221
222 LibUtilities::InterpCoeff1D(b0, coeff_tmp, bortho0, coeff);
223
224 Vmath::Zero(n_coeffs, coeff_tmp, 1);
225
226 Vmath::Vcopy(numMin, tmp = coeff, 1, tmp2 = coeff_tmp, 1);
227
228 LibUtilities::InterpCoeff1D(bortho0, coeff_tmp, b0, outarray);
229}
230
232 const Array<OneD, const NekDouble> &inarray,
233 Array<OneD, NekDouble> &outarray)
234{
235 if (m_base[0]->Collocation())
236 {
237 Vmath::Vcopy(m_ncoeffs, inarray, 1, outarray, 1);
238 }
239 else
240 {
241 int nInteriorDofs = m_ncoeffs - 2;
242 int offset = 0;
243
244 switch (m_base[0]->GetBasisType())
245 {
247 {
248 offset = 1;
249 }
250 break;
252 {
253 nInteriorDofs = m_ncoeffs;
254 offset = 0;
255 }
256 break;
259 {
260 offset = 2;
261 }
262 break;
263 default:
264 ASSERTL0(false, "This type of FwdTrans is not defined for this "
265 "expansion type");
266 }
267
268 fill(outarray.data(), outarray.data() + m_ncoeffs, 0.0);
269
271 {
272 outarray[GetVertexMap(0)] = inarray[0];
273 outarray[GetVertexMap(1)] = inarray[m_base[0]->GetNumPoints() - 1];
274
275 if (m_ncoeffs > 2)
276 {
277 // ideally, we would like to have tmp0 to be replaced by
278 // outarray (currently MassMatrixOp does not allow aliasing)
281
282 StdMatrixKey masskey(eMass, v_DetShapeType(), *this);
283 MassMatrixOp(outarray, tmp0, masskey);
284 v_IProductWRTBase(inarray, tmp1);
285
286 Vmath::Vsub(m_ncoeffs, tmp1, 1, tmp0, 1, tmp1, 1);
287
288 // get Mass matrix inverse (only of interior DOF)
289 DNekMatSharedPtr matsys =
290 (m_stdStaticCondMatrixManager[masskey])->GetBlock(1, 1);
291
292 Blas::Dgemv('N', nInteriorDofs, nInteriorDofs, 1.0,
293 &(matsys->GetPtr())[0], nInteriorDofs,
294 tmp1.data() + offset, 1, 0.0,
295 outarray.data() + offset, 1);
296 }
297 }
298 else
299 {
300 v_FwdTrans(inarray, outarray);
301 }
302 }
303}
304
305//---------------------------------------------------------------------
306// Inner product functions
307//---------------------------------------------------------------------
308/** \brief Inner product of \a inarray over region with respect to the
309 * expansion basis (this)->m_base[0] and return in \a outarray
310 *
311 * @param base0 - An array containing the values of the basis in the
312 * 0-direction at the quarature poitns
313 * @param inarray - Array of values evaluated at the physical
314 * quadrature points
315 * @param outarray the values of the inner product with respect to
316 * each basis over region will be stored in the array \a outarray as
317 * output of the function
318 * @param jac - An array of size 1 if not deformed or the number of
319 * quadrature points if deformed holding the values of the jacobian
320 * @param Deformed - a bool identifying if the inner product is to be
321 * treated as a deformed or regular integration which just relates to
322 * how the \param jac array is treated
323 */
325 const Array<OneD, const NekDouble> &base0,
326 const Array<OneD, const NekDouble> &inarray,
328 const bool Deformed)
329{
330 int nquad0 = m_base[0]->GetNumPoints();
331 int order0 = m_base[0]->GetNumModes();
332
333 // Swith statment using boost_pp and macros. This unfolls intwo a
334 // nested swtich statement where the outer swtich statement runs
335 // from SMIN to SMAX for modal order and the inner switch
336 // statemets run from the outer value of the case to 2*SMAX for
337 // the quadrature order. If you want to see it unwrapped compile
338 // in verbose mode and add --preprocess to the c++ command.
339 if (Deformed)
340 {
341 // Default case
342#undef IPRODUCTWRTBASE_DEF
343#define IPRODUCTWRTBASE_DEF \
344 IProductSegKernel<false, false, true>( \
345 order0, nquad0, (const vec_t *)inarray.data(), \
346 (const vec_t *)base0.data(), (const vec_t *)m_weights[0].data(), \
347 (const vec_t *)jac.data(), (vec_t *)outarray.data())
348
349 // Inner loop case over quarature points
350#undef IPRODUCTWRTBASE_Q
351#define IPRODUCTWRTBASE_Q(r, i) \
352 case NQ(i): \
353 IProductSegKernel<false, false, true>( \
354 NM(i), NQ(i), (const vec_t *)inarray.data(), \
355 (const vec_t *)base0.data(), (const vec_t *)m_weights[0].data(), \
356 (const vec_t *)jac.data(), (vec_t *)outarray.data()); \
357 break;
358
359 // outer loop case over modes
360#undef IPRODUCTWRTBASE_M
361#define IPRODUCTWRTBASE_M(r, i) \
362 case NM(i): \
363 { \
364 switch (nquad0) \
365 { \
366 BOOST_PP_FOR_##r((NM(i), NM_P1(i), BOOST_PP_MUL(2, NM(i))), \
367 STDLEV2TEST1, STDLEV2UPDATE1, \
368 IPRODUCTWRTBASE_Q) default : IPRODUCTWRTBASE_DEF; \
369 break; \
370 } \
371 } \
372 break;
373
374 // templated cases on equi-ordered modes and standard quad usage
375 // where quad order goes from mode order to 2(*mode order)
376 switch (order0)
377 {
378 BOOST_PP_FOR((SMIN, 0, SMAX), STDLEV2TEST, STDLEV2UPDATE,
380 default:
382 break;
383 }
384 }
385 else // non-deformed case
386 {
387 // Default case
388#undef IPRODUCTWRTBASE_DEF
389#define IPRODUCTWRTBASE_DEF \
390 IProductSegKernel<false, false, false>( \
391 order0, nquad0, (const vec_t *)inarray.data(), \
392 (const vec_t *)base0.data(), (const vec_t *)m_weights[0].data(), \
393 (const vec_t *)jac.data(), (vec_t *)outarray.data())
394
395 // Inner loop case over quarature points
396#undef IPRODUCTWRTBASE_Q
397#define IPRODUCTWRTBASE_Q(r, i) \
398 case NQ(i): \
399 IProductSegKernel<false, false, false>( \
400 NM(i), NQ(i), (const vec_t *)inarray.data(), \
401 (const vec_t *)base0.data(), (const vec_t *)m_weights[0].data(), \
402 (const vec_t *)jac.data(), (vec_t *)outarray.data()); \
403 break;
404
405 // outer loop case over modes
406#undef IPRODUCTWRTBASE_M
407#define IPRODUCTWRTBASE_M(r, i) \
408 case NM(i): \
409 { \
410 switch (nquad0) \
411 { \
412 BOOST_PP_FOR_##r((NM(i), NM_P1(i), BOOST_PP_MUL(2, NM(i))), \
413 STDLEV2TEST1, STDLEV2UPDATE1, \
414 IPRODUCTWRTBASE_Q) default : IPRODUCTWRTBASE_DEF; \
415 break; \
416 } \
417 } \
418 break;
419
420 // templated cases on equi-ordered modes and standard quad usage
421 // where quad order goes from mode order to 2(*mode order)
422 switch (order0)
423 {
424 BOOST_PP_FOR((SMIN, 0, SMAX), STDLEV2TEST, STDLEV2UPDATE,
426 default:
428 break;
429 }
430 }
431}
432
434 [[maybe_unused]] const int dir, const Array<OneD, const NekDouble> &inarray,
435 Array<OneD, NekDouble> &outarray)
436{
437 ASSERTL1(dir == 0, "input dir is out of range");
438 const Array<OneD, const NekDouble> one(1, 1.0);
439 v_IProductWRTBaseKernel(m_base[0]->GetDbdata(), inarray, outarray, one,
440 false);
441}
442
443//----------------------------
444// Evaluation
445//----------------------------
451
454{
455 xi[0] = eta[0];
456}
457
458void StdSegExp::v_FillMode(const int mode, Array<OneD, NekDouble> &outarray)
459{
460 int nquad = m_base[0]->GetNumPoints();
461 const NekDouble *base = m_base[0]->GetBdata().data();
462
463 ASSERTL2(mode <= m_ncoeffs,
464 "calling argument mode is larger than total expansion order");
465
466 Vmath::Vcopy(nquad, (NekDouble *)base + mode * nquad, 1, &outarray[0], 1);
467}
468
470 const Array<OneD, const NekDouble> &coords, int mode)
471{
472 return StdExpansion::BaryEvaluateBasis<0>(coords[0], mode);
473}
474
476 const Array<OneD, NekDouble> &coord,
477 const Array<OneD, const NekDouble> &inarray,
478 std::array<NekDouble, 3> &firstOrderDerivs)
479{
480 return StdExpansion1D::BaryTensorDeriv(coord, inarray, firstOrderDerivs);
481}
482
484 const Array<OneD, NekDouble> &coord,
485 const Array<OneD, const NekDouble> &inarray,
486 std::array<NekDouble, 3> &firstOrderDerivs,
487 std::array<NekDouble, 6> &secondOrderDerivs)
488{
489 return StdExpansion1D::BaryTensorDeriv(coord, inarray, firstOrderDerivs,
490 secondOrderDerivs);
491}
493 Array<OneD, NekDouble> &outarray,
494 [[maybe_unused]] const StdMatrixKey &mkey)
495{
496 int nquad = m_base[0]->GetNumPoints();
497
498 Array<OneD, NekDouble> physValues(nquad);
499 Array<OneD, NekDouble> dPhysValuesdx(nquad);
500
501 v_BwdTrans(inarray, physValues);
502
503 // Laplacian matrix operation
504 v_PhysDeriv(physValues, dPhysValuesdx, NullNekDouble1DArray,
506 v_IProductWRTBase(dPhysValuesdx, outarray);
507}
508
509void StdSegExp::v_LaplacianMatrixOp(const int k1, const int k2,
510 const Array<OneD, const NekDouble> &inarray,
511 Array<OneD, NekDouble> &outarray,
512 const StdMatrixKey &mkey)
513{
514 StdExpansion::LaplacianMatrixOp_MatFree(k1, k2, inarray, outarray, mkey);
515}
516
518 Array<OneD, NekDouble> &outarray,
519 const StdMatrixKey &mkey)
520{
521 int nquad = m_base[0]->GetNumPoints();
522
523 Array<OneD, NekDouble> physValues(nquad);
524 Array<OneD, NekDouble> dPhysValuesdx(nquad);
526
527 v_BwdTrans(inarray, physValues);
528
529 // mass matrix operation
530 v_IProductWRTBase(physValues, wsp);
531
532 // Laplacian matrix operation
533 const Array<OneD, const NekDouble> one(1, 1.0);
534 v_PhysDeriv(physValues, dPhysValuesdx, NullNekDouble1DArray,
536 v_IProductWRTBaseKernel(m_base[0]->GetDbdata(), dPhysValuesdx, outarray,
537 one, false);
539 outarray.data(), 1);
540}
541
543 const StdMatrixKey &mkey)
544{
545 // Generate an orthogonal expansion
546 int nq = m_base[0]->GetNumPoints();
547 int nmodes = m_base[0]->GetNumModes();
548 // Declare orthogonal basis.
550
552 StdSegExp OrthoExp(B);
553
554 // SVV parameters loaded from the .xml case file
555 NekDouble SvvDiffCoeff = mkey.GetConstFactor(eFactorSVVDiffCoeff);
556 int cutoff = (int)(mkey.GetConstFactor(eFactorSVVCutoffRatio)) * nmodes;
557
558 Array<OneD, NekDouble> orthocoeffs(OrthoExp.GetNcoeffs());
559
560 // project onto modal space.
561 OrthoExp.FwdTrans(array, orthocoeffs);
562
563 //
564 for (int j = 0; j < nmodes; ++j)
565 {
566 if (j >= cutoff) // to filter out only the "high-modes"
567 {
568 orthocoeffs[j] *=
569 (SvvDiffCoeff *
570 exp(-(j - nmodes) * (j - nmodes) /
571 ((NekDouble)((j - cutoff + 1) * (j - cutoff + 1)))));
572 }
573 else
574 {
575 orthocoeffs[j] *= 0.0;
576 }
577 }
578
579 // backward transform to physical space
580 OrthoExp.BwdTrans(orthocoeffs, array);
581}
582
584 const NekDouble alpha,
585 const NekDouble exponent,
586 const NekDouble cutoff)
587{
588 // Generate an orthogonal expansion
589 int nq = m_base[0]->GetNumPoints();
590 int nmodes = m_base[0]->GetNumModes();
591 int P = nmodes - 1;
592 // Declare orthogonal basis.
594
596 StdSegExp OrthoExp(B);
597
598 // Cutoff
599 int Pcut = cutoff * P;
600
601 // Project onto orthogonal space.
602 Array<OneD, NekDouble> orthocoeffs(OrthoExp.GetNcoeffs());
603 OrthoExp.FwdTrans(array, orthocoeffs);
604
605 //
606 NekDouble fac;
607 for (int j = 0; j < nmodes; ++j)
608 {
609 // to filter out only the "high-modes"
610 if (j > Pcut)
611 {
612 fac = (NekDouble)(j - Pcut) / ((NekDouble)(P - Pcut));
613 fac = pow(fac, exponent);
614 orthocoeffs[j] *= exp(-alpha * fac);
615 }
616 }
617
618 // backward transform to physical space
619 OrthoExp.BwdTrans(orthocoeffs, array);
620}
621
623 [[maybe_unused]] Array<OneD, NekDouble> &coords_1,
624 [[maybe_unused]] Array<OneD, NekDouble> &coords_2)
625{
626 Vmath::Vcopy(GetNumPoints(0), (m_base[0]->GetZ()).data(), 1, &coords_0[0],
627 1);
628}
629
630//---------------------------------------------------------------------
631// Helper functions
632//---------------------------------------------------------------------
633
635{
636 return 2;
637}
638
640{
641 return 2;
642}
643
644int StdSegExp::v_GetTraceNcoeffs([[maybe_unused]] const int i) const
645{
646 return 1;
647}
648
649int StdSegExp::v_GetTraceIntNcoeffs([[maybe_unused]] const int i) const
650{
651 return 0;
652}
653
654int StdSegExp::v_GetTraceNumPoints([[maybe_unused]] const int i) const
655{
656 return 1;
657}
658
660{
661 return 2;
662}
663
665{
666 return 2;
667}
668
670 const std::vector<unsigned int> &nummodes, int &modes_offset)
671{
672 int nmodes = nummodes[modes_offset];
673 modes_offset += 1;
674
675 return nmodes;
676}
677
678//---------------------------------------------------------------------
679// Wrapper functions
680//---------------------------------------------------------------------
681
683{
685 MatrixType mattype;
686
687 switch (mattype = mkey.GetMatrixType())
688 {
690 {
691 int nq0 = m_base[0]->GetNumPoints();
692 int nq;
693
694 // take definition from key
696 {
697 nq = (int)mkey.GetConstFactor(eFactorConst);
698 }
699 else
700 {
701 nq = nq0;
702 }
703
705 Array<OneD, NekDouble> coords(1);
708
709 for (int i = 0; i < neq; ++i)
710 {
711 coords[0] = -1.0 + 2 * i / (NekDouble)(neq - 1);
712 I = m_base[0]->GetI(coords);
713 Vmath::Vcopy(nq0, I->GetRawPtr(), 1, Mat->GetRawPtr() + i, neq);
714 }
715 }
716 break;
717 case ePhysInterpToGLL:
718 {
719 int nq0 = m_base[0]->GetNumPoints();
720 int nq;
721
722 // take definition from key
724 {
725 nq = (int)mkey.GetConstFactor(eFactorConst);
726 }
727 else
728 {
729 nq = nq0;
730 }
731
733 Array<OneD, NekDouble> coords(1);
736
737 const LibUtilities::PointsKey key(
739
741 LibUtilities::PointsManager()[key]->GetPoints(z);
742
743 for (int i = 0; i < neq; ++i)
744 {
745 coords[0] = z[i];
746 I = m_base[0]->GetI(coords);
747 Vmath::Vcopy(nq0, I->GetRawPtr(), 1, Mat->GetRawPtr() + i, neq);
748 }
749 }
750 break;
751 case eFwdTrans:
752 {
753 Mat =
755 StdMatrixKey iprodkey(eIProductWRTBase, v_DetShapeType(), *this);
756 DNekMat &Iprod = *GetStdMatrix(iprodkey);
757 StdMatrixKey imasskey(eInvMass, v_DetShapeType(), *this);
758 DNekMat &Imass = *GetStdMatrix(imasskey);
759
760 (*Mat) = Imass * Iprod;
761 }
762 break;
763 default:
764 {
766
767 if (mattype == eMass)
768 {
769 // For Fourier basis set the imaginary component
770 // of mean mode to have a unit diagonal component
771 // in mass matrix
773 {
774 (*Mat)(1, 1) = 1.0;
775 }
776 }
777 }
778 break;
779 }
780
781 return Mat;
782}
783
788
789//---------------------------------------------------------------------
790// Mappings
791//---------------------------------------------------------------------
792
794{
795 if (outarray.size() != NumBndryCoeffs())
796 {
798 }
799 const LibUtilities::BasisType Btype = GetBasisType(0);
800 int nummodes = m_base[0]->GetNumModes();
801
802 outarray[0] = 0;
803
804 switch (Btype)
805 {
808 case LibUtilities::eChebyshev:
810 outarray[1] = nummodes - 1;
811 break;
814 outarray[1] = 1;
815 break;
816 default:
817 ASSERTL0(0, "Mapping array is not defined for this expansion");
818 break;
819 }
820}
821
823{
824 int i;
825 if (outarray.size() != GetNcoeffs() - NumBndryCoeffs())
826 {
828 }
829 const LibUtilities::BasisType Btype = GetBasisType(0);
830
831 switch (Btype)
832 {
835 case LibUtilities::eChebyshev:
837 for (i = 0; i < GetNcoeffs() - 2; i++)
838 {
839 outarray[i] = i + 1;
840 }
841 break;
844 for (i = 0; i < GetNcoeffs() - 2; i++)
845 {
846 outarray[i] = i + 2;
847 }
848 break;
849 default:
850 ASSERTL0(0, "Mapping array is not defined for this expansion");
851 break;
852 }
853}
854
855int StdSegExp::v_GetVertexMap(int localVertexId,
856 [[maybe_unused]] bool useCoeffPacking)
857{
858 ASSERTL0((localVertexId == 0) || (localVertexId == 1),
859 "local vertex id"
860 "must be between 0 or 1");
861
862 int localDOF = localVertexId;
863
865 (localVertexId == 1))
866 {
867 localDOF = m_base[0]->GetNumModes() - 1;
868 }
869 return localDOF;
870}
871
873 Array<OneD, int> &conn, [[maybe_unused]] bool standard)
874{
875 int np = m_base[0]->GetNumPoints();
876
877 conn = Array<OneD, int>(2 * (np - 1));
878 int cnt = 0;
879 for (int i = 0; i < np - 1; ++i)
880 {
881 conn[cnt++] = i;
882 conn[cnt++] = i + 1;
883 }
884}
885
886/** \brief Get the map of the coefficient location to teh
887 * local trace coefficients
888 */
889
890void StdSegExp::v_GetTraceCoeffMap(const unsigned int traceid,
892{
893 int order0 = m_base[0]->GetNumModes();
894
895 ASSERTL0(traceid < 2, "eid must be between 0 and 1");
896
897 if (maparray.size() != 1)
898 {
899 maparray = Array<OneD, unsigned int>(1);
900 }
901
902 const LibUtilities::BasisType bType = GetBasisType(0);
903
904 if (bType == LibUtilities::eModified_A)
905 {
906 maparray[0] = (traceid == 0) ? 0 : 1;
907 }
908 else if (bType == LibUtilities::eGLL_Lagrange ||
910 {
911 maparray[0] = (traceid == 0) ? 0 : order0 - 1;
912 }
913 else
914 {
915 ASSERTL0(false, "Unknown Basis");
916 }
917}
918
921 Array<OneD, int> &signarray,
922 [[maybe_unused]] Orientation orient,
923 [[maybe_unused]] int P,
924 [[maybe_unused]] int Q)
925{
926 v_GetTraceCoeffMap(tid, maparray);
927
928 if (signarray.size() != 1)
929 {
930 signarray = Array<OneD, int>(1, 1);
931 }
932 else
933 {
934 signarray[0] = 1;
935 }
936}
937
939 [[maybe_unused]] const unsigned int eid,
940 Array<OneD, unsigned int> &maparray, Array<OneD, int> &signarray,
941 [[maybe_unused]] Orientation orient, [[maybe_unused]] int P,
942 [[maybe_unused]] int Q)
943{
944 // parameters for higher dimnesion traces
945 if (maparray.size() != 1)
946 {
947 maparray = Array<OneD, unsigned int>(1);
948 }
949
950 maparray[0] = 0;
951
952 if (signarray.size() != 1)
953 {
954 signarray = Array<OneD, int>(1, 1);
955 }
956 else
957 {
958 signarray[0] = 1;
959 }
960}
961
962} // namespace Nektar::StdRegions
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed to...
#define BWDTRANS_M(r, i)
#define IPRODUCTWRTBASE_DEF
#define BWDTRANS_DEF
#define IPRODUCTWRTBASE_M(r, i)
#define STDLEV2TEST(r, state)
#define STDLEV2UPDATE(r, state)
Describes the specification for a Basis.
Definition Basis.h:45
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 PhysTensorDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Evaluate the derivative at the physical quadrature points given by inarray and return in outarray.
NekDouble BaryTensorDeriv(const Array< OneD, NekDouble > &coord, const Array< OneD, const NekDouble > &inarray, std::array< NekDouble, 3 > &firstOrderDerivs)
void v_IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Inner product of inarray over region with respect to the expansion basis (this)->m_base[0] and return...
void v_PhysDeriv(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Calculate the derivative of the physical points in a given direction.
The base class for all shapes.
int GetNcoeffs(void) const
This function returns the total number of coefficients used in the expansion.
LibUtilities::BasisType GetBasisType(const int dir) const
This function returns the type of basis used in the dir direction.
DNekMatSharedPtr GetStdMatrix(const StdMatrixKey &mkey)
void MassMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdMatrixKey &mkey)
int GetVertexMap(const int localVertexId, bool useCoeffPacking=false)
virtual void v_FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Transform a given function from physical quadrature space to coefficient space.
DNekMatSharedPtr CreateGeneralMatrix(const StdMatrixKey &mkey)
this function generates the mass matrix
void LaplacianMatrixOp_MatFree(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdMatrixKey &mkey)
void BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
This function performs the Backward transformation from coefficient space to physical space.
LibUtilities::PointsType GetPointsType(const int dir) const
This function returns the type of quadrature points used in the dir direction.
void FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
LibUtilities::NekManager< StdMatrixKey, DNekBlkMat, StdMatrixKey::opLess > m_stdStaticCondMatrixManager
int GetNumPoints(const int dir) const
This function returns the number of quadrature points in the dir direction.
Array< OneD, LibUtilities::BasisSharedPtr > m_base
std::vector< Array< OneD, const NekDouble > > m_weights
MatrixType GetMatrixType() const
NekDouble GetConstFactor(const ConstFactorType &factor) const
bool ConstFactorExists(const ConstFactorType &factor) const
Class representing a segment element in reference space All interface of this class sits in StdExpans...
Definition StdSegExp.h:45
int v_NumDGBndryCoeffs() const override
NekDouble v_PhysEvalFirstDeriv(const Array< OneD, NekDouble > &coord, const Array< OneD, const NekDouble > &inarray, std::array< NekDouble, 3 > &firstOrderDerivs) override
void v_LaplacianMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdMatrixKey &mkey) override
void v_ReduceOrderCoeffs(int numMin, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
void v_SVVLaplacianFilter(Array< OneD, NekDouble > &array, const StdMatrixKey &mkey) override
void v_GetInteriorMap(Array< OneD, unsigned int > &outarray) override
NekDouble v_PhysEvaluateBasis(const Array< OneD, const NekDouble > &coords, int mode) final
LibUtilities::ShapeType v_DetShapeType() const override
Return Shape of region, using ShapeType enum list. i.e. Segment.
Definition StdSegExp.cpp:68
StdSegExp(const LibUtilities::BasisKey &Ba)
Constructor using BasisKey class for quadrature points and order definition.
Definition StdSegExp.cpp:57
NekDouble v_PhysEvalFirstSecondDeriv(const Array< OneD, NekDouble > &coord, const Array< OneD, const NekDouble > &inarray, std::array< NekDouble, 3 > &firstOrderDerivs, std::array< NekDouble, 6 > &secondOrderDerivs) override
int v_NumBndryCoeffs() const override
void v_HelmholtzMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdMatrixKey &mkey) override
void v_IProductWRTDerivBase(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
void v_LocCollapsedToLocCoord(const Array< OneD, const NekDouble > &eta, Array< OneD, NekDouble > &xi) override
void v_GetTraceCoeffMap(const unsigned int traceid, Array< OneD, unsigned int > &maparray) override
Get the map of the coefficient location to teh local trace coefficients.
int v_GetNverts() const final
int v_GetTraceNumPoints(const int i) const final
void v_FillMode(const int mode, Array< OneD, NekDouble > &outarray) override
int v_GetTraceNcoeffs(const int i) const final
void v_GetSimplexEquiSpacedConnectivity(Array< OneD, int > &conn, bool standard=true) override
void v_GetCoords(Array< OneD, NekDouble > &coords_0, Array< OneD, NekDouble > &coords_1, Array< OneD, NekDouble > &coords_2) override
int v_GetTraceIntNcoeffs(const int i) const final
int v_GetVertexMap(int localVertexId, bool useCoeffPacking=false) override
void v_ExponentialFilter(Array< OneD, NekDouble > &array, const NekDouble alpha, const NekDouble exponent, const NekDouble cutoff) override
DNekMatSharedPtr v_CreateStdMatrix(const StdMatrixKey &mkey) override
void v_BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Backward transform from coefficient space given in inarray and evaluate at the physical quadrature po...
int v_GetNtraces() const final
void v_GetBoundaryMap(Array< OneD, unsigned int > &outarray) override
void v_GetTraceToElementMap(const int tid, Array< OneD, unsigned int > &maparray, Array< OneD, int > &signarray, Orientation edgeOrient, int P, int Q) override
void v_GetElmtTraceToTraceMap(const unsigned int eid, Array< OneD, unsigned int > &maparray, Array< OneD, int > &signarray, Orientation edgeOrient, int P, int Q) override
void v_StdPhysDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_d0, Array< OneD, NekDouble > &out_d1=NullNekDouble1DArray, Array< OneD, NekDouble > &out_d2=NullNekDouble1DArray) override
Evaluate the derivative at the physical quadrature points given by inarray and return in outarray.
void v_LocCoordToLocCollapsed(const Array< OneD, const NekDouble > &xi, Array< OneD, NekDouble > &eta) override
bool v_IsBoundaryInteriorExpansion() const override
Definition StdSegExp.cpp:73
int v_CalcNumberOfCoefficients(const std::vector< unsigned int > &nummodes, int &modes_offset) override
DNekMatSharedPtr v_GenMatrix(const StdMatrixKey &mkey) override
void v_FwdTransBndConstrained(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
void v_IProductWRTBaseKernel(const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const Array< OneD, const NekDouble > &jac, const bool Deformed) override
Inner product of inarray over region with respect to the expansion basis (this)->m_base[0] and return...
static void Dgemv(const char &trans, const int &m, const int &n, const double &alpha, const double *a, const int &lda, const double *x, const int &incx, const double &beta, double *y, const int &incy)
BLAS level 2: Matrix vector multiply y = alpha A x plus beta y where A[m x n].
Definition Blas.hpp:152
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:117
constexpr int getNumberOfCoefficients(int Na)
PointsManagerT & PointsManager(void)
void InterpCoeff1D(const BasisKey &fbasis0, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, Array< OneD, NekDouble > &to)
@ eGaussLobattoLegendre
1D Gauss-Lobatto-Legendre quadrature points
Definition PointsType.h:51
@ eModified_B
Principle Modified Functions .
Definition BasisType.h:49
@ eGauss_Lagrange
Lagrange Polynomials using the Gauss points.
Definition BasisType.h:57
@ eOrtho_A
Principle Orthogonal Functions .
Definition BasisType.h:42
@ eGLL_Lagrange
Lagrange for SEM basis .
Definition BasisType.h:56
@ eModified_A
Principle Modified Functions .
Definition BasisType.h:48
@ eFourier
Fourier Expansion .
Definition BasisType.h:55
tinysimd::scalarT< double > vec_t
static Array< OneD, NekDouble > NullNekDouble1DArray
std::shared_ptr< DNekMat > DNekMatSharedPtr
void Zero(int n, T *x, const int incx)
Zero vector.
Definition Vmath.hpp:273
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition Vmath.hpp:825
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition Vmath.hpp:220
STL namespace.