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