Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SegExp.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File SegExp.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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: SegExp routines
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 #include <LocalRegions/SegExp.h>
39 
40 
41 namespace Nektar
42 {
43  namespace LocalRegions
44  {
45 
46  /**
47  * @class SegExp
48  * Defines a Segment local expansion.
49  */
50 
51  /// Constructor using BasisKey class for quadrature points and
52  /// order definition.
53  /**
54  * @param Ba Basis key of segment expansion.
55  * @param geom Description of geometry.
56  */
59  StdExpansion(Ba.GetNumModes(), 1, Ba),
60  StdExpansion1D(Ba.GetNumModes(), Ba),
61  StdRegions::StdSegExp(Ba),
62  Expansion(geom),
63  Expansion1D(geom),
64  m_matrixManager(
65  boost::bind(&SegExp::CreateMatrix, this, _1),
66  std::string("SegExpMatrix")),
67  m_staticCondMatrixManager(
68  boost::bind(&SegExp::CreateStaticCondMatrix, this, _1),
69  std::string("SegExpStaticCondMatrix"))
70  {
71  }
72 
73 
74  /// Copy Constructor
75  /**
76  * @param S Existing segment to duplicate.
77  */
79  StdExpansion(S),
80  StdExpansion1D(S),
81  StdRegions::StdSegExp(S),
82  Expansion(S),
83  Expansion1D(S),
84  m_matrixManager(S.m_matrixManager),
85  m_staticCondMatrixManager(S.m_staticCondMatrixManager)
86  {
87  }
88 
89 
90  /**
91  *
92  */
94  {
95  }
96 
97 
98  //----------------------------
99  // Integration Methods
100  //----------------------------
101 
102  /** \brief Integrate the physical point list \a inarray over region
103  and return the value
104 
105  Inputs:\n
106 
107  - \a inarray: definition of function to be returned at
108  quadrature point of expansion.
109 
110  Outputs:\n
111 
112  - returns \f$\int^1_{-1} u(\xi_1)d \xi_1 \f$ where \f$inarray[i]
113  = u(\xi_{1i}) \f$
114  */
115 
117  const Array<OneD, const NekDouble>& inarray)
118  {
119  int nquad0 = m_base[0]->GetNumPoints();
121  NekDouble ival;
122  Array<OneD,NekDouble> tmp(nquad0);
123 
124  // multiply inarray with Jacobian
125  if(m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
126  {
127  Vmath::Vmul(nquad0, jac, 1, inarray, 1, tmp,1);
128  }
129  else
130  {
131  Vmath::Smul(nquad0, jac[0], inarray, 1, tmp, 1);
132  }
133 
134  // call StdSegExp version;
135  ival = StdSegExp::v_Integral(tmp);
136  //ival = StdSegExp::Integral(tmp);
137  return ival;
138  }
139 
140  //-----------------------------
141  // Differentiation Methods
142  //-----------------------------
143 
144  /** \brief Evaluate the derivative \f$ d/d{\xi_1} \f$ at the
145  physical quadrature points given by \a inarray and return in \a
146  outarray.
147 
148  This is a wrapper around StdExpansion1D::Tensor_Deriv
149 
150  Input:\n
151 
152  - \a n: number of derivatives to be evaluated where \f$ n \leq dim\f$
153 
154  - \a inarray: array of function evaluated at the quadrature points
155 
156  Output: \n
157 
158  - \a outarray: array of the derivatives \f$
159  du/d_{\xi_1}|_{\xi_{1i}} d\xi_1/dx,
160  du/d_{\xi_1}|_{\xi_{1i}} d\xi_1/dy,
161  du/d_{\xi_1}|_{\xi_{1i}} d\xi_1/dz,
162  \f$ depending on value of \a dim
163  */
165  const Array<OneD, const NekDouble>& inarray,
166  Array<OneD,NekDouble> &out_d0,
167  Array<OneD,NekDouble> &out_d1,
168  Array<OneD,NekDouble> &out_d2)
169  {
170  int nquad0 = m_base[0]->GetNumPoints();
172  m_metricinfo->GetDerivFactors(GetPointsKeys());
173  Array<OneD,NekDouble> diff(nquad0);
174 
175  //StdExpansion1D::PhysTensorDeriv(inarray,diff);
176  PhysTensorDeriv(inarray,diff);
177  if(m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
178  {
179  if(out_d0.num_elements())
180  {
181  Vmath::Vmul(nquad0,&gmat[0][0],1,&diff[0],1,
182  &out_d0[0],1);
183  }
184 
185  if(out_d1.num_elements())
186  {
187  Vmath::Vmul(nquad0,&gmat[1][0],1,&diff[0],1,
188  &out_d1[0],1);
189  }
190 
191  if(out_d2.num_elements())
192  {
193  Vmath::Vmul(nquad0,&gmat[2][0],1,&diff[0],1,
194  &out_d2[0],1);
195  }
196  }
197  else
198  {
199  if(out_d0.num_elements())
200  {
201  Vmath::Smul(nquad0, gmat[0][0], diff, 1,
202  out_d0, 1);
203  }
204 
205  if(out_d1.num_elements())
206  {
207  Vmath::Smul(nquad0, gmat[1][0], diff, 1,
208  out_d1, 1);
209  }
210 
211  if(out_d2.num_elements())
212  {
213  Vmath::Smul(nquad0, gmat[2][0], diff, 1,
214  out_d2, 1);
215  }
216  }
217  }
218 
219  /**
220  *\brief Evaluate the derivative along a line:
221  * \f$ d/ds=\frac{spacedim}{||tangent||}d/d{\xi} \f$.
222  * The derivative is calculated performing
223  *the product \f$ du/d{s}=\nabla u \cdot tangent \f$.
224  *\param inarray function to derive
225  *\param out_ds result of the derivative operation
226  **/
228  const Array<OneD, const NekDouble>& inarray,
229  Array<OneD,NekDouble> &out_ds)
230  {
231  int nquad0 = m_base[0]->GetNumPoints();
232  int coordim = m_geom->GetCoordim();
233  Array<OneD, NekDouble> diff (nquad0);
234  //this operation is needed if you put out_ds==inarray
235  Vmath::Zero(nquad0,out_ds,1);
236  switch(coordim)
237  {
238  case 2:
239  //diff= dU/de
240  Array<OneD,NekDouble> diff(nquad0);
241 
242  PhysTensorDeriv(inarray,diff);
243 
244  //get dS/de= (Jac)^-1
246  if(m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
247  {
248  //calculate the derivative as (dU/de)*(Jac)^-1
249  Vmath::Vdiv(nquad0,diff,1,Jac ,1,out_ds,1);
250  }
251  else
252  {
253  NekDouble invJac = 1/Jac[0];
254  Vmath::Smul(nquad0, invJac,diff,1,out_ds,1);
255  }
256  }
257  }
258 
259  /**
260  *\brief Evaluate the derivative normal to a line:
261  * \f$ d/dn=\frac{spacedim}{||normal||}d/d{\xi} \f$.
262  * The derivative is calculated performing
263  *the product \f$ du/d{s}=\nabla u \cdot normal \f$.
264  *\param inarray function to derive
265  *\param out_dn result of the derivative operation
266  **/
268  const Array<OneD, const NekDouble>& inarray,
269  Array<OneD, NekDouble>& out_dn)
270  {
271  int nquad0 = m_base[0]->GetNumPoints();
273  m_metricinfo->GetDerivFactors(GetPointsKeys());
274  int coordim = m_geom->GetCoordim();
275  Array<OneD, NekDouble> out_dn_tmp(nquad0,0.0);
276  switch(coordim)
277  {
278  case 2:
279 
280  Array<OneD, NekDouble> inarray_d0(nquad0);
281  Array<OneD, NekDouble> inarray_d1(nquad0);
282 
283  v_PhysDeriv(inarray,inarray_d0,inarray_d1);
285  normals = Array<OneD, Array<OneD, NekDouble> >(coordim);
286  cout<<"der_n"<<endl;
287  for(int k=0; k<coordim; ++k)
288  {
289  normals[k]= Array<OneD, NekDouble>(nquad0);
290  }
291 // @TODO: this routine no longer makes sense, since normals are not unique on
292 // an edge
293 // normals = GetMetricInfo()->GetNormal();
294  for(int i=0; i<nquad0; i++)
295  {
296 cout<<"nx= "<<normals[0][i]<<" ny="<<normals[1][i]<<endl;
297  }
299  "normal vectors do not exist: check if a"
300  "boundary region is defined as I ");
301  // \nabla u \cdot normal
302  Vmath::Vmul(nquad0,normals[0],1,inarray_d0,1,out_dn_tmp,1);
303  Vmath::Vadd(nquad0,out_dn_tmp,1,out_dn,1,out_dn,1);
304  Vmath::Zero(nquad0,out_dn_tmp,1);
305  Vmath::Vmul(nquad0,normals[1],1,inarray_d1,1,out_dn_tmp,1);
306  Vmath::Vadd(nquad0,out_dn_tmp,1,out_dn,1,out_dn,1);
307 
308  for(int i=0; i<nquad0; i++)
309  {
310 cout<<"deps/dx ="<<inarray_d0[i]<<" deps/dy="<<inarray_d1[i]<<endl;
311  }
312 
313 
314  }
315 
316  }
317  void SegExp::v_PhysDeriv(const int dir,
318  const Array<OneD, const NekDouble>& inarray,
319  Array<OneD, NekDouble> &outarray)
320  {
321  switch(dir)
322  {
323  case 0:
324  {
325  PhysDeriv(inarray, outarray, NullNekDouble1DArray,
327  }
328  break;
329  case 1:
330  {
331  PhysDeriv(inarray, NullNekDouble1DArray, outarray,
333  }
334  break;
335  case 2:
336  {
338  NullNekDouble1DArray, outarray);
339  }
340  break;
341  default:
342  {
343  ASSERTL1(false,"input dir is out of range");
344  }
345  break;
346  }
347  }
348 
349 
350  //-----------------------------
351  // Transforms
352  //-----------------------------
353 
354  /** \brief Forward transform from physical quadrature space
355  stored in \a inarray and evaluate the expansion coefficients and
356  store in \a outarray
357 
358  Perform a forward transform using a Galerkin projection by
359  taking the inner product of the physical points and multiplying
360  by the inverse of the mass matrix using the Solve method of the
361  standard matrix container holding the local mass matrix, i.e.
362  \f$ {\bf \hat{u}} = {\bf M}^{-1} {\bf I} \f$ where \f$ {\bf I}[p] =
363  \int^1_{-1} \phi_p(\xi_1) u(\xi_1) d\xi_1 \f$
364 
365  Inputs:\n
366 
367  - \a inarray: array of physical quadrature points to be transformed
368 
369  Outputs:\n
370 
371  - \a outarray: updated array of expansion coefficients.
372 
373  */
374  // need to sort out family of matrices
376  const Array<OneD, const NekDouble>& inarray,
377  Array<OneD,NekDouble> &outarray)
378  {
379  if (m_base[0]->Collocation())
380  {
381  Vmath::Vcopy(m_ncoeffs, inarray, 1, outarray, 1);
382  }
383  else
384  {
385  v_IProductWRTBase(inarray,outarray);
386 
387  // get Mass matrix inverse
388  MatrixKey masskey(StdRegions::eInvMass, DetShapeType(), *this);
389  DNekScalMatSharedPtr matsys = m_matrixManager[masskey];
390 
391  // copy inarray in case inarray == outarray
392  NekVector<NekDouble> in(m_ncoeffs,outarray,eCopy);
394 
395  out = (*matsys)*in;
396  }
397  }
398 
400  const Array<OneD, const NekDouble>& inarray,
401  Array<OneD, NekDouble> &outarray)
402  {
403  if(m_base[0]->Collocation())
404  {
405  Vmath::Vcopy(m_ncoeffs, inarray, 1, outarray, 1);
406  }
407  else
408  {
409  int nInteriorDofs = m_ncoeffs-2;
410  int offset;
411 
412  switch (m_base[0]->GetBasisType())
413  {
415  {
416  offset = 1;
417  }
418  break;
420  {
421  nInteriorDofs = m_ncoeffs;
422  offset = 0;
423  }
424  break;
427  {
428  ASSERTL1(m_base[0]->GetPointsType() == LibUtilities::eGaussLobattoLegendre,"Cannot use FwdTrans_BndConstrained method with non GLL points");
429  offset = 2;
430  }
431  break;
432  default:
433  ASSERTL0(false,"This type of FwdTrans is not defined"
434  "for this expansion type");
435  }
436 
437  fill(outarray.get(), outarray.get()+m_ncoeffs, 0.0 );
438 
440  {
441 
442  outarray[GetVertexMap(0)] = inarray[0];
443  outarray[GetVertexMap(1)] =
444  inarray[m_base[0]->GetNumPoints()-1];
445 
446  if (m_ncoeffs>2)
447  {
448  // ideally, we would like to have tmp0 to be replaced
449  // by outarray (currently MassMatrixOp does not allow
450  // aliasing)
453 
454  StdRegions::StdMatrixKey stdmasskey(
456  MassMatrixOp(outarray,tmp0,stdmasskey);
457  v_IProductWRTBase(inarray,tmp1);
458 
459  Vmath::Vsub(m_ncoeffs, tmp1, 1, tmp0, 1, tmp1, 1);
460 
461  // get Mass matrix inverse (only of interior DOF)
462  MatrixKey masskey(
464  DNekScalMatSharedPtr matsys =
465  (m_staticCondMatrixManager[masskey])->GetBlock(1,1);
466 
467  Blas::Dgemv('N',nInteriorDofs,nInteriorDofs,
468  matsys->Scale(),
469  &((matsys->GetOwnedMatrix())->GetPtr())[0],
470  nInteriorDofs,tmp1.get()+offset,1,0.0,
471  outarray.get()+offset,1);
472  }
473  }
474  else
475  {
476  SegExp::v_FwdTrans(inarray, outarray);
477 
478  }
479  }
480  }
481 
482 
483  //-----------------------------
484  // Inner product functions
485  //-----------------------------
486 
487  /** \brief Inner product of \a inarray over region with respect to
488  the expansion basis (this)->_Base[0] and return in \a outarray
489 
490  Wrapper call to SegExp::IProduct_WRT_B
491 
492  Input:\n
493 
494  - \a inarray: array of function evaluated at the physical
495  collocation points
496 
497  Output:\n
498 
499  - \a outarray: array of inner product with respect to each
500  basis over region
501  */
503  const Array<OneD, const NekDouble>& inarray,
504  Array<OneD, NekDouble> &outarray)
505  {
506  v_IProductWRTBase(m_base[0]->GetBdata(),inarray,outarray,1);
507  }
508 
509 
510  /**
511  \brief Inner product of \a inarray over region with respect to
512  expansion basis \a base and return in \a outarray
513 
514  Calculate \f$ I[p] = \int^{1}_{-1} \phi_p(\xi_1) u(\xi_1) d\xi_1
515  = \sum_{i=0}^{nq-1} \phi_p(\xi_{1i}) u(\xi_{1i}) w_i \f$ where
516  \f$ outarray[p] = I[p], inarray[i] = u(\xi_{1i}), base[p*nq+i] =
517  \phi_p(\xi_{1i}) \f$.
518 
519  Inputs: \n
520 
521  - \a base: an array definiing the local basis for the inner
522  product usually passed from Basis->get_bdata() or
523  Basis->get_Dbdata()
524  - \a inarray: physical point array of function to be integrated
525  \f$ u(\xi_1) \f$
526  - \a coll_check: Flag to identify when a Basis->collocation()
527  call should be performed to see if this is a GLL_Lagrange basis
528  with a collocation property. (should be set to 0 if taking the
529  inner product with respect to the derivative of basis)
530 
531  Output: \n
532 
533  - \a outarray: array of coefficients representing the inner
534  product of function with ever mode in the exapnsion
535 
536  **/
538  const Array<OneD, const NekDouble>& base,
539  const Array<OneD, const NekDouble>& inarray,
540  Array<OneD, NekDouble> &outarray,
541  int coll_check)
542  {
543  int nquad0 = m_base[0]->GetNumPoints();
545  Array<OneD,NekDouble> tmp(nquad0);
546 
547 
548  // multiply inarray with Jacobian
549  if(m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
550  {
551  Vmath::Vmul(nquad0, jac, 1, inarray, 1, tmp, 1);
552  }
553  else
554  {
555  Vmath::Smul(nquad0, jac[0], inarray, 1, tmp, 1);
556  }
557  StdSegExp::v_IProductWRTBase(base,tmp,outarray,coll_check);
558  }
559 
560 
562  const int dir,
563  const Array<OneD, const NekDouble>& inarray,
564  Array<OneD, NekDouble> & outarray)
565  {
566  int nquad = m_base[0]->GetNumPoints();
567  const Array<TwoD, const NekDouble>& gmat =
568  m_metricinfo->GetDerivFactors(GetPointsKeys());
569 
570  Array<OneD, NekDouble> tmp1(nquad);
571 
572  switch(dir)
573  {
574  case 0:
575  {
576  if(m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
577  {
578  Vmath::Vmul(nquad,gmat[0],1,inarray,1,tmp1,1);
579  }
580  else
581  {
582  Vmath::Smul(nquad, gmat[0][0], inarray, 1, tmp1, 1);
583  }
584  }
585  break;
586  case 1:
587  {
588  if(m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
589  {
590  Vmath::Vmul(nquad,gmat[1],1,inarray,1,tmp1,1);
591  }
592  else
593  {
594  Vmath::Smul(nquad, gmat[1][0], inarray, 1, tmp1, 1);
595  }
596  }
597  break;
598  case 2:
599  {
600  ASSERTL1(m_geom->GetCoordim() == 3,"input dir is out of range");
601  if(m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
602  {
603  Vmath::Vmul(nquad,gmat[2],1,inarray,1,tmp1,1);
604  }
605  else
606  {
607  Vmath::Smul(nquad, gmat[2][0], inarray, 1, tmp1, 1);
608  }
609  }
610  break;
611  default:
612  {
613  ASSERTL1(false,"input dir is out of range");
614  }
615  break;
616  }
617  v_IProductWRTBase(m_base[0]->GetDbdata(),tmp1,outarray,1);
618  }
619 
623  Array<OneD, NekDouble> &outarray)
624  {
625  int nq = m_base[0]->GetNumPoints();
627 // cout << "I am segment " << GetGeom()->GetGlobalID() << endl;
628 // cout << "I want edge " << GetLeftAdjacentElementEdge() << endl;
629 // @TODO: This routine no longer makes sense as a normal is not unique to an edge
631  &normals =
634  Vmath::Vmul (nq, &Fx[0], 1, &normals[0][0], 1, &Fn[0], 1);
635  Vmath::Vvtvp(nq, &Fy[0], 1, &normals[1][0], 1, &Fn[0], 1, &Fn[0], 1);
636 
637  v_IProductWRTBase(Fn,outarray);
638  }
639 
641  const Array<OneD, const Array<OneD, NekDouble> > &Fvec,
642  Array<OneD, NekDouble> &outarray)
643  {
644  NormVectorIProductWRTBase(Fvec[0], Fvec[1], outarray);
645  }
646 
647  //-----------------------------
648  // Evaluation functions
649  //-----------------------------
650 
651 
652  /**
653  * Given the local cartesian coordinate \a Lcoord evaluate the
654  * value of physvals at this point by calling through to the
655  * StdExpansion method
656  */
658  const Array<OneD, const NekDouble> &Lcoord,
659  const Array<OneD, const NekDouble> &physvals)
660  {
661  // Evaluate point in local (eta) coordinates.
662  return StdSegExp::v_PhysEvaluate(Lcoord,physvals);
663  }
664 
666  const Array<OneD, const NekDouble>& coord,
667  const Array<OneD, const NekDouble> &physvals)
668  {
670 
671  ASSERTL0(m_geom,"m_geom not defined");
672  m_geom->GetLocCoords(coord,Lcoord);
673 
674  return StdSegExp::v_PhysEvaluate(Lcoord, physvals);
675  }
676 
677 
679  const Array<OneD, const NekDouble>& Lcoords,
680  Array<OneD,NekDouble> &coords)
681  {
682  int i;
683 
684  ASSERTL1(Lcoords[0] >= -1.0&& Lcoords[0] <= 1.0,
685  "Local coordinates are not in region [-1,1]");
686 
687  m_geom->FillGeom();
688  for(i = 0; i < m_geom->GetCoordim(); ++i)
689  {
690  coords[i] = m_geom->GetCoord(i,Lcoords);
691  }
692  }
693 
695  Array<OneD, NekDouble> &coords_0,
696  Array<OneD, NekDouble> &coords_1,
697  Array<OneD, NekDouble> &coords_2)
698  {
699  Expansion::v_GetCoords(coords_0, coords_1, coords_2);
700  }
701 
702  // Get vertex value from the 1D Phys space.
704  const int vertex,
705  const Array<OneD, const NekDouble> &inarray,
706  NekDouble &outarray)
707  {
708  int nquad = m_base[0]->GetNumPoints();
709 
711  {
712  switch (vertex)
713  {
714  case 0:
715  outarray = inarray[0];
716  break;
717  case 1:
718  outarray = inarray[nquad - 1];
719  break;
720  }
721  }
722  else
723  {
725  factors[StdRegions::eFactorGaussVertex] = vertex;
726 
729  DetShapeType(),*this,factors);
730 
731  DNekScalMatSharedPtr mat_gauss = m_matrixManager[key];
732 
733  outarray = Blas::Ddot(nquad, mat_gauss->GetOwnedMatrix()
734  ->GetPtr().get(), 1, &inarray[0], 1);
735  }
736  }
737 
738  // Get vertex value from the 1D Phys space.
740  const int edge,
741  const StdRegions::StdExpansionSharedPtr &EdgeExp,
742  const Array<OneD, const NekDouble> &inarray,
743  Array<OneD, NekDouble> &outarray,
745  {
746  NekDouble result;
747  v_GetVertexPhysVals(edge, inarray, result);
748  outarray[0] = result;
749  }
750 
751  //-----------------------------
752  // Helper functions
753  //-----------------------------
754 
756  Array<OneD, NekDouble> &coeffs,
758  {
759  v_SetCoeffsToOrientation(dir,coeffs,coeffs);
760  }
761 
765  Array<OneD, NekDouble> &outarray)
766  {
767 
768  if (dir == StdRegions::eBackwards)
769  {
770  if (&inarray[0] != &outarray[0])
771  {
772  Array<OneD,NekDouble> intmp (inarray);
773  ReverseCoeffsAndSign(intmp,outarray);
774  }
775  else
776  {
777  ReverseCoeffsAndSign(inarray,outarray);
778  }
779  }
780  }
781 
783  {
784  return m_geom->GetPorient(point);
785  }
786 
787 
789  {
791  ::AllocateSharedPtr(m_base[0]->GetBasisKey());
792  }
793 
795  {
796  return m_geom->GetCoordim();
797  }
798 
800  {
801  NEKERROR(ErrorUtil::efatal, "Got to SegExp");
802  return NullNekDouble1DArray;
803  }
804 
806  {
807  return m_metricinfo->GetGtype();
808  }
809 
810  int SegExp::v_GetNumPoints(const int dir) const
811  {
812  return GetNumPoints(dir);
813  }
814 
815  int SegExp::v_GetNcoeffs(void) const
816  {
817  return m_ncoeffs;
818  }
819 
821  {
822  return GetBasis(dir);
823  }
824 
825 
827  {
828  return 2;
829  }
830 
831 
833  {
834  return 2;
835  }
836 
837 
838  /// Unpack data from input file assuming it comes from
839  // the same expansion type
841  const NekDouble *data,
842  const std::vector<unsigned int > &nummodes,
843  const int mode_offset,
844  NekDouble *coeffs)
845  {
846  switch(m_base[0]->GetBasisType())
847  {
849  {
850  int fillorder = min((int) nummodes[mode_offset],m_ncoeffs);
851 
852  Vmath::Zero(m_ncoeffs,coeffs,1);
853  Vmath::Vcopy(fillorder,&data[0],1,&coeffs[0],1);
854  }
855  break;
857  {
858  // Assume that input is also Gll_Lagrange
859  // but no way to check;
861  nummodes[mode_offset],
864  p0,data, m_base[0]->GetPointsKey(), coeffs);
865  }
866  break;
868  {
869  // Assume that input is also Gauss_Lagrange
870  // but no way to check;
872  nummodes[mode_offset],
875  p0,data, m_base[0]->GetPointsKey(), coeffs);
876  }
877  break;
878  default:
879  ASSERTL0(false,
880  "basis is either not set up or not hierarchicial");
881  }
882  }
883 
884  void SegExp::v_ComputeVertexNormal(const int vertex)
885  {
886  int i;
887  const SpatialDomains::GeomFactorsSharedPtr &geomFactors =
888  GetGeom()->GetMetricInfo();
889  SpatialDomains::GeomType type = geomFactors->GetGtype();
890  const Array<TwoD, const NekDouble> &gmat =
891  geomFactors->GetDerivFactors(GetPointsKeys());
892  int nqe = 1;
893  int vCoordDim = GetCoordim();
894 
895  m_vertexNormals[vertex] =
898  m_vertexNormals[vertex];
899  for (i = 0; i < vCoordDim; ++i)
900  {
901  normal[i] = Array<OneD, NekDouble>(nqe);
902  }
903 
904  // Regular geometry case
905  if ((type == SpatialDomains::eRegular) ||
907  {
908  NekDouble vert;
909  // Set up normals
910  switch (vertex)
911  {
912  case 0:
913  for(i = 0; i < vCoordDim; ++i)
914  {
915  Vmath::Fill(nqe, -gmat[i][0], normal[i], 1);
916  }
917  break;
918  case 1:
919  for(i = 0; i < vCoordDim; ++i)
920  {
921  Vmath::Fill(nqe, gmat[i][0], normal[i], 1);
922  }
923  break;
924  default:
925  ASSERTL0(false,
926  "point is out of range (point < 2)");
927  }
928 
929  // normalise
930  vert = 0.0;
931  for (i =0 ; i < vCoordDim; ++i)
932  {
933  vert += normal[i][0]*normal[i][0];
934  }
935  vert = 1.0/sqrt(vert);
936  for (i = 0; i < vCoordDim; ++i)
937  {
938  Vmath::Smul(nqe, vert, normal[i], 1, normal[i], 1);
939  }
940  }
941  }
942 
943  //-----------------------------
944  // Operator creation functions
945  //-----------------------------
946 
947 
949  const Array<OneD, const NekDouble> &inarray,
950  Array<OneD, NekDouble> &outarray,
951  const StdRegions::StdMatrixKey &mkey)
952  {
953  int nquad = m_base[0]->GetNumPoints();
954  const Array<TwoD, const NekDouble>& gmat =
955  m_metricinfo->GetDerivFactors(GetPointsKeys());
956 
957  Array<OneD,NekDouble> physValues(nquad);
958  Array<OneD,NekDouble> dPhysValuesdx(nquad);
959 
960  BwdTrans(inarray,physValues);
961 
962  // Laplacian matrix operation
963  switch (m_geom->GetCoordim())
964  {
965  case 1:
966  {
967  PhysDeriv(physValues,dPhysValuesdx);
968 
969  // multiply with the proper geometric factors
970  if(m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
971  {
972  Vmath::Vmul(nquad,
973  &gmat[0][0],1,dPhysValuesdx.get(),1,
974  dPhysValuesdx.get(),1);
975  }
976  else
977  {
978  Blas::Dscal(nquad,
979  gmat[0][0], dPhysValuesdx.get(), 1);
980  }
981  }
982  break;
983  case 2:
984  {
985  Array<OneD,NekDouble> dPhysValuesdy(nquad);
986 
987  PhysDeriv(physValues,dPhysValuesdx,dPhysValuesdy);
988 
989  // multiply with the proper geometric factors
990  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
991  {
992  Vmath::Vmul (nquad,
993  &gmat[0][0],1,dPhysValuesdx.get(),1,
994  dPhysValuesdx.get(),1);
995  Vmath::Vvtvp(nquad,
996  &gmat[1][0],1,dPhysValuesdy.get(),1,
997  dPhysValuesdx.get(),1,
998  dPhysValuesdx.get(),1);
999  }
1000  else
1001  {
1002  Blas::Dscal(nquad,
1003  gmat[0][0], dPhysValuesdx.get(), 1);
1004  Blas::Daxpy(nquad,
1005  gmat[1][0], dPhysValuesdy.get(), 1,
1006  dPhysValuesdx.get(), 1);
1007  }
1008  }
1009  break;
1010  case 3:
1011  {
1012  Array<OneD,NekDouble> dPhysValuesdy(nquad);
1013  Array<OneD,NekDouble> dPhysValuesdz(nquad);
1014 
1015  PhysDeriv(physValues,dPhysValuesdx,
1016  dPhysValuesdy,dPhysValuesdz);
1017 
1018  // multiply with the proper geometric factors
1019  if(m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
1020  {
1021  Vmath::Vmul (nquad,
1022  &gmat[0][0], 1, dPhysValuesdx.get(), 1,
1023  dPhysValuesdx.get(),1);
1024  Vmath::Vvtvp(nquad,
1025  &gmat[1][0], 1, dPhysValuesdy.get(), 1,
1026  dPhysValuesdx.get(),1,
1027  dPhysValuesdx.get(),1);
1028  Vmath::Vvtvp(nquad,
1029  &gmat[2][0], 1, dPhysValuesdz.get(), 1,
1030  dPhysValuesdx.get(),1,
1031  dPhysValuesdx.get(),1);
1032  }
1033  else
1034  {
1035  Blas::Dscal(nquad, gmat[0][0], dPhysValuesdx.get(), 1);
1036  Blas::Daxpy(nquad,
1037  gmat[1][0], dPhysValuesdy.get(), 1,
1038  dPhysValuesdx.get(), 1);
1039  Blas::Daxpy(nquad,
1040  gmat[2][0], dPhysValuesdz.get(), 1,
1041  dPhysValuesdx.get(), 1);
1042  }
1043  }
1044  break;
1045  default:
1046  ASSERTL0(false,"Wrong number of dimensions");
1047  break;
1048  }
1049 
1050  v_IProductWRTBase(m_base[0]->GetDbdata(),dPhysValuesdx,outarray,1);
1051  }
1052 
1053 
1055  const Array<OneD, const NekDouble> &inarray,
1056  Array<OneD, NekDouble> &outarray,
1057  const StdRegions::StdMatrixKey &mkey)
1058  {
1059  int nquad = m_base[0]->GetNumPoints();
1060  const Array<TwoD, const NekDouble>& gmat =
1061  m_metricinfo->GetDerivFactors(GetPointsKeys());
1062  const NekDouble lambda =
1064 
1065  Array<OneD,NekDouble> physValues(nquad);
1066  Array<OneD,NekDouble> dPhysValuesdx(nquad);
1068 
1069  BwdTrans(inarray, physValues);
1070 
1071  // mass matrix operation
1072  v_IProductWRTBase((m_base[0]->GetBdata()),physValues,wsp,1);
1073 
1074  // Laplacian matrix operation
1075  switch (m_geom->GetCoordim())
1076  {
1077  case 1:
1078  {
1079  PhysDeriv(physValues,dPhysValuesdx);
1080 
1081  // multiply with the proper geometric factors
1082  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
1083  {
1084  Vmath::Vmul(nquad,
1085  &gmat[0][0],1,dPhysValuesdx.get(),1,
1086  dPhysValuesdx.get(),1);
1087  }
1088  else
1089  {
1090  Blas::Dscal(nquad, gmat[0][0], dPhysValuesdx.get(), 1);
1091  }
1092  }
1093  break;
1094  case 2:
1095  {
1096  Array<OneD,NekDouble> dPhysValuesdy(nquad);
1097 
1098  PhysDeriv(physValues, dPhysValuesdx, dPhysValuesdy);
1099 
1100  // multiply with the proper geometric factors
1101  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
1102  {
1103  Vmath::Vmul (nquad,
1104  &gmat[0][0], 1, dPhysValuesdx.get(), 1,
1105  dPhysValuesdx.get(), 1);
1106  Vmath::Vvtvp(nquad,
1107  &gmat[1][0], 1, dPhysValuesdy.get(), 1,
1108  dPhysValuesdx.get(), 1,
1109  dPhysValuesdx.get(), 1);
1110  }
1111  else
1112  {
1113  Blas::Dscal(nquad, gmat[0][0], dPhysValuesdx.get(), 1);
1114  Blas::Daxpy(nquad,
1115  gmat[1][0], dPhysValuesdy.get(), 1,
1116  dPhysValuesdx.get(), 1);
1117  }
1118  }
1119  break;
1120  case 3:
1121  {
1122  Array<OneD,NekDouble> dPhysValuesdy(nquad);
1123  Array<OneD,NekDouble> dPhysValuesdz(nquad);
1124 
1125  PhysDeriv(physValues, dPhysValuesdx,
1126  dPhysValuesdy, dPhysValuesdz);
1127 
1128  // multiply with the proper geometric factors
1129  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
1130  {
1131  Vmath::Vmul (nquad,
1132  &gmat[0][0], 1, dPhysValuesdx.get(), 1,
1133  dPhysValuesdx.get(), 1);
1134  Vmath::Vvtvp(nquad,
1135  &gmat[1][0], 1, dPhysValuesdy.get(), 1,
1136  dPhysValuesdx.get(), 1,
1137  dPhysValuesdx.get(), 1);
1138  Vmath::Vvtvp(nquad,
1139  &gmat[2][0], 1, dPhysValuesdz.get(), 1,
1140  dPhysValuesdx.get(), 1,
1141  dPhysValuesdx.get(), 1);
1142  }
1143  else
1144  {
1145  Blas::Dscal(nquad, gmat[0][0], dPhysValuesdx.get(), 1);
1146  Blas::Daxpy(nquad,
1147  gmat[1][0], dPhysValuesdy.get(), 1,
1148  dPhysValuesdx.get(), 1);
1149  Blas::Daxpy(nquad,
1150  gmat[2][0], dPhysValuesdz.get(),
1151  1, dPhysValuesdx.get(), 1);
1152  }
1153  }
1154  break;
1155  default:
1156  ASSERTL0(false,"Wrong number of dimensions");
1157  break;
1158  }
1159 
1160  v_IProductWRTBase(m_base[0]->GetDbdata(),dPhysValuesdx,outarray,1);
1161  Blas::Daxpy(m_ncoeffs, lambda, wsp.get(), 1, outarray.get(), 1);
1162  }
1163 
1164  //-----------------------------
1165  // Matrix creation functions
1166  //-----------------------------
1167 
1168 
1170  const MatrixKey &mkey)
1171  {
1172  return m_staticCondMatrixManager[mkey];
1173  }
1174 
1176  {
1177  m_staticCondMatrixManager.DeleteObject(mkey);
1178  }
1179 
1181  {
1182  return m_matrixManager[mkey];
1183  }
1184 
1185 
1187  const StdRegions::StdMatrixKey &mkey)
1188  {
1189  LibUtilities::BasisKey bkey = m_base[0]->GetBasisKey();
1192 
1193  return tmp->GetStdMatrix(mkey);
1194  }
1195 
1196 
1198  {
1199  DNekScalMatSharedPtr returnval;
1200  NekDouble fac;
1202 
1203  ASSERTL2(m_metricinfo->GetGtype() !=
1205  "Geometric information is not set up");
1206 
1207  switch (mkey.GetMatrixType())
1208  {
1209  case StdRegions::eMass:
1210  {
1211  if ((m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
1212  || (mkey.GetNVarCoeff()))
1213  {
1214  fac = 1.0;
1215  goto UseLocRegionsMatrix;
1216  }
1217  else
1218  {
1219  fac = (m_metricinfo->GetJac(ptsKeys))[0];
1220  goto UseStdRegionsMatrix;
1221  }
1222  }
1223  break;
1224  case StdRegions::eInvMass:
1225  {
1226  if ((m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
1227  || (mkey.GetNVarCoeff()))
1228  {
1229  NekDouble one = 1.0;
1230  StdRegions::StdMatrixKey masskey(
1231  StdRegions::eMass,DetShapeType(), *this);
1232  DNekMatSharedPtr mat = GenMatrix(masskey);
1233  mat->Invert();
1234 
1235  returnval = MemoryManager<DNekScalMat>::
1236  AllocateSharedPtr(one,mat);
1237  }
1238  else
1239  {
1240  fac = 1.0/(m_metricinfo->GetJac(ptsKeys))[0];
1241  goto UseStdRegionsMatrix;
1242  }
1243  }
1244  break;
1248  {
1249  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed ||
1250  mkey.GetNVarCoeff())
1251  {
1252  fac = 1.0;
1253  goto UseLocRegionsMatrix;
1254  }
1255  else
1256  {
1257  int dir = 0;
1258  switch(mkey.GetMatrixType())
1259  {
1261  dir = 0;
1262  break;
1264  ASSERTL1(m_geom->GetCoordim() >= 2,
1265  "Cannot call eWeakDeriv2 in a "
1266  "coordinate system which is not at "
1267  "least two-dimensional");
1268  dir = 1;
1269  break;
1271  ASSERTL1(m_geom->GetCoordim() == 3,
1272  "Cannot call eWeakDeriv2 in a "
1273  "coordinate system which is not "
1274  "three-dimensional");
1275  dir = 2;
1276  break;
1277  default:
1278  break;
1279  }
1280 
1282  mkey.GetShapeType(), *this);
1283 
1284  DNekMatSharedPtr WeakDerivStd = GetStdMatrix(deriv0key);
1285  fac = m_metricinfo->GetDerivFactors(ptsKeys)[dir][0]*
1286  m_metricinfo->GetJac(ptsKeys)[0];
1287 
1288  returnval = MemoryManager<DNekScalMat>::
1289  AllocateSharedPtr(fac,WeakDerivStd);
1290  }
1291  }
1292  break;
1294  {
1295  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
1296  {
1297  fac = 1.0;
1298  goto UseLocRegionsMatrix;
1299  }
1300  else
1301  {
1302  int coordim = m_geom->GetCoordim();
1303  fac = 0.0;
1304  for (int i = 0; i < coordim; ++i)
1305  {
1306  fac += m_metricinfo->GetDerivFactors(ptsKeys)[i][0]*
1307  m_metricinfo->GetDerivFactors(ptsKeys)[i][0];
1308  }
1309  fac *= m_metricinfo->GetJac(ptsKeys)[0];
1310  goto UseStdRegionsMatrix;
1311  }
1312  }
1313  break;
1315  {
1316  NekDouble factor =
1318  MatrixKey masskey(StdRegions::eMass,
1319  mkey.GetShapeType(), *this);
1320  DNekScalMat &MassMat = *(this->m_matrixManager[masskey]);
1322  *this, mkey.GetConstFactors(),
1323  mkey.GetVarCoeffs());
1324  DNekScalMat &LapMat = *(this->m_matrixManager[lapkey]);
1325 
1326  int rows = LapMat.GetRows();
1327  int cols = LapMat.GetColumns();
1328 
1329  DNekMatSharedPtr helm =
1331 
1332  NekDouble one = 1.0;
1333  (*helm) = LapMat + factor*MassMat;
1334 
1335  returnval =
1337  }
1338  break;
1343  {
1344  NekDouble one = 1.0;
1345 
1346  DNekMatSharedPtr mat = GenMatrix(mkey);
1347  returnval =
1349  }
1350  break;
1352  {
1353  NekDouble one = 1.0;
1354 
1355 // StdRegions::StdMatrixKey hkey(StdRegions::eHybridDGHelmholtz,
1356 // DetShapeType(),*this,
1357 // mkey.GetConstant(0),
1358 // mkey.GetConstant(1));
1360  DetShapeType(),
1361  *this, mkey.GetConstFactors(),
1362  mkey.GetVarCoeffs());
1363  DNekMatSharedPtr mat = GenMatrix(hkey);
1364 
1365  mat->Invert();
1366  returnval =
1368  }
1369  break;
1371  {
1372  DNekMatSharedPtr m_Ix;
1373  Array<OneD, NekDouble> coords(1, 0.0);
1375  int vertex = (int)factors[StdRegions::eFactorGaussVertex];
1376 
1377  coords[0] = (vertex == 0) ? -1.0 : 1.0;
1378 
1379  m_Ix = m_base[0]->GetI(coords);
1380  returnval =
1382  }
1383  break;
1384 
1385  UseLocRegionsMatrix:
1386  {
1387  DNekMatSharedPtr mat = GenMatrix(mkey);
1388  returnval =
1390  }
1391  break;
1392  UseStdRegionsMatrix:
1393  {
1394  DNekMatSharedPtr mat = GetStdMatrix(mkey);
1395  returnval =
1397  }
1398  break;
1399  default:
1400  NEKERROR(ErrorUtil::efatal, "Matrix creation not defined");
1401  break;
1402  }
1403 
1404  return returnval;
1405  }
1406 
1408  const StdRegions::StdMatrixKey &mkey)
1409  {
1410  DNekMatSharedPtr returnval;
1411 
1412  switch (mkey.GetMatrixType())
1413  {
1420  returnval = Expansion1D::v_GenMatrix(mkey);
1421  break;
1422  default:
1423  returnval = StdSegExp::v_GenMatrix(mkey);
1424  break;
1425  }
1426 
1427  return returnval;
1428  }
1429 
1430 
1432  const MatrixKey &mkey)
1433  {
1434  DNekScalBlkMatSharedPtr returnval;
1435 
1436  ASSERTL2(m_metricinfo->GetGtype() !=
1438  "Geometric information is not set up");
1439 
1440  // set up block matrix system
1441  int nbdry = NumBndryCoeffs();
1442  int nint = m_ncoeffs - nbdry;
1443  Array<OneD, unsigned int> exp_size(2);
1444  exp_size[0] = nbdry;
1445  exp_size[1] = nint;
1446 
1447  /// \todo Really need a constructor which takes Arrays
1449  AllocateSharedPtr(exp_size,exp_size);
1450  NekDouble factor = 1.0;
1451 
1452  switch (mkey.GetMatrixType())
1453  {
1455  case StdRegions::eHelmholtz: // special case since Helmholtz
1456  // not defined in StdRegions
1457 
1458  // use Deformed case for both regular and deformed geometries
1459  factor = 1.0;
1460  goto UseLocRegionsMatrix;
1461  break;
1462  default:
1463  if(m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
1464  {
1465  factor = 1.0;
1466  goto UseLocRegionsMatrix;
1467  }
1468  else
1469  {
1470  DNekScalMatSharedPtr mat = GetLocMatrix(mkey);
1471  factor = mat->Scale();
1472  goto UseStdRegionsMatrix;
1473  }
1474  break;
1475  UseStdRegionsMatrix:
1476  {
1477  NekDouble invfactor = 1.0/factor;
1478  NekDouble one = 1.0;
1480  DNekScalMatSharedPtr Atmp;
1481  DNekMatSharedPtr Asubmat;
1482 
1483  returnval->SetBlock(0,0,Atmp =
1485  factor,Asubmat = mat->GetBlock(0,0)));
1486  returnval->SetBlock(0,1,Atmp =
1488  one,Asubmat = mat->GetBlock(0,1)));
1489  returnval->SetBlock(1,0,Atmp =
1491  factor,Asubmat = mat->GetBlock(1,0)));
1492  returnval->SetBlock(1,1,Atmp =
1494  invfactor,Asubmat = mat->GetBlock(1,1)));
1495  }
1496  break;
1497  UseLocRegionsMatrix:
1498  {
1499  int i,j;
1500  NekDouble invfactor = 1.0/factor;
1501  NekDouble one = 1.0;
1502  DNekScalMat &mat = *GetLocMatrix(mkey);
1503  DNekMatSharedPtr A =
1505  DNekMatSharedPtr B =
1507  DNekMatSharedPtr C =
1509  DNekMatSharedPtr D =
1511 
1512  Array<OneD,unsigned int> bmap(nbdry);
1513  Array<OneD,unsigned int> imap(nint);
1514  GetBoundaryMap(bmap);
1515  GetInteriorMap(imap);
1516 
1517  for (i = 0; i < nbdry; ++i)
1518  {
1519  for (j = 0; j < nbdry; ++j)
1520  {
1521  (*A)(i,j) = mat(bmap[i],bmap[j]);
1522  }
1523 
1524  for (j = 0; j < nint; ++j)
1525  {
1526  (*B)(i,j) = mat(bmap[i],imap[j]);
1527  }
1528  }
1529 
1530  for (i = 0; i < nint; ++i)
1531  {
1532  for (j = 0; j < nbdry; ++j)
1533  {
1534  (*C)(i,j) = mat(imap[i],bmap[j]);
1535  }
1536 
1537  for (j = 0; j < nint; ++j)
1538  {
1539  (*D)(i,j) = mat(imap[i],imap[j]);
1540  }
1541  }
1542 
1543  // Calculate static condensed system
1544  if (nint)
1545  {
1546  D->Invert();
1547  (*B) = (*B)*(*D);
1548  (*A) = (*A) - (*B)*(*C);
1549  }
1550 
1551  DNekScalMatSharedPtr Atmp;
1552 
1553  returnval->SetBlock(0,0,Atmp = MemoryManager<DNekScalMat>::
1554  AllocateSharedPtr(factor,A));
1555  returnval->SetBlock(0,1,Atmp = MemoryManager<DNekScalMat>::
1556  AllocateSharedPtr(one,B));
1557  returnval->SetBlock(1,0,Atmp = MemoryManager<DNekScalMat>::
1558  AllocateSharedPtr(factor,C));
1559  returnval->SetBlock(1,1,Atmp = MemoryManager<DNekScalMat>::
1560  AllocateSharedPtr(invfactor,D));
1561  }
1562  }
1563 
1564 
1565  return returnval;
1566  }
1567 
1568 
1569  //-----------------------------
1570  // Private methods
1571  //-----------------------------
1572 
1573 
1574  /// Reverse the coefficients in a boundary interior expansion
1575  /// this routine is of use when we need the segment
1576  /// coefficients corresponding to a expansion in the reverse
1577  /// coordinate direction
1579  const Array<OneD,NekDouble> &inarray,
1580  Array<OneD,NekDouble> &outarray)
1581  {
1582 
1583  int m;
1584  NekDouble sgn = 1;
1585 
1586  ASSERTL1(&inarray[0] != &outarray[0],
1587  "inarray and outarray can not be the same");
1588  switch(GetBasisType(0))
1589  {
1591  //Swap vertices
1592  outarray[0] = inarray[1];
1593  outarray[1] = inarray[0];
1594  // negate odd modes
1595  for(m = 2; m < m_ncoeffs; ++m)
1596  {
1597  outarray[m] = sgn*inarray[m];
1598  sgn = -sgn;
1599  }
1600  break;
1603  for(m = 0; m < m_ncoeffs; ++m)
1604  {
1605  outarray[m_ncoeffs-1-m] = inarray[m];
1606  }
1607  break;
1608  default:
1609  ASSERTL0(false,"This basis is not allowed in this method");
1610  break;
1611  }
1612  }
1613 
1614  /* \brief Mass inversion product from \a inarray to \a outarray
1615  *
1616  * Multiply by the inverse of the mass matrix
1617  * \f$ {\bf \hat{u}} = {\bf M}^{-1} {\bf I} \f$
1618  *
1619  **/
1621  const Array<OneD, const NekDouble>& inarray,
1622  Array<OneD,NekDouble> &outarray)
1623  {
1624  // get Mass matrix inverse
1626  DetShapeType(),*this);
1627  DNekScalMatSharedPtr matsys = m_matrixManager[masskey];
1628 
1629  NekVector<NekDouble> in(m_ncoeffs,inarray,eCopy);
1630  NekVector<NekDouble> out(m_ncoeffs,outarray,eWrapper);
1631 
1632  out = (*matsys)*in;
1633  }
1634 
1635 
1636  } // end of namespace
1637 }//end of namespace
1638 
const LibUtilities::PointsKeyVector GetPointsKeys() const
virtual DNekScalBlkMatSharedPtr v_GetLocStaticCondMatrix(const MatrixKey &mkey)
Definition: SegExp.cpp:1169
LibUtilities::ShapeType DetShapeType() const
This function returns the shape of the expansion domain.
Definition: StdExpansion.h:470
NekDouble GetConstFactor(const ConstFactorType &factor) const
Definition: StdMatrixKey.h:122
DNekMatSharedPtr GenMatrix(const StdMatrixKey &mkey)
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
const NormalVector & GetEdgeNormal(const int edge) const
const LibUtilities::BasisSharedPtr & GetBasis(int dir) const
This function gets the shared point to basis in the dir direction.
Definition: StdExpansion.h:118
const ConstFactorMap & GetConstFactors() const
Definition: StdMatrixKey.h:142
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:158
virtual const LibUtilities::BasisSharedPtr & v_GetBasis(int dir) const
Definition: SegExp.cpp:820
virtual void v_GetCoord(const Array< OneD, const NekDouble > &Lcoords, Array< OneD, NekDouble > &coords)
Definition: SegExp.cpp:678
const VarCoeffMap & GetVarCoeffs() const
Definition: StdMatrixKey.h:168
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:220
MatrixType GetMatrixType() const
Definition: StdMatrixKey.h:82
void v_DropLocStaticCondMatrix(const MatrixKey &mkey)
Definition: SegExp.cpp:1175
void MassMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdMatrixKey &mkey)
Definition: StdExpansion.h:971
static Array< OneD, NekDouble > NullNekDouble1DArray
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
LibUtilities::NekManager< MatrixKey, DNekScalBlkMat, MatrixKey::opLess > m_staticCondMatrixManager
Definition: SegExp.h:248
virtual DNekMatSharedPtr v_GenMatrix(const StdRegions::StdMatrixKey &mkey)
Definition: Expansion1D.cpp:43
virtual NekDouble v_StdPhysEvaluate(const Array< OneD, const NekDouble > &Lcoord, const Array< OneD, const NekDouble > &physvals)
Definition: SegExp.cpp:657
std::map< int, NormalVector > m_vertexNormals
virtual void v_HelmholtzMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::StdMatrixKey &mkey)
Definition: SegExp.cpp:1054
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
Definition: Vmath.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: SegExp.cpp:375
int GetNumPoints(const int dir) const
This function returns the number of quadrature points in the dir direction.
Definition: StdExpansion.h:229
virtual void v_PhysDeriv_n(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_dn)
Evaluate the derivative normal to a line: . The derivative is calculated performing the product ...
Definition: SegExp.cpp:267
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:428
Principle Modified Functions .
Definition: BasisType.h:49
void NormVectorIProductWRTBase(const Array< OneD, const NekDouble > &Fx, Array< OneD, NekDouble > &outarray)
Definition: StdExpansion.h:727
virtual void v_ExtractDataToCoeffs(const NekDouble *data, const std::vector< unsigned int > &nummodes, const int mode_offset, NekDouble *coeffs)
Unpack data from input file assuming it comes from.
Definition: SegExp.cpp:840
SpatialDomains::GeomFactorsSharedPtr m_metricinfo
Definition: Expansion.h:126
Lagrange Polynomials using the Gauss points .
Definition: BasisType.h:54
virtual void v_GetTracePhysVals(const int edge, const StdRegions::StdExpansionSharedPtr &EdgeExp, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, StdRegions::Orientation orient)
Definition: SegExp.cpp:739
STL namespace.
LibUtilities::ShapeType GetShapeType() const
Definition: StdMatrixKey.h:87
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:251
virtual int v_GetNcoeffs(void) const
Definition: SegExp.cpp:815
virtual StdRegions::StdExpansionSharedPtr v_GetStdExp(void) const
Definition: SegExp.cpp:788
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
Definition: Vmath.cpp:227
SpatialDomains::GeometrySharedPtr m_geom
Definition: Expansion.h:125
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)->_Base[0] and return ...
Definition: SegExp.cpp:502
virtual void v_PhysDeriv_s(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_ds)
Evaluate the derivative along a line: . The derivative is calculated performing the product ...
Definition: SegExp.cpp:227
boost::shared_ptr< StdSegExp > StdSegExpSharedPtr
Definition: StdSegExp.h:47
boost::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:70
virtual int v_GetNumPoints(const int dir) const
Definition: SegExp.cpp:810
void PhysDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_d0, Array< OneD, NekDouble > &out_d1=NullNekDouble1DArray, Array< OneD, NekDouble > &out_d2=NullNekDouble1DArray)
virtual void v_NormVectorIProductWRTBase(const Array< OneD, const NekDouble > &Fx, const Array< OneD, const NekDouble > &Fy, Array< OneD, NekDouble > &outarray)
Definition: SegExp.cpp:620
DNekMatSharedPtr GetStdMatrix(const StdMatrixKey &mkey)
Definition: StdExpansion.h:700
boost::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
1D Gauss-Gauss-Legendre quadrature points
Definition: PointsType.h:47
Expansion2DSharedPtr GetLeftAdjacentElementExp() const
Definition: Expansion1D.h:123
DNekBlkMatSharedPtr GetStdStaticCondMatrix(const StdMatrixKey &mkey)
Definition: StdExpansion.h:705
int GetVertexMap(const int localVertexId, bool useCoeffPacking=false)
Definition: StdExpansion.h:826
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
Definition: Vmath.cpp:199
void ReverseCoeffsAndSign(const Array< OneD, NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Reverse the coefficients in a boundary interior expansion this routine is of use when we need the seg...
Definition: SegExp.cpp:1578
virtual SpatialDomains::GeomType v_MetricInfoType()
Definition: SegExp.cpp:805
virtual DNekMatSharedPtr v_GenMatrix(const StdRegions::StdMatrixKey &mkey)
Definition: SegExp.cpp:1407
virtual StdRegions::Orientation v_GetPorient(int point)
Definition: SegExp.cpp:782
Principle Modified Functions .
Definition: BasisType.h:50
virtual void v_ComputeVertexNormal(const int vertex)
Definition: SegExp.cpp:884
virtual void v_GetCoords(Array< OneD, NekDouble > &coords_1, Array< OneD, NekDouble > &coords_2, Array< OneD, NekDouble > &coords_3)
Definition: Expansion.cpp:211
boost::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
Definition: NekTypeDefs.hpp:74
void GetInteriorMap(Array< OneD, unsigned int > &outarray)
Definition: StdExpansion.h:821
Defines a specification for a set of points.
Definition: Points.h:58
double NekDouble
virtual const Array< OneD, const NekDouble > & v_GetPhysNormals(void)
Definition: SegExp.cpp:799
DNekScalBlkMatSharedPtr CreateStaticCondMatrix(const MatrixKey &mkey)
Definition: SegExp.cpp:1431
virtual void v_FwdTrans_BndConstrained(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: SegExp.cpp:399
virtual void v_LaplacianMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdRegions::StdMatrixKey &mkey)
Definition: SegExp.cpp:948
T Ddot(int n, const Array< OneD, const T > &w, const int incw, const Array< OneD, const T > &x, const int incx, const Array< OneD, const int > &y, const int incy)
Definition: VmathArray.hpp:434
DNekScalMatSharedPtr CreateMatrix(const MatrixKey &mkey)
Definition: SegExp.cpp:1197
LibUtilities::BasisType GetBasisType(const int dir) const
This function returns the type of basis used in the dir direction.
Definition: StdExpansion.h:165
virtual DNekScalMatSharedPtr v_GetLocMatrix(const MatrixKey &mkey)
Definition: SegExp.cpp:1180
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:329
virtual void v_GetVertexPhysVals(const int vertex, const Array< OneD, const NekDouble > &inarray, NekDouble &outarray)
Definition: SegExp.cpp:703
boost::shared_ptr< DNekBlkMat > DNekBlkMatSharedPtr
Definition: NekTypeDefs.hpp:72
DNekScalMatSharedPtr GetLocMatrix(const LocalRegions::MatrixKey &mkey)
Definition: Expansion.cpp:83
virtual void v_GetCoords(Array< OneD, NekDouble > &coords_1, Array< OneD, NekDouble > &coords_2, Array< OneD, NekDouble > &coords_3)
Definition: SegExp.cpp:694
SpatialDomains::GeometrySharedPtr GetGeom() const
Definition: Expansion.cpp:148
virtual void v_SetCoeffsToOrientation(Array< OneD, NekDouble > &coeffs, StdRegions::Orientation dir)
Definition: SegExp.cpp:755
boost::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
Definition: GeomFactors.h:62
virtual int v_NumDGBndryCoeffs() const
Definition: SegExp.cpp:832
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...
void MultiplyByElmtInvMass(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: SegExp.cpp:1620
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
Definition: ErrorUtil.hpp:213
Geometry is straight-sided with constant geometric factors.
void Interp1D(const BasisKey &fbasis0, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, Array< OneD, NekDouble > &to)
this function interpolates a 1D function evaluated at the quadrature points of the basis fbasis0 to ...
Definition: Interp.cpp:54
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: SegExp.cpp:164
boost::shared_ptr< Geometry1D > Geometry1DSharedPtr
Definition: Geometry1D.h:48
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:525
virtual int v_GetCoordim()
Definition: SegExp.cpp:794
virtual NekDouble v_Integral(const Array< OneD, const NekDouble > &inarray)
Integrate the physical point list inarray over region and return the value.
Definition: SegExp.cpp:116
virtual DNekMatSharedPtr v_CreateStdMatrix(const StdRegions::StdMatrixKey &mkey)
Definition: SegExp.cpp:1186
GeomType
Indicates the type of element geometry.
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayofArray
boost::shared_ptr< Basis > BasisSharedPtr
Lagrange for SEM basis .
Definition: BasisType.h:53
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:359
virtual void v_IProductWRTDerivBase(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: SegExp.cpp:561
boost::shared_ptr< StdExpansion > StdExpansionSharedPtr
LibUtilities::PointsType GetPointsType(const int dir) const
This function returns the type of quadrature points used in the dir direction.
Definition: StdExpansion.h:216
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:191
Array< OneD, LibUtilities::BasisSharedPtr > m_base
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1047
Geometry is curved or has non-constant factors.
void GetBoundaryMap(Array< OneD, unsigned int > &outarray)
Definition: StdExpansion.h:816
Describes the specification for a Basis.
Definition: Basis.h:50
virtual NekDouble v_PhysEvaluate(const Array< OneD, const NekDouble > &coord, const Array< OneD, const NekDouble > &physvals)
Definition: SegExp.cpp:665
virtual int v_NumBndryCoeffs() const
Definition: SegExp.cpp:826
1D Gauss-Lobatto-Legendre quadrature points
Definition: PointsType.h:50
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:285
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:169
LibUtilities::NekManager< MatrixKey, DNekScalMat, MatrixKey::opLess > m_matrixManager
Definition: SegExp.h:246