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
324 /*
325 * @brief Create sub-VarCoeffEntry without copying data.
326 *
327 * @param offset Offset from the first entry of the m_coeff array.
328 * @param size Length of the new sub-set of the original m_coeff array.
329 *
330 * The restrict function returns a VarCoeffEntry that
331 * holds a m_coeff array with a subset of the original
332 * VarCoeffEntry.
333 */
334 VarCoeffEntry restrict(size_t offset, size_t size) const
335 {
336 VarCoeffEntry tmp;
337
338 // This avoids copy of Array
339 tmp.m_coeffs = Array<OneD, NekDouble>(size, m_coeffs + offset);
340
341 // The logic is that since we are using a 'window' into the original
342 // data we should preserve the original hash of that data.
343 // Giving just m_hash will result in the same hash for all collections.
344 // This is sufficient, because if we only need to update once every time
345 // step. For possible future changes, we could combine it with the
346 // offset and size to make it different enough to the original hash, if
347 // necessary.
348 tmp.m_hash = m_hash;
349
350 return tmp;
351 }
352
353protected:
354 /**
355 * @brief Computes the hash of this entry using #hash_range.
356 */
358 {
359 if (m_coeffs.size() == 0)
360 {
361 m_hash = 0;
362 return;
363 }
364
365 m_hash = hash_range(m_coeffs.begin(), m_coeffs.end());
366 }
367
368 /// Hash of the entries inside #m_coeffs.
369 std::size_t m_hash = 0;
370
371 /// Storage for the variable coefficient entries.
373};
374
375typedef std::map<StdRegions::VarCoeffType, VarCoeffEntry> VarCoeffMap;
377
378inline VarCoeffMap RestrictCoeffMap(const VarCoeffMap &m, size_t offset,
379 size_t cnt)
380{
381 VarCoeffMap ret;
382
383 for (auto &x : m)
384 {
385 ret[x.first] = x.second.restrict(offset, cnt);
386 }
387
388 return ret;
389}
390
392{
412
413const char *const ConstFactorTypeMap[] = {"FactorLambda",
414 "FactorCoeffD00",
415 "FactorCoeffD11",
416 "FactorCoeffD22",
417 "FactorCoeffD01",
418 "FactorCoeffD02",
419 "FactorCoeffD12",
420 "FactorTau",
421 "FactorTime",
422 "FactorSVVCutoffRatio",
423 "FactorSVVDiffCoeff",
424 "FactorSVVPowerKerDiffCoeff",
425 "FactorSVVDGKerDiffCoeff",
426 "FactorGaussVertex",
427 "FactorGaussEdge",
428 "FactorGJP",
429 "FactorConstant"};
430typedef std::map<ConstFactorType, NekDouble> ConstFactorMap;
432
433// FactorMap
436
438{
444 eDir1FwdDir1_Dir2FwdDir2, // These flags are interpreted as
445 eDir1FwdDir1_Dir2BwdDir2, // taking the second direction to the
446 eDir1BwdDir1_Dir2FwdDir2, // first direction. So Dir1FwdDir2 takes
447 eDir1BwdDir1_Dir2BwdDir2, // direction 2 and makes it backward
448 eDir1FwdDir2_Dir2FwdDir1, // to direction 1 in the mapped face.
449 eDir1FwdDir2_Dir2BwdDir1, // Note be careful not to flip this
450 eDir1BwdDir2_Dir2FwdDir1, // convention especially when using
451 eDir1BwdDir2_Dir2BwdDir1, // transposed mappings.
454
455const char *const OrientationMap[] = {"NoOrientation",
456 "Fwd",
457 "Bwd",
458 "Forwards",
459 "Backwards",
460 "Dir1FwdDir1_Dir2FwdDir2",
461 "Dir1FwdDir1_Dir2BwdDir2",
462 "Dir1BwdDir1_Dir2FwdDir2",
463 "Dir1BwdDir1_Dir2BwdDir2",
464 "Dir1FwdDir2_Dir2FwdDir1",
465 "Dir1FwdDir2_Dir2BwdDir1",
466 "Dir1BwdDir2_Dir2FwdDir1",
467 "Dir1BwdDir2_Dir2BwdDir1"};
468
469// Defines a "fast find"
470// Assumes that first/last define the beginning/ending of
471// a continuous range of classes, and that start is
472// an iterator between first and last
473
474template <class InputIterator, class EqualityComparable>
475InputIterator find(InputIterator first, InputIterator last,
476 InputIterator startingpoint, const EqualityComparable &value)
477{
478 InputIterator val;
479
480 if (startingpoint == first)
481 {
482 val = find(first, last, value);
483 }
484 else
485 {
486 val = find(startingpoint, last, value);
487 if (val == last)
488 {
489 val = find(first, startingpoint, value);
490 if (val == startingpoint)
491 {
492 val = last;
493 }
494 }
495 }
496 return val;
497}
498
499// Optimized Kernel Entries
501const int kSVVDGFiltermodesmax = 11;
502// Optimized Kernel Entries for p = 2 - 10
503const NekDouble kSVVDGFilter[9][11] = {
504 {0, 0.36212, 1, 0, 0, 0, 0, 0, 0, 0, 0},
505 {0, 0.70546, 0.078836, 1, 0, 0, 0, 0, 0, 0, 0},
506 {0, 0, 0.49411, 0.072394, 1, 0, 0, 0, 0, 0, 0},
507 {0, 0, 0.000073566, 0.40506, 0.094122, 1, 0, 0, 0, 0, 0},
508 {0, 0, 0, 0.0001422, 0.36863, 0.11815, 1, 0, 0, 0, 0},
509 {0, 0, 0, 0, 0.00019497, 0.41397, 0.16927, 1, 0, 0, 0},
510 {0, 0, 0, 0, 0, 0.0009762, 0.12747, 0.13763, 1, 0, 0},
511 {0, 0, 0, 0, 0, 0, 0.0023592, 0.23683, 0.17196, 1, 0},
512 {0, 0, 0, 0, 0, 0, 0, 0.0026055, 0.28682, 0.22473, 1}};
513
514} // namespace Nektar::StdRegions
515
516#endif // STDREGIONS_H
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:475
const int kSVVDGFiltermodesmin
Definition: StdRegions.hpp:500
static FactorMap NullFactorMap
Definition: StdRegions.hpp:435
const char *const VarCoeffTypeMap[]
Definition: StdRegions.hpp:234
const int kSVVDGFiltermodesmax
Definition: StdRegions.hpp:501
const NekDouble kSVVDGFilter[9][11]
Definition: StdRegions.hpp:503
const char *const ConstFactorTypeMap[]
Definition: StdRegions.hpp:413
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:378
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:430
static ConstFactorMap NullConstFactorMap
Definition: StdRegions.hpp:431
const char *const OrientationMap[]
Definition: StdRegions.hpp:455
ConstFactorMap FactorMap
Definition: StdRegions.hpp:434
static VarCoeffMap NullVarCoeffMap
Definition: StdRegions.hpp:376
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
Definition: StdRegions.hpp:375
std::size_t hash_range(Iter first, Iter last)
Definition: HashUtils.hpp:64
double NekDouble
Representation of a variable coefficient.
Definition: StdRegions.hpp:265
VarCoeffEntry restrict(size_t offset, size_t size) const
Definition: StdRegions.hpp:334
Array< OneD, NekDouble > m_coeffs
Storage for the variable coefficient entries.
Definition: StdRegions.hpp:372
std::size_t m_hash
Hash of the entries inside m_coeffs.
Definition: StdRegions.hpp:369
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:357
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