Nektar++
Loading...
Searching...
No Matches
DiffusionScalarVolFluxKernels.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: DiffusionScalarVolFluxKernels.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: Scalar IP diffusion volume flux kernels.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#pragma once
36
39
40namespace Nektar::detail
41{
42
43template <typename ExecSpace, unsigned int NDIM, typename TData>
45 const size_t npts, const unsigned int nvarComps, const size_t derivStride,
46 const size_t outStride, const TData *diffCoeff, const TData *derivbase,
47 TData *outbase, const unsigned int streamID)
48{
49 using vec_t =
51 TData>::type;
52 constexpr unsigned int vec_width =
53 (std::is_same_v<ExecSpace, NektarSpaces::AVX>)
55 : 1;
56
57 const size_t groupsize = npts / vec_width;
58 const auto derivvec = reinterpret_cast<const vec_t *>(derivbase);
59 auto outvec = reinterpret_cast<vec_t *>(outbase);
60
61 const size_t derivVecStride = derivStride / vec_width;
62 const size_t outVecStride = outStride / vec_width;
63
65
66 Nektar::parallel_for<ExecSpace>(
67 0u, groupsize, NEKTAR_LAMBDA(const size_t i) {
68 for (unsigned int f = 0; f < nvarComps; ++f)
69 {
70 for (unsigned int outDir = 0; outDir < NDIM; ++outDir)
71 {
72 vec_t flux = vec_t(0.0);
73 for (unsigned int derivDir = 0; derivDir < NDIM; ++derivDir)
74 {
75 const auto diffIdx = LibUtilities::GetDiffCoeffMap(
76 NDIM, outDir * NDIM + derivDir);
77 const size_t derivIdx =
78 (f * NDIM + derivDir) * derivVecStride + i;
79 flux += vec_t(diffCoeff[diffIdx]) * derivvec[derivIdx];
80 }
81
82 outvec[(f * NDIM + outDir) * outVecStride + i] = flux;
83 }
84 }
85 });
86
88}
89
90} // namespace Nektar::detail
#define NEKTAR_LAMBDA
#define NEK_FORCE_INLINE
Definition NekInline.hpp:46
NEK_HOSTDEVICE_INLINE unsigned int GetDiffCoeffMap(const unsigned int ncoord, const unsigned int index)
static NEK_FORCE_INLINE void DiffusionScalarVolFluxKernelLauncher(const size_t npts, const unsigned int nvarComps, const size_t derivStride, const size_t outStride, const TData *diffCoeff, const TData *derivbase, TData *outbase, const unsigned int streamID)
static void LoopExecutionSetStreamID(const unsigned int streamID)
tinysimd::simd< NekDouble > vec_t
typename abi< ScalarType, width >::type simd
Definition tinysimd.hpp:138