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.num_elements();
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  //----------------------------
515 
516  void StdSegExp::v_FillMode(const int mode, Array<OneD, NekDouble> &outarray)
517  {
518  int nquad = m_base[0]->GetNumPoints();
519  const NekDouble * base = m_base[0]->GetBdata().get();
520 
521  ASSERTL2(mode <= m_ncoeffs,
522  "calling argument mode is larger than total expansion order");
523 
524  Vmath::Vcopy(nquad,(NekDouble *)base+mode*nquad,1, &outarray[0],1);
525  }
526 
527 
529  const Array<OneD, const NekDouble>& coords,
530  const Array<OneD, const NekDouble>& physvals)
531  {
532  return StdExpansion1D::v_PhysEvaluate(coords, physvals);
533  }
534 
536  const Array<OneD, const NekDouble> &inarray,
537  Array<OneD, NekDouble> &outarray,
538  const StdMatrixKey &mkey)
539  {
540  boost::ignore_unused(mkey);
541 
542  int nquad = m_base[0]->GetNumPoints();
543 
544  Array<OneD,NekDouble> physValues(nquad);
545  Array<OneD,NekDouble> dPhysValuesdx(nquad);
546 
547  v_BwdTrans(inarray,physValues);
548 
549  // Laplacian matrix operation
550  v_PhysDeriv(physValues,dPhysValuesdx);
551  v_IProductWRTBase(m_base[0]->GetDbdata(),dPhysValuesdx,outarray,1);
552  }
553 
554 
556  const Array<OneD, const NekDouble> &inarray,
557  Array<OneD, NekDouble> &outarray,
558  const StdMatrixKey &mkey)
559  {
560  int nquad = m_base[0]->GetNumPoints();
561 
562  Array<OneD,NekDouble> physValues(nquad);
563  Array<OneD,NekDouble> dPhysValuesdx(nquad);
565 
566  v_BwdTrans(inarray,physValues);
567 
568  // mass matrix operation
569  v_IProductWRTBase((m_base[0]->GetBdata()),physValues,wsp,1);
570 
571  // Laplacian matrix operation
572  v_PhysDeriv(physValues,dPhysValuesdx);
573  v_IProductWRTBase(m_base[0]->GetDbdata(),dPhysValuesdx,outarray,1);
574  Blas::Daxpy(m_ncoeffs, mkey.GetConstFactor(eFactorLambda), wsp.get(), 1, outarray.get(), 1);
575  }
576 
578  const StdMatrixKey &mkey)
579  {
580  // Generate an orthogonal expansion
581  int nq = m_base[0]->GetNumPoints();
582  int nmodes = m_base[0]->GetNumModes();
583  // Declare orthogonal basis.
585 
587  StdSegExp OrthoExp(B);
588 
589  //SVV parameters loaded from the .xml case file
590  NekDouble SvvDiffCoeff = mkey.GetConstFactor(eFactorSVVDiffCoeff);
591  int cutoff = (int) (mkey.GetConstFactor(eFactorSVVCutoffRatio))*nmodes;
592 
593  Array<OneD, NekDouble> orthocoeffs(OrthoExp.GetNcoeffs());
594 
595  // project onto modal space.
596  OrthoExp.FwdTrans(array,orthocoeffs);
597 
598  //
599  for(int j = 0; j < nmodes; ++j)
600  {
601  if(j >= cutoff)//to filter out only the "high-modes"
602  {
603  orthocoeffs[j] *=
604  (SvvDiffCoeff*exp(-(j-nmodes)*(j-nmodes)/
605  ((NekDouble)((j-cutoff+1)*
606  (j-cutoff+1)))));
607  }
608  else
609  {
610  orthocoeffs[j] *= 0.0;
611  }
612  }
613 
614  // backward transform to physical space
615  OrthoExp.BwdTrans(orthocoeffs,array);
616  }
617 
619  Array<OneD, NekDouble> &array,
620  const NekDouble alpha,
621  const NekDouble exponent,
622  const NekDouble cutoff)
623  {
624  // Generate an orthogonal expansion
625  int nq = m_base[0]->GetNumPoints();
626  int nmodes = m_base[0]->GetNumModes();
627  int P = nmodes - 1;
628  // Declare orthogonal basis.
630 
632  StdSegExp OrthoExp(B);
633 
634  // Cutoff
635  int Pcut = cutoff*P;
636 
637  // Project onto orthogonal space.
638  Array<OneD, NekDouble> orthocoeffs(OrthoExp.GetNcoeffs());
639  OrthoExp.FwdTrans(array,orthocoeffs);
640 
641  //
642  NekDouble fac;
643  for(int j = 0; j < nmodes; ++j)
644  {
645  //to filter out only the "high-modes"
646  if(j > Pcut)
647  {
648  fac = (NekDouble) (j - Pcut) / ( (NekDouble) (P - Pcut) );
649  fac = pow(fac, exponent);
650  orthocoeffs[j] *= exp(-alpha*fac);
651  }
652  }
653 
654  // backward transform to physical space
655  OrthoExp.BwdTrans(orthocoeffs,array);
656  }
657 
658  //up to here
660  const Array<OneD, const NekDouble> &inarray,
661  Array<OneD, NekDouble> &outarray)
662  {
663  int nquad0 = m_base[0]->GetNumPoints();
664 
665  const Array<OneD, const NekDouble>& w0 = m_base[0]->GetW();
666 
667  Vmath::Vmul(nquad0, inarray.get(),1,
668  w0.get(),1,outarray.get(),1);
669  }
670 
672  Array<OneD, NekDouble> &coords_0,
673  Array<OneD, NekDouble> &coords_1,
674  Array<OneD, NekDouble> &coords_2)
675  {
676  boost::ignore_unused(coords_1, coords_2);
677  Blas::Dcopy(GetNumPoints(0),(m_base[0]->GetZ()).get(),
678  1,&coords_0[0],1);
679  }
680 
681 
682 
683 
684 
685  //---------------------------------------------------------------------
686  // Helper functions
687  //---------------------------------------------------------------------
688 
690  {
691  return 2;
692  }
693 
695  {
696  return 2;
697  }
698 
700  {
701  return 2;
702  }
703 
705  const std::vector<unsigned int> &nummodes,
706  int &modes_offset)
707  {
708  int nmodes = nummodes[modes_offset];
709  modes_offset += 1;
710 
711  return nmodes;
712  }
713 
714  //---------------------------------------------------------------------
715  // Wrapper functions
716  //---------------------------------------------------------------------
717 
719  {
720  DNekMatSharedPtr Mat;
721  MatrixType mattype;
722 
723  switch(mattype = mkey.GetMatrixType())
724  {
726  {
727  int nq = m_base[0]->GetNumPoints();
728 
729  // take definition from key
731  {
732  nq = (int) mkey.GetConstFactor(eFactorConst);
733  }
734 
737  Array<OneD, NekDouble > coords (1);
738  DNekMatSharedPtr I ;
740  AllocateSharedPtr(neq, nq);
741 
742  for(int i = 0; i < neq; ++i)
743  {
744  coords[0] = -1.0 + 2*i/(NekDouble)(neq-1);
745  I = m_base[0]->GetI(coords);
746  Vmath::Vcopy(nq, I->GetRawPtr(), 1,
747  Mat->GetRawPtr()+i,neq);
748  }
749  }
750  break;
751  case eFwdTrans:
752  {
754  StdMatrixKey iprodkey(eIProductWRTBase,v_DetShapeType(),*this);
755  DNekMat &Iprod = *GetStdMatrix(iprodkey);
756  StdMatrixKey imasskey(eInvMass,v_DetShapeType(),*this);
757  DNekMat &Imass = *GetStdMatrix(imasskey);
758 
759  (*Mat) = Imass*Iprod;
760  }
761  break;
762  default:
763  {
765 
766  if(mattype == eMass)
767  {
768  // For Fourier basis set the imaginary component
769  // of mean mode to have a unit diagonal component
770  // in mass matrix
772  {
773  (*Mat)(1,1) = 1.0;
774  }
775  }
776  }
777  break;
778  }
779 
780  return Mat;
781  }
782 
783 
785  {
786  return v_GenMatrix(mkey);
787  }
788 
789  //---------------------------------------------------------------------
790  // Mappings
791  //---------------------------------------------------------------------
792 
793 
795  {
796  if(outarray.num_elements() != NumBndryCoeffs())
797  {
799  }
800  const LibUtilities::BasisType Btype = GetBasisType(0);
801  int nummodes = m_base[0]->GetNumModes();
802 
803  outarray[0] = 0;
804 
805  switch(Btype)
806  {
811  outarray[1]= nummodes-1;
812  break;
815  outarray[1] = 1;
816  break;
817  default:
818  ASSERTL0(0,"Mapping array is not defined for this expansion");
819  break;
820  }
821  }
822 
824  {
825  int i;
826  if(outarray.num_elements()!=GetNcoeffs()-NumBndryCoeffs())
827  {
829  }
830  const LibUtilities::BasisType Btype = GetBasisType(0);
831 
832  switch(Btype)
833  {
838  for(i = 0 ; i < GetNcoeffs()-2;i++)
839  {
840  outarray[i] = i+1;
841  }
842  break;
845  for(i = 0 ; i < GetNcoeffs()-2;i++)
846  {
847  outarray[i] = i+2;
848  }
849  break;
850  default:
851  ASSERTL0(0,"Mapping array is not defined for this expansion");
852  break;
853  }
854  }
855 
856  int StdSegExp::v_GetVertexMap(int localVertexId,bool useCoeffPacking)
857  {
858  boost::ignore_unused(useCoeffPacking);
859  ASSERTL0((localVertexId==0)||(localVertexId==1),"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,
874  bool standard)
875  {
876  boost::ignore_unused(standard);
877  int np = m_base[0]->GetNumPoints();
878 
879  conn = Array<OneD, int>(2*(np-1));
880  int cnt = 0;
881  for(int i = 0; i < np-1; ++i)
882  {
883  conn[cnt++] = i;
884  conn[cnt++] = i+1;
885  }
886  }
887 
888  }//end namespace
889 }//end namespace
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_IProductWRTDerivBase(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdSegExp.cpp:474
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
virtual void v_GetBoundaryMap(Array< OneD, unsigned int > &outarray)
Definition: StdSegExp.cpp:794
virtual void v_ExponentialFilter(Array< OneD, NekDouble > &array, const NekDouble alpha, const NekDouble exponent, const NekDouble cutoff)
Definition: StdSegExp.cpp:618
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_GetCoords(Array< OneD, NekDouble > &coords_0, Array< OneD, NekDouble > &coords_1, Array< OneD, NekDouble > &coords_2)
Definition: StdSegExp.cpp:671
void MassMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdMatrixKey &mkey)
Definition: StdExpansion.h:974
int GetNumPoints(const int dir) const
This function returns the number of quadrature points in the dir direction.
Definition: StdExpansion.h:228
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 int v_GetNverts() const
Definition: StdSegExp.cpp:689
virtual void v_BwdTrans_SumFac(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdSegExp.cpp:393
void InterpCoeff1D(const BasisKey &fbasis0, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, Array< OneD, NekDouble > &to)
Definition: InterpCoeff.cpp:46
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
Principle Modified Functions .
Definition: BasisType.h:48
Lagrange Polynomials using the Gauss points .
Definition: BasisType.h:55
STL namespace.
virtual void v_FillMode(const int mode, Array< OneD, NekDouble > &outarray)
Definition: StdSegExp.cpp:516
StdSegExp()
Default constructor.
Definition: StdSegExp.cpp:50
Fourier Expansion .
Definition: BasisType.h:53
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:69
Chebyshev Polynomials .
Definition: BasisType.h:57
LibUtilities::NekManager< StdMatrixKey, DNekBlkMat, StdMatrixKey::opLess > m_stdStaticCondMatrixManager
MatrixType GetMatrixType() const
Definition: StdMatrixKey.h:81
DNekMatSharedPtr GetStdMatrix(const StdMatrixKey &mkey)
Definition: StdExpansion.h:714
virtual bool v_IsBoundaryInteriorExpansion()
Definition: StdSegExp.cpp:90
virtual LibUtilities::ShapeType v_DetShapeType() const
Return Shape of region, using ShapeType enum list. i.e. Segment.
Definition: StdSegExp.cpp:85
virtual int v_GetVertexMap(int localVertexId, bool useCoeffPacking=false)
Definition: StdSegExp.cpp:856
virtual int v_CalcNumberOfCoefficients(const std::vector< unsigned int > &nummodes, int &modes_offset)
Definition: StdSegExp.cpp:704
virtual void v_SVVLaplacianFilter(Array< OneD, NekDouble > &array, const StdMatrixKey &mkey)
Definition: StdSegExp.cpp:577
virtual int v_NumDGBndryCoeffs() const
Definition: StdSegExp.cpp:699
virtual int v_NumBndryCoeffs() const
Definition: StdSegExp.cpp:694
Class representing a segment element in reference space.
Definition: StdSegExp.h:53
The base class for all shapes.
Definition: StdExpansion.h:68
int GetVertexMap(const int localVertexId, bool useCoeffPacking=false)
Definition: StdExpansion.h:822
virtual DNekMatSharedPtr v_GenMatrix(const StdMatrixKey &mkey)
Definition: StdSegExp.cpp:718
Principle Modified Functions .
Definition: BasisType.h:49
virtual DNekMatSharedPtr v_CreateStdMatrix(const StdMatrixKey &mkey)
Definition: StdSegExp.cpp:784
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
DNekMatSharedPtr CreateGeneralMatrix(const StdMatrixKey &mkey)
this function generates the mass matrix
Principle Orthogonal Functions .
Definition: BasisType.h:45
Defines a specification for a set of points.
Definition: Points.h:59
double NekDouble
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:168
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 NekDouble v_PhysEvaluate(const Array< OneD, const NekDouble > &Lcoords, const Array< OneD, const NekDouble > &physvals)
Definition: StdSegExp.cpp:528
NekDouble GetConstFactor(const ConstFactorType &factor) const
Definition: StdMatrixKey.h:121
int GetNcoeffs(void) const
This function returns the total number of coefficients used in the expansion.
Definition: StdExpansion.h:130
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:346
LibUtilities::PointsType GetPointsType(const int dir) const
This function returns the type of quadrature points used in the dir direction.
Definition: StdExpansion.h:215
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...
bool ConstFactorExists(const ConstFactorType &factor) const
Definition: StdMatrixKey.h:130
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
Definition: ErrorUtil.hpp:274
LibUtilities::BasisType GetBasisType(const int dir) const
This function returns the type of basis used in the dir direction.
Definition: StdExpansion.h:164
virtual void v_HelmholtzMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdMatrixKey &mkey)
Definition: StdSegExp.cpp:555
virtual void v_FwdTrans_BndConstrained(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdSegExp.cpp:319
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:530
virtual void v_MultiplyByStdQuadratureMetric(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdSegExp.cpp:659
virtual void v_ReduceOrderCoeffs(int numMin, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdSegExp.cpp:243
virtual void v_GetSimplexEquiSpacedConnectivity(Array< OneD, int > &conn, bool standard=true)
Definition: StdSegExp.cpp:872
Lagrange for SEM basis .
Definition: BasisType.h:54
T Vsum(int n, const T *x, const int incx)
Subtract return sum(x)
Definition: Vmath.cpp:740
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:376
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:250
Array< OneD, LibUtilities::BasisSharedPtr > m_base
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:110
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1064
virtual void v_LaplacianMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdMatrixKey &mkey)
Definition: StdSegExp.cpp:535
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:103
Describes the specification for a Basis.
Definition: Basis.h:49
virtual NekDouble v_PhysEvaluate(const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &physvals)
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:51
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
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:186
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_GetInteriorMap(Array< OneD, unsigned int > &outarray)
Definition: StdSegExp.cpp:823
void FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
This function performs the Forward transformation from physical space to coefficient space...