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