Nektar++
StdNodalPrismExp.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File StdNodalPrismExp.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: Nodal prismatic routines built upon StdExpansion3D
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <boost/core/ignore_unused.hpp>
36 
38 #include <LibUtilities/Foundations/ManagerAccess.h> // for PointsManager, etc
39 
40 namespace Nektar
41 {
42  namespace StdRegions
43  {
45  const LibUtilities::BasisKey &Ba,
46  const LibUtilities::BasisKey &Bb,
47  const LibUtilities::BasisKey &Bc,
49  StdExpansion (LibUtilities::StdPrismData::getNumberOfCoefficients(
50  Ba.GetNumModes(),
51  Bb.GetNumModes(),
52  Bc.GetNumModes()),
53  3,Ba,Bb,Bc),
54  StdExpansion3D(LibUtilities::StdPrismData::getNumberOfCoefficients(
55  Ba.GetNumModes(),
56  Bb.GetNumModes(),
57  Bc.GetNumModes()),
58  Ba,Bb,Bc),
59  StdPrismExp (Ba,Bb,Bc),
60  m_nodalPointsKey(Ba.GetNumModes(),Ntype)
61  {
62  ASSERTL0(Ba.GetNumModes() <= Bc.GetNumModes(),
63  "order in 'a' direction is higher than order "
64  "in 'c' direction");
65  }
66 
68  StdExpansion(T),
69  StdExpansion3D(T),
70  StdPrismExp(T),
72  {
73  }
74 
76  {
77  }
78 
79 
80 
82  {
83  return true;
84  }
85 
86  //-------------------------------
87  // Nodal basis specific routines
88  //-------------------------------
89 
91  const Array<OneD, const NekDouble>& inarray,
92  Array<OneD, NekDouble>& outarray)
93  {
97  DNekMatSharedPtr inv_vdm = GetStdMatrix(Nkey);
98 
100  NekVector<NekDouble> modal(m_ncoeffs,outarray,eWrapper);
101  modal = (*inv_vdm) * nodal;
102  }
103 
104  // Operate with transpose of NodalToModal transformation
106  const Array<OneD, const NekDouble>& inarray,
107  Array<OneD, NekDouble>& outarray)
108  {
112  DNekMatSharedPtr inv_vdm = GetStdMatrix(Nkey);
113 
114  NekVector<NekDouble> nodal(m_ncoeffs,inarray,eCopy);
115  NekVector<NekDouble> modal(m_ncoeffs,outarray,eWrapper);
116  modal = Transpose(*inv_vdm) * nodal;
117  }
118 
120  const Array<OneD, const NekDouble>& inarray,
121  Array<OneD, NekDouble>& outarray)
122  {
123  StdMatrixKey Nkey(eNBasisTrans, DetShapeType(), *this,
126  DNekMatSharedPtr vdm = GetStdMatrix(Nkey);
127 
128  // Multiply out matrix
129  NekVector<NekDouble> modal(m_ncoeffs,inarray,eWrapper);
130  NekVector<NekDouble> nodal(m_ncoeffs,outarray,eWrapper);
131  nodal = (*vdm)*modal;
132  }
133 
138  {
139  // Get 3D nodal distribution.
140  LibUtilities::PointsManager()[m_nodalPointsKey]->GetPoints(x,y,z);
141  }
142 
144  {
145  int i,j;
148  DNekMatSharedPtr Mat;
149 
152  GetNodalPoints(r,s,t);
153 
154  //Store the values of m_phys in a temporary array
155  int nqtot = GetTotPoints();
156  Array<OneD,NekDouble> tmp_phys(nqtot);
157 
158  for(i = 0; i < m_ncoeffs; ++i)
159  {
160  // fill physical space with mode i
161  StdPrismExp::v_FillMode(i,tmp_phys);
162 
163  // interpolate mode i to the Nodal points 'j' and
164  // store in outarray
165  for(j = 0; j < m_ncoeffs; ++j)
166  {
167  c[0] = r[j];
168  c[1] = s[j];
169  c[2] = t[j];
170  (*Mat)(j,i) = StdPrismExp::v_PhysEvaluate(c,tmp_phys);
171  }
172  }
173 
174  return Mat;
175  }
176 
177 
178  //---------------------------------------
179  // Transforms
180  //---------------------------------------
181 
183  const Array<OneD, const NekDouble>& inarray,
184  Array<OneD, NekDouble>& outarray)
185  {
186  v_BwdTrans_SumFac(inarray,outarray);
187  }
188 
190  const Array<OneD, const NekDouble>& inarray,
191  Array<OneD, NekDouble>& outarray)
192  {
194  NodalToModal(inarray,tmp);
195  StdPrismExp::v_BwdTrans_SumFac(tmp,outarray);
196  }
197 
199  const Array<OneD, const NekDouble>& inarray,
200  Array<OneD, NekDouble>& outarray)
201  {
202  v_IProductWRTBase(inarray,outarray);
203 
204  // get Mass matrix inverse
205  StdMatrixKey masskey(eInvMass, DetShapeType(), *this,
208  DNekMatSharedPtr matsys = GetStdMatrix(masskey);
209 
210  // copy inarray in case inarray == outarray
211  NekVector<NekDouble> in(m_ncoeffs,outarray,eCopy);
213 
214  out = (*matsys)*in;
215  }
216 
217 
218  //---------------------------------------
219  // Inner product functions
220  //---------------------------------------
221 
223  const Array<OneD, const NekDouble>& inarray,
224  Array<OneD, NekDouble>& outarray)
225  {
226  v_IProductWRTBase_SumFac(inarray,outarray);
227  }
228 
230  const Array<OneD, const NekDouble>& inarray,
231  Array<OneD, NekDouble>& outarray,
232  bool multiplybyweights)
233  {
234  StdPrismExp::v_IProductWRTBase_SumFac(inarray,outarray,multiplybyweights);
235  NodalToModalTranspose(outarray,outarray);
236  }
237 
239  const int dir,
240  const Array<OneD, const NekDouble>& inarray,
241  Array<OneD, NekDouble>& outarray)
242  {
243  v_IProductWRTDerivBase_SumFac(dir,inarray,outarray);
244  }
245 
247  const int dir,
248  const Array<OneD, const NekDouble>& inarray,
249  Array<OneD, NekDouble>& outarray)
250  {
251  StdPrismExp::v_IProductWRTDerivBase_SumFac(dir,inarray,outarray);
252  NodalToModalTranspose(outarray,outarray);
253  }
254 
255  //---------------------------------------
256  // Evaluation functions
257  //---------------------------------------
258 
260  const int mode,
261  Array<OneD, NekDouble> &outarray)
262  {
263  ASSERTL2(mode >= m_ncoeffs,
264  "calling argument mode is larger than total expansion order");
265 
266  Vmath::Zero(m_ncoeffs, outarray, 1);
267  outarray[mode] = 1.0;
268  v_BwdTrans(outarray,outarray);
269  }
270 
271 
272  //---------------------------------------
273  // Mapping functions
274  //---------------------------------------
275 
276  /*
277  void StdNodalTriExp::v_GetFaceToElementMap(
278  const int fid,
279  const FaceOrientation faceOrient,
280  Array<OneD, unsigned int> &maparray,
281  Array<OneD, int> &signarray,
282  int nummodesA,
283  int nummodesB)
284  {
285  int P, Q, i, j, k, idx = 0, nFaceCoeffs = 0;
286 
287  ASSERTL0(fid >= 0 && fid <= 3,
288  "Local face ID must be between 0 and 3");
289 
290  if (nummodesA == -1)
291  {
292  switch(fid)
293  {
294  case 0:
295  nummodesA = m_base[0]->GetNumModes();
296  nummodesB = m_base[1]->GetNumModes();
297  break;
298  case 1:
299  nummodesA = m_base[0]->GetNumModes();
300  nummodesB = m_base[2]->GetNumModes();
301  break;
302  case 2:
303  case 3:
304  nummodesA = m_base[1]->GetNumModes();
305  nummodesB = m_base[2]->GetNumModes();
306  break;
307  }
308  }
309 
310  P = nummodesA;
311  Q = nummodesB;
312  nFaceCoeffs = Q + ((P-1)*(1 + 2*(Q-1) - (P-1)))/2;
313 
314  if (maparray.num_elements() != nFaceCoeffs)
315  {
316  maparray = Array<OneD, unsigned int>(nFaceCoeffs);
317  }
318 
319  if (signarray.num_elements() != nFaceCoeffs)
320  {
321  signarray = Array<OneD, int>(nFaceCoeffs,1);
322  }
323  else
324  {
325  fill(signarray.get(), signarray.get()+nFaceCoeffs, 1);
326  }
327 
328  switch(fid)
329  {
330  case 0:
331  // Add vertices.
332  maparray[idx++] = 0;
333  maparray[idx++] = 1;
334  maparray[idx++] = 2;
335 
336  // Add edges.
337  for (i = 2; i < P; ++i)
338  {
339  maparray[idx++] = ;
340  }
341  }
342  }
343  */
344 
345  int StdNodalPrismExp::v_GetVertexMap(const int localVertexId,
346  bool useCoeffPacking)
347  {
348  boost::ignore_unused(useCoeffPacking);
349  ASSERTL0(false,"Needs setting up");
350  return localVertexId;
351  }
352 
354  Array<OneD, unsigned int>& outarray)
355  {
356  unsigned int i;
357  const unsigned int nBndryCoeff = NumBndryCoeffs();
358 
359  if (outarray.num_elements() != nBndryCoeff)
360  {
361  outarray = Array<OneD, unsigned int>(nBndryCoeff);
362  }
363 
364  for (i = 0; i < nBndryCoeff; i++)
365  {
366  outarray[i] = i;
367  }
368  }
369 
371  Array<OneD, unsigned int>& outarray)
372  {
373  unsigned int i;
374  const unsigned int nBndryCoeff = NumBndryCoeffs();
375 
376  if (outarray.num_elements() != m_ncoeffs-nBndryCoeff)
377  {
378  outarray = Array<OneD, unsigned int>(
379  m_ncoeffs-nBndryCoeff);
380  }
381 
382  for (i = nBndryCoeff; i < m_ncoeffs; i++)
383  {
384  outarray[i-nBndryCoeff] = i;
385  }
386  }
387 
388 
389  //---------------------------------------
390  // Wrapper functions
391  //---------------------------------------
392 
394  {
395  DNekMatSharedPtr Mat;
396 
397  switch(mkey.GetMatrixType())
398  {
399  case eNBasisTrans:
400  Mat = GenNBasisTransMatrix();
401  break;
402  default:
404  break;
405  }
406 
407  return Mat;
408  }
409 
411  const StdMatrixKey &mkey)
412  {
413  return StdNodalPrismExp::v_GenMatrix(mkey);
414  }
415  } // end of namespace
416 } // end of namespace
virtual void v_IProductWRTDerivBase(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Inner product of inarray over region with respect to the object&#39;s default expansion basis; output in ...
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
PointsType GetPointsType() const
Definition: Points.h:112
virtual void v_FillMode(const int mode, Array< OneD, NekDouble > &outarray)
virtual void v_BwdTrans_SumFac(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
LibUtilities::ShapeType DetShapeType() const
This function returns the shape of the expansion domain.
Definition: StdExpansion.h:469
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...
void GetNodalPoints(Array< OneD, const NekDouble > &x, Array< OneD, const NekDouble > &y, Array< OneD, const NekDouble > &z)
std::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:69
MatrixType GetMatrixType() const
Definition: StdMatrixKey.h:81
virtual void v_BwdTrans_SumFac(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
DNekMatSharedPtr GetStdMatrix(const StdMatrixKey &mkey)
Definition: StdExpansion.h:714
void ModalToNodal(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
virtual void v_IProductWRTBase_SumFac(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool mult=true)
The base class for all shapes.
Definition: StdExpansion.h:68
int GetNumModes() const
Returns the order of the basis.
Definition: Basis.h:86
virtual void v_IProductWRTDerivBase_SumFac(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
void NodalToModal(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
virtual DNekMatSharedPtr v_GenMatrix(const StdMatrixKey &mkey)
virtual void v_BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
virtual DNekMatSharedPtr v_CreateStdMatrix(const StdMatrixKey &mkey)
Class representing a prismatic element in reference space.
Definition: StdPrismExp.h:48
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
PointsManagerT & PointsManager(void)
DNekMatSharedPtr CreateGeneralMatrix(const StdMatrixKey &mkey)
this function generates the mass matrix
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
virtual void v_IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Calculate the inner product of inarray with respect to the basis B=base0*base1*base2 and put into out...
LibUtilities::PointsKey m_nodalPointsKey
virtual void v_GetInteriorMap(Array< OneD, unsigned int > &outarray)
virtual int v_GetVertexMap(const int localVertexId, bool useCoeffPacking=false)
virtual void v_GetBoundaryMap(Array< OneD, unsigned int > &outarray)
void NodalToModalTranspose(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed t...
Definition: ErrorUtil.hpp:274
virtual void v_IProductWRTDerivBase_SumFac(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
virtual NekDouble v_PhysEvaluate(const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &physvals)
This function evaluates the expansion at a single (arbitrary) point of the domain.
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
Definition: StdExpansion.h:140
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:376
virtual void v_IProductWRTBase_SumFac(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool multiplybyweights=true)
virtual void v_FillMode(const int mode, Array< OneD, NekDouble > &outarray)
Describes the specification for a Basis.
Definition: Basis.h:49
static VarCoeffMap NullVarCoeffMap
Definition: StdRegions.hpp:265
static ConstFactorMap NullConstFactorMap
Definition: StdRegions.hpp:295