Nektar++
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 
35 #include <boost/core/ignore_unused.hpp>
36 
37 #include <StdRegions/StdSegExp.h>
39 
40 
41 using namespace std;
42 
43 namespace Nektar
44 {
45  namespace StdRegions
46  {
47 
48  /** \brief Default constructor */
49 
50  StdSegExp::StdSegExp()
51  {
52  }
53 
54 
55  /** \brief Constructor using BasisKey class for quadrature points and
56  * order definition
57  *
58  * \param Ba BasisKey class definition containing order and quadrature
59  * points.
60  */
61 
62  StdSegExp::StdSegExp(const LibUtilities::BasisKey &Ba):
63  StdExpansion(Ba.GetNumModes(), 1, Ba),
64  StdExpansion1D(Ba.GetNumModes(),Ba)
65  {
66  }
67 
68 
69  /** \brief Copy Constructor */
70 
72  StdExpansion(T),
74  {
75  }
76 
77 
79  {
80  }
81 
82  /** \brief Return Shape of region, using ShapeType enum list.
83  * i.e. Segment
84  */
86  {
88  }
89 
91  {
92 
93  bool returnval = false;
94 
96  {
97  returnval = true;
98  }
99 
101  {
102  returnval = true;
103  }
104 
105  return returnval;
106  }
107 
108 
109 
110 
111  //---------------------------------------------------------------------
112  // Integration Methods
113  //---------------------------------------------------------------------
114 
115  /** \brief Integrate the physical point list \a inarray over region
116  * and return the value
117  *
118  * \param inarray definition of function to be integrated evauluated at
119  * quadrature point of expansion.
120  * \return returns \f$\int^1_{-1} u(\xi_1)d \xi_1 \f$ where \f$inarray[i]
121  * = u(\xi_{1i}) \f$
122  */
124  {
125  NekDouble Int = 0.0;
126  int nquad0 = m_base[0]->GetNumPoints();
127  Array<OneD, NekDouble> tmp(nquad0);
128  Array<OneD, const NekDouble> z = m_base[0]->GetZ();
129  Array<OneD, const NekDouble> w0 = m_base[0]->GetW();
130 
131  // multiply by integration constants
132  Vmath::Vmul(nquad0, inarray, 1, w0, 1, tmp, 1);
133 
134  Int = Vmath::Vsum(nquad0, tmp, 1);
135 
136  return Int;
137  }
138 
139 
140 
141 
142  //---------------------------------------------------------------------
143  // Differentiation Methods
144  //---------------------------------------------------------------------
145 
146 
147  /** \brief Evaluate the derivative \f$ d/d{\xi_1} \f$ at the physical
148  * quadrature points given by \a inarray and return in \a outarray.
149  *
150  * This is a wrapper around StdExpansion1D::Tensor_Deriv
151  * \param inarray array of a function evaluated at the quadrature points
152  * \param outarray the resulting array of the derivative \f$
153  * du/d_{\xi_1}|_{\xi_{1i}} \f$ will be stored in the array \a outarra
154  */
155 
157  Array<OneD, NekDouble> &out_d0,
158  Array<OneD, NekDouble> &out_d1,
159  Array<OneD, NekDouble> &out_d2)
160  {
161  boost::ignore_unused(out_d1, out_d2);
162  PhysTensorDeriv(inarray,out_d0);
163  }
164 
165 
166  void StdSegExp::v_PhysDeriv(const int dir,
167  const Array<OneD, const NekDouble>& inarray,
168  Array<OneD, NekDouble> &outarray)
169  {
170  boost::ignore_unused(dir);
171  ASSERTL1(dir==0,"input dir is out of range");
172  PhysTensorDeriv(inarray,outarray);
173  // PhysDeriv(inarray, outarray);
174  }
175 
177  const Array<OneD, const NekDouble>& inarray,
178  Array<OneD, NekDouble> &out_d0,
179  Array<OneD, NekDouble> &out_d1,
180  Array<OneD, NekDouble> &out_d2)
181  {
182  boost::ignore_unused(out_d1, out_d2);
183  PhysTensorDeriv(inarray,out_d0);
184  // PhysDeriv(inarray, out_d0);
185  }
186 
188  const int dir,
189  const Array<OneD, const NekDouble>& inarray,
190  Array<OneD, NekDouble> &outarray)
191  {
192  boost::ignore_unused(dir);
193  ASSERTL1(dir==0,"input dir is out of range");
194  PhysTensorDeriv(inarray,outarray);
195  // PhysDeriv(inarray, outarray);
196  }
197 
198 
199 
200  //---------------------------------------------------------------------
201  // Transforms
202  //---------------------------------------------------------------------
203 
204  /** \brief Backward transform from coefficient space given
205  * in \a inarray and evaluate at the physical quadrature
206  * points \a outarray
207  *
208  * Operation can be evaluated as \f$ u(\xi_{1i}) =
209  * \sum_{p=0}^{order-1} \hat{u}_p \phi_p(\xi_{1i}) \f$ or equivalently
210  * \f$ {\bf u} = {\bf B}^T {\bf \hat{u}} \f$ where
211  * \f${\bf B}[i][j] = \phi_i(\xi_{1j}), \mbox{\_coeffs}[p] = {\bf
212  * \hat{u}}[p] \f$
213  *
214  * The function takes the coefficient array \a inarray as
215  * input for the transformation
216  *
217  * \param inarray: the coeffficients of the expansion
218  *
219  * \param outarray: the resulting array of the values of the function at
220  * the physical quadrature points will be stored in the array \a outarray
221  */
222 
224  const Array<OneD, const NekDouble>& inarray,
225  Array<OneD, NekDouble> &outarray)
226  {
227  int nquad = m_base[0]->GetNumPoints();
228 
229  if(m_base[0]->Collocation())
230  {
231  Vmath::Vcopy(nquad, inarray, 1, outarray, 1);
232  }
233  else
234  {
235 
236  Blas::Dgemv('N',nquad,m_base[0]->GetNumModes(),1.0,
237  (m_base[0]->GetBdata()).get(),
238  nquad,&inarray[0],1,0.0,&outarray[0],1);
239 
240  }
241  }
242 
244  int numMin,
245  const Array<OneD, const NekDouble> &inarray,
246  Array<OneD, NekDouble> &outarray)
247  {
248  int n_coeffs = inarray.size();
249 
250  Array<OneD, NekDouble> coeff(n_coeffs);
251  Array<OneD, NekDouble> coeff_tmp(n_coeffs,0.0);
254 
255  int nmodes0 = m_base[0]->GetNumModes();
256 
257  Vmath::Vcopy(n_coeffs,inarray,1,coeff_tmp,1);
258 
259  const LibUtilities::PointsKey Pkey0(
261 
262  LibUtilities::BasisKey b0(m_base[0]->GetBasisType(),nmodes0,Pkey0);
263 
264  LibUtilities::BasisKey bortho0(LibUtilities::eOrtho_A,nmodes0,Pkey0);
265 
267  b0, coeff_tmp, bortho0, coeff);
268 
269  Vmath::Zero(n_coeffs,coeff_tmp,1);
270 
271  Vmath::Vcopy(numMin,
272  tmp = coeff,1,
273  tmp2 = coeff_tmp,1);
274 
276  bortho0, coeff_tmp, b0, outarray);
277  }
278 
279  /**
280  * \brief Forward transform from physical quadrature space stored in \a
281  * inarray and evaluate the expansion coefficients and store in \a
282  * outarray
283  *
284  * Perform a forward transform using a Galerkin projection by taking the
285  * inner product of the physical points and multiplying by the inverse
286  * of the mass matrix using the Solve method of the standard matrix
287  * container holding the local mass matrix, i.e. \f$ {\bf \hat{u}} =
288  * {\bf M}^{-1} {\bf I} \f$ where \f$ {\bf I}[p] = \int^1_{-1}
289  * \phi_p(\xi_1) u(\xi_1) d\xi_1 \f$
290  *
291  * This function stores the expansion coefficients calculated by the
292  * transformation in the coefficient space array \a outarray
293  *
294  * \param inarray: array of physical quadrature points to be transformed
295  * \param outarray: the coeffficients of the expansion
296  */
298  Array<OneD, NekDouble> &outarray)
299  {
300  if(m_base[0]->Collocation())
301  {
302  Vmath::Vcopy(m_ncoeffs, inarray, 1, outarray, 1);
303  }
304  else
305  {
306  v_IProductWRTBase(inarray,outarray);
307 
308  // get Mass matrix inverse
309  StdMatrixKey masskey(eInvMass,v_DetShapeType(),*this);
310  DNekMatSharedPtr matsys = GetStdMatrix(masskey);
311 
312  NekVector<NekDouble> in(m_ncoeffs,outarray,eCopy);
314 
315  out = (*matsys)*in;
316  }
317  }
318 
320  const Array<OneD, const NekDouble>& inarray,
321  Array<OneD, NekDouble> &outarray)
322  {
323  if(m_base[0]->Collocation())
324  {
325  Vmath::Vcopy(m_ncoeffs, inarray, 1, outarray, 1);
326  }
327  else
328  {
329  int nInteriorDofs = m_ncoeffs-2;
330  int offset = 0;
331 
332  switch(m_base[0]->GetBasisType())
333  {
335  {
336  offset = 1;
337  }
338  break;
340  {
341  nInteriorDofs = m_ncoeffs;
342  offset = 0;
343  }
344  break;
347  {
348  offset = 2;
349  }
350  break;
351  default:
352  ASSERTL0(false,"This type of FwdTrans is not defined for this expansion type");
353  }
354 
355  fill(outarray.get(), outarray.get()+m_ncoeffs, 0.0 );
356 
358  {
359  outarray[GetVertexMap(0)] = inarray[0];
360  outarray[GetVertexMap(1)] = inarray[m_base[0]->GetNumPoints()-1];
361 
362  if(m_ncoeffs>2)
363  {
364  // ideally, we would like to have tmp0 to be replaced by
365  // outarray (currently MassMatrixOp does not allow aliasing)
368 
369  StdMatrixKey masskey(eMass,v_DetShapeType(),*this);
370  MassMatrixOp(outarray,tmp0,masskey);
371  v_IProductWRTBase(inarray,tmp1);
372 
373  Vmath::Vsub(m_ncoeffs, tmp1, 1, tmp0, 1, tmp1, 1);
374 
375  // get Mass matrix inverse (only of interior DOF)
376  DNekMatSharedPtr matsys =
377  (m_stdStaticCondMatrixManager[masskey])-> GetBlock(1,1);
378 
379  Blas::Dgemv('N',nInteriorDofs,nInteriorDofs,1.0,
380  &(matsys->GetPtr())[0],nInteriorDofs,tmp1.get()
381  +offset,1,0.0,outarray.get()+offset,1);
382  }
383  }
384  else
385  {
386  StdSegExp::v_FwdTrans(inarray, outarray);
387  }
388  }
389 
390  }
391 
392 
394  Array<OneD, NekDouble> &outarray)
395  {
396  v_BwdTrans(inarray, outarray);
397  }
398 
399 
400 
401  //---------------------------------------------------------------------
402  // Inner product functions
403  //---------------------------------------------------------------------
404 
405 
406 
407  /** \brief Inner product of \a inarray over region with respect to
408  * expansion basis \a base and return in \a outarray
409  *
410  * Calculate \f$ I[p] = \int^{1}_{-1} \phi_p(\xi_1) u(\xi_1) d\xi_1
411  * = \sum_{i=0}^{nq-1} \phi_p(\xi_{1i}) u(\xi_{1i}) w_i \f$ where
412  * \f$ outarray[p] = I[p], inarray[i] = u(\xi_{1i}), base[p*nq+i] =
413  * \phi_p(\xi_{1i}) \f$.
414  *
415  * \param base an array defining the local basis for the inner product
416  * usually passed from Basis->GetBdata() or Basis->GetDbdata()
417  * \param inarray: physical point array of function to be integrated
418  * \f$ u(\xi_1) \f$
419  * \param coll_check flag to identify when a Basis->Collocation() call
420  * should be performed to see if this is a GLL_Lagrange basis with a
421  * collocation property. (should be set to 0 if taking the inner
422  * product with respect to the derivative of basis)
423  * \param outarray the values of the inner product with respect to
424  * each basis over region will be stored in the array \a outarray as
425  * output of the function
426  */
427 
429  const Array<OneD, const NekDouble> &base,
430  const Array<OneD, const NekDouble> &inarray,
431  Array<OneD, NekDouble> &outarray,
432  int coll_check)
433  {
434  boost::ignore_unused(coll_check);
435 
436  int nquad = m_base[0]->GetNumPoints();
437  Array<OneD, NekDouble> tmp(nquad);
438  Array<OneD, const NekDouble> w = m_base[0]->GetW();
439 
440  Vmath::Vmul(nquad, inarray, 1, w, 1, tmp, 1);
441 
442  /* Comment below was a bug for collocated basis
443  if(coll_check&&m_base[0]->Collocation())
444  {
445  Vmath::Vcopy(nquad, tmp, 1, outarray, 1);
446  }
447  else
448  {
449  Blas::Dgemv('T',nquad,m_ncoeffs,1.0,base.get(),nquad,
450  &tmp[0],1,0.0,outarray.get(),1);
451  }*/
452 
453  // Correct implementation
454  Blas::Dgemv('T',nquad,m_ncoeffs,1.0,base.get(),nquad,
455  &tmp[0],1,0.0,outarray.get(),1);
456  }
457 
458  /** \brief Inner product of \a inarray over region with respect to the
459  * expansion basis (this)->m_base[0] and return in \a outarray
460  *
461  * Wrapper call to StdSegExp::IProductWRTBase
462  * \param inarray array of function values evaluated at the physical
463  * collocation points
464  * \param outarray the values of the inner product with respect to
465  * each basis over region will be stored in the array \a outarray as
466  * output of the function
467  */
469  Array<OneD, NekDouble> &outarray)
470  {
471  v_IProductWRTBase(m_base[0]->GetBdata(),inarray,outarray,1);
472  }
473 
475  const int dir,
476  const Array<OneD, const NekDouble>& inarray,
477  Array<OneD, NekDouble> & outarray)
478  {
479  boost::ignore_unused(dir);
480  ASSERTL1(dir >= 0 && dir < 1,"input dir is out of range");
481  v_IProductWRTBase(m_base[0]->GetDbdata(),inarray,outarray,1);
482  }
483 
485  const Array<OneD, const NekDouble>& inarray,
486  Array<OneD, NekDouble> &outarray,
487  bool multiplybyweights)
488  {
489  int nquad = m_base[0]->GetNumPoints();
490  Array<OneD, NekDouble> tmp(nquad);
491  Array<OneD, const NekDouble> w = m_base[0]->GetW();
492  Array<OneD, const NekDouble> base = m_base[0]->GetBdata();
493 
494  if(multiplybyweights)
495  {
496  Vmath::Vmul(nquad, inarray, 1, w, 1, tmp, 1);
497 
498  Blas::Dgemv('T',nquad,m_ncoeffs,1.0,base.get(),nquad,
499  &tmp[0],1,0.0,outarray.get(),1);
500  }
501  else
502  {
503  Blas::Dgemv('T',nquad,m_ncoeffs,1.0,base.get(),nquad,
504  &inarray[0],1,0.0,outarray.get(),1);
505  }
506  }
507 
508 
509 
510 
511 
512  //----------------------------
513  // Evaluation
514  //----------------------------
517  {
518  eta[0] = xi[0];
519  }
520 
522  (const Array<OneD, const NekDouble>& eta,
524  {
525  xi[0] = eta[0];
526  }
527 
528  void StdSegExp::v_FillMode(const int mode, Array<OneD, NekDouble> &outarray)
529  {
530  int nquad = m_base[0]->GetNumPoints();
531  const NekDouble * base = m_base[0]->GetBdata().get();
532 
533  ASSERTL2(mode <= m_ncoeffs,
534  "calling argument mode is larger than total expansion order");
535 
536  Vmath::Vcopy(nquad,(NekDouble *)base+mode*nquad,1, &outarray[0],1);
537  }
538 
540  const Array<OneD, const NekDouble>& coords,
541  int mode)
542  {
543  return StdExpansion::BaryEvaluateBasis<0>(coords[0], mode);
544  }
545 
547  const Array<OneD, const NekDouble> &inarray,
548  Array<OneD, NekDouble> &outarray,
549  const StdMatrixKey &mkey)
550  {
551  boost::ignore_unused(mkey);
552 
553  int nquad = m_base[0]->GetNumPoints();
554 
555  Array<OneD,NekDouble> physValues(nquad);
556  Array<OneD,NekDouble> dPhysValuesdx(nquad);
557 
558  v_BwdTrans(inarray,physValues);
559 
560  // Laplacian matrix operation
561  v_PhysDeriv(physValues,dPhysValuesdx);
562  v_IProductWRTBase(m_base[0]->GetDbdata(),dPhysValuesdx,outarray,1);
563  }
564 
565 
567  const Array<OneD, const NekDouble> &inarray,
568  Array<OneD, NekDouble> &outarray,
569  const StdMatrixKey &mkey)
570  {
571  int nquad = m_base[0]->GetNumPoints();
572 
573  Array<OneD,NekDouble> physValues(nquad);
574  Array<OneD,NekDouble> dPhysValuesdx(nquad);
576 
577  v_BwdTrans(inarray,physValues);
578 
579  // mass matrix operation
580  v_IProductWRTBase((m_base[0]->GetBdata()),physValues,wsp,1);
581 
582  // Laplacian matrix operation
583  v_PhysDeriv(physValues,dPhysValuesdx);
584  v_IProductWRTBase(m_base[0]->GetDbdata(),dPhysValuesdx,outarray,1);
585  Blas::Daxpy(m_ncoeffs, mkey.GetConstFactor(eFactorLambda), wsp.get(), 1, outarray.get(), 1);
586  }
587 
589  const StdMatrixKey &mkey)
590  {
591  // Generate an orthogonal expansion
592  int nq = m_base[0]->GetNumPoints();
593  int nmodes = m_base[0]->GetNumModes();
594  // Declare orthogonal basis.
596 
598  StdSegExp OrthoExp(B);
599 
600  //SVV parameters loaded from the .xml case file
601  NekDouble SvvDiffCoeff = mkey.GetConstFactor(eFactorSVVDiffCoeff);
602  int cutoff = (int) (mkey.GetConstFactor(eFactorSVVCutoffRatio))*nmodes;
603 
604  Array<OneD, NekDouble> orthocoeffs(OrthoExp.GetNcoeffs());
605 
606  // project onto modal space.
607  OrthoExp.FwdTrans(array,orthocoeffs);
608 
609  //
610  for(int j = 0; j < nmodes; ++j)
611  {
612  if(j >= cutoff)//to filter out only the "high-modes"
613  {
614  orthocoeffs[j] *=
615  (SvvDiffCoeff*exp(-(j-nmodes)*(j-nmodes)/
616  ((NekDouble)((j-cutoff+1)*
617  (j-cutoff+1)))));
618  }
619  else
620  {
621  orthocoeffs[j] *= 0.0;
622  }
623  }
624 
625  // backward transform to physical space
626  OrthoExp.BwdTrans(orthocoeffs,array);
627  }
628 
630  Array<OneD, NekDouble> &array,
631  const NekDouble alpha,
632  const NekDouble exponent,
633  const NekDouble cutoff)
634  {
635  // Generate an orthogonal expansion
636  int nq = m_base[0]->GetNumPoints();
637  int nmodes = m_base[0]->GetNumModes();
638  int P = nmodes - 1;
639  // Declare orthogonal basis.
641 
643  StdSegExp OrthoExp(B);
644 
645  // Cutoff
646  int Pcut = cutoff*P;
647 
648  // Project onto orthogonal space.
649  Array<OneD, NekDouble> orthocoeffs(OrthoExp.GetNcoeffs());
650  OrthoExp.FwdTrans(array,orthocoeffs);
651 
652  //
653  NekDouble fac;
654  for(int j = 0; j < nmodes; ++j)
655  {
656  //to filter out only the "high-modes"
657  if(j > Pcut)
658  {
659  fac = (NekDouble) (j - Pcut) / ( (NekDouble) (P - Pcut) );
660  fac = pow(fac, exponent);
661  orthocoeffs[j] *= exp(-alpha*fac);
662  }
663  }
664 
665  // backward transform to physical space
666  OrthoExp.BwdTrans(orthocoeffs,array);
667  }
668 
669  //up to here
671  const Array<OneD, const NekDouble> &inarray,
672  Array<OneD, NekDouble> &outarray)
673  {
674  int nquad0 = m_base[0]->GetNumPoints();
675 
676  const Array<OneD, const NekDouble>& w0 = m_base[0]->GetW();
677 
678  Vmath::Vmul(nquad0, inarray.get(),1,
679  w0.get(),1,outarray.get(),1);
680  }
681 
683  Array<OneD, NekDouble> &coords_0,
684  Array<OneD, NekDouble> &coords_1,
685  Array<OneD, NekDouble> &coords_2)
686  {
687  boost::ignore_unused(coords_1, coords_2);
688  Blas::Dcopy(GetNumPoints(0),(m_base[0]->GetZ()).get(),
689  1,&coords_0[0],1);
690  }
691 
692 
693 
694 
695 
696  //---------------------------------------------------------------------
697  // Helper functions
698  //---------------------------------------------------------------------
699 
701  {
702  return 2;
703  }
704 
706  {
707  return 2;
708  }
709 
710  int StdSegExp::v_GetTraceNcoeffs(const int i) const
711  {
712  boost::ignore_unused(i);
713  return 1;
714  }
715 
716  int StdSegExp::v_GetTraceNumPoints(const int i) const
717  {
718  boost::ignore_unused(i);
719  return 1;
720  }
721 
723  {
724  return 2;
725  }
726 
728  {
729  return 2;
730  }
731 
733  const std::vector<unsigned int> &nummodes,
734  int &modes_offset)
735  {
736  int nmodes = nummodes[modes_offset];
737  modes_offset += 1;
738 
739  return nmodes;
740  }
741 
742  //---------------------------------------------------------------------
743  // Wrapper functions
744  //---------------------------------------------------------------------
745 
747  {
748  DNekMatSharedPtr Mat;
749  MatrixType mattype;
750 
751  switch(mattype = mkey.GetMatrixType())
752  {
754  {
755  int nq = m_base[0]->GetNumPoints();
756 
757  // take definition from key
759  {
760  nq = (int) mkey.GetConstFactor(eFactorConst);
761  }
762 
765  Array<OneD, NekDouble > coords (1);
766  DNekMatSharedPtr I ;
768  AllocateSharedPtr(neq, nq);
769 
770  for(int i = 0; i < neq; ++i)
771  {
772  coords[0] = -1.0 + 2*i/(NekDouble)(neq-1);
773  I = m_base[0]->GetI(coords);
774  Vmath::Vcopy(nq, I->GetRawPtr(), 1,
775  Mat->GetRawPtr()+i,neq);
776  }
777  }
778  break;
779  case eFwdTrans:
780  {
782  StdMatrixKey iprodkey(eIProductWRTBase,v_DetShapeType(),*this);
783  DNekMat &Iprod = *GetStdMatrix(iprodkey);
784  StdMatrixKey imasskey(eInvMass,v_DetShapeType(),*this);
785  DNekMat &Imass = *GetStdMatrix(imasskey);
786 
787  (*Mat) = Imass*Iprod;
788  }
789  break;
790  default:
791  {
793 
794  if(mattype == eMass)
795  {
796  // For Fourier basis set the imaginary component
797  // of mean mode to have a unit diagonal component
798  // in mass matrix
800  {
801  (*Mat)(1,1) = 1.0;
802  }
803  }
804  }
805  break;
806  }
807 
808  return Mat;
809  }
810 
811 
813  {
814  return v_GenMatrix(mkey);
815  }
816 
817  //---------------------------------------------------------------------
818  // Mappings
819  //---------------------------------------------------------------------
820 
821 
823  {
824  if(outarray.size() != NumBndryCoeffs())
825  {
827  }
828  const LibUtilities::BasisType Btype = GetBasisType(0);
829  int nummodes = m_base[0]->GetNumModes();
830 
831  outarray[0] = 0;
832 
833  switch(Btype)
834  {
839  outarray[1]= nummodes-1;
840  break;
843  outarray[1] = 1;
844  break;
845  default:
846  ASSERTL0(0,"Mapping array is not defined for this expansion");
847  break;
848  }
849  }
850 
852  {
853  int i;
854  if(outarray.size()!=GetNcoeffs()-NumBndryCoeffs())
855  {
857  }
858  const LibUtilities::BasisType Btype = GetBasisType(0);
859 
860  switch(Btype)
861  {
866  for(i = 0 ; i < GetNcoeffs()-2;i++)
867  {
868  outarray[i] = i+1;
869  }
870  break;
873  for(i = 0 ; i < GetNcoeffs()-2;i++)
874  {
875  outarray[i] = i+2;
876  }
877  break;
878  default:
879  ASSERTL0(0,"Mapping array is not defined for this expansion");
880  break;
881  }
882  }
883 
884  int StdSegExp::v_GetVertexMap(int localVertexId,bool useCoeffPacking)
885  {
886  boost::ignore_unused(useCoeffPacking);
887  ASSERTL0((localVertexId==0)||(localVertexId==1),"local vertex id"
888  "must be between 0 or 1");
889 
890  int localDOF = localVertexId;
891 
893  (localVertexId==1) )
894  {
895  localDOF = m_base[0]->GetNumModes()-1;
896  }
897  return localDOF;
898  }
899 
901  Array<OneD, int> &conn,
902  bool standard)
903  {
904  boost::ignore_unused(standard);
905  int np = m_base[0]->GetNumPoints();
906 
907  conn = Array<OneD, int>(2*(np-1));
908  int cnt = 0;
909  for(int i = 0; i < np-1; ++i)
910  {
911  conn[cnt++] = i;
912  conn[cnt++] = i+1;
913  }
914  }
915 
917  const int tid,
918  Array<OneD, unsigned int>& maparray,
919  Array<OneD, int>& signarray,
920  Orientation orient,
921  int P, int Q)
922  {
923  boost::ignore_unused(P,Q,orient);
924  int order0 = m_base[0]->GetNumModes();
925 
926  ASSERTL0(tid < 2,"eid must be between 0 and 1");
927 
928  if (maparray.size() != 2)
929  {
930  maparray = Array<OneD, unsigned int>(2);
931  }
932 
933  if(signarray.size() != 2)
934  {
935  signarray = Array<OneD, int>(2, 1);
936  }
937  else
938  {
939  fill(signarray.get(), signarray.get()+2, 1);
940  }
941 
942  const LibUtilities::BasisType bType = GetBasisType(0);
943 
944  if (bType == LibUtilities::eModified_A)
945  {
946  maparray[0] = 0;
947  maparray[1] = 1;
948  }
949  else if(bType == LibUtilities::eGLL_Lagrange ||
951  {
952  maparray[0] = 0;
953  maparray[1] = order0-1;
954  }
955  else
956  {
957  ASSERTL0(false,"Unknown Basis");
958  }
959  }
960 
961  }//end namespace
962 }//end namespace
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:250
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed to...
Definition: ErrorUtil.hpp:274
Describes the specification for a Basis.
Definition: Basis.h:50
Defines a specification for a set of points.
Definition: Points.h:60
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.
The base class for all shapes.
Definition: StdExpansion.h:63
int GetNcoeffs(void) const
This function returns the total number of coefficients used in the expansion.
Definition: StdExpansion.h:124
LibUtilities::BasisType GetBasisType(const int dir) const
This function returns the type of basis used in the dir direction.
Definition: StdExpansion.h:158
DNekMatSharedPtr GetStdMatrix(const StdMatrixKey &mkey)
Definition: StdExpansion.h:617
void MassMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdMatrixKey &mkey)
Definition: StdExpansion.h:762
int GetVertexMap(const int localVertexId, bool useCoeffPacking=false)
Definition: StdExpansion.h:697
DNekMatSharedPtr CreateGeneralMatrix(const StdMatrixKey &mkey)
this function generates the mass matrix
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:433
LibUtilities::PointsType GetPointsType(const int dir) const
This function returns the type of quadrature points used in the dir direction.
Definition: StdExpansion.h:208
void FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
This function performs the Forward transformation from physical space to coefficient space.
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.
Definition: StdExpansion.h:221
Array< OneD, LibUtilities::BasisSharedPtr > m_base
MatrixType GetMatrixType() const
Definition: StdMatrixKey.h:81
NekDouble GetConstFactor(const ConstFactorType &factor) const
Definition: StdMatrixKey.h:121
bool ConstFactorExists(const ConstFactorType &factor) const
Definition: StdMatrixKey.h:130
Class representing a segment element in reference space.
Definition: StdSegExp.h:54
virtual int v_GetTraceNumPoints(const int i) const
Definition: StdSegExp.cpp:716
virtual void v_GetCoords(Array< OneD, NekDouble > &coords_0, Array< OneD, NekDouble > &coords_1, Array< OneD, NekDouble > &coords_2)
Definition: StdSegExp.cpp:682
virtual void v_ExponentialFilter(Array< OneD, NekDouble > &array, const NekDouble alpha, const NekDouble exponent, const NekDouble cutoff)
Definition: StdSegExp.cpp:629
virtual 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)
Definition: StdSegExp.cpp:176
virtual void v_FillMode(const int mode, Array< OneD, NekDouble > &outarray)
Definition: StdSegExp.cpp:528
virtual int v_GetNverts() const
Definition: StdSegExp.cpp:700
virtual void v_FwdTrans_BndConstrained(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdSegExp.cpp:319
virtual void v_GetBoundaryMap(Array< OneD, unsigned int > &outarray)
Definition: StdSegExp.cpp:822
virtual void v_LocCoordToLocCollapsed(const Array< OneD, const NekDouble > &xi, Array< OneD, NekDouble > &eta)
Definition: StdSegExp.cpp:515
virtual void v_HelmholtzMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdMatrixKey &mkey)
Definition: StdSegExp.cpp:566
NekDouble v_PhysEvaluateBasis(const Array< OneD, const NekDouble > &coords, int mode) final
Definition: StdSegExp.cpp:539
virtual DNekMatSharedPtr v_CreateStdMatrix(const StdMatrixKey &mkey)
Definition: StdSegExp.cpp:812
virtual void v_GetTraceToElementMap(const int tid, Array< OneD, unsigned int > &maparray, Array< OneD, int > &signarray, Orientation edgeOrient, int P, int Q)
Definition: StdSegExp.cpp:916
virtual void v_IProductWRTBase_SumFac(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool multiplybyweights=true)
Definition: StdSegExp.cpp:484
virtual void v_PhysDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_d0, Array< OneD, NekDouble > &out_d1=NullNekDouble1DArray, Array< OneD, NekDouble > &out_d2=NullNekDouble1DArray)
Evaluate the derivative at the physical quadrature points given by inarray and return in outarray.
Definition: StdSegExp.cpp:156
virtual void v_LaplacianMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdMatrixKey &mkey)
Definition: StdSegExp.cpp:546
virtual void v_MultiplyByStdQuadratureMetric(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdSegExp.cpp:670
virtual int v_NumDGBndryCoeffs() const
Definition: StdSegExp.cpp:727
virtual int v_GetVertexMap(int localVertexId, bool useCoeffPacking=false)
Definition: StdSegExp.cpp:884
virtual LibUtilities::ShapeType v_DetShapeType() const
Return Shape of region, using ShapeType enum list. i.e. Segment.
Definition: StdSegExp.cpp:85
virtual void v_ReduceOrderCoeffs(int numMin, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdSegExp.cpp:243
StdSegExp()
Default constructor.
Definition: StdSegExp.cpp:50
virtual void v_LocCollapsedToLocCoord(const Array< OneD, const NekDouble > &eta, Array< OneD, NekDouble > &xi)
Definition: StdSegExp.cpp:522
virtual int v_GetNtraces() const
Definition: StdSegExp.cpp:705
virtual int v_NumBndryCoeffs() const
Definition: StdSegExp.cpp:722
virtual void v_BwdTrans_SumFac(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdSegExp.cpp:393
virtual NekDouble v_Integral(const Array< OneD, const NekDouble > &inarray)
Integrate the physical point list inarray over region and return the value.
Definition: StdSegExp.cpp:123
virtual void v_BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Backward transform from coefficient space given in inarray and evaluate at the physical quadrature po...
Definition: StdSegExp.cpp:223
virtual void v_FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Forward transform from physical quadrature space stored in inarray and evaluate the expansion coeffic...
Definition: StdSegExp.cpp:297
virtual void v_SVVLaplacianFilter(Array< OneD, NekDouble > &array, const StdMatrixKey &mkey)
Definition: StdSegExp.cpp:588
virtual DNekMatSharedPtr v_GenMatrix(const StdMatrixKey &mkey)
Definition: StdSegExp.cpp:746
virtual void v_IProductWRTDerivBase(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdSegExp.cpp:474
virtual bool v_IsBoundaryInteriorExpansion()
Definition: StdSegExp.cpp:90
virtual void v_GetInteriorMap(Array< OneD, unsigned int > &outarray)
Definition: StdSegExp.cpp:851
virtual void v_IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Inner product of inarray over region with respect to the expansion basis (this)->m_base[0] and return...
Definition: StdSegExp.cpp:468
virtual int v_GetTraceNcoeffs(const int i) const
Definition: StdSegExp.cpp:710
virtual void v_GetSimplexEquiSpacedConnectivity(Array< OneD, int > &conn, bool standard=true)
Definition: StdSegExp.cpp:900
virtual int v_CalcNumberOfCoefficients(const std::vector< unsigned int > &nummodes, int &modes_offset)
Definition: StdSegExp.cpp:732
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 = A x where A[m x n].
Definition: Blas.hpp:265
static void Dcopy(const int &n, const double *x, const int &incx, double *y, const int &incy)
BLAS level 1: Copy x to y.
Definition: Blas.hpp:160
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:167
void InterpCoeff1D(const BasisKey &fbasis0, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, Array< OneD, NekDouble > &to)
Definition: InterpCoeff.cpp:46
@ 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:55
@ eOrtho_A
Principle Orthogonal Functions .
Definition: BasisType.h:45
@ eGLL_Lagrange
Lagrange for SEM basis .
Definition: BasisType.h:54
@ eChebyshev
Chebyshev Polynomials .
Definition: BasisType.h:57
@ eModified_A
Principle Modified Functions .
Definition: BasisType.h:48
@ eFourier
Fourier Expansion .
Definition: BasisType.h:53
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:69
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.cpp:192
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
Definition: Vmath.cpp:846
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:436
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1199
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.cpp:372
P
Definition: main.py:133