Nektar++
StdRegions.hpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: StdRegions.hpp
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: Definition of enum lists and constants
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef STDREGIONS_HPP
36 #define STDREGIONS_HPP
37 
41 #include <map>
42 
43 namespace Nektar
44 {
45 
46 /** \brief The namespace associated with the the StdRegions library
47  * (\ref pageStdRegions "StdRegions introduction")
48  */
49 namespace StdRegions
50 {
52 {
53  // eStdPointExp,
73 };
74 
75 const char *const ElementTypeMap[] = {
76  //"StdPointExp",
77  "StdSegExp", "SegExp", "StdQuadExp", "StdTriExp", "StdNodalTriExp",
78  "QuadExp", "TriExp", "NodalTriExp", "StdHexExp", "StdPrismExp",
79  "StdPyrExp", "StdTetExp", "StdNodalTetExp", "HexExp", "PrismExp",
80  "PyrExp", "TetExp", "NodalTetExp",
81 };
82 
83 /** @todo we need to tidy up matrix construction approach
84  * probably using a factory type approach
85  */
87 {
141 };
142 
143 const char *const MatrixTypeMap[] = {"NoMatrixType",
144  "Mass",
145  "Mass wiht Diagonal GJP",
146  "InvMass",
147  "Laplacian",
148  "Laplacian00",
149  "Laplacian01",
150  "Laplacian02",
151  "Laplacian10",
152  "Laplacian11",
153  "Laplacian12",
154  "Laplacian20",
155  "Laplacian21",
156  "Laplacian22",
157  "InvLaplacianWithUnityMean",
158  "WeakDeriv0",
159  "WeakDeriv1",
160  "WeakDeriv2",
161  "WeakDirectionalDeriv",
162  "MassLevelCurvature",
163  "LinearAdvectionReaction",
164  "LinearAdvectionDiffusionReaction",
165  "NBasisTrans",
166  "InvNBasisTrans",
167  "BwdTrans",
168  "BwdMat",
169  "IProductWRTBase",
170  "IProductWRTDerivBase0",
171  "IProductWRTDerivBase1",
172  "IProductWRTDerivBase2",
173  "DerivBase0",
174  "DerivBase1",
175  "DerivBase2",
176  "Helmholtz",
177  "Helmholtz with Diagonal GJP",
178  "HybridDGHelmholz",
179  "InvHybridDGHelmholtz",
180  "HybridDGHelmBndLam",
181  "HybridDGLamToQ0",
182  "HybridDGLamToQ1",
183  "HybridDGLamToQ2",
184  "HybridDGLamToU",
185  "FwdTrans",
186  "PreconR",
187  "PreconRMass",
188  "PreconLinearSpace",
189  "PreconLinearSpaceMass",
190  "InterpGauss",
191  "GaussDG",
192  "PhysInterpToEquiSpaced",
193  "EquiSpacedToCoeffs",
194  "NormDerivOnTrace"};
195 
197 {
230 };
231 
232 const char *const VarCoeffTypeMap[] = {
233  "VarCoeffMass", "VarCoeffLaplacian", "VarCoeffWeakDeriv",
234  "VarCoeffD00", "VarCoeffD11", "VarCoeffD22",
235  "VarCoeffD01", "VarCoeffD02", "VarCoeffD12",
236  "VarCoeffVelX", "VarCoeffVelY", "VarCoeffVelZ",
237  "VarCoeffMF1x", "VarCoeffMF1y", "VarCoeffMF1z",
238  "VarCoeffMF1Div", "VarCoeffMF1Mag", "VarCoeffMF2x",
239  "VarCoeffMF2y", "VarCoeffMF2z", "VarCoeffMF2Div",
240  "VarCoeffMF2Mag", "VarCoeffMF3x", "VarCoeffMF3y",
241  "VarCoeffMF3z", "VarCoeffMF3Div", "VarCoeffMF3Mag",
242  "VarCoeffMF", "VarCoeffMFDiv", "VarCoeffGmat",
243  "VarCoeffGJPNormVel"};
244 
245 /**
246  * @brief Representation of a variable coefficient.
247  *
248  * Variable coefficients are entries stored inside a #VarCoeffMap which
249  * are defined at each quadrature/solution point within an element. This
250  * class wraps that concept, storing the values in #m_coeffs, but also
251  * stores alongside this a hash of the data in #m_hash. This is then
252  * used within MultiRegions::GlobalMatrixKey to efficiently distinguish
253  * between matrix keys that have variable coefficients defined, but
254  * whose entries are different.
255  *
256  * For that reason the entries here are deliberately protected by const
257  * references; i.e. the entries inside of #m_coeffs should not be
258  * modified in-place, but a new array copied in so that the hash can be
259  * recalculated.
260  */
262 {
263  /// Default constructor.
264  VarCoeffEntry() = default;
265 
266  /**
267  * @brief Copy an array of values into this entry.
268  *
269  * Upon copy into #m_coeffs, compute the hash of this entry using
270  * #ComputeHash.
271  *
272  * @param input Variable coefficients to be defined at each
273  * solution point.
274  */
276  {
277  ComputeHash();
278  }
279 
280  /**
281  * @brief Access an entry @p idx within #m_coeffs.
282  *
283  * @param idx Index of the entry to access.
284  */
285  const NekDouble &operator[](std::size_t idx) const
286  {
287  return m_coeffs[idx];
288  }
289 
290  /**
291  * @brief Assignment operator given an array @p rhs.
292  *
293  * Upon copy into #m_coeffs, compute the hash of this entry using
294  * #ComputeHash.
295  *
296  * @param rhs Variable coefficients to be defined at each
297  * solution point.
298  */
300  {
301  m_coeffs = rhs;
302  ComputeHash();
303  }
304 
305  /**
306  * @brief Returns a const reference to the coefficients.
307  */
309  {
310  return m_coeffs;
311  }
312 
313  /**
314  * @brief Returns the hash of this entry.
315  */
316  std::size_t GetHash() const
317  {
318  return m_hash;
319  }
320 
321 protected:
322  /**
323  * @brief Computes the hash of this entry using #hash_range.
324  */
325  void ComputeHash()
326  {
327  if (m_coeffs.size() == 0)
328  {
329  m_hash = 0;
330  return;
331  }
332 
333  m_hash = hash_range(m_coeffs.begin(), m_coeffs.end());
334  }
335 
336  /// Hash of the entries inside #m_coeffs.
337  std::size_t m_hash = 0;
338 
339  /// Storage for the variable coefficient entries.
341 };
342 
343 typedef std::map<StdRegions::VarCoeffType, VarCoeffEntry> VarCoeffMap;
345 
346 inline VarCoeffMap RestrictCoeffMap(const VarCoeffMap &m, size_t offset,
347  size_t cnt)
348 {
349  VarCoeffMap ret;
350 
351  for (auto &x : m)
352  {
353  ret[x.first] =
354  Array<OneD, NekDouble>(cnt, x.second.GetValue() + offset);
355  }
356 
357  return ret;
358 }
359 
361 {
380 };
381 
382 const char *const ConstFactorTypeMap[] = {"FactorLambda",
383  "FactorCoeffD00",
384  "FactorCoeffD11",
385  "FactorCoeffD22",
386  "FactorCoeffD01",
387  "FactorCoeffD02",
388  "FactorCoeffD12",
389  "FactorTau",
390  "FactorTime",
391  "FactorSVVCutoffRatio",
392  "FactorSVVDiffCoeff",
393  "FactorSVVPowerKerDiffCoeff",
394  "FactorSVVDGKerDiffCoeff",
395  "FactorGaussVertex",
396  "FactorGaussEdge",
397  "FactorGJP",
398  "FactorConstant"};
399 typedef std::map<ConstFactorType, NekDouble> ConstFactorMap;
401 
402 // FactorMap
405 
407 {
413  eDir1FwdDir1_Dir2FwdDir2, // These flags are interpreted as
414  eDir1FwdDir1_Dir2BwdDir2, // taking the second direction to the
415  eDir1BwdDir1_Dir2FwdDir2, // first direction. So Dir1FwdDir2 takes
416  eDir1BwdDir1_Dir2BwdDir2, // direction 2 and makes it backward
417  eDir1FwdDir2_Dir2FwdDir1, // to direction 1 in the mapped face.
418  eDir1FwdDir2_Dir2BwdDir1, // Note be careful not to flip this
419  eDir1BwdDir2_Dir2FwdDir1, // convention especially when using
420  eDir1BwdDir2_Dir2BwdDir1, // transposed mappings.
422 };
423 
424 const char *const OrientationMap[] = {"NoOrientation",
425  "Fwd",
426  "Bwd",
427  "Forwards",
428  "Backwards",
429  "Dir1FwdDir1_Dir2FwdDir2",
430  "Dir1FwdDir1_Dir2BwdDir2",
431  "Dir1BwdDir1_Dir2FwdDir2",
432  "Dir1BwdDir1_Dir2BwdDir2",
433  "Dir1FwdDir2_Dir2FwdDir1",
434  "Dir1FwdDir2_Dir2BwdDir1",
435  "Dir1BwdDir2_Dir2FwdDir1",
436  "Dir1BwdDir2_Dir2BwdDir1"};
437 
438 // Defines a "fast find"
439 // Assumes that first/last define the beginning/ending of
440 // a continuous range of classes, and that start is
441 // an iterator between first and last
442 
443 template <class InputIterator, class EqualityComparable>
444 InputIterator find(InputIterator first, InputIterator last,
445  InputIterator startingpoint, const EqualityComparable &value)
446 {
447  InputIterator val;
448 
449  if (startingpoint == first)
450  {
451  val = find(first, last, value);
452  }
453  else
454  {
455  val = find(startingpoint, last, value);
456  if (val == last)
457  {
458  val = find(first, startingpoint, value);
459  if (val == startingpoint)
460  {
461  val = last;
462  }
463  }
464  }
465  return val;
466 }
467 
468 // Optimized Kernel Entries
469 const int kSVVDGFiltermodesmin = 3;
470 const int kSVVDGFiltermodesmax = 11;
471 // Optimized Kernel Entries for p = 2 - 10
472 const NekDouble kSVVDGFilter[9][11] = {
473  {0, 0.36212, 1, 0, 0, 0, 0, 0, 0, 0, 0},
474  {0, 0.70546, 0.078836, 1, 0, 0, 0, 0, 0, 0, 0},
475  {0, 0, 0.49411, 0.072394, 1, 0, 0, 0, 0, 0, 0},
476  {0, 0, 0.000073566, 0.40506, 0.094122, 1, 0, 0, 0, 0, 0},
477  {0, 0, 0, 0.0001422, 0.36863, 0.11815, 1, 0, 0, 0, 0},
478  {0, 0, 0, 0, 0.00019497, 0.41397, 0.16927, 1, 0, 0, 0},
479  {0, 0, 0, 0, 0, 0.0009762, 0.12747, 0.13763, 1, 0, 0},
480  {0, 0, 0, 0, 0, 0, 0.0023592, 0.23683, 0.17196, 1, 0},
481  {0, 0, 0, 0, 0, 0, 0, 0.0026055, 0.28682, 0.22473, 1}};
482 
483 } // namespace StdRegions
484 } // namespace Nektar
485 
486 #endif // STDREGIONS_H
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:444
const int kSVVDGFiltermodesmin
Definition: StdRegions.hpp:469
static FactorMap NullFactorMap
Definition: StdRegions.hpp:404
const char *const VarCoeffTypeMap[]
Definition: StdRegions.hpp:232
const int kSVVDGFiltermodesmax
Definition: StdRegions.hpp:470
const NekDouble kSVVDGFilter[9][11]
Definition: StdRegions.hpp:472
const char *const ConstFactorTypeMap[]
Definition: StdRegions.hpp:382
const char *const ElementTypeMap[]
Definition: StdRegions.hpp:75
const char *const MatrixTypeMap[]
Definition: StdRegions.hpp:143
VarCoeffMap RestrictCoeffMap(const VarCoeffMap &m, size_t offset, size_t cnt)
Definition: StdRegions.hpp:346
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:399
static ConstFactorMap NullConstFactorMap
Definition: StdRegions.hpp:400
const char *const OrientationMap[]
Definition: StdRegions.hpp:424
ConstFactorMap FactorMap
Definition: StdRegions.hpp:403
static VarCoeffMap NullVarCoeffMap
Definition: StdRegions.hpp:344
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
Definition: StdRegions.hpp:343
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
std::size_t hash_range(Iter first, Iter last)
Definition: HashUtils.hpp:68
double NekDouble
Representation of a variable coefficient.
Definition: StdRegions.hpp:262
Array< OneD, NekDouble > m_coeffs
Storage for the variable coefficient entries.
Definition: StdRegions.hpp:340
const NekDouble & operator[](std::size_t idx) const
Access an entry idx within m_coeffs.
Definition: StdRegions.hpp:285
std::size_t m_hash
Hash of the entries inside m_coeffs.
Definition: StdRegions.hpp:337
std::size_t GetHash() const
Returns the hash of this entry.
Definition: StdRegions.hpp:316
VarCoeffEntry()=default
Default constructor.
void ComputeHash()
Computes the hash of this entry using hash_range.
Definition: StdRegions.hpp:325
void operator=(const Array< OneD, const NekDouble > &rhs)
Assignment operator given an array rhs.
Definition: StdRegions.hpp:299
VarCoeffEntry(const Array< OneD, const NekDouble > &input)
Copy an array of values into this entry.
Definition: StdRegions.hpp:275
const Array< OneD, const NekDouble > & GetValue() const
Returns a const reference to the coefficients.
Definition: StdRegions.hpp:308